index-BO_iYk_v.js 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729
  1. function Yse(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 c_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $A={exports:{}},rb={};var KU;function Zse(){if(KU)return rb;KU=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 rb.Fragment=e,rb.jsx=n,rb.jsxs=n,rb}var XU;function Qse(){return XU||(XU=1,$A.exports=Zse()),$A.exports}var s=Qse(),HA={exports:{}},xn={};var YU;function Jse(){if(YU)return xn;YU=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"),m=Symbol.iterator;function p(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,x={};function v(z,V,Z){this.props=z,this.context=V,this.refs=x,this.updater=Z||b}v.prototype.isReactComponent={},v.prototype.setState=function(z,V){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,V,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function S(){}S.prototype=v.prototype;function M(z,V,Z){this.props=z,this.context=V,this.refs=x,this.updater=Z||b}var N=M.prototype=new S;N.constructor=M,y(N,v.prototype),N.isPureReactComponent=!0;var A=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function T(z,V,Z){var ne=Z.ref;return{$$typeof:t,type:z,key:V,ref:ne!==void 0?ne:null,props:Z}}function R(z,V){return T(z.type,V,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function O(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Z){return V[Z]})}var q=/\/+/g;function j(z,V){return typeof z=="object"&&z!==null&&z.key!=null?O(""+z.key):V.toString(36)}function W(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(k,k):(z.status="pending",z.then(function(V){z.status==="pending"&&(z.status="fulfilled",z.value=V)},function(V){z.status==="pending"&&(z.status="rejected",z.reason=V)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function K(z,V,Z,ne,he){var fe=typeof z;(fe==="undefined"||fe==="boolean")&&(z=null);var le=!1;if(z===null)le=!0;else switch(fe){case"bigint":case"string":case"number":le=!0;break;case"object":switch(z.$$typeof){case t:case e:le=!0;break;case d:return le=z._init,K(le(z._payload),V,Z,ne,he)}}if(le)return he=he(z),le=ne===""?"."+j(z,0):ne,A(he)?(Z="",le!=null&&(Z=le.replace(q,"$&/")+"/"),K(he,V,Z,"",function(we){return we})):he!=null&&(U(he)&&(he=R(he,Z+(he.key==null||z&&z.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+le)),V.push(he)),1;le=0;var Ee=ne===""?".":ne+":";if(A(z))for(var me=0;me<z.length;me++)ne=z[me],fe=Ee+j(ne,me),le+=K(ne,V,Z,fe,he);else if(me=p(z),typeof me=="function")for(z=me.call(z),me=0;!(ne=z.next()).done;)ne=ne.value,fe=Ee+j(ne,me++),le+=K(ne,V,Z,fe,he);else if(fe==="object"){if(typeof z.then=="function")return K(W(z),V,Z,ne,he);throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return le}function G(z,V,Z){if(z==null)return z;var ne=[],he=0;return K(z,ne,"","",function(fe){return V.call(Z,fe,he++)}),ne}function J(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(Z){(z._status===0||z._status===-1)&&(z._status=1,z._result=Z)},function(Z){(z._status===0||z._status===-1)&&(z._status=2,z._result=Z)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var ie=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},re={map:G,forEach:function(z,V,Z){G(z,function(){V.apply(this,arguments)},Z)},count:function(z){var V=0;return G(z,function(){V++}),V},toArray:function(z){return G(z,function(V){return V})||[]},only:function(z){if(!U(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return xn.Activity=f,xn.Children=re,xn.Component=v,xn.Fragment=n,xn.Profiler=i,xn.PureComponent=M,xn.StrictMode=r,xn.Suspense=c,xn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,xn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return C.H.useMemoCache(z)}},xn.cache=function(z){return function(){return z.apply(null,arguments)}},xn.cacheSignal=function(){return null},xn.cloneElement=function(z,V,Z){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ne=y({},z.props),he=z.key;if(V!=null)for(fe in V.key!==void 0&&(he=""+V.key),V)!D.call(V,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&V.ref===void 0||(ne[fe]=V[fe]);var fe=arguments.length-2;if(fe===1)ne.children=Z;else if(1<fe){for(var le=Array(fe),Ee=0;Ee<fe;Ee++)le[Ee]=arguments[Ee+2];ne.children=le}return T(z.type,he,ne)},xn.createContext=function(z){return z={$$typeof:o,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:a,_context:z},z},xn.createElement=function(z,V,Z){var ne,he={},fe=null;if(V!=null)for(ne in V.key!==void 0&&(fe=""+V.key),V)D.call(V,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(he[ne]=V[ne]);var le=arguments.length-2;if(le===1)he.children=Z;else if(1<le){for(var Ee=Array(le),me=0;me<le;me++)Ee[me]=arguments[me+2];he.children=Ee}if(z&&z.defaultProps)for(ne in le=z.defaultProps,le)he[ne]===void 0&&(he[ne]=le[ne]);return T(z,fe,he)},xn.createRef=function(){return{current:null}},xn.forwardRef=function(z){return{$$typeof:l,render:z}},xn.isValidElement=U,xn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:J}},xn.memo=function(z,V){return{$$typeof:u,type:z,compare:V===void 0?null:V}},xn.startTransition=function(z){var V=C.T,Z={};C.T=Z;try{var ne=z(),he=C.S;he!==null&&he(Z,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(k,ie)}catch(fe){ie(fe)}finally{V!==null&&Z.types!==null&&(V.types=Z.types),C.T=V}},xn.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},xn.use=function(z){return C.H.use(z)},xn.useActionState=function(z,V,Z){return C.H.useActionState(z,V,Z)},xn.useCallback=function(z,V){return C.H.useCallback(z,V)},xn.useContext=function(z){return C.H.useContext(z)},xn.useDebugValue=function(){},xn.useDeferredValue=function(z,V){return C.H.useDeferredValue(z,V)},xn.useEffect=function(z,V){return C.H.useEffect(z,V)},xn.useEffectEvent=function(z){return C.H.useEffectEvent(z)},xn.useId=function(){return C.H.useId()},xn.useImperativeHandle=function(z,V,Z){return C.H.useImperativeHandle(z,V,Z)},xn.useInsertionEffect=function(z,V){return C.H.useInsertionEffect(z,V)},xn.useLayoutEffect=function(z,V){return C.H.useLayoutEffect(z,V)},xn.useMemo=function(z,V){return C.H.useMemo(z,V)},xn.useOptimistic=function(z,V){return C.H.useOptimistic(z,V)},xn.useReducer=function(z,V,Z){return C.H.useReducer(z,V,Z)},xn.useRef=function(z){return C.H.useRef(z)},xn.useState=function(z){return C.H.useState(z)},xn.useSyncExternalStore=function(z,V,Z){return C.H.useSyncExternalStore(z,V,Z)},xn.useTransition=function(){return C.H.useTransition()},xn.version="19.2.3",xn}var ZU;function Vg(){return ZU||(ZU=1,HA.exports=Jse()),HA.exports}var w=Vg();const Dr=fl(w),eoe=Yse({__proto__:null,default:Dr},[w]);var VA={exports:{}},ib={},GA={exports:{}},WA={};var QU;function toe(){return QU||(QU=1,(function(t){function e(K,G){var J=K.length;K.push(G);e:for(;0<J;){var ie=J-1>>>1,re=K[ie];if(0<i(re,G))K[ie]=G,K[J]=re,J=ie;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],J=K.pop();if(J!==G){K[0]=J;e:for(var ie=0,re=K.length,z=re>>>1;ie<z;){var V=2*(ie+1)-1,Z=K[V],ne=V+1,he=K[ne];if(0>i(Z,J))ne<re&&0>i(he,Z)?(K[ie]=he,K[ne]=J,ie=ne):(K[ie]=Z,K[V]=J,ie=V);else if(ne<re&&0>i(he,J))K[ie]=he,K[ne]=J,ie=ne;else break e}}return G}function i(K,G){var J=K.sortIndex-G.sortIndex;return J!==0?J:K.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,m=3,p=!1,b=!1,y=!1,x=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function N(K){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function A(K){if(y=!1,N(K),!b)if(n(c)!==null)b=!0,k||(k=!0,O());else{var G=n(u);G!==null&&W(A,G.startTime-K)}}var k=!1,C=-1,D=5,T=-1;function R(){return x?!0:!(t.unstable_now()-T<D)}function U(){if(x=!1,k){var K=t.unstable_now();T=K;var G=!0;try{e:{b=!1,y&&(y=!1,S(C),C=-1),p=!0;var J=m;try{t:{for(N(K),f=n(c);f!==null&&!(f.expirationTime>K&&R());){var ie=f.callback;if(typeof ie=="function"){f.callback=null,m=f.priorityLevel;var re=ie(f.expirationTime<=K);if(K=t.unstable_now(),typeof re=="function"){f.callback=re,N(K),G=!0;break t}f===n(c)&&r(c),N(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var z=n(u);z!==null&&W(A,z.startTime-K),G=!1}}break e}finally{f=null,m=J,p=!1}G=void 0}}finally{G?O():k=!1}}}var O;if(typeof M=="function")O=function(){M(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=U,O=function(){j.postMessage(null)}}else O=function(){v(U,0)};function W(K,G){C=v(function(){K(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(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(K){switch(m){case 1:case 2:case 3:var G=3;break;default:G=m}var J=m;m=G;try{return K()}finally{m=J}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var J=m;m=K;try{return G()}finally{m=J}},t.unstable_scheduleCallback=function(K,G,J){var ie=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ie+J:ie):J=ie,K){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=J+re,K={id:d++,callback:G,priorityLevel:K,startTime:J,expirationTime:re,sortIndex:-1},J>ie?(K.sortIndex=J,e(u,K),n(c)===null&&K===n(u)&&(y?(S(C),C=-1):y=!0,W(A,J-ie))):(K.sortIndex=re,e(c,K),b||p||(b=!0,k||(k=!0,O()))),K},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(K){var G=m;return function(){var J=m;m=G;try{return K.apply(this,arguments)}finally{m=J}}}})(WA)),WA}var JU;function noe(){return JU||(JU=1,GA.exports=toe()),GA.exports}var qA={exports:{}},Ea={};var ez;function roe(){if(ez)return Ea;ez=1;var t=Vg();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 Ea.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ea.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)},Ea.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()}},Ea.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))},Ea.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Ea.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=typeof u.integrity=="string"?u.integrity:void 0,p=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:m,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Ea.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)},Ea.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})}},Ea.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)},Ea.requestFormReset=function(c){r.d.r(c)},Ea.unstable_batchedUpdates=function(c,u){return c(u)},Ea.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Ea.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ea.version="19.2.3",Ea}var tz;function mq(){if(tz)return qA.exports;tz=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(),qA.exports=roe(),qA.exports}var nz;function ioe(){if(nz)return ib;nz=1;var t=noe(),e=Vg(),n=mq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+g+" 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 g=h,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var _=h,E=g;;){var P=_.return;if(P===null)break;var I=P.alternate;if(I===null){if(E=P.return,E!==null){_=E;continue}break}if(P.child===I.child){for(I=P.child;I;){if(I===_)return c(P),h;if(I===E)return c(P),g;I=I.sibling}throw Error(r(188))}if(_.return!==E.return)_=P,E=I;else{for(var Q=!1,ge=P.child;ge;){if(ge===_){Q=!0,_=P,E=I;break}if(ge===E){Q=!0,E=P,_=I;break}ge=ge.sibling}if(!Q){for(ge=I.child;ge;){if(ge===_){Q=!0,_=I,E=P;break}if(ge===E){Q=!0,E=I,_=P;break}ge=ge.sibling}if(!Q)throw Error(r(189))}}if(_.alternate!==E)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),M=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case v:return"Profiler";case x:return"StrictMode";case A:return"Suspense";case k:return"SuspenseList";case T:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case b:return"Portal";case M:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case N:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case D:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var W=Array.isArray,K=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,J={pending:!1,data:null,method:null,action:null},ie=[],re=-1;function z(h){return{current:h}}function V(h){0>re||(h.current=ie[re],ie[re]=null,re--)}function Z(h,g){re++,ie[re]=h.current,h.current=g}var ne=z(null),he=z(null),fe=z(null),le=z(null);function Ee(h,g){switch(Z(fe,g),Z(he,h),Z(ne,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?xU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=xU(g),h=bU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(ne),Z(ne,h)}function me(){V(ne),V(he),V(fe)}function we(h){h.memoizedState!==null&&Z(le,h);var g=ne.current,_=bU(g,h.type);g!==_&&(Z(he,h),Z(ne,_))}function De(h){he.current===h&&(V(ne),V(he)),le.current===h&&(V(le),Jx._currentValue=J)}var ee,Qe;function B(h){if(ee===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);ee=g&&g[1]||"",Qe=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+ee+h+Qe}var te=!1;function Y(h,g){if(!h||te)return"";te=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var E={DetermineComponentFrameRoot:function(){try{if(g){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(ct){var ot=ct}Reflect.construct(h,[],bt)}else{try{bt.call()}catch(ct){ot=ct}h.call(bt.prototype)}}else{try{throw Error()}catch(ct){ot=ct}(bt=h())&&typeof bt.catch=="function"&&bt.catch(function(){})}}catch(ct){if(ct&&ot&&typeof ct.stack=="string")return[ct.stack,ot.stack]}return[null,null]}};E.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(E.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(E.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=E.DetermineComponentFrameRoot(),Q=I[0],ge=I[1];if(Q&&ge){var Re=Q.split(`
  4. `),st=ge.split(`
  5. `);for(P=E=0;E<Re.length&&!Re[E].includes("DetermineComponentFrameRoot");)E++;for(;P<st.length&&!st[P].includes("DetermineComponentFrameRoot");)P++;if(E===Re.length||P===st.length)for(E=Re.length-1,P=st.length-1;1<=E&&0<=P&&Re[E]!==st[P];)P--;for(;1<=E&&0<=P;E--,P--)if(Re[E]!==st[P]){if(E!==1||P!==1)do if(E--,P--,0>P||Re[E]!==st[P]){var mt=`
  6. `+Re[E].replace(" at new "," at ");return h.displayName&&mt.includes("<anonymous>")&&(mt=mt.replace("<anonymous>",h.displayName)),mt}while(1<=E&&0<=P);break}}}finally{te=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?B(_):""}function H(h,g){switch(h.tag){case 26:case 27:case 5:return B(h.type);case 16:return B("Lazy");case 13:return h.child!==g&&g!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return Y(h.type,!1);case 11:return Y(h.type.render,!1);case 1:return Y(h.type,!0);case 31:return B("Activity");default:return""}}function F(h){try{var g="",_=null;do g+=H(h,_),_=h,h=h.return;while(h);return g}catch(E){return`
  7. Error generating stack: `+E.message+`
  8. `+E.stack}}var de=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,Le=t.unstable_cancelCallback,Se=t.unstable_shouldYield,$=t.unstable_requestPaint,L=t.unstable_now,X=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,ae=t.unstable_NormalPriority,Te=t.unstable_LowPriority,Pe=t.unstable_IdlePriority,Xe=t.log,Je=t.unstable_setDisableYieldValue,Ze=null,oe=null;function ye(h){if(typeof Xe=="function"&&Je(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Ze,h)}catch{}}var Ce=Math.clz32?Math.clz32:se,$e=Math.log,lt=Math.LN2;function se(h){return h>>>=0,h===0?32:31-($e(h)/lt|0)|0}var ze=256,ve=262144,He=4194304;function Oe(h){var g=h&42;if(g!==0)return g;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,g,_){var E=h.pendingLanes;if(E===0)return 0;var P=0,I=h.suspendedLanes,Q=h.pingedLanes;h=h.warmLanes;var ge=E&134217727;return ge!==0?(E=ge&~I,E!==0?P=Oe(E):(Q&=ge,Q!==0?P=Oe(Q):_||(_=ge&~h,_!==0&&(P=Oe(_))))):(ge=E&~I,ge!==0?P=Oe(ge):Q!==0?P=Oe(Q):_||(_=E&~h,_!==0&&(P=Oe(_)))),P===0?0:g!==0&&g!==P&&(g&I)===0&&(I=P&-P,_=g&-g,I>=_||I===32&&(_&4194048)!==0)?g:P}function Be(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function at(h,g){switch(h){case 1:case 2:case 4:case 8:case 64:return g+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 g+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 Rt(){var h=He;return He<<=1,(He&62914560)===0&&(He=4194304),h}function Tt(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function nn(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,g,_,E,P,I){var Q=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var ge=h.entanglements,Re=h.expirationTimes,st=h.hiddenUpdates;for(_=Q&~_;0<_;){var mt=31-Ce(_),bt=1<<mt;ge[mt]=0,Re[mt]=-1;var ot=st[mt];if(ot!==null)for(st[mt]=null,mt=0;mt<ot.length;mt++){var ct=ot[mt];ct!==null&&(ct.lane&=-536870913)}_&=~bt}E!==0&&ln(h,E,0),I!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=I&~(Q&~g))}function ln(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var E=31-Ce(g);h.entangledLanes|=g,h.entanglements[E]=h.entanglements[E]|1073741824|_&261930}function ft(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var E=31-Ce(_),P=1<<E;P&g|h[E]&g&&(h[E]|=g),_&=~P}}function Xt(h,g){var _=g&-g;return _=(_&42)!==0?1:tn(_),(_&(h.suspendedLanes|g))!==0?0:_}function tn(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 wt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function gr(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:BU(h.type))}function Nr(h,g){var _=G.p;try{return G.p=h,g()}finally{G.p=_}}var _r=Math.random().toString(36).slice(2),er="__reactFiber$"+_r,vt="__reactProps$"+_r,on="__reactContainer$"+_r,Nn="__reactEvents$"+_r,ce="__reactListeners$"+_r,Ue="__reactHandles$"+_r,We="__reactResources$"+_r,rt="__reactMarker$"+_r;function et(h){delete h[er],delete h[vt],delete h[Nn],delete h[ce],delete h[Ue]}function Ct(h){var g=h[er];if(g)return g;for(var _=h.parentNode;_;){if(g=_[on]||_[er]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=EU(h);h!==null;){if(_=h[er])return _;h=EU(h)}return g}h=_,_=h.parentNode}return null}function yt(h){if(h=h[er]||h[on]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Mt(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Vt(h){var g=h[We];return g||(g=h[We]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function ue(h){h[rt]=!0}var je=new Set,Ge={};function qe(h,g){Ve(h,g),Ve(h+"Capture",g)}function Ve(h,g){for(Ge[h]=g,h=0;h<g.length;h++)je.add(g[h])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Pt={},_t={};function pt(h){return de.call(_t,h)?!0:de.call(Pt,h)?!1:xt.test(h)?_t[h]=!0:(Pt[h]=!0,!1)}function St(h,g,_){if(pt(g))if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var E=g.toLowerCase().slice(0,5);if(E!=="data-"&&E!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+_)}}function Ot(h,g,_){if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+_)}}function Ft(h,g,_,E){if(E===null)h.removeAttribute(_);else{switch(typeof E){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+E)}}function be(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function kt(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function rn(h,g,_){var E=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof E<"u"&&typeof E.get=="function"&&typeof E.set=="function"){var P=E.get,I=E.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(Q){_=""+Q,I.call(this,Q)}}),Object.defineProperty(h,g,{enumerable:E.enumerable}),{getValue:function(){return _},setValue:function(Q){_=""+Q},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function zt(h){if(!h._valueTracker){var g=kt(h)?"checked":"value";h._valueTracker=rn(h,g,""+h[g])}}function cn(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),E="";return h&&(E=kt(h)?h.checked?"true":"false":h.value),h=E,h!==_?(g.setValue(h),!0):!1}function $t(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 Gt=/[\n"\\]/g;function an(h){return h.replace(Gt,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function wi(h,g,_,E,P,I,Q,ge){h.name="",Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?h.type=Q:h.removeAttribute("type"),g!=null?Q==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+be(g)):h.value!==""+be(g)&&(h.value=""+be(g)):Q!=="submit"&&Q!=="reset"||h.removeAttribute("value"),g!=null?ta(h,Q,be(g)):_!=null?ta(h,Q,be(_)):E!=null&&h.removeAttribute("value"),P==null&&I!=null&&(h.defaultChecked=!!I),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ge!=null&&typeof ge!="function"&&typeof ge!="symbol"&&typeof ge!="boolean"?h.name=""+be(ge):h.removeAttribute("name")}function Qs(h,g,_,E,P,I,Q,ge){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(h.type=I),g!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||g!=null)){zt(h);return}_=_!=null?""+be(_):"",g=g!=null?""+be(g):_,ge||g===h.value||(h.value=g),h.defaultValue=g}E=E??P,E=typeof E!="function"&&typeof E!="symbol"&&!!E,h.checked=ge?h.checked:!!E,h.defaultChecked=!!E,Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"&&(h.name=Q),zt(h)}function ta(h,g,_){g==="number"&&$t(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function Js(h,g,_,E){if(h=h.options,g){g={};for(var P=0;P<_.length;P++)g["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=g.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&E&&(h[_].defaultSelected=!0)}else{for(_=""+be(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,E&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function tr(h,g,_){if(g!=null&&(g=""+be(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+be(_):""}function na(h,g,_,E){if(g==null){if(E!=null){if(_!=null)throw Error(r(92));if(W(E)){if(1<E.length)throw Error(r(93));E=E[0]}_=E}_==null&&(_=""),g=_}_=be(g),h.defaultValue=_,E=h.textContent,E===_&&E!==""&&E!==null&&(h.value=E),zt(h)}function Si(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var ra=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 ia(h,g,_){var E=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?E?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":E?h.setProperty(g,_):typeof _!="number"||_===0||ra.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function mm(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var E in _)!_.hasOwnProperty(E)||g!=null&&g.hasOwnProperty(E)||(E.indexOf("--")===0?h.setProperty(E,""):E==="float"?h.cssFloat="":h[E]="");for(var P in g)E=g[P],g.hasOwnProperty(P)&&_[P]!==E&&ia(h,P,E)}else for(var I in g)g.hasOwnProperty(I)&&ia(h,I,g[I])}function Io(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 Wie=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"]]),qie=/^[\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 ev(h){return qie.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function hc(){}var UN=null;function zN(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var pm=null,gm=null;function gI(h){var g=yt(h);if(g&&(h=g.stateNode)){var _=h[vt]||null;e:switch(h=g.stateNode,g.type){case"input":if(wi(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+an(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var E=_[g];if(E!==h&&E.form===h.form){var P=E[vt]||null;if(!P)throw Error(r(90));wi(E,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)E=_[g],E.form===h.form&&cn(E)}break e;case"textarea":tr(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&Js(h,!!_.multiple,g,!1)}}}var BN=!1;function xI(h,g,_){if(BN)return h(g,_);BN=!0;try{var E=h(g);return E}finally{if(BN=!1,(pm!==null||gm!==null)&&(Bv(),pm&&(g=pm,h=gm,gm=pm=null,gI(g),h)))for(g=0;g<h.length;g++)gI(h[g])}}function gx(h,g){var _=h.stateNode;if(_===null)return null;var E=_[vt]||null;if(E===null)return null;_=E[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(h=h.type,E=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!E;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var fc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$N=!1;if(fc)try{var xx={};Object.defineProperty(xx,"passive",{get:function(){$N=!0}}),window.addEventListener("test",xx,xx),window.removeEventListener("test",xx,xx)}catch{$N=!1}var Tu=null,HN=null,tv=null;function bI(){if(tv)return tv;var h,g=HN,_=g.length,E,P="value"in Tu?Tu.value:Tu.textContent,I=P.length;for(h=0;h<_&&g[h]===P[h];h++);var Q=_-h;for(E=1;E<=Q&&g[_-E]===P[I-E];E++);return tv=P.slice(h,1<E?1-E:void 0)}function nv(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function rv(){return!0}function yI(){return!1}function rs(h){function g(_,E,P,I,Q){this._reactName=_,this._targetInst=P,this.type=E,this.nativeEvent=I,this.target=Q,this.currentTarget=null;for(var ge in h)h.hasOwnProperty(ge)&&(_=h[ge],this[ge]=_?_(I):I[ge]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?rv:yI,this.isPropagationStopped=yI,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=rv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=rv)},persist:function(){},isPersistent:rv}),g}var bh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},iv=rs(bh),bx=f({},bh,{view:0,detail:0}),Kie=rs(bx),VN,GN,yx,av=f({},bx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:qN,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!==yx&&(yx&&h.type==="mousemove"?(VN=h.screenX-yx.screenX,GN=h.screenY-yx.screenY):GN=VN=0,yx=h),VN)},movementY:function(h){return"movementY"in h?h.movementY:GN}}),vI=rs(av),Xie=f({},av,{dataTransfer:0}),Yie=rs(Xie),Zie=f({},bx,{relatedTarget:0}),WN=rs(Zie),Qie=f({},bh,{animationName:0,elapsedTime:0,pseudoElement:0}),Jie=rs(Qie),eae=f({},bh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),tae=rs(eae),nae=f({},bh,{data:0}),_I=rs(nae),rae={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iae={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"},aae={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sae(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=aae[h])?!!g[h]:!1}function qN(){return sae}var oae=f({},bx,{key:function(h){if(h.key){var g=rae[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=nv(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?iae[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:qN,charCode:function(h){return h.type==="keypress"?nv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?nv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),lae=rs(oae),cae=f({},av,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wI=rs(cae),uae=f({},bx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:qN}),dae=rs(uae),hae=f({},bh,{propertyName:0,elapsedTime:0,pseudoElement:0}),fae=rs(hae),mae=f({},av,{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}),pae=rs(mae),gae=f({},bh,{newState:0,oldState:0}),xae=rs(gae),bae=[9,13,27,32],KN=fc&&"CompositionEvent"in window,vx=null;fc&&"documentMode"in document&&(vx=document.documentMode);var yae=fc&&"TextEvent"in window&&!vx,SI=fc&&(!KN||vx&&8<vx&&11>=vx),MI=" ",EI=!1;function NI(h,g){switch(h){case"keyup":return bae.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function AI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var xm=!1;function vae(h,g){switch(h){case"compositionend":return AI(g);case"keypress":return g.which!==32?null:(EI=!0,MI);case"textInput":return h=g.data,h===MI&&EI?null:h;default:return null}}function _ae(h,g){if(xm)return h==="compositionend"||!KN&&NI(h,g)?(h=bI(),tv=HN=Tu=null,xm=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return SI&&g.locale!=="ko"?null:g.data;default:return null}}var wae={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 TI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!wae[h.type]:g==="textarea"}function CI(h,g,_,E){pm?gm?gm.push(E):gm=[E]:pm=E,g=Kv(g,"onChange"),0<g.length&&(_=new iv("onChange","change",null,_,E),h.push({event:_,listeners:g}))}var _x=null,wx=null;function Sae(h){dU(h,0)}function sv(h){var g=Mt(h);if(cn(g))return h}function kI(h,g){if(h==="change")return g}var jI=!1;if(fc){var XN;if(fc){var YN="oninput"in document;if(!YN){var PI=document.createElement("div");PI.setAttribute("oninput","return;"),YN=typeof PI.oninput=="function"}XN=YN}else XN=!1;jI=XN&&(!document.documentMode||9<document.documentMode)}function RI(){_x&&(_x.detachEvent("onpropertychange",DI),wx=_x=null)}function DI(h){if(h.propertyName==="value"&&sv(wx)){var g=[];CI(g,wx,h,zN(h)),xI(Sae,g)}}function Mae(h,g,_){h==="focusin"?(RI(),_x=g,wx=_,_x.attachEvent("onpropertychange",DI)):h==="focusout"&&RI()}function Eae(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return sv(wx)}function Nae(h,g){if(h==="click")return sv(g)}function Aae(h,g){if(h==="input"||h==="change")return sv(g)}function Tae(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Ns=typeof Object.is=="function"?Object.is:Tae;function Sx(h,g){if(Ns(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),E=Object.keys(g);if(_.length!==E.length)return!1;for(E=0;E<_.length;E++){var P=_[E];if(!de.call(g,P)||!Ns(h[P],g[P]))return!1}return!0}function OI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function LI(h,g){var _=OI(h);h=0;for(var E;_;){if(_.nodeType===3){if(E=h+_.textContent.length,h<=g&&E>=g)return{node:_,offset:g-h};h=E}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=OI(_)}}function II(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?II(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function FI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=$t(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=$t(h.document)}return g}function ZN(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var Cae=fc&&"documentMode"in document&&11>=document.documentMode,bm=null,QN=null,Mx=null,JN=!1;function UI(h,g,_){var E=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;JN||bm==null||bm!==$t(E)||(E=bm,"selectionStart"in E&&ZN(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),Mx&&Sx(Mx,E)||(Mx=E,E=Kv(QN,"onSelect"),0<E.length&&(g=new iv("onSelect","select",null,g,_),h.push({event:g,listeners:E}),g.target=bm)))}function yh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var ym={animationend:yh("Animation","AnimationEnd"),animationiteration:yh("Animation","AnimationIteration"),animationstart:yh("Animation","AnimationStart"),transitionrun:yh("Transition","TransitionRun"),transitionstart:yh("Transition","TransitionStart"),transitioncancel:yh("Transition","TransitionCancel"),transitionend:yh("Transition","TransitionEnd")},e2={},zI={};fc&&(zI=document.createElement("div").style,"AnimationEvent"in window||(delete ym.animationend.animation,delete ym.animationiteration.animation,delete ym.animationstart.animation),"TransitionEvent"in window||delete ym.transitionend.transition);function vh(h){if(e2[h])return e2[h];if(!ym[h])return h;var g=ym[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in zI)return e2[h]=g[_];return h}var BI=vh("animationend"),$I=vh("animationiteration"),HI=vh("animationstart"),kae=vh("transitionrun"),jae=vh("transitionstart"),Pae=vh("transitioncancel"),VI=vh("transitionend"),GI=new Map,t2="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(" ");t2.push("scrollEnd");function Fo(h,g){GI.set(h,g),qe(g,[h])}var ov=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=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(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},eo=[],vm=0,n2=0;function lv(){for(var h=vm,g=n2=vm=0;g<h;){var _=eo[g];eo[g++]=null;var E=eo[g];eo[g++]=null;var P=eo[g];eo[g++]=null;var I=eo[g];if(eo[g++]=null,E!==null&&P!==null){var Q=E.pending;Q===null?P.next=P:(P.next=Q.next,Q.next=P),E.pending=P}I!==0&&WI(_,P,I)}}function cv(h,g,_,E){eo[vm++]=h,eo[vm++]=g,eo[vm++]=_,eo[vm++]=E,n2|=E,h.lanes|=E,h=h.alternate,h!==null&&(h.lanes|=E)}function r2(h,g,_,E){return cv(h,g,_,E),uv(h)}function _h(h,g){return cv(h,null,null,g),uv(h)}function WI(h,g,_){h.lanes|=_;var E=h.alternate;E!==null&&(E.lanes|=_);for(var P=!1,I=h.return;I!==null;)I.childLanes|=_,E=I.alternate,E!==null&&(E.childLanes|=_),I.tag===22&&(h=I.stateNode,h===null||h._visibility&1||(P=!0)),h=I,I=I.return;return h.tag===3?(I=h.stateNode,P&&g!==null&&(P=31-Ce(_),h=I.hiddenUpdates,E=h[P],E===null?h[P]=[g]:E.push(g),g.lane=_|536870912),I):null}function uv(h){if(50<Wx)throw Wx=0,hA=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var _m={};function Rae(h,g,_,E){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=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function As(h,g,_,E){return new Rae(h,g,_,E)}function i2(h){return h=h.prototype,!(!h||!h.isReactComponent)}function mc(h,g){var _=h.alternate;return _===null?(_=As(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.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,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function qI(h,g){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=g,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,g=_.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function dv(h,g,_,E,P,I){var Q=0;if(E=h,typeof h=="function")i2(h)&&(Q=1);else if(typeof h=="string")Q=Fse(h,_,ne.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case T:return h=As(31,_,g,P),h.elementType=T,h.lanes=I,h;case y:return wh(_.children,P,I,g);case x:Q=8,P|=24;break;case v:return h=As(12,_,g,P|2),h.elementType=v,h.lanes=I,h;case A:return h=As(13,_,g,P),h.elementType=A,h.lanes=I,h;case k:return h=As(19,_,g,P),h.elementType=k,h.lanes=I,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case M:Q=10;break e;case S:Q=9;break e;case N:Q=11;break e;case C:Q=14;break e;case D:Q=16,E=null;break e}Q=29,_=Error(r(130,h===null?"null":typeof h,"")),E=null}return g=As(Q,_,g,P),g.elementType=h,g.type=E,g.lanes=I,g}function wh(h,g,_,E){return h=As(7,h,E,g),h.lanes=_,h}function a2(h,g,_){return h=As(6,h,null,g),h.lanes=_,h}function KI(h){var g=As(18,null,null,0);return g.stateNode=h,g}function s2(h,g,_){return g=As(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var XI=new WeakMap;function to(h,g){if(typeof h=="object"&&h!==null){var _=XI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:F(g)},XI.set(h,g),g)}return{value:h,source:g,stack:F(g)}}var wm=[],Sm=0,hv=null,Ex=0,no=[],ro=0,Cu=null,yl=1,vl="";function pc(h,g){wm[Sm++]=Ex,wm[Sm++]=hv,hv=h,Ex=g}function YI(h,g,_){no[ro++]=yl,no[ro++]=vl,no[ro++]=Cu,Cu=h;var E=yl;h=vl;var P=32-Ce(E)-1;E&=~(1<<P),_+=1;var I=32-Ce(g)+P;if(30<I){var Q=P-P%5;I=(E&(1<<Q)-1).toString(32),E>>=Q,P-=Q,yl=1<<32-Ce(g)+P|_<<P|E,vl=I+h}else yl=1<<I|_<<P|E,vl=h}function o2(h){h.return!==null&&(pc(h,1),YI(h,1,0))}function l2(h){for(;h===hv;)hv=wm[--Sm],wm[Sm]=null,Ex=wm[--Sm],wm[Sm]=null;for(;h===Cu;)Cu=no[--ro],no[ro]=null,vl=no[--ro],no[ro]=null,yl=no[--ro],no[ro]=null}function ZI(h,g){no[ro++]=yl,no[ro++]=vl,no[ro++]=Cu,yl=g.id,vl=g.overflow,Cu=h}var aa=null,Ar=null,Ln=!1,ku=null,io=!1,c2=Error(r(519));function ju(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Nx(to(g,h)),c2}function QI(h){var g=h.stateNode,_=h.type,E=h.memoizedProps;switch(g[er]=h,g[vt]=E,_){case"dialog":kn("cancel",g),kn("close",g);break;case"iframe":case"object":case"embed":kn("load",g);break;case"video":case"audio":for(_=0;_<Kx.length;_++)kn(Kx[_],g);break;case"source":kn("error",g);break;case"img":case"image":case"link":kn("error",g),kn("load",g);break;case"details":kn("toggle",g);break;case"input":kn("invalid",g),Qs(g,E.value,E.defaultValue,E.checked,E.defaultChecked,E.type,E.name,!0);break;case"select":kn("invalid",g);break;case"textarea":kn("invalid",g),na(g,E.value,E.defaultValue,E.children)}_=E.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||E.suppressHydrationWarning===!0||pU(g.textContent,_)?(E.popover!=null&&(kn("beforetoggle",g),kn("toggle",g)),E.onScroll!=null&&kn("scroll",g),E.onScrollEnd!=null&&kn("scrollend",g),E.onClick!=null&&(g.onclick=hc),g=!0):g=!1,g||ju(h,!0)}function JI(h){for(aa=h.return;aa;)switch(aa.tag){case 5:case 31:case 13:io=!1;return;case 27:case 3:io=!0;return;default:aa=aa.return}}function Mm(h){if(h!==aa)return!1;if(!Ln)return JI(h),Ln=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||AA(h.type,h.memoizedProps)),_=!_),_&&Ar&&ju(h),JI(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Ar=MU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Ar=MU(h)}else g===27?(g=Ar,Gu(h.type)?(h=PA,PA=null,Ar=h):Ar=g):Ar=aa?so(h.stateNode.nextSibling):null;return!0}function Sh(){Ar=aa=null,Ln=!1}function u2(){var h=ku;return h!==null&&(ls===null?ls=h:ls.push.apply(ls,h),ku=null),h}function Nx(h){ku===null?ku=[h]:ku.push(h)}var d2=z(null),Mh=null,gc=null;function Pu(h,g,_){Z(d2,g._currentValue),g._currentValue=_}function xc(h){h._currentValue=d2.current,V(d2)}function h2(h,g,_){for(;h!==null;){var E=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,E!==null&&(E.childLanes|=g)):E!==null&&(E.childLanes&g)!==g&&(E.childLanes|=g),h===_)break;h=h.return}}function f2(h,g,_,E){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var I=P.dependencies;if(I!==null){var Q=P.child;I=I.firstContext;e:for(;I!==null;){var ge=I;I=P;for(var Re=0;Re<g.length;Re++)if(ge.context===g[Re]){I.lanes|=_,ge=I.alternate,ge!==null&&(ge.lanes|=_),h2(I.return,_,h),E||(Q=null);break e}I=ge.next}}else if(P.tag===18){if(Q=P.return,Q===null)throw Error(r(341));Q.lanes|=_,I=Q.alternate,I!==null&&(I.lanes|=_),h2(Q,_,h),Q=null}else Q=P.child;if(Q!==null)Q.return=P;else for(Q=P;Q!==null;){if(Q===h){Q=null;break}if(P=Q.sibling,P!==null){P.return=Q.return,Q=P;break}Q=Q.return}P=Q}}function Em(h,g,_,E){h=null;for(var P=g,I=!1;P!==null;){if(!I){if((P.flags&524288)!==0)I=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Q=P.alternate;if(Q===null)throw Error(r(387));if(Q=Q.memoizedProps,Q!==null){var ge=P.type;Ns(P.pendingProps.value,Q.value)||(h!==null?h.push(ge):h=[ge])}}else if(P===le.current){if(Q=P.alternate,Q===null)throw Error(r(387));Q.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Jx):h=[Jx])}P=P.return}h!==null&&f2(g,h,_,E),g.flags|=262144}function fv(h){for(h=h.firstContext;h!==null;){if(!Ns(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Eh(h){Mh=h,gc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function sa(h){return eF(Mh,h)}function mv(h,g){return Mh===null&&Eh(h),eF(h,g)}function eF(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},gc===null){if(h===null)throw Error(r(308));gc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else gc=gc.next=g;return _}var Dae=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,E){h.push(E)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},Oae=t.unstable_scheduleCallback,Lae=t.unstable_NormalPriority,ui={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function m2(){return{controller:new Dae,data:new Map,refCount:0}}function Ax(h){h.refCount--,h.refCount===0&&Oae(Lae,function(){h.controller.abort()})}var Tx=null,p2=0,Nm=0,Am=null;function Iae(h,g){if(Tx===null){var _=Tx=[];p2=0,Nm=bA(),Am={status:"pending",value:void 0,then:function(E){_.push(E)}}}return p2++,g.then(tF,tF),g}function tF(){if(--p2===0&&Tx!==null){Am!==null&&(Am.status="fulfilled");var h=Tx;Tx=null,Nm=0,Am=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function Fae(h,g){var _=[],E={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){E.status="fulfilled",E.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(E.status="rejected",E.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),E}var nF=K.S;K.S=function(h,g){U5=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Iae(h,g),nF!==null&&nF(h,g)};var Nh=z(null);function g2(){var h=Nh.current;return h!==null?h:xr.pooledCache}function pv(h,g){g===null?Z(Nh,Nh.current):Z(Nh,g.pool)}function rF(){var h=g2();return h===null?null:{parent:ui._currentValue,pool:h}}var Tm=Error(r(460)),x2=Error(r(474)),gv=Error(r(542)),xv={then:function(){}};function iF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function aF(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(hc,hc),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,oF(h),h;default:if(typeof g.status=="string")g.then(hc,hc);else{if(h=xr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(E){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=E}},function(E){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=E}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,oF(h),h}throw Th=g,Tm}}function Ah(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Th=_,Tm):_}}var Th=null;function sF(){if(Th===null)throw Error(r(459));var h=Th;return Th=null,h}function oF(h){if(h===Tm||h===gv)throw Error(r(483))}var Cm=null,Cx=0;function bv(h){var g=Cx;return Cx+=1,Cm===null&&(Cm=[]),aF(Cm,h,g)}function kx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function yv(h,g){throw g.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function lF(h){function g(Ye,Ie){if(h){var it=Ye.deletions;it===null?(Ye.deletions=[Ie],Ye.flags|=16):it.push(Ie)}}function _(Ye,Ie){if(!h)return null;for(;Ie!==null;)g(Ye,Ie),Ie=Ie.sibling;return null}function E(Ye){for(var Ie=new Map;Ye!==null;)Ye.key!==null?Ie.set(Ye.key,Ye):Ie.set(Ye.index,Ye),Ye=Ye.sibling;return Ie}function P(Ye,Ie){return Ye=mc(Ye,Ie),Ye.index=0,Ye.sibling=null,Ye}function I(Ye,Ie,it){return Ye.index=it,h?(it=Ye.alternate,it!==null?(it=it.index,it<Ie?(Ye.flags|=67108866,Ie):it):(Ye.flags|=67108866,Ie)):(Ye.flags|=1048576,Ie)}function Q(Ye){return h&&Ye.alternate===null&&(Ye.flags|=67108866),Ye}function ge(Ye,Ie,it,gt){return Ie===null||Ie.tag!==6?(Ie=a2(it,Ye.mode,gt),Ie.return=Ye,Ie):(Ie=P(Ie,it),Ie.return=Ye,Ie)}function Re(Ye,Ie,it,gt){var Qt=it.type;return Qt===y?mt(Ye,Ie,it.props.children,gt,it.key):Ie!==null&&(Ie.elementType===Qt||typeof Qt=="object"&&Qt!==null&&Qt.$$typeof===D&&Ah(Qt)===Ie.type)?(Ie=P(Ie,it.props),kx(Ie,it),Ie.return=Ye,Ie):(Ie=dv(it.type,it.key,it.props,null,Ye.mode,gt),kx(Ie,it),Ie.return=Ye,Ie)}function st(Ye,Ie,it,gt){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==it.containerInfo||Ie.stateNode.implementation!==it.implementation?(Ie=s2(it,Ye.mode,gt),Ie.return=Ye,Ie):(Ie=P(Ie,it.children||[]),Ie.return=Ye,Ie)}function mt(Ye,Ie,it,gt,Qt){return Ie===null||Ie.tag!==7?(Ie=wh(it,Ye.mode,gt,Qt),Ie.return=Ye,Ie):(Ie=P(Ie,it),Ie.return=Ye,Ie)}function bt(Ye,Ie,it){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number"||typeof Ie=="bigint")return Ie=a2(""+Ie,Ye.mode,it),Ie.return=Ye,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case p:return it=dv(Ie.type,Ie.key,Ie.props,null,Ye.mode,it),kx(it,Ie),it.return=Ye,it;case b:return Ie=s2(Ie,Ye.mode,it),Ie.return=Ye,Ie;case D:return Ie=Ah(Ie),bt(Ye,Ie,it)}if(W(Ie)||O(Ie))return Ie=wh(Ie,Ye.mode,it,null),Ie.return=Ye,Ie;if(typeof Ie.then=="function")return bt(Ye,bv(Ie),it);if(Ie.$$typeof===M)return bt(Ye,mv(Ye,Ie),it);yv(Ye,Ie)}return null}function ot(Ye,Ie,it,gt){var Qt=Ie!==null?Ie.key:null;if(typeof it=="string"&&it!==""||typeof it=="number"||typeof it=="bigint")return Qt!==null?null:ge(Ye,Ie,""+it,gt);if(typeof it=="object"&&it!==null){switch(it.$$typeof){case p:return it.key===Qt?Re(Ye,Ie,it,gt):null;case b:return it.key===Qt?st(Ye,Ie,it,gt):null;case D:return it=Ah(it),ot(Ye,Ie,it,gt)}if(W(it)||O(it))return Qt!==null?null:mt(Ye,Ie,it,gt,null);if(typeof it.then=="function")return ot(Ye,Ie,bv(it),gt);if(it.$$typeof===M)return ot(Ye,Ie,mv(Ye,it),gt);yv(Ye,it)}return null}function ct(Ye,Ie,it,gt,Qt){if(typeof gt=="string"&&gt!==""||typeof gt=="number"||typeof gt=="bigint")return Ye=Ye.get(it)||null,ge(Ie,Ye,""+gt,Qt);if(typeof gt=="object"&&gt!==null){switch(gt.$$typeof){case p:return Ye=Ye.get(gt.key===null?it:gt.key)||null,Re(Ie,Ye,gt,Qt);case b:return Ye=Ye.get(gt.key===null?it:gt.key)||null,st(Ie,Ye,gt,Qt);case D:return gt=Ah(gt),ct(Ye,Ie,it,gt,Qt)}if(W(gt)||O(gt))return Ye=Ye.get(it)||null,mt(Ie,Ye,gt,Qt,null);if(typeof gt.then=="function")return ct(Ye,Ie,it,bv(gt),Qt);if(gt.$$typeof===M)return ct(Ye,Ie,it,mv(Ie,gt),Qt);yv(Ie,gt)}return null}function Kt(Ye,Ie,it,gt){for(var Qt=null,$n=null,Yt=Ie,vn=Ie=0,On=null;Yt!==null&&vn<it.length;vn++){Yt.index>vn?(On=Yt,Yt=null):On=Yt.sibling;var Hn=ot(Ye,Yt,it[vn],gt);if(Hn===null){Yt===null&&(Yt=On);break}h&&Yt&&Hn.alternate===null&&g(Ye,Yt),Ie=I(Hn,Ie,vn),$n===null?Qt=Hn:$n.sibling=Hn,$n=Hn,Yt=On}if(vn===it.length)return _(Ye,Yt),Ln&&pc(Ye,vn),Qt;if(Yt===null){for(;vn<it.length;vn++)Yt=bt(Ye,it[vn],gt),Yt!==null&&(Ie=I(Yt,Ie,vn),$n===null?Qt=Yt:$n.sibling=Yt,$n=Yt);return Ln&&pc(Ye,vn),Qt}for(Yt=E(Yt);vn<it.length;vn++)On=ct(Yt,Ye,vn,it[vn],gt),On!==null&&(h&&On.alternate!==null&&Yt.delete(On.key===null?vn:On.key),Ie=I(On,Ie,vn),$n===null?Qt=On:$n.sibling=On,$n=On);return h&&Yt.forEach(function(Yu){return g(Ye,Yu)}),Ln&&pc(Ye,vn),Qt}function sn(Ye,Ie,it,gt){if(it==null)throw Error(r(151));for(var Qt=null,$n=null,Yt=Ie,vn=Ie=0,On=null,Hn=it.next();Yt!==null&&!Hn.done;vn++,Hn=it.next()){Yt.index>vn?(On=Yt,Yt=null):On=Yt.sibling;var Yu=ot(Ye,Yt,Hn.value,gt);if(Yu===null){Yt===null&&(Yt=On);break}h&&Yt&&Yu.alternate===null&&g(Ye,Yt),Ie=I(Yu,Ie,vn),$n===null?Qt=Yu:$n.sibling=Yu,$n=Yu,Yt=On}if(Hn.done)return _(Ye,Yt),Ln&&pc(Ye,vn),Qt;if(Yt===null){for(;!Hn.done;vn++,Hn=it.next())Hn=bt(Ye,Hn.value,gt),Hn!==null&&(Ie=I(Hn,Ie,vn),$n===null?Qt=Hn:$n.sibling=Hn,$n=Hn);return Ln&&pc(Ye,vn),Qt}for(Yt=E(Yt);!Hn.done;vn++,Hn=it.next())Hn=ct(Yt,Ye,vn,Hn.value,gt),Hn!==null&&(h&&Hn.alternate!==null&&Yt.delete(Hn.key===null?vn:Hn.key),Ie=I(Hn,Ie,vn),$n===null?Qt=Hn:$n.sibling=Hn,$n=Hn);return h&&Yt.forEach(function(Xse){return g(Ye,Xse)}),Ln&&pc(Ye,vn),Qt}function cr(Ye,Ie,it,gt){if(typeof it=="object"&&it!==null&&it.type===y&&it.key===null&&(it=it.props.children),typeof it=="object"&&it!==null){switch(it.$$typeof){case p:e:{for(var Qt=it.key;Ie!==null;){if(Ie.key===Qt){if(Qt=it.type,Qt===y){if(Ie.tag===7){_(Ye,Ie.sibling),gt=P(Ie,it.props.children),gt.return=Ye,Ye=gt;break e}}else if(Ie.elementType===Qt||typeof Qt=="object"&&Qt!==null&&Qt.$$typeof===D&&Ah(Qt)===Ie.type){_(Ye,Ie.sibling),gt=P(Ie,it.props),kx(gt,it),gt.return=Ye,Ye=gt;break e}_(Ye,Ie);break}else g(Ye,Ie);Ie=Ie.sibling}it.type===y?(gt=wh(it.props.children,Ye.mode,gt,it.key),gt.return=Ye,Ye=gt):(gt=dv(it.type,it.key,it.props,null,Ye.mode,gt),kx(gt,it),gt.return=Ye,Ye=gt)}return Q(Ye);case b:e:{for(Qt=it.key;Ie!==null;){if(Ie.key===Qt)if(Ie.tag===4&&Ie.stateNode.containerInfo===it.containerInfo&&Ie.stateNode.implementation===it.implementation){_(Ye,Ie.sibling),gt=P(Ie,it.children||[]),gt.return=Ye,Ye=gt;break e}else{_(Ye,Ie);break}else g(Ye,Ie);Ie=Ie.sibling}gt=s2(it,Ye.mode,gt),gt.return=Ye,Ye=gt}return Q(Ye);case D:return it=Ah(it),cr(Ye,Ie,it,gt)}if(W(it))return Kt(Ye,Ie,it,gt);if(O(it)){if(Qt=O(it),typeof Qt!="function")throw Error(r(150));return it=Qt.call(it),sn(Ye,Ie,it,gt)}if(typeof it.then=="function")return cr(Ye,Ie,bv(it),gt);if(it.$$typeof===M)return cr(Ye,Ie,mv(Ye,it),gt);yv(Ye,it)}return typeof it=="string"&&it!==""||typeof it=="number"||typeof it=="bigint"?(it=""+it,Ie!==null&&Ie.tag===6?(_(Ye,Ie.sibling),gt=P(Ie,it),gt.return=Ye,Ye=gt):(_(Ye,Ie),gt=a2(it,Ye.mode,gt),gt.return=Ye,Ye=gt),Q(Ye)):_(Ye,Ie)}return function(Ye,Ie,it,gt){try{Cx=0;var Qt=cr(Ye,Ie,it,gt);return Cm=null,Qt}catch(Yt){if(Yt===Tm||Yt===gv)throw Yt;var $n=As(29,Yt,null,Ye.mode);return $n.lanes=gt,$n.return=Ye,$n}}}var Ch=lF(!0),cF=lF(!1),Ru=!1;function b2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function y2(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function Du(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Ou(h,g,_){var E=h.updateQueue;if(E===null)return null;if(E=E.shared,(Kn&2)!==0){var P=E.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),E.pending=g,g=uv(h),WI(h,null,_),g}return cv(h,E,g,_),uv(h)}function jx(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var E=g.lanes;E&=h.pendingLanes,_|=E,g.lanes=_,ft(h,_)}}function v2(h,g){var _=h.updateQueue,E=h.alternate;if(E!==null&&(E=E.updateQueue,_===E)){var P=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var Q={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?P=I=Q:I=I.next=Q,_=_.next}while(_!==null);I===null?P=I=g:I=I.next=g}else P=I=g;_={baseState:E.baseState,firstBaseUpdate:P,lastBaseUpdate:I,shared:E.shared,callbacks:E.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var _2=!1;function Px(){if(_2){var h=Am;if(h!==null)throw h}}function Rx(h,g,_,E){_2=!1;var P=h.updateQueue;Ru=!1;var I=P.firstBaseUpdate,Q=P.lastBaseUpdate,ge=P.shared.pending;if(ge!==null){P.shared.pending=null;var Re=ge,st=Re.next;Re.next=null,Q===null?I=st:Q.next=st,Q=Re;var mt=h.alternate;mt!==null&&(mt=mt.updateQueue,ge=mt.lastBaseUpdate,ge!==Q&&(ge===null?mt.firstBaseUpdate=st:ge.next=st,mt.lastBaseUpdate=Re))}if(I!==null){var bt=P.baseState;Q=0,mt=st=Re=null,ge=I;do{var ot=ge.lane&-536870913,ct=ot!==ge.lane;if(ct?(Dn&ot)===ot:(E&ot)===ot){ot!==0&&ot===Nm&&(_2=!0),mt!==null&&(mt=mt.next={lane:0,tag:ge.tag,payload:ge.payload,callback:null,next:null});e:{var Kt=h,sn=ge;ot=g;var cr=_;switch(sn.tag){case 1:if(Kt=sn.payload,typeof Kt=="function"){bt=Kt.call(cr,bt,ot);break e}bt=Kt;break e;case 3:Kt.flags=Kt.flags&-65537|128;case 0:if(Kt=sn.payload,ot=typeof Kt=="function"?Kt.call(cr,bt,ot):Kt,ot==null)break e;bt=f({},bt,ot);break e;case 2:Ru=!0}}ot=ge.callback,ot!==null&&(h.flags|=64,ct&&(h.flags|=8192),ct=P.callbacks,ct===null?P.callbacks=[ot]:ct.push(ot))}else ct={lane:ot,tag:ge.tag,payload:ge.payload,callback:ge.callback,next:null},mt===null?(st=mt=ct,Re=bt):mt=mt.next=ct,Q|=ot;if(ge=ge.next,ge===null){if(ge=P.shared.pending,ge===null)break;ct=ge,ge=ct.next,ct.next=null,P.lastBaseUpdate=ct,P.shared.pending=null}}while(!0);mt===null&&(Re=bt),P.baseState=Re,P.firstBaseUpdate=st,P.lastBaseUpdate=mt,I===null&&(P.shared.lanes=0),zu|=Q,h.lanes=Q,h.memoizedState=bt}}function uF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function dF(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)uF(_[h],g)}var km=z(null),vv=z(0);function hF(h,g){h=Nc,Z(vv,h),Z(km,g),Nc=h|g.baseLanes}function w2(){Z(vv,Nc),Z(km,km.current)}function S2(){Nc=vv.current,V(km),V(vv)}var Ts=z(null),ao=null;function Lu(h){var g=h.alternate;Z(ai,ai.current&1),Z(Ts,h),ao===null&&(g===null||km.current!==null||g.memoizedState!==null)&&(ao=h)}function M2(h){Z(ai,ai.current),Z(Ts,h),ao===null&&(ao=h)}function fF(h){h.tag===22?(Z(ai,ai.current),Z(Ts,h),ao===null&&(ao=h)):Iu()}function Iu(){Z(ai,ai.current),Z(Ts,Ts.current)}function Cs(h){V(Ts),ao===h&&(ao=null),V(ai)}var ai=z(0);function _v(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||kA(_)||jA(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var bc=0,bn=null,or=null,di=null,wv=!1,jm=!1,kh=!1,Sv=0,Dx=0,Pm=null,Uae=0;function Wr(){throw Error(r(321))}function E2(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Ns(h[_],g[_]))return!1;return!0}function N2(h,g,_,E,P,I){return bc=I,bn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?YF:B2,kh=!1,I=_(E,P),kh=!1,jm&&(I=pF(g,_,E,P)),mF(h),I}function mF(h){K.H=Ix;var g=or!==null&&or.next!==null;if(bc=0,di=or=bn=null,wv=!1,Dx=0,Pm=null,g)throw Error(r(300));h===null||hi||(h=h.dependencies,h!==null&&fv(h)&&(hi=!0))}function pF(h,g,_,E){bn=h;var P=0;do{if(jm&&(Pm=null),Dx=0,jm=!1,25<=P)throw Error(r(301));if(P+=1,di=or=null,h.updateQueue!=null){var I=h.updateQueue;I.lastEffect=null,I.events=null,I.stores=null,I.memoCache!=null&&(I.memoCache.index=0)}K.H=ZF,I=g(_,E)}while(jm);return I}function zae(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?Ox(g):g,h=h.useState()[0],(or!==null?or.memoizedState:null)!==h&&(bn.flags|=1024),g}function A2(){var h=Sv!==0;return Sv=0,h}function T2(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function C2(h){if(wv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}wv=!1}bc=0,di=or=bn=null,jm=!1,Dx=Sv=0,Pm=null}function Ba(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return di===null?bn.memoizedState=di=h:di=di.next=h,di}function si(){if(or===null){var h=bn.alternate;h=h!==null?h.memoizedState:null}else h=or.next;var g=di===null?bn.memoizedState:di.next;if(g!==null)di=g,or=h;else{if(h===null)throw bn.alternate===null?Error(r(467)):Error(r(310));or=h,h={memoizedState:or.memoizedState,baseState:or.baseState,baseQueue:or.baseQueue,queue:or.queue,next:null},di===null?bn.memoizedState=di=h:di=di.next=h}return di}function Mv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ox(h){var g=Dx;return Dx+=1,Pm===null&&(Pm=[]),h=aF(Pm,h,g),g=bn,(di===null?g.memoizedState:di.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?YF:B2),h}function Ev(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Ox(h);if(h.$$typeof===M)return sa(h)}throw Error(r(438,String(h)))}function k2(h){var g=null,_=bn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var E=bn.alternate;E!==null&&(E=E.updateQueue,E!==null&&(E=E.memoCache,E!=null&&(g={data:E.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=Mv(),bn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),E=0;E<h;E++)_[E]=R;return g.index++,_}function yc(h,g){return typeof g=="function"?g(h):g}function Nv(h){var g=si();return j2(g,or,h)}function j2(h,g,_){var E=h.queue;if(E===null)throw Error(r(311));E.lastRenderedReducer=_;var P=h.baseQueue,I=E.pending;if(I!==null){if(P!==null){var Q=P.next;P.next=I.next,I.next=Q}g.baseQueue=P=I,E.pending=null}if(I=h.baseState,P===null)h.memoizedState=I;else{g=P.next;var ge=Q=null,Re=null,st=g,mt=!1;do{var bt=st.lane&-536870913;if(bt!==st.lane?(Dn&bt)===bt:(bc&bt)===bt){var ot=st.revertLane;if(ot===0)Re!==null&&(Re=Re.next={lane:0,revertLane:0,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null}),bt===Nm&&(mt=!0);else if((bc&ot)===ot){st=st.next,ot===Nm&&(mt=!0);continue}else bt={lane:0,revertLane:st.revertLane,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Re===null?(ge=Re=bt,Q=I):Re=Re.next=bt,bn.lanes|=ot,zu|=ot;bt=st.action,kh&&_(I,bt),I=st.hasEagerState?st.eagerState:_(I,bt)}else ot={lane:bt,revertLane:st.revertLane,gesture:st.gesture,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Re===null?(ge=Re=ot,Q=I):Re=Re.next=ot,bn.lanes|=bt,zu|=bt;st=st.next}while(st!==null&&st!==g);if(Re===null?Q=I:Re.next=ge,!Ns(I,h.memoizedState)&&(hi=!0,mt&&(_=Am,_!==null)))throw _;h.memoizedState=I,h.baseState=Q,h.baseQueue=Re,E.lastRenderedState=I}return P===null&&(E.lanes=0),[h.memoizedState,E.dispatch]}function P2(h){var g=si(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var E=_.dispatch,P=_.pending,I=g.memoizedState;if(P!==null){_.pending=null;var Q=P=P.next;do I=h(I,Q.action),Q=Q.next;while(Q!==P);Ns(I,g.memoizedState)||(hi=!0),g.memoizedState=I,g.baseQueue===null&&(g.baseState=I),_.lastRenderedState=I}return[I,E]}function gF(h,g,_){var E=bn,P=si(),I=Ln;if(I){if(_===void 0)throw Error(r(407));_=_()}else _=g();var Q=!Ns((or||P).memoizedState,_);if(Q&&(P.memoizedState=_,hi=!0),P=P.queue,O2(yF.bind(null,E,P,h),[h]),P.getSnapshot!==g||Q||di!==null&&di.memoizedState.tag&1){if(E.flags|=2048,Rm(9,{destroy:void 0},bF.bind(null,E,P,_,g),null),xr===null)throw Error(r(349));I||(bc&127)!==0||xF(E,g,_)}return _}function xF(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=bn.updateQueue,g===null?(g=Mv(),bn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function bF(h,g,_,E){g.value=_,g.getSnapshot=E,vF(g)&&_F(h)}function yF(h,g,_){return _(function(){vF(g)&&_F(h)})}function vF(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Ns(h,_)}catch{return!0}}function _F(h){var g=_h(h,2);g!==null&&cs(g,h,2)}function R2(h){var g=Ba();if(typeof h=="function"){var _=h;if(h=_(),kh){ye(!0);try{_()}finally{ye(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yc,lastRenderedState:h},g}function wF(h,g,_,E){return h.baseState=_,j2(h,or,typeof E=="function"?E:yc)}function Bae(h,g,_,E,P){if(Cv(h))throw Error(r(485));if(h=g.action,h!==null){var I={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Q){I.listeners.push(Q)}};K.T!==null?_(!0):I.isTransition=!1,E(I),_=g.pending,_===null?(I.next=g.pending=I,SF(g,I)):(I.next=_.next,g.pending=_.next=I)}}function SF(h,g){var _=g.action,E=g.payload,P=h.state;if(g.isTransition){var I=K.T,Q={};K.T=Q;try{var ge=_(P,E),Re=K.S;Re!==null&&Re(Q,ge),MF(h,g,ge)}catch(st){D2(h,g,st)}finally{I!==null&&Q.types!==null&&(I.types=Q.types),K.T=I}}else try{I=_(P,E),MF(h,g,I)}catch(st){D2(h,g,st)}}function MF(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(E){EF(h,g,E)},function(E){return D2(h,g,E)}):EF(h,g,_)}function EF(h,g,_){g.status="fulfilled",g.value=_,NF(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,SF(h,_)))}function D2(h,g,_){var E=h.pending;if(h.pending=null,E!==null){E=E.next;do g.status="rejected",g.reason=_,NF(g),g=g.next;while(g!==E)}h.action=null}function NF(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function AF(h,g){return g}function TF(h,g){if(Ln){var _=xr.formState;if(_!==null){e:{var E=bn;if(Ln){if(Ar){t:{for(var P=Ar,I=io;P.nodeType!==8;){if(!I){P=null;break t}if(P=so(P.nextSibling),P===null){P=null;break t}}I=P.data,P=I==="F!"||I==="F"?P:null}if(P){Ar=so(P.nextSibling),E=P.data==="F!";break e}}ju(E)}E=!1}E&&(g=_[0])}}return _=Ba(),_.memoizedState=_.baseState=g,E={pending:null,lanes:0,dispatch:null,lastRenderedReducer:AF,lastRenderedState:g},_.queue=E,_=qF.bind(null,bn,E),E.dispatch=_,E=R2(!1),I=z2.bind(null,bn,!1,E.queue),E=Ba(),P={state:g,dispatch:null,action:h,pending:null},E.queue=P,_=Bae.bind(null,bn,P,I,_),P.dispatch=_,E.memoizedState=h,[g,_,!1]}function CF(h){var g=si();return kF(g,or,h)}function kF(h,g,_){if(g=j2(h,g,AF)[0],h=Nv(yc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var E=Ox(g)}catch(Q){throw Q===Tm?gv:Q}else E=g;g=si();var P=g.queue,I=P.dispatch;return _!==g.memoizedState&&(bn.flags|=2048,Rm(9,{destroy:void 0},$ae.bind(null,P,_),null)),[E,I,h]}function $ae(h,g){h.action=g}function jF(h){var g=si(),_=or;if(_!==null)return kF(g,_,h);si(),g=g.memoizedState,_=si();var E=_.queue.dispatch;return _.memoizedState=h,[g,E,!1]}function Rm(h,g,_,E){return h={tag:h,create:_,deps:E,inst:g,next:null},g=bn.updateQueue,g===null&&(g=Mv(),bn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(E=_.next,_.next=h,h.next=E,g.lastEffect=h),h}function PF(){return si().memoizedState}function Av(h,g,_,E){var P=Ba();bn.flags|=h,P.memoizedState=Rm(1|g,{destroy:void 0},_,E===void 0?null:E)}function Tv(h,g,_,E){var P=si();E=E===void 0?null:E;var I=P.memoizedState.inst;or!==null&&E!==null&&E2(E,or.memoizedState.deps)?P.memoizedState=Rm(g,I,_,E):(bn.flags|=h,P.memoizedState=Rm(1|g,I,_,E))}function RF(h,g){Av(8390656,8,h,g)}function O2(h,g){Tv(2048,8,h,g)}function Hae(h){bn.flags|=4;var g=bn.updateQueue;if(g===null)g=Mv(),bn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function DF(h){var g=si().memoizedState;return Hae({ref:g,nextImpl:h}),function(){if((Kn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function OF(h,g){return Tv(4,2,h,g)}function LF(h,g){return Tv(4,4,h,g)}function IF(h,g){if(typeof g=="function"){h=h();var _=g(h);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function FF(h,g,_){_=_!=null?_.concat([h]):null,Tv(4,4,IF.bind(null,g,h),_)}function L2(){}function UF(h,g){var _=si();g=g===void 0?null:g;var E=_.memoizedState;return g!==null&&E2(g,E[1])?E[0]:(_.memoizedState=[h,g],h)}function zF(h,g){var _=si();g=g===void 0?null:g;var E=_.memoizedState;if(g!==null&&E2(g,E[1]))return E[0];if(E=h(),kh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[E,g],E}function I2(h,g,_){return _===void 0||(bc&1073741824)!==0&&(Dn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=B5(),bn.lanes|=h,zu|=h,_)}function BF(h,g,_,E){return Ns(_,g)?_:km.current!==null?(h=I2(h,_,E),Ns(h,g)||(hi=!0),h):(bc&42)===0||(bc&1073741824)!==0&&(Dn&261930)===0?(hi=!0,h.memoizedState=_):(h=B5(),bn.lanes|=h,zu|=h,g)}function $F(h,g,_,E,P){var I=G.p;G.p=I!==0&&8>I?I:8;var Q=K.T,ge={};K.T=ge,z2(h,!1,g,_);try{var Re=P(),st=K.S;if(st!==null&&st(ge,Re),Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var mt=Fae(Re,E);Lx(h,g,mt,Ps(h))}else Lx(h,g,E,Ps(h))}catch(bt){Lx(h,g,{then:function(){},status:"rejected",reason:bt},Ps())}finally{G.p=I,Q!==null&&ge.types!==null&&(Q.types=ge.types),K.T=Q}}function Vae(){}function F2(h,g,_,E){if(h.tag!==5)throw Error(r(476));var P=HF(h).queue;$F(h,P,g,J,_===null?Vae:function(){return VF(h),_(E)})}function HF(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yc,lastRenderedState:J},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function VF(h){var g=HF(h);g.next===null&&(g=h.alternate.memoizedState),Lx(h,g.next.queue,{},Ps())}function U2(){return sa(Jx)}function GF(){return si().memoizedState}function WF(){return si().memoizedState}function Gae(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Ps();h=Du(_);var E=Ou(g,h,_);E!==null&&(cs(E,g,_),jx(E,g,_)),g={cache:m2()},h.payload=g;return}g=g.return}}function Wae(h,g,_){var E=Ps();_={lane:E,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Cv(h)?KF(g,_):(_=r2(h,g,_,E),_!==null&&(cs(_,h,E),XF(_,g,E)))}function qF(h,g,_){var E=Ps();Lx(h,g,_,E)}function Lx(h,g,_,E){var P={lane:E,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Cv(h))KF(g,P);else{var I=h.alternate;if(h.lanes===0&&(I===null||I.lanes===0)&&(I=g.lastRenderedReducer,I!==null))try{var Q=g.lastRenderedState,ge=I(Q,_);if(P.hasEagerState=!0,P.eagerState=ge,Ns(ge,Q))return cv(h,g,P,0),xr===null&&lv(),!1}catch{}if(_=r2(h,g,P,E),_!==null)return cs(_,h,E),XF(_,g,E),!0}return!1}function z2(h,g,_,E){if(E={lane:2,revertLane:bA(),gesture:null,action:E,hasEagerState:!1,eagerState:null,next:null},Cv(h)){if(g)throw Error(r(479))}else g=r2(h,_,E,2),g!==null&&cs(g,h,2)}function Cv(h){var g=h.alternate;return h===bn||g!==null&&g===bn}function KF(h,g){jm=wv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function XF(h,g,_){if((_&4194048)!==0){var E=g.lanes;E&=h.pendingLanes,_|=E,g.lanes=_,ft(h,_)}}var Ix={readContext:sa,use:Ev,useCallback:Wr,useContext:Wr,useEffect:Wr,useImperativeHandle:Wr,useLayoutEffect:Wr,useInsertionEffect:Wr,useMemo:Wr,useReducer:Wr,useRef:Wr,useState:Wr,useDebugValue:Wr,useDeferredValue:Wr,useTransition:Wr,useSyncExternalStore:Wr,useId:Wr,useHostTransitionStatus:Wr,useFormState:Wr,useActionState:Wr,useOptimistic:Wr,useMemoCache:Wr,useCacheRefresh:Wr};Ix.useEffectEvent=Wr;var YF={readContext:sa,use:Ev,useCallback:function(h,g){return Ba().memoizedState=[h,g===void 0?null:g],h},useContext:sa,useEffect:RF,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,Av(4194308,4,IF.bind(null,g,h),_)},useLayoutEffect:function(h,g){return Av(4194308,4,h,g)},useInsertionEffect:function(h,g){Av(4,2,h,g)},useMemo:function(h,g){var _=Ba();g=g===void 0?null:g;var E=h();if(kh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[E,g],E},useReducer:function(h,g,_){var E=Ba();if(_!==void 0){var P=_(g);if(kh){ye(!0);try{_(g)}finally{ye(!1)}}}else P=g;return E.memoizedState=E.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},E.queue=h,h=h.dispatch=Wae.bind(null,bn,h),[E.memoizedState,h]},useRef:function(h){var g=Ba();return h={current:h},g.memoizedState=h},useState:function(h){h=R2(h);var g=h.queue,_=qF.bind(null,bn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:L2,useDeferredValue:function(h,g){var _=Ba();return I2(_,h,g)},useTransition:function(){var h=R2(!1);return h=$F.bind(null,bn,h.queue,!0,!1),Ba().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var E=bn,P=Ba();if(Ln){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),xr===null)throw Error(r(349));(Dn&127)!==0||xF(E,g,_)}P.memoizedState=_;var I={value:_,getSnapshot:g};return P.queue=I,RF(yF.bind(null,E,I,h),[h]),E.flags|=2048,Rm(9,{destroy:void 0},bF.bind(null,E,I,_,g),null),_},useId:function(){var h=Ba(),g=xr.identifierPrefix;if(Ln){var _=vl,E=yl;_=(E&~(1<<32-Ce(E)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Sv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=Uae++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:U2,useFormState:TF,useActionState:TF,useOptimistic:function(h){var g=Ba();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=z2.bind(null,bn,!0,_),_.dispatch=g,[h,g]},useMemoCache:k2,useCacheRefresh:function(){return Ba().memoizedState=Gae.bind(null,bn)},useEffectEvent:function(h){var g=Ba(),_={impl:h};return g.memoizedState=_,function(){if((Kn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},B2={readContext:sa,use:Ev,useCallback:UF,useContext:sa,useEffect:O2,useImperativeHandle:FF,useInsertionEffect:OF,useLayoutEffect:LF,useMemo:zF,useReducer:Nv,useRef:PF,useState:function(){return Nv(yc)},useDebugValue:L2,useDeferredValue:function(h,g){var _=si();return BF(_,or.memoizedState,h,g)},useTransition:function(){var h=Nv(yc)[0],g=si().memoizedState;return[typeof h=="boolean"?h:Ox(h),g]},useSyncExternalStore:gF,useId:GF,useHostTransitionStatus:U2,useFormState:CF,useActionState:CF,useOptimistic:function(h,g){var _=si();return wF(_,or,h,g)},useMemoCache:k2,useCacheRefresh:WF};B2.useEffectEvent=DF;var ZF={readContext:sa,use:Ev,useCallback:UF,useContext:sa,useEffect:O2,useImperativeHandle:FF,useInsertionEffect:OF,useLayoutEffect:LF,useMemo:zF,useReducer:P2,useRef:PF,useState:function(){return P2(yc)},useDebugValue:L2,useDeferredValue:function(h,g){var _=si();return or===null?I2(_,h,g):BF(_,or.memoizedState,h,g)},useTransition:function(){var h=P2(yc)[0],g=si().memoizedState;return[typeof h=="boolean"?h:Ox(h),g]},useSyncExternalStore:gF,useId:GF,useHostTransitionStatus:U2,useFormState:jF,useActionState:jF,useOptimistic:function(h,g){var _=si();return or!==null?wF(_,or,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:k2,useCacheRefresh:WF};ZF.useEffectEvent=DF;function $2(h,g,_,E){g=h.memoizedState,_=_(E,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var H2={enqueueSetState:function(h,g,_){h=h._reactInternals;var E=Ps(),P=Du(E);P.payload=g,_!=null&&(P.callback=_),g=Ou(h,P,E),g!==null&&(cs(g,h,E),jx(g,h,E))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var E=Ps(),P=Du(E);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=Ou(h,P,E),g!==null&&(cs(g,h,E),jx(g,h,E))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Ps(),E=Du(_);E.tag=2,g!=null&&(E.callback=g),g=Ou(h,E,_),g!==null&&(cs(g,h,_),jx(g,h,_))}};function QF(h,g,_,E,P,I,Q){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(E,I,Q):g.prototype&&g.prototype.isPureReactComponent?!Sx(_,E)||!Sx(P,I):!0}function JF(h,g,_,E){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,E),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,E),g.state!==h&&H2.enqueueReplaceState(g,g.state,null)}function jh(h,g){var _=g;if("ref"in g){_={};for(var E in g)E!=="ref"&&(_[E]=g[E])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function e5(h){ov(h)}function t5(h){console.error(h)}function n5(h){ov(h)}function kv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(E){setTimeout(function(){throw E})}}function r5(h,g,_){try{var E=h.onCaughtError;E(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function V2(h,g,_){return _=Du(_),_.tag=3,_.payload={element:null},_.callback=function(){kv(h,g)},_}function i5(h){return h=Du(h),h.tag=3,h}function a5(h,g,_,E){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var I=E.value;h.payload=function(){return P(I)},h.callback=function(){r5(g,_,E)}}var Q=_.stateNode;Q!==null&&typeof Q.componentDidCatch=="function"&&(h.callback=function(){r5(g,_,E),typeof P!="function"&&(Bu===null?Bu=new Set([this]):Bu.add(this));var ge=E.stack;this.componentDidCatch(E.value,{componentStack:ge!==null?ge:""})})}function qae(h,g,_,E,P){if(_.flags|=32768,E!==null&&typeof E=="object"&&typeof E.then=="function"){if(g=_.alternate,g!==null&&Em(g,_,P,!0),_=Ts.current,_!==null){switch(_.tag){case 31:case 13:return ao===null?$v():_.alternate===null&&qr===0&&(qr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,E===xv?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([E]):g.add(E),pA(h,E,P)),!1;case 22:return _.flags|=65536,E===xv?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([E])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([E]):_.add(E)),pA(h,E,P)),!1}throw Error(r(435,_.tag))}return pA(h,E,P),$v(),!1}if(Ln)return g=Ts.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,E!==c2&&(h=Error(r(422),{cause:E}),Nx(to(h,_)))):(E!==c2&&(g=Error(r(423),{cause:E}),Nx(to(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,E=to(E,_),P=V2(h.stateNode,E,P),v2(h,P),qr!==4&&(qr=2)),!1;var I=Error(r(520),{cause:E});if(I=to(I,_),Gx===null?Gx=[I]:Gx.push(I),qr!==4&&(qr=2),g===null)return!0;E=to(E,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=V2(_.stateNode,E,h),v2(_,h),!1;case 1:if(g=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(Bu===null||!Bu.has(I))))return _.flags|=65536,P&=-P,_.lanes|=P,P=i5(P),a5(P,h,_,E),v2(_,P),!1}_=_.return}while(_!==null);return!1}var G2=Error(r(461)),hi=!1;function oa(h,g,_,E){g.child=h===null?cF(g,null,_,E):Ch(g,h.child,_,E)}function s5(h,g,_,E,P){_=_.render;var I=g.ref;if("ref"in E){var Q={};for(var ge in E)ge!=="ref"&&(Q[ge]=E[ge])}else Q=E;return Eh(g),E=N2(h,g,_,Q,I,P),ge=A2(),h!==null&&!hi?(T2(h,g,P),vc(h,g,P)):(Ln&&ge&&o2(g),g.flags|=1,oa(h,g,E,P),g.child)}function o5(h,g,_,E,P){if(h===null){var I=_.type;return typeof I=="function"&&!i2(I)&&I.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=I,l5(h,g,I,E,P)):(h=dv(_.type,null,E,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(I=h.child,!J2(h,P)){var Q=I.memoizedProps;if(_=_.compare,_=_!==null?_:Sx,_(Q,E)&&h.ref===g.ref)return vc(h,g,P)}return g.flags|=1,h=mc(I,E),h.ref=g.ref,h.return=g,g.child=h}function l5(h,g,_,E,P){if(h!==null){var I=h.memoizedProps;if(Sx(I,E)&&h.ref===g.ref)if(hi=!1,g.pendingProps=E=I,J2(h,P))(h.flags&131072)!==0&&(hi=!0);else return g.lanes=h.lanes,vc(h,g,P)}return W2(h,g,_,E,P)}function c5(h,g,_,E){var P=E.children,I=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),E.mode==="hidden"){if((g.flags&128)!==0){if(I=I!==null?I.baseLanes|_:_,h!==null){for(E=g.child=h.child,P=0;E!==null;)P=P|E.lanes|E.childLanes,E=E.sibling;E=P&~I}else E=0,g.child=null;return u5(h,g,I,_,E)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&pv(g,I!==null?I.cachePool:null),I!==null?hF(g,I):w2(),fF(g);else return E=g.lanes=536870912,u5(h,g,I!==null?I.baseLanes|_:_,_,E)}else I!==null?(pv(g,I.cachePool),hF(g,I),Iu(),g.memoizedState=null):(h!==null&&pv(g,null),w2(),Iu());return oa(h,g,P,_),g.child}function Fx(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function u5(h,g,_,E,P){var I=g2();return I=I===null?null:{parent:ui._currentValue,pool:I},g.memoizedState={baseLanes:_,cachePool:I},h!==null&&pv(g,null),w2(),fF(g),h!==null&&Em(h,g,E,!0),g.childLanes=P,null}function jv(h,g){return g=Rv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function d5(h,g,_){return Ch(g,h.child,null,_),h=jv(g,g.pendingProps),h.flags|=2,Cs(g),g.memoizedState=null,h}function Kae(h,g,_){var E=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Ln){if(E.mode==="hidden")return h=jv(g,E),g.lanes=536870912,Fx(null,h);if(M2(g),(h=Ar)?(h=SU(h,io),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Cu!==null?{id:yl,overflow:vl}:null,retryLane:536870912,hydrationErrors:null},_=KI(h),_.return=g,g.child=_,aa=g,Ar=null)):h=null,h===null)throw ju(g);return g.lanes=536870912,null}return jv(g,E)}var I=h.memoizedState;if(I!==null){var Q=I.dehydrated;if(M2(g),P)if(g.flags&256)g.flags&=-257,g=d5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(hi||Em(h,g,_,!1),P=(_&h.childLanes)!==0,hi||P){if(E=xr,E!==null&&(Q=Xt(E,_),Q!==0&&Q!==I.retryLane))throw I.retryLane=Q,_h(h,Q),cs(E,h,Q),G2;$v(),g=d5(h,g,_)}else h=I.treeContext,Ar=so(Q.nextSibling),aa=g,Ln=!0,ku=null,io=!1,h!==null&&ZI(g,h),g=jv(g,E),g.flags|=4096;return g}return h=mc(h.child,{mode:E.mode,children:E.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Pv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function W2(h,g,_,E,P){return Eh(g),_=N2(h,g,_,E,void 0,P),E=A2(),h!==null&&!hi?(T2(h,g,P),vc(h,g,P)):(Ln&&E&&o2(g),g.flags|=1,oa(h,g,_,P),g.child)}function h5(h,g,_,E,P,I){return Eh(g),g.updateQueue=null,_=pF(g,E,_,P),mF(h),E=A2(),h!==null&&!hi?(T2(h,g,I),vc(h,g,I)):(Ln&&E&&o2(g),g.flags|=1,oa(h,g,_,I),g.child)}function f5(h,g,_,E,P){if(Eh(g),g.stateNode===null){var I=_m,Q=_.contextType;typeof Q=="object"&&Q!==null&&(I=sa(Q)),I=new _(E,I),g.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=H2,g.stateNode=I,I._reactInternals=g,I=g.stateNode,I.props=E,I.state=g.memoizedState,I.refs={},b2(g),Q=_.contextType,I.context=typeof Q=="object"&&Q!==null?sa(Q):_m,I.state=g.memoizedState,Q=_.getDerivedStateFromProps,typeof Q=="function"&&($2(g,_,Q,E),I.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(Q=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),Q!==I.state&&H2.enqueueReplaceState(I,I.state,null),Rx(g,E,I,P),Px(),I.state=g.memoizedState),typeof I.componentDidMount=="function"&&(g.flags|=4194308),E=!0}else if(h===null){I=g.stateNode;var ge=g.memoizedProps,Re=jh(_,ge);I.props=Re;var st=I.context,mt=_.contextType;Q=_m,typeof mt=="object"&&mt!==null&&(Q=sa(mt));var bt=_.getDerivedStateFromProps;mt=typeof bt=="function"||typeof I.getSnapshotBeforeUpdate=="function",ge=g.pendingProps!==ge,mt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ge||st!==Q)&&JF(g,I,E,Q),Ru=!1;var ot=g.memoizedState;I.state=ot,Rx(g,E,I,P),Px(),st=g.memoizedState,ge||ot!==st||Ru?(typeof bt=="function"&&($2(g,_,bt,E),st=g.memoizedState),(Re=Ru||QF(g,_,Re,E,ot,st,Q))?(mt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(g.flags|=4194308)):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=E,g.memoizedState=st),I.props=E,I.state=st,I.context=Q,E=Re):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),E=!1)}else{I=g.stateNode,y2(h,g),Q=g.memoizedProps,mt=jh(_,Q),I.props=mt,bt=g.pendingProps,ot=I.context,st=_.contextType,Re=_m,typeof st=="object"&&st!==null&&(Re=sa(st)),ge=_.getDerivedStateFromProps,(st=typeof ge=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(Q!==bt||ot!==Re)&&JF(g,I,E,Re),Ru=!1,ot=g.memoizedState,I.state=ot,Rx(g,E,I,P),Px();var ct=g.memoizedState;Q!==bt||ot!==ct||Ru||h!==null&&h.dependencies!==null&&fv(h.dependencies)?(typeof ge=="function"&&($2(g,_,ge,E),ct=g.memoizedState),(mt=Ru||QF(g,_,mt,E,ot,ct,Re)||h!==null&&h.dependencies!==null&&fv(h.dependencies))?(st||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(E,ct,Re),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(E,ct,Re)),typeof I.componentDidUpdate=="function"&&(g.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof I.componentDidUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),g.memoizedProps=E,g.memoizedState=ct),I.props=E,I.state=ct,I.context=Re,E=mt):(typeof I.componentDidUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),E=!1)}return I=E,Pv(h,g),E=(g.flags&128)!==0,I||E?(I=g.stateNode,_=E&&typeof _.getDerivedStateFromError!="function"?null:I.render(),g.flags|=1,h!==null&&E?(g.child=Ch(g,h.child,null,P),g.child=Ch(g,null,_,P)):oa(h,g,_,P),g.memoizedState=I.state,h=g.child):h=vc(h,g,P),h}function m5(h,g,_,E){return Sh(),g.flags|=256,oa(h,g,_,E),g.child}var q2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function K2(h){return{baseLanes:h,cachePool:rF()}}function X2(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=js),h}function p5(h,g,_){var E=g.pendingProps,P=!1,I=(g.flags&128)!==0,Q;if((Q=I)||(Q=h!==null&&h.memoizedState===null?!1:(ai.current&2)!==0),Q&&(P=!0,g.flags&=-129),Q=(g.flags&32)!==0,g.flags&=-33,h===null){if(Ln){if(P?Lu(g):Iu(),(h=Ar)?(h=SU(h,io),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Cu!==null?{id:yl,overflow:vl}:null,retryLane:536870912,hydrationErrors:null},_=KI(h),_.return=g,g.child=_,aa=g,Ar=null)):h=null,h===null)throw ju(g);return jA(h)?g.lanes=32:g.lanes=536870912,null}var ge=E.children;return E=E.fallback,P?(Iu(),P=g.mode,ge=Rv({mode:"hidden",children:ge},P),E=wh(E,P,_,null),ge.return=g,E.return=g,ge.sibling=E,g.child=ge,E=g.child,E.memoizedState=K2(_),E.childLanes=X2(h,Q,_),g.memoizedState=q2,Fx(null,E)):(Lu(g),Y2(g,ge))}var Re=h.memoizedState;if(Re!==null&&(ge=Re.dehydrated,ge!==null)){if(I)g.flags&256?(Lu(g),g.flags&=-257,g=Z2(h,g,_)):g.memoizedState!==null?(Iu(),g.child=h.child,g.flags|=128,g=null):(Iu(),ge=E.fallback,P=g.mode,E=Rv({mode:"visible",children:E.children},P),ge=wh(ge,P,_,null),ge.flags|=2,E.return=g,ge.return=g,E.sibling=ge,g.child=E,Ch(g,h.child,null,_),E=g.child,E.memoizedState=K2(_),E.childLanes=X2(h,Q,_),g.memoizedState=q2,g=Fx(null,E));else if(Lu(g),jA(ge)){if(Q=ge.nextSibling&&ge.nextSibling.dataset,Q)var st=Q.dgst;Q=st,E=Error(r(419)),E.stack="",E.digest=Q,Nx({value:E,source:null,stack:null}),g=Z2(h,g,_)}else if(hi||Em(h,g,_,!1),Q=(_&h.childLanes)!==0,hi||Q){if(Q=xr,Q!==null&&(E=Xt(Q,_),E!==0&&E!==Re.retryLane))throw Re.retryLane=E,_h(h,E),cs(Q,h,E),G2;kA(ge)||$v(),g=Z2(h,g,_)}else kA(ge)?(g.flags|=192,g.child=h.child,g=null):(h=Re.treeContext,Ar=so(ge.nextSibling),aa=g,Ln=!0,ku=null,io=!1,h!==null&&ZI(g,h),g=Y2(g,E.children),g.flags|=4096);return g}return P?(Iu(),ge=E.fallback,P=g.mode,Re=h.child,st=Re.sibling,E=mc(Re,{mode:"hidden",children:E.children}),E.subtreeFlags=Re.subtreeFlags&65011712,st!==null?ge=mc(st,ge):(ge=wh(ge,P,_,null),ge.flags|=2),ge.return=g,E.return=g,E.sibling=ge,g.child=E,Fx(null,E),E=g.child,ge=h.child.memoizedState,ge===null?ge=K2(_):(P=ge.cachePool,P!==null?(Re=ui._currentValue,P=P.parent!==Re?{parent:Re,pool:Re}:P):P=rF(),ge={baseLanes:ge.baseLanes|_,cachePool:P}),E.memoizedState=ge,E.childLanes=X2(h,Q,_),g.memoizedState=q2,Fx(h.child,E)):(Lu(g),_=h.child,h=_.sibling,_=mc(_,{mode:"visible",children:E.children}),_.return=g,_.sibling=null,h!==null&&(Q=g.deletions,Q===null?(g.deletions=[h],g.flags|=16):Q.push(h)),g.child=_,g.memoizedState=null,_)}function Y2(h,g){return g=Rv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Rv(h,g){return h=As(22,h,null,g),h.lanes=0,h}function Z2(h,g,_){return Ch(g,h.child,null,_),h=Y2(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function g5(h,g,_){h.lanes|=g;var E=h.alternate;E!==null&&(E.lanes|=g),h2(h.return,g,_)}function Q2(h,g,_,E,P,I){var Q=h.memoizedState;Q===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:E,tail:_,tailMode:P,treeForkCount:I}:(Q.isBackwards=g,Q.rendering=null,Q.renderingStartTime=0,Q.last=E,Q.tail=_,Q.tailMode=P,Q.treeForkCount=I)}function x5(h,g,_){var E=g.pendingProps,P=E.revealOrder,I=E.tail;E=E.children;var Q=ai.current,ge=(Q&2)!==0;if(ge?(Q=Q&1|2,g.flags|=128):Q&=1,Z(ai,Q),oa(h,g,E,_),E=Ln?Ex:0,!ge&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&g5(h,_,g);else if(h.tag===19)g5(h,_,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=g.child,P=null;_!==null;)h=_.alternate,h!==null&&_v(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),Q2(g,!1,P,_,I,E);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&_v(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}Q2(g,!0,_,null,I,E);break;case"together":Q2(g,!1,null,null,void 0,E);break;default:g.memoizedState=null}return g.child}function vc(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),zu|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(Em(h,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,_=mc(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=mc(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function J2(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&fv(h)))}function Xae(h,g,_){switch(g.tag){case 3:Ee(g,g.stateNode.containerInfo),Pu(g,ui,h.memoizedState.cache),Sh();break;case 27:case 5:we(g);break;case 4:Ee(g,g.stateNode.containerInfo);break;case 10:Pu(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,M2(g),null;break;case 13:var E=g.memoizedState;if(E!==null)return E.dehydrated!==null?(Lu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?p5(h,g,_):(Lu(g),h=vc(h,g,_),h!==null?h.sibling:null);Lu(g);break;case 19:var P=(h.flags&128)!==0;if(E=(_&g.childLanes)!==0,E||(Em(h,g,_,!1),E=(_&g.childLanes)!==0),P){if(E)return x5(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),Z(ai,ai.current),E)break;return null;case 22:return g.lanes=0,c5(h,g,_,g.pendingProps);case 24:Pu(g,ui,h.memoizedState.cache)}return vc(h,g,_)}function b5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)hi=!0;else{if(!J2(h,_)&&(g.flags&128)===0)return hi=!1,Xae(h,g,_);hi=(h.flags&131072)!==0}else hi=!1,Ln&&(g.flags&1048576)!==0&&YI(g,Ex,g.index);switch(g.lanes=0,g.tag){case 16:e:{var E=g.pendingProps;if(h=Ah(g.elementType),g.type=h,typeof h=="function")i2(h)?(E=jh(h,E),g.tag=1,g=f5(null,g,h,E,_)):(g.tag=0,g=W2(null,g,h,E,_));else{if(h!=null){var P=h.$$typeof;if(P===N){g.tag=11,g=s5(null,g,h,E,_);break e}else if(P===C){g.tag=14,g=o5(null,g,h,E,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return W2(h,g,g.type,g.pendingProps,_);case 1:return E=g.type,P=jh(E,g.pendingProps),f5(h,g,E,P,_);case 3:e:{if(Ee(g,g.stateNode.containerInfo),h===null)throw Error(r(387));E=g.pendingProps;var I=g.memoizedState;P=I.element,y2(h,g),Rx(g,E,null,_);var Q=g.memoizedState;if(E=Q.cache,Pu(g,ui,E),E!==I.cache&&f2(g,[ui],_,!0),Px(),E=Q.element,I.isDehydrated)if(I={element:E,isDehydrated:!1,cache:Q.cache},g.updateQueue.baseState=I,g.memoizedState=I,g.flags&256){g=m5(h,g,E,_);break e}else if(E!==P){P=to(Error(r(424)),g),Nx(P),g=m5(h,g,E,_);break e}else for(h=g.stateNode.containerInfo,h.nodeType===9?h=h.body:h=h.nodeName==="HTML"?h.ownerDocument.body:h,Ar=so(h.firstChild),aa=g,Ln=!0,ku=null,io=!0,_=cF(g,null,E,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Sh(),E===P){g=vc(h,g,_);break e}oa(h,g,E,_)}g=g.child}return g;case 26:return Pv(h,g),h===null?(_=CU(g.type,null,g.pendingProps,null))?g.memoizedState=_:Ln||(_=g.type,h=g.pendingProps,E=Xv(fe.current).createElement(_),E[er]=g,E[vt]=h,la(E,_,h),ue(E),g.stateNode=E):g.memoizedState=CU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return we(g),h===null&&Ln&&(E=g.stateNode=NU(g.type,g.pendingProps,fe.current),aa=g,io=!0,P=Ar,Gu(g.type)?(PA=P,Ar=so(E.firstChild)):Ar=P),oa(h,g,g.pendingProps.children,_),Pv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Ln&&((P=E=Ar)&&(E=Ese(E,g.type,g.pendingProps,io),E!==null?(g.stateNode=E,aa=g,Ar=so(E.firstChild),io=!1,P=!0):P=!1),P||ju(g)),we(g),P=g.type,I=g.pendingProps,Q=h!==null?h.memoizedProps:null,E=I.children,AA(P,I)?E=null:Q!==null&&AA(P,Q)&&(g.flags|=32),g.memoizedState!==null&&(P=N2(h,g,zae,null,null,_),Jx._currentValue=P),Pv(h,g),oa(h,g,E,_),g.child;case 6:return h===null&&Ln&&((h=_=Ar)&&(_=Nse(_,g.pendingProps,io),_!==null?(g.stateNode=_,aa=g,Ar=null,h=!0):h=!1),h||ju(g)),null;case 13:return p5(h,g,_);case 4:return Ee(g,g.stateNode.containerInfo),E=g.pendingProps,h===null?g.child=Ch(g,null,E,_):oa(h,g,E,_),g.child;case 11:return s5(h,g,g.type,g.pendingProps,_);case 7:return oa(h,g,g.pendingProps,_),g.child;case 8:return oa(h,g,g.pendingProps.children,_),g.child;case 12:return oa(h,g,g.pendingProps.children,_),g.child;case 10:return E=g.pendingProps,Pu(g,g.type,E.value),oa(h,g,E.children,_),g.child;case 9:return P=g.type._context,E=g.pendingProps.children,Eh(g),P=sa(P),E=E(P),g.flags|=1,oa(h,g,E,_),g.child;case 14:return o5(h,g,g.type,g.pendingProps,_);case 15:return l5(h,g,g.type,g.pendingProps,_);case 19:return x5(h,g,_);case 31:return Kae(h,g,_);case 22:return c5(h,g,_,g.pendingProps);case 24:return Eh(g),E=sa(ui),h===null?(P=g2(),P===null&&(P=xr,I=m2(),P.pooledCache=I,I.refCount++,I!==null&&(P.pooledCacheLanes|=_),P=I),g.memoizedState={parent:E,cache:P},b2(g),Pu(g,ui,P)):((h.lanes&_)!==0&&(y2(h,g),Rx(g,null,null,_),Px()),P=h.memoizedState,I=g.memoizedState,P.parent!==E?(P={parent:E,cache:E},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),Pu(g,ui,E)):(E=I.cache,Pu(g,ui,E),E!==P.cache&&f2(g,[ui],_,!0))),oa(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function _c(h){h.flags|=4}function eA(h,g,_,E,P){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(G5())h.flags|=8192;else throw Th=xv,x2}else h.flags&=-16777217}function y5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!DU(g))if(G5())h.flags|=8192;else throw Th=xv,x2}function Dv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Rt():536870912,h.lanes|=g,Im|=g)}function Ux(h,g){if(!Ln)switch(h.tailMode){case"hidden":g=h.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var E=null;_!==null;)_.alternate!==null&&(E=_),_=_.sibling;E===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:E.sibling=null}}function Tr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,E=0;if(g)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags&65011712,E|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,E|=P.subtreeFlags,E|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=E,h.childLanes=_,g}function Yae(h,g,_){var E=g.pendingProps;switch(l2(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tr(g),null;case 1:return Tr(g),null;case 3:return _=g.stateNode,E=null,h!==null&&(E=h.memoizedState.cache),g.memoizedState.cache!==E&&(g.flags|=2048),xc(ui),me(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Mm(g)?_c(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,u2())),Tr(g),null;case 26:var P=g.type,I=g.memoizedState;return h===null?(_c(g),I!==null?(Tr(g),y5(g,I)):(Tr(g),eA(g,P,null,E,_))):I?I!==h.memoizedState?(_c(g),Tr(g),y5(g,I)):(Tr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==E&&_c(g),Tr(g),eA(g,P,h,E,_)),null;case 27:if(De(g),_=fe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==E&&_c(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Tr(g),null}h=ne.current,Mm(g)?QI(g):(h=NU(P,E,_),g.stateNode=h,_c(g))}return Tr(g),null;case 5:if(De(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==E&&_c(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Tr(g),null}if(I=ne.current,Mm(g))QI(g);else{var Q=Xv(fe.current);switch(I){case 1:I=Q.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:I=Q.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":I=Q.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":I=Q.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":I=Q.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof E.is=="string"?Q.createElement("select",{is:E.is}):Q.createElement("select"),E.multiple?I.multiple=!0:E.size&&(I.size=E.size);break;default:I=typeof E.is=="string"?Q.createElement(P,{is:E.is}):Q.createElement(P)}}I[er]=g,I[vt]=E;e:for(Q=g.child;Q!==null;){if(Q.tag===5||Q.tag===6)I.appendChild(Q.stateNode);else if(Q.tag!==4&&Q.tag!==27&&Q.child!==null){Q.child.return=Q,Q=Q.child;continue}if(Q===g)break e;for(;Q.sibling===null;){if(Q.return===null||Q.return===g)break e;Q=Q.return}Q.sibling.return=Q.return,Q=Q.sibling}g.stateNode=I;e:switch(la(I,P,E),P){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}E&&_c(g)}}return Tr(g),eA(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==E&&_c(g);else{if(typeof E!="string"&&g.stateNode===null)throw Error(r(166));if(h=fe.current,Mm(g)){if(h=g.stateNode,_=g.memoizedProps,E=null,P=aa,P!==null)switch(P.tag){case 27:case 5:E=P.memoizedProps}h[er]=g,h=!!(h.nodeValue===_||E!==null&&E.suppressHydrationWarning===!0||pU(h.nodeValue,_)),h||ju(g,!0)}else h=Xv(h).createTextNode(E),h[er]=g,g.stateNode=h}return Tr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(E=Mm(g),_!==null){if(h===null){if(!E)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[er]=g}else Sh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Tr(g),h=!1}else _=u2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Cs(g),g):(Cs(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Tr(g),null;case 13:if(E=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Mm(g),E!==null&&E.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=g.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[er]=g}else Sh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Tr(g),P=!1}else P=u2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(Cs(g),g):(Cs(g),null)}return Cs(g),(g.flags&128)!==0?(g.lanes=_,g):(_=E!==null,h=h!==null&&h.memoizedState!==null,_&&(E=g.child,P=null,E.alternate!==null&&E.alternate.memoizedState!==null&&E.alternate.memoizedState.cachePool!==null&&(P=E.alternate.memoizedState.cachePool.pool),I=null,E.memoizedState!==null&&E.memoizedState.cachePool!==null&&(I=E.memoizedState.cachePool.pool),I!==P&&(E.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),Dv(g,g.updateQueue),Tr(g),null);case 4:return me(),h===null&&wA(g.stateNode.containerInfo),Tr(g),null;case 10:return xc(g.type),Tr(g),null;case 19:if(V(ai),E=g.memoizedState,E===null)return Tr(g),null;if(P=(g.flags&128)!==0,I=E.rendering,I===null)if(P)Ux(E,!1);else{if(qr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(I=_v(h),I!==null){for(g.flags|=128,Ux(E,!1),h=I.updateQueue,g.updateQueue=h,Dv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)qI(_,h),_=_.sibling;return Z(ai,ai.current&1|2),Ln&&pc(g,E.treeForkCount),g.child}h=h.sibling}E.tail!==null&&L()>Uv&&(g.flags|=128,P=!0,Ux(E,!1),g.lanes=4194304)}else{if(!P)if(h=_v(I),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,Dv(g,h),Ux(E,!0),E.tail===null&&E.tailMode==="hidden"&&!I.alternate&&!Ln)return Tr(g),null}else 2*L()-E.renderingStartTime>Uv&&_!==536870912&&(g.flags|=128,P=!0,Ux(E,!1),g.lanes=4194304);E.isBackwards?(I.sibling=g.child,g.child=I):(h=E.last,h!==null?h.sibling=I:g.child=I,E.last=I)}return E.tail!==null?(h=E.tail,E.rendering=h,E.tail=h.sibling,E.renderingStartTime=L(),h.sibling=null,_=ai.current,Z(ai,P?_&1|2:_&1),Ln&&pc(g,E.treeForkCount),h):(Tr(g),null);case 22:case 23:return Cs(g),S2(),E=g.memoizedState!==null,h!==null?h.memoizedState!==null!==E&&(g.flags|=8192):E&&(g.flags|=8192),E?(_&536870912)!==0&&(g.flags&128)===0&&(Tr(g),g.subtreeFlags&6&&(g.flags|=8192)):Tr(g),_=g.updateQueue,_!==null&&Dv(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),E=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(E=g.memoizedState.cachePool.pool),E!==_&&(g.flags|=2048),h!==null&&V(Nh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),xc(ui),Tr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Zae(h,g){switch(l2(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return xc(ui),me(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return De(g),null;case 31:if(g.memoizedState!==null){if(Cs(g),g.alternate===null)throw Error(r(340));Sh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Cs(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Sh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return V(ai),null;case 4:return me(),null;case 10:return xc(g.type),null;case 22:case 23:return Cs(g),S2(),h!==null&&V(Nh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return xc(ui),null;case 25:return null;default:return null}}function v5(h,g){switch(l2(g),g.tag){case 3:xc(ui),me();break;case 26:case 27:case 5:De(g);break;case 4:me();break;case 31:g.memoizedState!==null&&Cs(g);break;case 13:Cs(g);break;case 19:V(ai);break;case 10:xc(g.type);break;case 22:case 23:Cs(g),S2(),h!==null&&V(Nh);break;case 24:xc(ui)}}function zx(h,g){try{var _=g.updateQueue,E=_!==null?_.lastEffect:null;if(E!==null){var P=E.next;_=P;do{if((_.tag&h)===h){E=void 0;var I=_.create,Q=_.inst;E=I(),Q.destroy=E}_=_.next}while(_!==P)}}catch(ge){rr(g,g.return,ge)}}function Fu(h,g,_){try{var E=g.updateQueue,P=E!==null?E.lastEffect:null;if(P!==null){var I=P.next;E=I;do{if((E.tag&h)===h){var Q=E.inst,ge=Q.destroy;if(ge!==void 0){Q.destroy=void 0,P=g;var Re=_,st=ge;try{st()}catch(mt){rr(P,Re,mt)}}}E=E.next}while(E!==I)}}catch(mt){rr(g,g.return,mt)}}function _5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{dF(g,_)}catch(E){rr(h,h.return,E)}}}function w5(h,g,_){_.props=jh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(E){rr(h,g,E)}}function Bx(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var E=h.stateNode;break;case 30:E=h.stateNode;break;default:E=h.stateNode}typeof _=="function"?h.refCleanup=_(E):_.current=E}}catch(P){rr(h,g,P)}}function _l(h,g){var _=h.ref,E=h.refCleanup;if(_!==null)if(typeof E=="function")try{E()}catch(P){rr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){rr(h,g,P)}else _.current=null}function S5(h){var g=h.type,_=h.memoizedProps,E=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&E.focus();break e;case"img":_.src?E.src=_.src:_.srcSet&&(E.srcset=_.srcSet)}}catch(P){rr(h,h.return,P)}}function tA(h,g,_){try{var E=h.stateNode;yse(E,h.type,_,g),E[vt]=g}catch(P){rr(h,h.return,P)}}function M5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Gu(h.type)||h.tag===4}function nA(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||M5(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&&Gu(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 rA(h,g,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=hc));else if(E!==4&&(E===27&&Gu(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(rA(h,g,_),h=h.sibling;h!==null;)rA(h,g,_),h=h.sibling}function Ov(h,g,_){var E=h.tag;if(E===5||E===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(E!==4&&(E===27&&Gu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Ov(h,g,_),h=h.sibling;h!==null;)Ov(h,g,_),h=h.sibling}function E5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var E=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);la(g,E,_),g[er]=h,g[vt]=_}catch(I){rr(h,h.return,I)}}var wc=!1,fi=!1,iA=!1,N5=typeof WeakSet=="function"?WeakSet:Set,Ii=null;function Qae(h,g){if(h=h.containerInfo,EA=n_,h=FI(h),ZN(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var E=_.getSelection&&_.getSelection();if(E&&E.rangeCount!==0){_=E.anchorNode;var P=E.anchorOffset,I=E.focusNode;E=E.focusOffset;try{_.nodeType,I.nodeType}catch{_=null;break e}var Q=0,ge=-1,Re=-1,st=0,mt=0,bt=h,ot=null;t:for(;;){for(var ct;bt!==_||P!==0&&bt.nodeType!==3||(ge=Q+P),bt!==I||E!==0&&bt.nodeType!==3||(Re=Q+E),bt.nodeType===3&&(Q+=bt.nodeValue.length),(ct=bt.firstChild)!==null;)ot=bt,bt=ct;for(;;){if(bt===h)break t;if(ot===_&&++st===P&&(ge=Q),ot===I&&++mt===E&&(Re=Q),(ct=bt.nextSibling)!==null)break;bt=ot,ot=bt.parentNode}bt=ct}_=ge===-1||Re===-1?null:{start:ge,end:Re}}else _=null}_=_||{start:0,end:0}}else _=null;for(NA={focusedElem:h,selectionRange:_},n_=!1,Ii=g;Ii!==null;)if(g=Ii,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Ii=h;else for(;Ii!==null;){switch(g=Ii,I=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&I!==null){h=void 0,_=g,P=I.memoizedProps,I=I.memoizedState,E=_.stateNode;try{var Kt=jh(_.type,P);h=E.getSnapshotBeforeUpdate(Kt,I),E.__reactInternalSnapshotBeforeUpdate=h}catch(sn){rr(_,_.return,sn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)CA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":CA(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=g.sibling,h!==null){h.return=g.return,Ii=h;break}Ii=g.return}}function A5(h,g,_){var E=_.flags;switch(_.tag){case 0:case 11:case 15:Mc(h,_),E&4&&zx(5,_);break;case 1:if(Mc(h,_),E&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(Q){rr(_,_.return,Q)}else{var P=jh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(Q){rr(_,_.return,Q)}}E&64&&_5(_),E&512&&Bx(_,_.return);break;case 3:if(Mc(h,_),E&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{dF(h,g)}catch(Q){rr(_,_.return,Q)}}break;case 27:g===null&&E&4&&E5(_);case 26:case 5:Mc(h,_),g===null&&E&4&&S5(_),E&512&&Bx(_,_.return);break;case 12:Mc(h,_);break;case 31:Mc(h,_),E&4&&k5(h,_);break;case 13:Mc(h,_),E&4&&j5(h,_),E&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=ose.bind(null,_),Ase(h,_))));break;case 22:if(E=_.memoizedState!==null||wc,!E){g=g!==null&&g.memoizedState!==null||fi,P=wc;var I=fi;wc=E,(fi=g)&&!I?Ec(h,_,(_.subtreeFlags&8772)!==0):Mc(h,_),wc=P,fi=I}break;case 30:break;default:Mc(h,_)}}function T5(h){var g=h.alternate;g!==null&&(h.alternate=null,T5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&et(g)),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 Pr=null,is=!1;function Sc(h,g,_){for(_=_.child;_!==null;)C5(h,g,_),_=_.sibling}function C5(h,g,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Ze,_)}catch{}switch(_.tag){case 26:fi||_l(_,g),Sc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:fi||_l(_,g);var E=Pr,P=is;Gu(_.type)&&(Pr=_.stateNode,is=!1),Sc(h,g,_),Yx(_.stateNode),Pr=E,is=P;break;case 5:fi||_l(_,g);case 6:if(E=Pr,P=is,Pr=null,Sc(h,g,_),Pr=E,is=P,Pr!==null)if(is)try{(Pr.nodeType===9?Pr.body:Pr.nodeName==="HTML"?Pr.ownerDocument.body:Pr).removeChild(_.stateNode)}catch(I){rr(_,g,I)}else try{Pr.removeChild(_.stateNode)}catch(I){rr(_,g,I)}break;case 18:Pr!==null&&(is?(h=Pr,_U(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Gm(h)):_U(Pr,_.stateNode));break;case 4:E=Pr,P=is,Pr=_.stateNode.containerInfo,is=!0,Sc(h,g,_),Pr=E,is=P;break;case 0:case 11:case 14:case 15:Fu(2,_,g),fi||Fu(4,_,g),Sc(h,g,_);break;case 1:fi||(_l(_,g),E=_.stateNode,typeof E.componentWillUnmount=="function"&&w5(_,g,E)),Sc(h,g,_);break;case 21:Sc(h,g,_);break;case 22:fi=(E=fi)||_.memoizedState!==null,Sc(h,g,_),fi=E;break;default:Sc(h,g,_)}}function k5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Gm(h)}catch(_){rr(g,g.return,_)}}}function j5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Gm(h)}catch(_){rr(g,g.return,_)}}function Jae(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new N5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new N5),g;default:throw Error(r(435,h.tag))}}function Lv(h,g){var _=Jae(h);g.forEach(function(E){if(!_.has(E)){_.add(E);var P=lse.bind(null,h,E);E.then(P,P)}})}function as(h,g){var _=g.deletions;if(_!==null)for(var E=0;E<_.length;E++){var P=_[E],I=h,Q=g,ge=Q;e:for(;ge!==null;){switch(ge.tag){case 27:if(Gu(ge.type)){Pr=ge.stateNode,is=!1;break e}break;case 5:Pr=ge.stateNode,is=!1;break e;case 3:case 4:Pr=ge.stateNode.containerInfo,is=!0;break e}ge=ge.return}if(Pr===null)throw Error(r(160));C5(I,Q,P),Pr=null,is=!1,I=P.alternate,I!==null&&(I.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)P5(g,h),g=g.sibling}var Uo=null;function P5(h,g){var _=h.alternate,E=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:as(g,h),ss(h),E&4&&(Fu(3,h,h.return),zx(3,h),Fu(5,h,h.return));break;case 1:as(g,h),ss(h),E&512&&(fi||_===null||_l(_,_.return)),E&64&&wc&&(h=h.updateQueue,h!==null&&(E=h.callbacks,E!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?E:_.concat(E))));break;case 26:var P=Uo;if(as(g,h),ss(h),E&512&&(fi||_===null||_l(_,_.return)),E&4){var I=_!==null?_.memoizedState:null;if(E=h.memoizedState,_===null)if(E===null)if(h.stateNode===null){e:{E=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(E){case"title":I=P.getElementsByTagName("title")[0],(!I||I[rt]||I[er]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=P.createElement(E),P.head.insertBefore(I,P.querySelector("head > title"))),la(I,E,_),I[er]=h,ue(I),E=I;break e;case"link":var Q=PU("link","href",P).get(E+(_.href||""));if(Q){for(var ge=0;ge<Q.length;ge++)if(I=Q[ge],I.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&I.getAttribute("rel")===(_.rel==null?null:_.rel)&&I.getAttribute("title")===(_.title==null?null:_.title)&&I.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Q.splice(ge,1);break t}}I=P.createElement(E),la(I,E,_),P.head.appendChild(I);break;case"meta":if(Q=PU("meta","content",P).get(E+(_.content||""))){for(ge=0;ge<Q.length;ge++)if(I=Q[ge],I.getAttribute("content")===(_.content==null?null:""+_.content)&&I.getAttribute("name")===(_.name==null?null:_.name)&&I.getAttribute("property")===(_.property==null?null:_.property)&&I.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&I.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Q.splice(ge,1);break t}}I=P.createElement(E),la(I,E,_),P.head.appendChild(I);break;default:throw Error(r(468,E))}I[er]=h,ue(I),E=I}h.stateNode=E}else RU(P,h.type,h.stateNode);else h.stateNode=jU(P,E,h.memoizedProps);else I!==E?(I===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):I.count--,E===null?RU(P,h.type,h.stateNode):jU(P,E,h.memoizedProps)):E===null&&h.stateNode!==null&&tA(h,h.memoizedProps,_.memoizedProps)}break;case 27:as(g,h),ss(h),E&512&&(fi||_===null||_l(_,_.return)),_!==null&&E&4&&tA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(as(g,h),ss(h),E&512&&(fi||_===null||_l(_,_.return)),h.flags&32){P=h.stateNode;try{Si(P,"")}catch(Kt){rr(h,h.return,Kt)}}E&4&&h.stateNode!=null&&(P=h.memoizedProps,tA(h,P,_!==null?_.memoizedProps:P)),E&1024&&(iA=!0);break;case 6:if(as(g,h),ss(h),E&4){if(h.stateNode===null)throw Error(r(162));E=h.memoizedProps,_=h.stateNode;try{_.nodeValue=E}catch(Kt){rr(h,h.return,Kt)}}break;case 3:if(Qv=null,P=Uo,Uo=Yv(g.containerInfo),as(g,h),Uo=P,ss(h),E&4&&_!==null&&_.memoizedState.isDehydrated)try{Gm(g.containerInfo)}catch(Kt){rr(h,h.return,Kt)}iA&&(iA=!1,R5(h));break;case 4:E=Uo,Uo=Yv(h.stateNode.containerInfo),as(g,h),ss(h),Uo=E;break;case 12:as(g,h),ss(h);break;case 31:as(g,h),ss(h),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 13:as(g,h),ss(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Fv=L()),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 22:P=h.memoizedState!==null;var Re=_!==null&&_.memoizedState!==null,st=wc,mt=fi;if(wc=st||P,fi=mt||Re,as(g,h),fi=mt,wc=st,ss(h),E&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||Re||wc||fi||Ph(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){Re=_=g;try{if(I=Re.stateNode,P)Q=I.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none";else{ge=Re.stateNode;var bt=Re.memoizedProps.style,ot=bt!=null&&bt.hasOwnProperty("display")?bt.display:null;ge.style.display=ot==null||typeof ot=="boolean"?"":(""+ot).trim()}}catch(Kt){rr(Re,Re.return,Kt)}}}else if(g.tag===6){if(_===null){Re=g;try{Re.stateNode.nodeValue=P?"":Re.memoizedProps}catch(Kt){rr(Re,Re.return,Kt)}}}else if(g.tag===18){if(_===null){Re=g;try{var ct=Re.stateNode;P?wU(ct,!0):wU(Re.stateNode,!1)}catch(Kt){rr(Re,Re.return,Kt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}E&4&&(E=h.updateQueue,E!==null&&(_=E.retryQueue,_!==null&&(E.retryQueue=null,Lv(h,_))));break;case 19:as(g,h),ss(h),E&4&&(E=h.updateQueue,E!==null&&(h.updateQueue=null,Lv(h,E)));break;case 30:break;case 21:break;default:as(g,h),ss(h)}}function ss(h){var g=h.flags;if(g&2){try{for(var _,E=h.return;E!==null;){if(M5(E)){_=E;break}E=E.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,I=nA(h);Ov(h,I,P);break;case 5:var Q=_.stateNode;_.flags&32&&(Si(Q,""),_.flags&=-33);var ge=nA(h);Ov(h,ge,Q);break;case 3:case 4:var Re=_.stateNode.containerInfo,st=nA(h);rA(h,st,Re);break;default:throw Error(r(161))}}catch(mt){rr(h,h.return,mt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function R5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;R5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Mc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)A5(h,g.alternate,g),g=g.sibling}function Ph(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Fu(4,g,g.return),Ph(g);break;case 1:_l(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&w5(g,g.return,_),Ph(g);break;case 27:Yx(g.stateNode);case 26:case 5:_l(g,g.return),Ph(g);break;case 22:g.memoizedState===null&&Ph(g);break;case 30:Ph(g);break;default:Ph(g)}h=h.sibling}}function Ec(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var E=g.alternate,P=h,I=g,Q=I.flags;switch(I.tag){case 0:case 11:case 15:Ec(P,I,_),zx(4,I);break;case 1:if(Ec(P,I,_),E=I,P=E.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(st){rr(E,E.return,st)}if(E=I,P=E.updateQueue,P!==null){var ge=E.stateNode;try{var Re=P.shared.hiddenCallbacks;if(Re!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Re.length;P++)uF(Re[P],ge)}catch(st){rr(E,E.return,st)}}_&&Q&64&&_5(I),Bx(I,I.return);break;case 27:E5(I);case 26:case 5:Ec(P,I,_),_&&E===null&&Q&4&&S5(I),Bx(I,I.return);break;case 12:Ec(P,I,_);break;case 31:Ec(P,I,_),_&&Q&4&&k5(P,I);break;case 13:Ec(P,I,_),_&&Q&4&&j5(P,I);break;case 22:I.memoizedState===null&&Ec(P,I,_),Bx(I,I.return);break;case 30:break;default:Ec(P,I,_)}g=g.sibling}}function aA(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Ax(_))}function sA(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Ax(h))}function zo(h,g,_,E){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)D5(h,g,_,E),g=g.sibling}function D5(h,g,_,E){var P=g.flags;switch(g.tag){case 0:case 11:case 15:zo(h,g,_,E),P&2048&&zx(9,g);break;case 1:zo(h,g,_,E);break;case 3:zo(h,g,_,E),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Ax(h)));break;case 12:if(P&2048){zo(h,g,_,E),h=g.stateNode;try{var I=g.memoizedProps,Q=I.id,ge=I.onPostCommit;typeof ge=="function"&&ge(Q,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Re){rr(g,g.return,Re)}}else zo(h,g,_,E);break;case 31:zo(h,g,_,E);break;case 13:zo(h,g,_,E);break;case 23:break;case 22:I=g.stateNode,Q=g.alternate,g.memoizedState!==null?I._visibility&2?zo(h,g,_,E):$x(h,g):I._visibility&2?zo(h,g,_,E):(I._visibility|=2,Dm(h,g,_,E,(g.subtreeFlags&10256)!==0||!1)),P&2048&&aA(Q,g);break;case 24:zo(h,g,_,E),P&2048&&sA(g.alternate,g);break;default:zo(h,g,_,E)}}function Dm(h,g,_,E,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var I=h,Q=g,ge=_,Re=E,st=Q.flags;switch(Q.tag){case 0:case 11:case 15:Dm(I,Q,ge,Re,P),zx(8,Q);break;case 23:break;case 22:var mt=Q.stateNode;Q.memoizedState!==null?mt._visibility&2?Dm(I,Q,ge,Re,P):$x(I,Q):(mt._visibility|=2,Dm(I,Q,ge,Re,P)),P&&st&2048&&aA(Q.alternate,Q);break;case 24:Dm(I,Q,ge,Re,P),P&&st&2048&&sA(Q.alternate,Q);break;default:Dm(I,Q,ge,Re,P)}g=g.sibling}}function $x(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,E=g,P=E.flags;switch(E.tag){case 22:$x(_,E),P&2048&&aA(E.alternate,E);break;case 24:$x(_,E),P&2048&&sA(E.alternate,E);break;default:$x(_,E)}g=g.sibling}}var Hx=8192;function Om(h,g,_){if(h.subtreeFlags&Hx)for(h=h.child;h!==null;)O5(h,g,_),h=h.sibling}function O5(h,g,_){switch(h.tag){case 26:Om(h,g,_),h.flags&Hx&&h.memoizedState!==null&&Use(_,Uo,h.memoizedState,h.memoizedProps);break;case 5:Om(h,g,_);break;case 3:case 4:var E=Uo;Uo=Yv(h.stateNode.containerInfo),Om(h,g,_),Uo=E;break;case 22:h.memoizedState===null&&(E=h.alternate,E!==null&&E.memoizedState!==null?(E=Hx,Hx=16777216,Om(h,g,_),Hx=E):Om(h,g,_));break;default:Om(h,g,_)}}function L5(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function Vx(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var E=g[_];Ii=E,F5(E,h)}L5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)I5(h),h=h.sibling}function I5(h){switch(h.tag){case 0:case 11:case 15:Vx(h),h.flags&2048&&Fu(9,h,h.return);break;case 3:Vx(h);break;case 12:Vx(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Iv(h)):Vx(h);break;default:Vx(h)}}function Iv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var E=g[_];Ii=E,F5(E,h)}L5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Fu(8,g,g.return),Iv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Iv(g));break;default:Iv(g)}h=h.sibling}}function F5(h,g){for(;Ii!==null;){var _=Ii;switch(_.tag){case 0:case 11:case 15:Fu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var E=_.memoizedState.cachePool.pool;E!=null&&E.refCount++}break;case 24:Ax(_.memoizedState.cache)}if(E=_.child,E!==null)E.return=_,Ii=E;else e:for(_=h;Ii!==null;){E=Ii;var P=E.sibling,I=E.return;if(T5(E),E===_){Ii=null;break e}if(P!==null){P.return=I,Ii=P;break e}Ii=I}}}var ese={getCacheForType:function(h){var g=sa(ui),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return sa(ui).controller.signal}},tse=typeof WeakMap=="function"?WeakMap:Map,Kn=0,xr=null,Cn=null,Dn=0,nr=0,ks=null,Uu=!1,Lm=!1,oA=!1,Nc=0,qr=0,zu=0,Rh=0,lA=0,js=0,Im=0,Gx=null,ls=null,cA=!1,Fv=0,U5=0,Uv=1/0,zv=null,Bu=null,Mi=0,$u=null,Fm=null,Ac=0,uA=0,dA=null,z5=null,Wx=0,hA=null;function Ps(){return(Kn&2)!==0&&Dn!==0?Dn&-Dn:K.T!==null?bA():gr()}function B5(){if(js===0)if((Dn&536870912)===0||Ln){var h=ve;ve<<=1,(ve&3932160)===0&&(ve=262144),js=h}else js=536870912;return h=Ts.current,h!==null&&(h.flags|=32),js}function cs(h,g,_){(h===xr&&(nr===2||nr===9)||h.cancelPendingCommit!==null)&&(Um(h,0),Hu(h,Dn,js,!1)),nn(h,_),((Kn&2)===0||h!==xr)&&(h===xr&&((Kn&2)===0&&(Rh|=_),qr===4&&Hu(h,Dn,js,!1)),wl(h))}function $5(h,g,_){if((Kn&6)!==0)throw Error(r(327));var E=!_&&(g&127)===0&&(g&h.expiredLanes)===0||Be(h,g),P=E?ise(h,g):mA(h,g,!0),I=E;do{if(P===0){Lm&&!E&&Hu(h,g,0,!1);break}else{if(_=h.current.alternate,I&&!nse(_)){P=mA(h,g,!1),I=!1;continue}if(P===2){if(I=g,h.errorRecoveryDisabledLanes&I)var Q=0;else Q=h.pendingLanes&-536870913,Q=Q!==0?Q:Q&536870912?536870912:0;if(Q!==0){g=Q;e:{var ge=h;P=Gx;var Re=ge.current.memoizedState.isDehydrated;if(Re&&(Um(ge,Q).flags|=256),Q=mA(ge,Q,!1),Q!==2){if(oA&&!Re){ge.errorRecoveryDisabledLanes|=I,Rh|=I,P=4;break e}I=ls,ls=P,I!==null&&(ls===null?ls=I:ls.push.apply(ls,I))}P=Q}if(I=!1,P!==2)continue}}if(P===1){Um(h,0),Hu(h,g,0,!0);break}e:{switch(E=h,I=P,I){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Hu(E,g,js,!Uu);break e;case 2:ls=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=Fv+300-L(),10<P)){if(Hu(E,g,js,!Uu),Ne(E,0,!0)!==0)break e;Ac=g,E.timeoutHandle=yU(H5.bind(null,E,_,ls,zv,cA,g,js,Rh,Im,Uu,I,"Throttled",-0,0),P);break e}H5(E,_,ls,zv,cA,g,js,Rh,Im,Uu,I,null,-0,0)}}break}while(!0);wl(h)}function H5(h,g,_,E,P,I,Q,ge,Re,st,mt,bt,ot,ct){if(h.timeoutHandle=-1,bt=g.subtreeFlags,bt&8192||(bt&16785408)===16785408){bt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:hc},O5(g,I,bt);var Kt=(I&62914560)===I?Fv-L():(I&4194048)===I?U5-L():0;if(Kt=zse(bt,Kt),Kt!==null){Ac=I,h.cancelPendingCommit=Kt(Z5.bind(null,h,g,I,_,E,P,Q,ge,Re,mt,bt,null,ot,ct)),Hu(h,I,Q,!st);return}}Z5(h,g,I,_,E,P,Q,ge,Re)}function nse(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var E=0;E<_.length;E++){var P=_[E],I=P.getSnapshot;P=P.value;try{if(!Ns(I(),P))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function Hu(h,g,_,E){g&=~lA,g&=~Rh,h.suspendedLanes|=g,h.pingedLanes&=~g,E&&(h.warmLanes|=g),E=h.expirationTimes;for(var P=g;0<P;){var I=31-Ce(P),Q=1<<I;E[I]=-1,P&=~Q}_!==0&&ln(h,_,g)}function Bv(){return(Kn&6)===0?(qx(0),!1):!0}function fA(){if(Cn!==null){if(nr===0)var h=Cn.return;else h=Cn,gc=Mh=null,C2(h),Cm=null,Cx=0,h=Cn;for(;h!==null;)v5(h.alternate,h),h=h.return;Cn=null}}function Um(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,wse(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Ac=0,fA(),xr=h,Cn=_=mc(h.current,null),Dn=g,nr=0,ks=null,Uu=!1,Lm=Be(h,g),oA=!1,Im=js=lA=Rh=zu=qr=0,ls=Gx=null,cA=!1,(g&8)!==0&&(g|=g&32);var E=h.entangledLanes;if(E!==0)for(h=h.entanglements,E&=g;0<E;){var P=31-Ce(E),I=1<<P;g|=h[P],E&=~I}return Nc=g,lv(),_}function V5(h,g){bn=null,K.H=Ix,g===Tm||g===gv?(g=sF(),nr=3):g===x2?(g=sF(),nr=4):nr=g===G2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,ks=g,Cn===null&&(qr=1,kv(h,to(g,h.current)))}function G5(){var h=Ts.current;return h===null?!0:(Dn&4194048)===Dn?ao===null:(Dn&62914560)===Dn||(Dn&536870912)!==0?h===ao:!1}function W5(){var h=K.H;return K.H=Ix,h===null?Ix:h}function q5(){var h=K.A;return K.A=ese,h}function $v(){qr=4,Uu||(Dn&4194048)!==Dn&&Ts.current!==null||(Lm=!0),(zu&134217727)===0&&(Rh&134217727)===0||xr===null||Hu(xr,Dn,js,!1)}function mA(h,g,_){var E=Kn;Kn|=2;var P=W5(),I=q5();(xr!==h||Dn!==g)&&(zv=null,Um(h,g)),g=!1;var Q=qr;e:do try{if(nr!==0&&Cn!==null){var ge=Cn,Re=ks;switch(nr){case 8:fA(),Q=6;break e;case 3:case 2:case 9:case 6:Ts.current===null&&(g=!0);var st=nr;if(nr=0,ks=null,zm(h,ge,Re,st),_&&Lm){Q=0;break e}break;default:st=nr,nr=0,ks=null,zm(h,ge,Re,st)}}rse(),Q=qr;break}catch(mt){V5(h,mt)}while(!0);return g&&h.shellSuspendCounter++,gc=Mh=null,Kn=E,K.H=P,K.A=I,Cn===null&&(xr=null,Dn=0,lv()),Q}function rse(){for(;Cn!==null;)K5(Cn)}function ise(h,g){var _=Kn;Kn|=2;var E=W5(),P=q5();xr!==h||Dn!==g?(zv=null,Uv=L()+500,Um(h,g)):Lm=Be(h,g);e:do try{if(nr!==0&&Cn!==null){g=Cn;var I=ks;t:switch(nr){case 1:nr=0,ks=null,zm(h,g,I,1);break;case 2:case 9:if(iF(I)){nr=0,ks=null,X5(g);break}g=function(){nr!==2&&nr!==9||xr!==h||(nr=7),wl(h)},I.then(g,g);break e;case 3:nr=7;break e;case 4:nr=5;break e;case 7:iF(I)?(nr=0,ks=null,X5(g)):(nr=0,ks=null,zm(h,g,I,7));break;case 5:var Q=null;switch(Cn.tag){case 26:Q=Cn.memoizedState;case 5:case 27:var ge=Cn;if(Q?DU(Q):ge.stateNode.complete){nr=0,ks=null;var Re=ge.sibling;if(Re!==null)Cn=Re;else{var st=ge.return;st!==null?(Cn=st,Hv(st)):Cn=null}break t}}nr=0,ks=null,zm(h,g,I,5);break;case 6:nr=0,ks=null,zm(h,g,I,6);break;case 8:fA(),qr=6;break e;default:throw Error(r(462))}}ase();break}catch(mt){V5(h,mt)}while(!0);return gc=Mh=null,K.H=E,K.A=P,Kn=_,Cn!==null?0:(xr=null,Dn=0,lv(),qr)}function ase(){for(;Cn!==null&&!Se();)K5(Cn)}function K5(h){var g=b5(h.alternate,h,Nc);h.memoizedProps=h.pendingProps,g===null?Hv(h):Cn=g}function X5(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=h5(_,g,g.pendingProps,g.type,void 0,Dn);break;case 11:g=h5(_,g,g.pendingProps,g.type.render,g.ref,Dn);break;case 5:C2(g);default:v5(_,g),g=Cn=qI(g,Nc),g=b5(_,g,Nc)}h.memoizedProps=h.pendingProps,g===null?Hv(h):Cn=g}function zm(h,g,_,E){gc=Mh=null,C2(g),Cm=null,Cx=0;var P=g.return;try{if(qae(h,P,g,_,Dn)){qr=1,kv(h,to(_,h.current)),Cn=null;return}}catch(I){if(P!==null)throw Cn=P,I;qr=1,kv(h,to(_,h.current)),Cn=null;return}g.flags&32768?(Ln||E===1?h=!0:Lm||(Dn&536870912)!==0?h=!1:(Uu=h=!0,(E===2||E===9||E===3||E===6)&&(E=Ts.current,E!==null&&E.tag===13&&(E.flags|=16384))),Y5(g,h)):Hv(g)}function Hv(h){var g=h;do{if((g.flags&32768)!==0){Y5(g,Uu);return}h=g.return;var _=Yae(g.alternate,g,Nc);if(_!==null){Cn=_;return}if(g=g.sibling,g!==null){Cn=g;return}Cn=g=h}while(g!==null);qr===0&&(qr=5)}function Y5(h,g){do{var _=Zae(h.alternate,h);if(_!==null){_.flags&=32767,Cn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){Cn=h;return}Cn=h=_}while(h!==null);qr=6,Cn=null}function Z5(h,g,_,E,P,I,Q,ge,Re){h.cancelPendingCommit=null;do Vv();while(Mi!==0);if((Kn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(I=g.lanes|g.childLanes,I|=n2,Lt(h,_,I,Q,ge,Re),h===xr&&(Cn=xr=null,Dn=0),Fm=g,$u=h,Ac=_,uA=I,dA=P,z5=E,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,cse(ae,function(){return nU(),null})):(h.callbackNode=null,h.callbackPriority=0),E=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||E){E=K.T,K.T=null,P=G.p,G.p=2,Q=Kn,Kn|=4;try{Qae(h,g,_)}finally{Kn=Q,G.p=P,K.T=E}}Mi=1,Q5(),J5(),eU()}}function Q5(){if(Mi===1){Mi=0;var h=$u,g=Fm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var E=G.p;G.p=2;var P=Kn;Kn|=4;try{P5(g,h);var I=NA,Q=FI(h.containerInfo),ge=I.focusedElem,Re=I.selectionRange;if(Q!==ge&&ge&&ge.ownerDocument&&II(ge.ownerDocument.documentElement,ge)){if(Re!==null&&ZN(ge)){var st=Re.start,mt=Re.end;if(mt===void 0&&(mt=st),"selectionStart"in ge)ge.selectionStart=st,ge.selectionEnd=Math.min(mt,ge.value.length);else{var bt=ge.ownerDocument||document,ot=bt&&bt.defaultView||window;if(ot.getSelection){var ct=ot.getSelection(),Kt=ge.textContent.length,sn=Math.min(Re.start,Kt),cr=Re.end===void 0?sn:Math.min(Re.end,Kt);!ct.extend&&sn>cr&&(Q=cr,cr=sn,sn=Q);var Ye=LI(ge,sn),Ie=LI(ge,cr);if(Ye&&Ie&&(ct.rangeCount!==1||ct.anchorNode!==Ye.node||ct.anchorOffset!==Ye.offset||ct.focusNode!==Ie.node||ct.focusOffset!==Ie.offset)){var it=bt.createRange();it.setStart(Ye.node,Ye.offset),ct.removeAllRanges(),sn>cr?(ct.addRange(it),ct.extend(Ie.node,Ie.offset)):(it.setEnd(Ie.node,Ie.offset),ct.addRange(it))}}}}for(bt=[],ct=ge;ct=ct.parentNode;)ct.nodeType===1&&bt.push({element:ct,left:ct.scrollLeft,top:ct.scrollTop});for(typeof ge.focus=="function"&&ge.focus(),ge=0;ge<bt.length;ge++){var gt=bt[ge];gt.element.scrollLeft=gt.left,gt.element.scrollTop=gt.top}}n_=!!EA,NA=EA=null}finally{Kn=P,G.p=E,K.T=_}}h.current=g,Mi=2}}function J5(){if(Mi===2){Mi=0;var h=$u,g=Fm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var E=G.p;G.p=2;var P=Kn;Kn|=4;try{A5(h,g.alternate,g)}finally{Kn=P,G.p=E,K.T=_}}Mi=3}}function eU(){if(Mi===4||Mi===3){Mi=0,$();var h=$u,g=Fm,_=Ac,E=z5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Mi=5:(Mi=0,Fm=$u=null,tU(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(Bu=null),wt(_),g=g.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Ze,g,void 0,(g.current.flags&128)===128)}catch{}if(E!==null){g=K.T,P=G.p,G.p=2,K.T=null;try{for(var I=h.onRecoverableError,Q=0;Q<E.length;Q++){var ge=E[Q];I(ge.value,{componentStack:ge.stack})}}finally{K.T=g,G.p=P}}(Ac&3)!==0&&Vv(),wl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===hA?Wx++:(Wx=0,hA=h):Wx=0,qx(0)}}function tU(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Ax(g)))}function Vv(){return Q5(),J5(),eU(),nU()}function nU(){if(Mi!==5)return!1;var h=$u,g=uA;uA=0;var _=wt(Ac),E=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=dA,dA=null;var I=$u,Q=Ac;if(Mi=0,Fm=$u=null,Ac=0,(Kn&6)!==0)throw Error(r(331));var ge=Kn;if(Kn|=4,I5(I.current),D5(I,I.current,Q,_),Kn=ge,qx(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Ze,I)}catch{}return!0}finally{G.p=P,K.T=E,tU(h,g)}}function rU(h,g,_){g=to(_,g),g=V2(h.stateNode,g,2),h=Ou(h,g,2),h!==null&&(nn(h,2),wl(h))}function rr(h,g,_){if(h.tag===3)rU(h,h,_);else for(;g!==null;){if(g.tag===3){rU(g,h,_);break}else if(g.tag===1){var E=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(Bu===null||!Bu.has(E))){h=to(_,h),_=i5(2),E=Ou(g,_,2),E!==null&&(a5(_,E,g,h),nn(E,2),wl(E));break}}g=g.return}}function pA(h,g,_){var E=h.pingCache;if(E===null){E=h.pingCache=new tse;var P=new Set;E.set(g,P)}else P=E.get(g),P===void 0&&(P=new Set,E.set(g,P));P.has(_)||(oA=!0,P.add(_),h=sse.bind(null,h,g,_),g.then(h,h))}function sse(h,g,_){var E=h.pingCache;E!==null&&E.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,xr===h&&(Dn&_)===_&&(qr===4||qr===3&&(Dn&62914560)===Dn&&300>L()-Fv?(Kn&2)===0&&Um(h,0):lA|=_,Im===Dn&&(Im=0)),wl(h)}function iU(h,g){g===0&&(g=Rt()),h=_h(h,g),h!==null&&(nn(h,g),wl(h))}function ose(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),iU(h,_)}function lse(h,g){var _=0;switch(h.tag){case 31:case 13:var E=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:E=h.stateNode;break;case 22:E=h.stateNode._retryCache;break;default:throw Error(r(314))}E!==null&&E.delete(g),iU(h,_)}function cse(h,g){return Ae(h,g)}var Gv=null,Bm=null,gA=!1,Wv=!1,xA=!1,Vu=0;function wl(h){h!==Bm&&h.next===null&&(Bm===null?Gv=Bm=h:Bm=Bm.next=h),Wv=!0,gA||(gA=!0,dse())}function qx(h,g){if(!xA&&Wv){xA=!0;do for(var _=!1,E=Gv;E!==null;){if(h!==0){var P=E.pendingLanes;if(P===0)var I=0;else{var Q=E.suspendedLanes,ge=E.pingedLanes;I=(1<<31-Ce(42|h)+1)-1,I&=P&~(Q&~ge),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(_=!0,lU(E,I))}else I=Dn,I=Ne(E,E===xr?I:0,E.cancelPendingCommit!==null||E.timeoutHandle!==-1),(I&3)===0||Be(E,I)||(_=!0,lU(E,I));E=E.next}while(_);xA=!1}}function use(){aU()}function aU(){Wv=gA=!1;var h=0;Vu!==0&&_se()&&(h=Vu);for(var g=L(),_=null,E=Gv;E!==null;){var P=E.next,I=sU(E,g);I===0?(E.next=null,_===null?Gv=P:_.next=P,P===null&&(Bm=_)):(_=E,(h!==0||(I&3)!==0)&&(Wv=!0)),E=P}Mi!==0&&Mi!==5||qx(h),Vu!==0&&(Vu=0)}function sU(h,g){for(var _=h.suspendedLanes,E=h.pingedLanes,P=h.expirationTimes,I=h.pendingLanes&-62914561;0<I;){var Q=31-Ce(I),ge=1<<Q,Re=P[Q];Re===-1?((ge&_)===0||(ge&E)!==0)&&(P[Q]=at(ge,g)):Re<=g&&(h.expiredLanes|=ge),I&=~ge}if(g=xr,_=Dn,_=Ne(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),E=h.callbackNode,_===0||h===g&&(nr===2||nr===9)||h.cancelPendingCommit!==null)return E!==null&&E!==null&&Le(E),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Be(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(E!==null&&Le(E),wt(_)){case 2:case 8:_=_e;break;case 32:_=ae;break;case 268435456:_=Pe;break;default:_=ae}return E=oU.bind(null,h),_=Ae(_,E),h.callbackPriority=g,h.callbackNode=_,g}return E!==null&&E!==null&&Le(E),h.callbackPriority=2,h.callbackNode=null,2}function oU(h,g){if(Mi!==0&&Mi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Vv()&&h.callbackNode!==_)return null;var E=Dn;return E=Ne(h,h===xr?E:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),E===0?null:($5(h,E,g),sU(h,L()),h.callbackNode!=null&&h.callbackNode===_?oU.bind(null,h):null)}function lU(h,g){if(Vv())return null;$5(h,g,!0)}function dse(){Sse(function(){(Kn&6)!==0?Ae(xe,use):aU()})}function bA(){if(Vu===0){var h=Nm;h===0&&(h=ze,ze<<=1,(ze&261888)===0&&(ze=256)),Vu=h}return Vu}function cU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ev(""+h)}function uU(h,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,h.id&&_.setAttribute("form",h.id),g.parentNode.insertBefore(_,g),h=new FormData(h),_.parentNode.removeChild(_),h}function hse(h,g,_,E,P){if(g==="submit"&&_&&_.stateNode===P){var I=cU((P[vt]||null).action),Q=E.submitter;Q&&(g=(g=Q[vt]||null)?cU(g.formAction):Q.getAttribute("formAction"),g!==null&&(I=g,Q=null));var ge=new iv("action","action",null,E,P);h.push({event:ge,listeners:[{instance:null,listener:function(){if(E.defaultPrevented){if(Vu!==0){var Re=Q?uU(P,Q):new FormData(P);F2(_,{pending:!0,data:Re,method:P.method,action:I},null,Re)}}else typeof I=="function"&&(ge.preventDefault(),Re=Q?uU(P,Q):new FormData(P),F2(_,{pending:!0,data:Re,method:P.method,action:I},I,Re))},currentTarget:P}]})}}for(var yA=0;yA<t2.length;yA++){var vA=t2[yA],fse=vA.toLowerCase(),mse=vA[0].toUpperCase()+vA.slice(1);Fo(fse,"on"+mse)}Fo(BI,"onAnimationEnd"),Fo($I,"onAnimationIteration"),Fo(HI,"onAnimationStart"),Fo("dblclick","onDoubleClick"),Fo("focusin","onFocus"),Fo("focusout","onBlur"),Fo(kae,"onTransitionRun"),Fo(jae,"onTransitionStart"),Fo(Pae,"onTransitionCancel"),Fo(VI,"onTransitionEnd"),Ve("onMouseEnter",["mouseout","mouseover"]),Ve("onMouseLeave",["mouseout","mouseover"]),Ve("onPointerEnter",["pointerout","pointerover"]),Ve("onPointerLeave",["pointerout","pointerover"]),qe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),qe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),qe("onBeforeInput",["compositionend","keypress","textInput","paste"]),qe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),qe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),qe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kx="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(" "),pse=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kx));function dU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var E=h[_],P=E.event;E=E.listeners;e:{var I=void 0;if(g)for(var Q=E.length-1;0<=Q;Q--){var ge=E[Q],Re=ge.instance,st=ge.currentTarget;if(ge=ge.listener,Re!==I&&P.isPropagationStopped())break e;I=ge,P.currentTarget=st;try{I(P)}catch(mt){ov(mt)}P.currentTarget=null,I=Re}else for(Q=0;Q<E.length;Q++){if(ge=E[Q],Re=ge.instance,st=ge.currentTarget,ge=ge.listener,Re!==I&&P.isPropagationStopped())break e;I=ge,P.currentTarget=st;try{I(P)}catch(mt){ov(mt)}P.currentTarget=null,I=Re}}}}function kn(h,g){var _=g[Nn];_===void 0&&(_=g[Nn]=new Set);var E=h+"__bubble";_.has(E)||(hU(g,h,2,!1),_.add(E))}function _A(h,g,_){var E=0;g&&(E|=4),hU(_,h,E,g)}var qv="_reactListening"+Math.random().toString(36).slice(2);function wA(h){if(!h[qv]){h[qv]=!0,je.forEach(function(_){_!=="selectionchange"&&(pse.has(_)||_A(_,!1,h),_A(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[qv]||(g[qv]=!0,_A("selectionchange",!1,g))}}function hU(h,g,_,E){switch(BU(g)){case 2:var P=Hse;break;case 8:P=Vse;break;default:P=IA}_=P.bind(null,g,_,h),P=void 0,!$N||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),E?P!==void 0?h.addEventListener(g,_,{capture:!0,passive:P}):h.addEventListener(g,_,!0):P!==void 0?h.addEventListener(g,_,{passive:P}):h.addEventListener(g,_,!1)}function SA(h,g,_,E,P){var I=E;if((g&1)===0&&(g&2)===0&&E!==null)e:for(;;){if(E===null)return;var Q=E.tag;if(Q===3||Q===4){var ge=E.stateNode.containerInfo;if(ge===P)break;if(Q===4)for(Q=E.return;Q!==null;){var Re=Q.tag;if((Re===3||Re===4)&&Q.stateNode.containerInfo===P)return;Q=Q.return}for(;ge!==null;){if(Q=Ct(ge),Q===null)return;if(Re=Q.tag,Re===5||Re===6||Re===26||Re===27){E=I=Q;continue e}ge=ge.parentNode}}E=E.return}xI(function(){var st=I,mt=zN(_),bt=[];e:{var ot=GI.get(h);if(ot!==void 0){var ct=iv,Kt=h;switch(h){case"keypress":if(nv(_)===0)break e;case"keydown":case"keyup":ct=lae;break;case"focusin":Kt="focus",ct=WN;break;case"focusout":Kt="blur",ct=WN;break;case"beforeblur":case"afterblur":ct=WN;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ct=vI;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ct=Yie;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ct=dae;break;case BI:case $I:case HI:ct=Jie;break;case VI:ct=fae;break;case"scroll":case"scrollend":ct=Kie;break;case"wheel":ct=pae;break;case"copy":case"cut":case"paste":ct=tae;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ct=wI;break;case"toggle":case"beforetoggle":ct=xae}var sn=(g&4)!==0,cr=!sn&&(h==="scroll"||h==="scrollend"),Ye=sn?ot!==null?ot+"Capture":null:ot;sn=[];for(var Ie=st,it;Ie!==null;){var gt=Ie;if(it=gt.stateNode,gt=gt.tag,gt!==5&&gt!==26&&gt!==27||it===null||Ye===null||(gt=gx(Ie,Ye),gt!=null&&sn.push(Xx(Ie,gt,it))),cr)break;Ie=Ie.return}0<sn.length&&(ot=new ct(ot,Kt,null,_,mt),bt.push({event:ot,listeners:sn}))}}if((g&7)===0){e:{if(ot=h==="mouseover"||h==="pointerover",ct=h==="mouseout"||h==="pointerout",ot&&_!==UN&&(Kt=_.relatedTarget||_.fromElement)&&(Ct(Kt)||Kt[on]))break e;if((ct||ot)&&(ot=mt.window===mt?mt:(ot=mt.ownerDocument)?ot.defaultView||ot.parentWindow:window,ct?(Kt=_.relatedTarget||_.toElement,ct=st,Kt=Kt?Ct(Kt):null,Kt!==null&&(cr=a(Kt),sn=Kt.tag,Kt!==cr||sn!==5&&sn!==27&&sn!==6)&&(Kt=null)):(ct=null,Kt=st),ct!==Kt)){if(sn=vI,gt="onMouseLeave",Ye="onMouseEnter",Ie="mouse",(h==="pointerout"||h==="pointerover")&&(sn=wI,gt="onPointerLeave",Ye="onPointerEnter",Ie="pointer"),cr=ct==null?ot:Mt(ct),it=Kt==null?ot:Mt(Kt),ot=new sn(gt,Ie+"leave",ct,_,mt),ot.target=cr,ot.relatedTarget=it,gt=null,Ct(mt)===st&&(sn=new sn(Ye,Ie+"enter",Kt,_,mt),sn.target=it,sn.relatedTarget=cr,gt=sn),cr=gt,ct&&Kt)t:{for(sn=gse,Ye=ct,Ie=Kt,it=0,gt=Ye;gt;gt=sn(gt))it++;gt=0;for(var Qt=Ie;Qt;Qt=sn(Qt))gt++;for(;0<it-gt;)Ye=sn(Ye),it--;for(;0<gt-it;)Ie=sn(Ie),gt--;for(;it--;){if(Ye===Ie||Ie!==null&&Ye===Ie.alternate){sn=Ye;break t}Ye=sn(Ye),Ie=sn(Ie)}sn=null}else sn=null;ct!==null&&fU(bt,ot,ct,sn,!1),Kt!==null&&cr!==null&&fU(bt,cr,Kt,sn,!0)}}e:{if(ot=st?Mt(st):window,ct=ot.nodeName&&ot.nodeName.toLowerCase(),ct==="select"||ct==="input"&&ot.type==="file")var $n=kI;else if(TI(ot))if(jI)$n=Aae;else{$n=Eae;var Yt=Mae}else ct=ot.nodeName,!ct||ct.toLowerCase()!=="input"||ot.type!=="checkbox"&&ot.type!=="radio"?st&&Io(st.elementType)&&($n=kI):$n=Nae;if($n&&($n=$n(h,st))){CI(bt,$n,_,mt);break e}Yt&&Yt(h,ot,st),h==="focusout"&&st&&ot.type==="number"&&st.memoizedProps.value!=null&&ta(ot,"number",ot.value)}switch(Yt=st?Mt(st):window,h){case"focusin":(TI(Yt)||Yt.contentEditable==="true")&&(bm=Yt,QN=st,Mx=null);break;case"focusout":Mx=QN=bm=null;break;case"mousedown":JN=!0;break;case"contextmenu":case"mouseup":case"dragend":JN=!1,UI(bt,_,mt);break;case"selectionchange":if(Cae)break;case"keydown":case"keyup":UI(bt,_,mt)}var vn;if(KN)e:{switch(h){case"compositionstart":var On="onCompositionStart";break e;case"compositionend":On="onCompositionEnd";break e;case"compositionupdate":On="onCompositionUpdate";break e}On=void 0}else xm?NI(h,_)&&(On="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(On="onCompositionStart");On&&(SI&&_.locale!=="ko"&&(xm||On!=="onCompositionStart"?On==="onCompositionEnd"&&xm&&(vn=bI()):(Tu=mt,HN="value"in Tu?Tu.value:Tu.textContent,xm=!0)),Yt=Kv(st,On),0<Yt.length&&(On=new _I(On,h,null,_,mt),bt.push({event:On,listeners:Yt}),vn?On.data=vn:(vn=AI(_),vn!==null&&(On.data=vn)))),(vn=yae?vae(h,_):_ae(h,_))&&(On=Kv(st,"onBeforeInput"),0<On.length&&(Yt=new _I("onBeforeInput","beforeinput",null,_,mt),bt.push({event:Yt,listeners:On}),Yt.data=vn)),hse(bt,h,st,_,mt)}dU(bt,g)})}function Xx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function Kv(h,g){for(var _=g+"Capture",E=[];h!==null;){var P=h,I=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||I===null||(P=gx(h,_),P!=null&&E.unshift(Xx(h,P,I)),P=gx(h,g),P!=null&&E.push(Xx(h,P,I))),h.tag===3)return E;h=h.return}return[]}function gse(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function fU(h,g,_,E,P){for(var I=g._reactName,Q=[];_!==null&&_!==E;){var ge=_,Re=ge.alternate,st=ge.stateNode;if(ge=ge.tag,Re!==null&&Re===E)break;ge!==5&&ge!==26&&ge!==27||st===null||(Re=st,P?(st=gx(_,I),st!=null&&Q.unshift(Xx(_,st,Re))):P||(st=gx(_,I),st!=null&&Q.push(Xx(_,st,Re)))),_=_.return}Q.length!==0&&h.push({event:g,listeners:Q})}var xse=/\r\n?/g,bse=/\u0000|\uFFFD/g;function mU(h){return(typeof h=="string"?h:""+h).replace(xse,`
  9. `).replace(bse,"")}function pU(h,g){return g=mU(g),mU(h)===g}function lr(h,g,_,E,P,I){switch(_){case"children":typeof E=="string"?g==="body"||g==="textarea"&&E===""||Si(h,E):(typeof E=="number"||typeof E=="bigint")&&g!=="body"&&Si(h,""+E);break;case"className":Ot(h,"class",E);break;case"tabIndex":Ot(h,"tabindex",E);break;case"dir":case"role":case"viewBox":case"width":case"height":Ot(h,_,E);break;case"style":mm(h,E,I);break;case"data":if(g!=="object"){Ot(h,"data",E);break}case"src":case"href":if(E===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(E==null||typeof E=="function"||typeof E=="symbol"||typeof E=="boolean"){h.removeAttribute(_);break}E=ev(""+E),h.setAttribute(_,E);break;case"action":case"formAction":if(typeof E=="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 I=="function"&&(_==="formAction"?(g!=="input"&&lr(h,g,"name",P.name,P,null),lr(h,g,"formEncType",P.formEncType,P,null),lr(h,g,"formMethod",P.formMethod,P,null),lr(h,g,"formTarget",P.formTarget,P,null)):(lr(h,g,"encType",P.encType,P,null),lr(h,g,"method",P.method,P,null),lr(h,g,"target",P.target,P,null)));if(E==null||typeof E=="symbol"||typeof E=="boolean"){h.removeAttribute(_);break}E=ev(""+E),h.setAttribute(_,E);break;case"onClick":E!=null&&(h.onclick=hc);break;case"onScroll":E!=null&&kn("scroll",h);break;case"onScrollEnd":E!=null&&kn("scrollend",h);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(_=E.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=E&&typeof E!="function"&&typeof E!="symbol";break;case"muted":h.muted=E&&typeof E!="function"&&typeof E!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(E==null||typeof E=="function"||typeof E=="boolean"||typeof E=="symbol"){h.removeAttribute("xlink:href");break}_=ev(""+E),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":E!=null&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,""+E):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":E&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":E===!0?h.setAttribute(_,""):E!==!1&&E!=null&&typeof E!="function"&&typeof E!="symbol"?h.setAttribute(_,E):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":E!=null&&typeof E!="function"&&typeof E!="symbol"&&!isNaN(E)&&1<=E?h.setAttribute(_,E):h.removeAttribute(_);break;case"rowSpan":case"start":E==null||typeof E=="function"||typeof E=="symbol"||isNaN(E)?h.removeAttribute(_):h.setAttribute(_,E);break;case"popover":kn("beforetoggle",h),kn("toggle",h),St(h,"popover",E);break;case"xlinkActuate":Ft(h,"http://www.w3.org/1999/xlink","xlink:actuate",E);break;case"xlinkArcrole":Ft(h,"http://www.w3.org/1999/xlink","xlink:arcrole",E);break;case"xlinkRole":Ft(h,"http://www.w3.org/1999/xlink","xlink:role",E);break;case"xlinkShow":Ft(h,"http://www.w3.org/1999/xlink","xlink:show",E);break;case"xlinkTitle":Ft(h,"http://www.w3.org/1999/xlink","xlink:title",E);break;case"xlinkType":Ft(h,"http://www.w3.org/1999/xlink","xlink:type",E);break;case"xmlBase":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:base",E);break;case"xmlLang":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:lang",E);break;case"xmlSpace":Ft(h,"http://www.w3.org/XML/1998/namespace","xml:space",E);break;case"is":St(h,"is",E);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Wie.get(_)||_,St(h,_,E))}}function MA(h,g,_,E,P,I){switch(_){case"style":mm(h,E,I);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(_=E.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof E=="string"?Si(h,E):(typeof E=="number"||typeof E=="bigint")&&Si(h,""+E);break;case"onScroll":E!=null&&kn("scroll",h);break;case"onScrollEnd":E!=null&&kn("scrollend",h);break;case"onClick":E!=null&&(h.onclick=hc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ge.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),g=_.slice(2,P?_.length-7:void 0),I=h[vt]||null,I=I!=null?I[_]:null,typeof I=="function"&&h.removeEventListener(g,I,P),typeof E=="function")){typeof I!="function"&&I!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,E,P);break e}_ in h?h[_]=E:E===!0?h.setAttribute(_,""):St(h,_,E)}}}function la(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":kn("error",h),kn("load",h);var E=!1,P=!1,I;for(I in _)if(_.hasOwnProperty(I)){var Q=_[I];if(Q!=null)switch(I){case"src":E=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:lr(h,g,I,Q,_,null)}}P&&lr(h,g,"srcSet",_.srcSet,_,null),E&&lr(h,g,"src",_.src,_,null);return;case"input":kn("invalid",h);var ge=I=Q=P=null,Re=null,st=null;for(E in _)if(_.hasOwnProperty(E)){var mt=_[E];if(mt!=null)switch(E){case"name":P=mt;break;case"type":Q=mt;break;case"checked":Re=mt;break;case"defaultChecked":st=mt;break;case"value":I=mt;break;case"defaultValue":ge=mt;break;case"children":case"dangerouslySetInnerHTML":if(mt!=null)throw Error(r(137,g));break;default:lr(h,g,E,mt,_,null)}}Qs(h,I,ge,Re,st,Q,P,!1);return;case"select":kn("invalid",h),E=Q=I=null;for(P in _)if(_.hasOwnProperty(P)&&(ge=_[P],ge!=null))switch(P){case"value":I=ge;break;case"defaultValue":Q=ge;break;case"multiple":E=ge;default:lr(h,g,P,ge,_,null)}g=I,_=Q,h.multiple=!!E,g!=null?Js(h,!!E,g,!1):_!=null&&Js(h,!!E,_,!0);return;case"textarea":kn("invalid",h),I=P=E=null;for(Q in _)if(_.hasOwnProperty(Q)&&(ge=_[Q],ge!=null))switch(Q){case"value":E=ge;break;case"defaultValue":P=ge;break;case"children":I=ge;break;case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(91));break;default:lr(h,g,Q,ge,_,null)}na(h,E,P,I);return;case"option":for(Re in _)_.hasOwnProperty(Re)&&(E=_[Re],E!=null)&&(Re==="selected"?h.selected=E&&typeof E!="function"&&typeof E!="symbol":lr(h,g,Re,E,_,null));return;case"dialog":kn("beforetoggle",h),kn("toggle",h),kn("cancel",h),kn("close",h);break;case"iframe":case"object":kn("load",h);break;case"video":case"audio":for(E=0;E<Kx.length;E++)kn(Kx[E],h);break;case"image":kn("error",h),kn("load",h);break;case"details":kn("toggle",h);break;case"embed":case"source":case"link":kn("error",h),kn("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(st in _)if(_.hasOwnProperty(st)&&(E=_[st],E!=null))switch(st){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:lr(h,g,st,E,_,null)}return;default:if(Io(g)){for(mt in _)_.hasOwnProperty(mt)&&(E=_[mt],E!==void 0&&MA(h,g,mt,E,_,void 0));return}}for(ge in _)_.hasOwnProperty(ge)&&(E=_[ge],E!=null&&lr(h,g,ge,E,_,null))}function yse(h,g,_,E){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,I=null,Q=null,ge=null,Re=null,st=null,mt=null;for(ct in _){var bt=_[ct];if(_.hasOwnProperty(ct)&&bt!=null)switch(ct){case"checked":break;case"value":break;case"defaultValue":Re=bt;default:E.hasOwnProperty(ct)||lr(h,g,ct,null,E,bt)}}for(var ot in E){var ct=E[ot];if(bt=_[ot],E.hasOwnProperty(ot)&&(ct!=null||bt!=null))switch(ot){case"type":I=ct;break;case"name":P=ct;break;case"checked":st=ct;break;case"defaultChecked":mt=ct;break;case"value":Q=ct;break;case"defaultValue":ge=ct;break;case"children":case"dangerouslySetInnerHTML":if(ct!=null)throw Error(r(137,g));break;default:ct!==bt&&lr(h,g,ot,ct,E,bt)}}wi(h,Q,ge,Re,st,mt,I,P);return;case"select":ct=Q=ge=ot=null;for(I in _)if(Re=_[I],_.hasOwnProperty(I)&&Re!=null)switch(I){case"value":break;case"multiple":ct=Re;default:E.hasOwnProperty(I)||lr(h,g,I,null,E,Re)}for(P in E)if(I=E[P],Re=_[P],E.hasOwnProperty(P)&&(I!=null||Re!=null))switch(P){case"value":ot=I;break;case"defaultValue":ge=I;break;case"multiple":Q=I;default:I!==Re&&lr(h,g,P,I,E,Re)}g=ge,_=Q,E=ct,ot!=null?Js(h,!!_,ot,!1):!!E!=!!_&&(g!=null?Js(h,!!_,g,!0):Js(h,!!_,_?[]:"",!1));return;case"textarea":ct=ot=null;for(ge in _)if(P=_[ge],_.hasOwnProperty(ge)&&P!=null&&!E.hasOwnProperty(ge))switch(ge){case"value":break;case"children":break;default:lr(h,g,ge,null,E,P)}for(Q in E)if(P=E[Q],I=_[Q],E.hasOwnProperty(Q)&&(P!=null||I!=null))switch(Q){case"value":ot=P;break;case"defaultValue":ct=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==I&&lr(h,g,Q,P,E,I)}tr(h,ot,ct);return;case"option":for(var Kt in _)ot=_[Kt],_.hasOwnProperty(Kt)&&ot!=null&&!E.hasOwnProperty(Kt)&&(Kt==="selected"?h.selected=!1:lr(h,g,Kt,null,E,ot));for(Re in E)ot=E[Re],ct=_[Re],E.hasOwnProperty(Re)&&ot!==ct&&(ot!=null||ct!=null)&&(Re==="selected"?h.selected=ot&&typeof ot!="function"&&typeof ot!="symbol":lr(h,g,Re,ot,E,ct));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 sn in _)ot=_[sn],_.hasOwnProperty(sn)&&ot!=null&&!E.hasOwnProperty(sn)&&lr(h,g,sn,null,E,ot);for(st in E)if(ot=E[st],ct=_[st],E.hasOwnProperty(st)&&ot!==ct&&(ot!=null||ct!=null))switch(st){case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,g));break;default:lr(h,g,st,ot,E,ct)}return;default:if(Io(g)){for(var cr in _)ot=_[cr],_.hasOwnProperty(cr)&&ot!==void 0&&!E.hasOwnProperty(cr)&&MA(h,g,cr,void 0,E,ot);for(mt in E)ot=E[mt],ct=_[mt],!E.hasOwnProperty(mt)||ot===ct||ot===void 0&&ct===void 0||MA(h,g,mt,ot,E,ct);return}}for(var Ye in _)ot=_[Ye],_.hasOwnProperty(Ye)&&ot!=null&&!E.hasOwnProperty(Ye)&&lr(h,g,Ye,null,E,ot);for(bt in E)ot=E[bt],ct=_[bt],!E.hasOwnProperty(bt)||ot===ct||ot==null&&ct==null||lr(h,g,bt,ot,E,ct)}function gU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vse(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),E=0;E<_.length;E++){var P=_[E],I=P.transferSize,Q=P.initiatorType,ge=P.duration;if(I&&ge&&gU(Q)){for(Q=0,ge=P.responseEnd,E+=1;E<_.length;E++){var Re=_[E],st=Re.startTime;if(st>ge)break;var mt=Re.transferSize,bt=Re.initiatorType;mt&&gU(bt)&&(Re=Re.responseEnd,Q+=mt*(Re<ge?1:(ge-st)/(Re-st)))}if(--E,g+=8*(I+Q)/(P.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var EA=null,NA=null;function Xv(h){return h.nodeType===9?h:h.ownerDocument}function xU(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 bU(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function AA(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var TA=null;function _se(){var h=window.event;return h&&h.type==="popstate"?h===TA?!1:(TA=h,!0):(TA=null,!1)}var yU=typeof setTimeout=="function"?setTimeout:void 0,wse=typeof clearTimeout=="function"?clearTimeout:void 0,vU=typeof Promise=="function"?Promise:void 0,Sse=typeof queueMicrotask=="function"?queueMicrotask:typeof vU<"u"?function(h){return vU.resolve(null).then(h).catch(Mse)}:yU;function Mse(h){setTimeout(function(){throw h})}function Gu(h){return h==="head"}function _U(h,g){var _=g,E=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(E===0){h.removeChild(P),Gm(g);return}E--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")E++;else if(_==="html")Yx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Yx(_);for(var I=_.firstChild;I;){var Q=I.nextSibling,ge=I.nodeName;I[rt]||ge==="SCRIPT"||ge==="STYLE"||ge==="LINK"&&I.rel.toLowerCase()==="stylesheet"||_.removeChild(I),I=Q}}else _==="body"&&Yx(h.ownerDocument.body);_=P}while(_);Gm(g)}function wU(h,g){var _=h;h=0;do{var E=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),E&&E.nodeType===8)if(_=E.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=E}while(_)}function CA(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":CA(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Ese(h,g,_,E){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!E&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(E){if(!h[rt])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(I=h.getAttribute("rel"),I==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(I!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(I=h.getAttribute("src"),(I!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&I&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var I=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===I)return h}else return h;if(h=so(h.nextSibling),h===null)break}return null}function Nse(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=so(h.nextSibling),h===null))return null;return h}function SU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=so(h.nextSibling),h===null))return null;return h}function kA(h){return h.data==="$?"||h.data==="$~"}function jA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Ase(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var E=function(){g(),_.removeEventListener("DOMContentLoaded",E)};_.addEventListener("DOMContentLoaded",E),h._reactRetry=E}}function so(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var PA=null;function MU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return so(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function EU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return h;g--}else _!=="/$"&&_!=="/&"||g++}h=h.previousSibling}return null}function NU(h,g,_){switch(g=Xv(_),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Yx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);et(h)}var oo=new Map,AU=new Set;function Yv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Tc=G.d;G.d={f:Tse,r:Cse,D:kse,C:jse,L:Pse,m:Rse,X:Ose,S:Dse,M:Lse};function Tse(){var h=Tc.f(),g=Bv();return h||g}function Cse(h){var g=yt(h);g!==null&&g.tag===5&&g.type==="form"?VF(g):Tc.r(h)}var $m=typeof document>"u"?null:document;function TU(h,g,_){var E=$m;if(E&&typeof g=="string"&&g){var P=an(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),AU.has(P)||(AU.add(P),h={rel:h,crossOrigin:_,href:g},E.querySelector(P)===null&&(g=E.createElement("link"),la(g,"link",h),ue(g),E.head.appendChild(g)))}}function kse(h){Tc.D(h),TU("dns-prefetch",h,null)}function jse(h,g){Tc.C(h,g),TU("preconnect",h,g)}function Pse(h,g,_){Tc.L(h,g,_);var E=$m;if(E&&h&&g){var P='link[rel="preload"][as="'+an(g)+'"]';g==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+an(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+an(_.imageSizes)+'"]')):P+='[href="'+an(h)+'"]';var I=P;switch(g){case"style":I=Hm(h);break;case"script":I=Vm(h)}oo.has(I)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),oo.set(I,h),E.querySelector(P)!==null||g==="style"&&E.querySelector(Zx(I))||g==="script"&&E.querySelector(Qx(I))||(g=E.createElement("link"),la(g,"link",h),ue(g),E.head.appendChild(g)))}}function Rse(h,g){Tc.m(h,g);var _=$m;if(_&&h){var E=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+an(E)+'"][href="'+an(h)+'"]',I=P;switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=Vm(h)}if(!oo.has(I)&&(h=f({rel:"modulepreload",href:h},g),oo.set(I,h),_.querySelector(P)===null)){switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Qx(I)))return}E=_.createElement("link"),la(E,"link",h),ue(E),_.head.appendChild(E)}}}function Dse(h,g,_){Tc.S(h,g,_);var E=$m;if(E&&h){var P=Vt(E).hoistableStyles,I=Hm(h);g=g||"default";var Q=P.get(I);if(!Q){var ge={loading:0,preload:null};if(Q=E.querySelector(Zx(I)))ge.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=oo.get(I))&&RA(h,_);var Re=Q=E.createElement("link");ue(Re),la(Re,"link",h),Re._p=new Promise(function(st,mt){Re.onload=st,Re.onerror=mt}),Re.addEventListener("load",function(){ge.loading|=1}),Re.addEventListener("error",function(){ge.loading|=2}),ge.loading|=4,Zv(Q,g,E)}Q={type:"stylesheet",instance:Q,count:1,state:ge},P.set(I,Q)}}}function Ose(h,g){Tc.X(h,g);var _=$m;if(_&&h){var E=Vt(_).hoistableScripts,P=Vm(h),I=E.get(P);I||(I=_.querySelector(Qx(P)),I||(h=f({src:h,async:!0},g),(g=oo.get(P))&&DA(h,g),I=_.createElement("script"),ue(I),la(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},E.set(P,I))}}function Lse(h,g){Tc.M(h,g);var _=$m;if(_&&h){var E=Vt(_).hoistableScripts,P=Vm(h),I=E.get(P);I||(I=_.querySelector(Qx(P)),I||(h=f({src:h,async:!0,type:"module"},g),(g=oo.get(P))&&DA(h,g),I=_.createElement("script"),ue(I),la(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},E.set(P,I))}}function CU(h,g,_,E){var P=(P=fe.current)?Yv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Hm(_.href),_=Vt(P).hoistableStyles,E=_.get(g),E||(E={type:"style",instance:null,count:0,state:null},_.set(g,E)),E):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Hm(_.href);var I=Vt(P).hoistableStyles,Q=I.get(h);if(Q||(P=P.ownerDocument||P,Q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(h,Q),(I=P.querySelector(Zx(h)))&&!I._p&&(Q.instance=I,Q.state.loading=5),oo.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},oo.set(h,_),I||Ise(P,h,_,Q.state))),g&&E===null)throw Error(r(528,""));return Q}if(g&&E!==null)throw Error(r(529,""));return null;case"script":return g=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=Vm(_),_=Vt(P).hoistableScripts,E=_.get(g),E||(E={type:"script",instance:null,count:0,state:null},_.set(g,E)),E):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Hm(h){return'href="'+an(h)+'"'}function Zx(h){return'link[rel="stylesheet"]['+h+"]"}function kU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Ise(h,g,_,E){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?E.loading=1:(g=h.createElement("link"),E.preload=g,g.addEventListener("load",function(){return E.loading|=1}),g.addEventListener("error",function(){return E.loading|=2}),la(g,"link",_),ue(g),h.head.appendChild(g))}function Vm(h){return'[src="'+an(h)+'"]'}function Qx(h){return"script[async]"+h}function jU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var E=h.querySelector('style[data-href~="'+an(_.href)+'"]');if(E)return g.instance=E,ue(E),E;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return E=(h.ownerDocument||h).createElement("style"),ue(E),la(E,"style",P),Zv(E,_.precedence,h),g.instance=E;case"stylesheet":P=Hm(_.href);var I=h.querySelector(Zx(P));if(I)return g.state.loading|=4,g.instance=I,ue(I),I;E=kU(_),(P=oo.get(P))&&RA(E,P),I=(h.ownerDocument||h).createElement("link"),ue(I);var Q=I;return Q._p=new Promise(function(ge,Re){Q.onload=ge,Q.onerror=Re}),la(I,"link",E),g.state.loading|=4,Zv(I,_.precedence,h),g.instance=I;case"script":return I=Vm(_.src),(P=h.querySelector(Qx(I)))?(g.instance=P,ue(P),P):(E=_,(P=oo.get(I))&&(E=f({},_),DA(E,P)),h=h.ownerDocument||h,P=h.createElement("script"),ue(P),la(P,"link",E),h.head.appendChild(P),g.instance=P);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(E=g.instance,g.state.loading|=4,Zv(E,_.precedence,h));return g.instance}function Zv(h,g,_){for(var E=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=E.length?E[E.length-1]:null,I=P,Q=0;Q<E.length;Q++){var ge=E[Q];if(ge.dataset.precedence===g)I=ge;else if(I!==P)break}I?I.parentNode.insertBefore(h,I.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function RA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function DA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var Qv=null;function PU(h,g,_){if(Qv===null){var E=new Map,P=Qv=new Map;P.set(_,E)}else P=Qv,E=P.get(_),E||(E=new Map,P.set(_,E));if(E.has(h))return E;for(E.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var I=_[P];if(!(I[rt]||I[er]||h==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var Q=I.getAttribute(g)||"";Q=h+Q;var ge=E.get(Q);ge?ge.push(I):E.set(Q,[I])}}return E}function RU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function Fse(h,g,_){if(_===1||g.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;return g.rel==="stylesheet"?(h=g.disabled,typeof g.precedence=="string"&&h==null):!0;case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function DU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function Use(h,g,_,E){if(_.type==="stylesheet"&&(typeof E.media!="string"||matchMedia(E.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Hm(E.href),I=g.querySelector(Zx(P));if(I){g=I._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=Jv.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=I,ue(I);return}I=g.ownerDocument||g,E=kU(E),(P=oo.get(P))&&RA(E,P),I=I.createElement("link"),ue(I);var Q=I;Q._p=new Promise(function(ge,Re){Q.onload=ge,Q.onerror=Re}),la(I,"link",E),_.instance=I}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Jv.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var OA=0;function zse(h,g){return h.stylesheets&&h.count===0&&t_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var E=setTimeout(function(){if(h.stylesheets&&t_(h,h.stylesheets),h.unsuspend){var I=h.unsuspend;h.unsuspend=null,I()}},6e4+g);0<h.imgBytes&&OA===0&&(OA=62500*vse());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&t_(h,h.stylesheets),h.unsuspend)){var I=h.unsuspend;h.unsuspend=null,I()}},(h.imgBytes>OA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(E),clearTimeout(P)}}:null}function Jv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)t_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var e_=null;function t_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,e_=new Map,g.forEach(Bse,h),e_=null,Jv.call(h))}function Bse(h,g){if(!(g.state.loading&4)){var _=e_.get(h);if(_)var E=_.get(null);else{_=new Map,e_.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<P.length;I++){var Q=P[I];(Q.nodeName==="LINK"||Q.getAttribute("media")!=="not all")&&(_.set(Q.dataset.precedence,Q),E=Q)}E&&_.set(null,E)}P=g.instance,Q=P.getAttribute("data-precedence"),I=_.get(Q)||E,I===E&&_.set(null,P),_.set(Q,P),this.count++,E=Jv.bind(this),P.addEventListener("load",E),P.addEventListener("error",E),I?I.parentNode.insertBefore(P,I.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Jx={$$typeof:M,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function $se(h,g,_,E,P,I,Q,ge,Re){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=Tt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Tt(0),this.hiddenUpdates=Tt(null),this.identifierPrefix=E,this.onUncaughtError=P,this.onCaughtError=I,this.onRecoverableError=Q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Re,this.incompleteTransitions=new Map}function OU(h,g,_,E,P,I,Q,ge,Re,st,mt,bt){return h=new $se(h,g,_,Q,Re,st,mt,bt,ge),g=1,I===!0&&(g|=24),I=As(3,null,null,g),h.current=I,I.stateNode=h,g=m2(),g.refCount++,h.pooledCache=g,g.refCount++,I.memoizedState={element:E,isDehydrated:_,cache:g},b2(I),h}function LU(h){return h?(h=_m,h):_m}function IU(h,g,_,E,P,I){P=LU(P),E.context===null?E.context=P:E.pendingContext=P,E=Du(g),E.payload={element:_},I=I===void 0?null:I,I!==null&&(E.callback=I),_=Ou(h,E,g),_!==null&&(cs(_,h,g),jx(_,h,g))}function FU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function LA(h,g){FU(h,g),(h=h.alternate)&&FU(h,g)}function UU(h){if(h.tag===13||h.tag===31){var g=_h(h,67108864);g!==null&&cs(g,h,67108864),LA(h,67108864)}}function zU(h){if(h.tag===13||h.tag===31){var g=Ps();g=tn(g);var _=_h(h,g);_!==null&&cs(_,h,g),LA(h,g)}}var n_=!0;function Hse(h,g,_,E){var P=K.T;K.T=null;var I=G.p;try{G.p=2,IA(h,g,_,E)}finally{G.p=I,K.T=P}}function Vse(h,g,_,E){var P=K.T;K.T=null;var I=G.p;try{G.p=8,IA(h,g,_,E)}finally{G.p=I,K.T=P}}function IA(h,g,_,E){if(n_){var P=FA(E);if(P===null)SA(h,g,E,r_,_),$U(h,E);else if(Wse(P,h,g,_,E))E.stopPropagation();else if($U(h,E),g&4&&-1<Gse.indexOf(h)){for(;P!==null;){var I=yt(P);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var Q=Oe(I.pendingLanes);if(Q!==0){var ge=I;for(ge.pendingLanes|=2,ge.entangledLanes|=2;Q;){var Re=1<<31-Ce(Q);ge.entanglements[1]|=Re,Q&=~Re}wl(I),(Kn&6)===0&&(Uv=L()+500,qx(0))}}break;case 31:case 13:ge=_h(I,2),ge!==null&&cs(ge,I,2),Bv(),LA(I,2)}if(I=FA(E),I===null&&SA(h,g,E,r_,_),I===P)break;P=I}P!==null&&E.stopPropagation()}else SA(h,g,E,null,_)}}function FA(h){return h=zN(h),UA(h)}var r_=null;function UA(h){if(r_=null,h=Ct(h),h!==null){var g=a(h);if(g===null)h=null;else{var _=g.tag;if(_===13){if(h=o(g),h!==null)return h;h=null}else if(_===31){if(h=l(g),h!==null)return h;h=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return r_=h,null}function BU(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(X()){case xe:return 2;case _e:return 8;case ae:case Te:return 32;case Pe:return 268435456;default:return 32}default:return 32}}var zA=!1,Wu=null,qu=null,Ku=null,eb=new Map,tb=new Map,Xu=[],Gse="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 $U(h,g){switch(h){case"focusin":case"focusout":Wu=null;break;case"dragenter":case"dragleave":qu=null;break;case"mouseover":case"mouseout":Ku=null;break;case"pointerover":case"pointerout":eb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":tb.delete(g.pointerId)}}function nb(h,g,_,E,P,I){return h===null||h.nativeEvent!==I?(h={blockedOn:g,domEventName:_,eventSystemFlags:E,nativeEvent:I,targetContainers:[P]},g!==null&&(g=yt(g),g!==null&&UU(g)),h):(h.eventSystemFlags|=E,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Wse(h,g,_,E,P){switch(g){case"focusin":return Wu=nb(Wu,h,g,_,E,P),!0;case"dragenter":return qu=nb(qu,h,g,_,E,P),!0;case"mouseover":return Ku=nb(Ku,h,g,_,E,P),!0;case"pointerover":var I=P.pointerId;return eb.set(I,nb(eb.get(I)||null,h,g,_,E,P)),!0;case"gotpointercapture":return I=P.pointerId,tb.set(I,nb(tb.get(I)||null,h,g,_,E,P)),!0}return!1}function HU(h){var g=Ct(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,Nr(h.priority,function(){zU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Nr(h.priority,function(){zU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function i_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=FA(h.nativeEvent);if(_===null){_=h.nativeEvent;var E=new _.constructor(_.type,_);UN=E,_.target.dispatchEvent(E),UN=null}else return g=yt(_),g!==null&&UU(g),h.blockedOn=_,!1;g.shift()}return!0}function VU(h,g,_){i_(h)&&_.delete(g)}function qse(){zA=!1,Wu!==null&&i_(Wu)&&(Wu=null),qu!==null&&i_(qu)&&(qu=null),Ku!==null&&i_(Ku)&&(Ku=null),eb.forEach(VU),tb.forEach(VU)}function a_(h,g){h.blockedOn===g&&(h.blockedOn=null,zA||(zA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,qse)))}var s_=null;function GU(h){s_!==h&&(s_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){s_===h&&(s_=null);for(var g=0;g<h.length;g+=3){var _=h[g],E=h[g+1],P=h[g+2];if(typeof E!="function"){if(UA(E||_)===null)continue;break}var I=yt(_);I!==null&&(h.splice(g,3),g-=3,F2(I,{pending:!0,data:P,method:_.method,action:E},E,P))}}))}function Gm(h){function g(Re){return a_(Re,h)}Wu!==null&&a_(Wu,h),qu!==null&&a_(qu,h),Ku!==null&&a_(Ku,h),eb.forEach(g),tb.forEach(g);for(var _=0;_<Xu.length;_++){var E=Xu[_];E.blockedOn===h&&(E.blockedOn=null)}for(;0<Xu.length&&(_=Xu[0],_.blockedOn===null);)HU(_),_.blockedOn===null&&Xu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(E=0;E<_.length;E+=3){var P=_[E],I=_[E+1],Q=P[vt]||null;if(typeof I=="function")Q||GU(_);else if(Q){var ge=null;if(I&&I.hasAttribute("formAction")){if(P=I,Q=I[vt]||null)ge=Q.formAction;else if(UA(P)!==null)continue}else ge=Q.action;typeof ge=="function"?_[E+1]=ge:(_.splice(E,3),E-=3),GU(_)}}}function WU(){function h(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(Q){return P=Q})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),E||setTimeout(_,20)}function _(){if(!E&&!navigation.transition){var I=navigation.currentEntry;I&&I.url!=null&&navigation.navigate(I.url,{state:I.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var E=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){E=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function BA(h){this._internalRoot=h}o_.prototype.render=BA.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,E=Ps();IU(_,E,h,g,null,null)},o_.prototype.unmount=BA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;IU(h.current,2,null,h,null,null),Bv(),g[on]=null}};function o_(h){this._internalRoot=h}o_.prototype.unstable_scheduleHydration=function(h){if(h){var g=gr();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Xu.length&&g!==0&&g<Xu[_].priority;_++);Xu.splice(_,0,h),_===0&&HU(h)}};var qU=e.version;if(qU!=="19.2.3")throw Error(r(527,qU,"19.2.3"));G.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Kse={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var l_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!l_.isDisabled&&l_.supportsFiber)try{Ze=l_.inject(Kse),oe=l_}catch{}}return ib.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,E="",P=e5,I=t5,Q=n5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(E=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(I=g.onCaughtError),g.onRecoverableError!==void 0&&(Q=g.onRecoverableError)),g=OU(h,1,!1,null,null,_,E,null,P,I,Q,WU),h[on]=g.current,wA(h),new BA(g)},ib.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var E=!1,P="",I=e5,Q=t5,ge=n5,Re=null;return _!=null&&(_.unstable_strictMode===!0&&(E=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(I=_.onUncaughtError),_.onCaughtError!==void 0&&(Q=_.onCaughtError),_.onRecoverableError!==void 0&&(ge=_.onRecoverableError),_.formState!==void 0&&(Re=_.formState)),g=OU(h,1,!0,g,_??null,E,P,Re,I,Q,ge,WU),g.context=LU(null),_=g.current,E=Ps(),E=tn(E),P=Du(E),P.callback=null,Ou(_,P,E),_=E,g.current.lanes=_,nn(g,_),wl(g),h[on]=g.current,wA(h),new o_(g)},ib.version="19.2.3",ib}var rz;function aoe(){if(rz)return VA.exports;rz=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(),VA.exports=ioe(),VA.exports}var soe=aoe();const hn=t=>typeof t=="string",ab=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},iz=t=>t==null?"":""+t,ooe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},loe=/###/g,az=t=>t&&t.indexOf("###")>-1?t.replace(loe,"."):t,sz=t=>!t||hn(t),Jb=(t,e,n)=>{const r=hn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(sz(t))return{};const a=az(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return sz(t)?{}:{obj:t,k:az(r[i])}},oz=(t,e,n)=>{const{obj:r,k:i}=Jb(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=Jb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=Jb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},coe=(t,e,n,r)=>{const{obj:i,k:a}=Jb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},Sw=(t,e)=>{const{obj:n,k:r}=Jb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},uoe=(t,e,n)=>{const r=Sw(t,n);return r!==void 0?r:Sw(e,n)},pq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?hn(t[r])||t[r]instanceof String||hn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):pq(t[r],e[r],n):t[r]=e[r]);return t},Wm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var doe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const hoe=t=>hn(t)?t.replace(/[&<>"'\/]/g,e=>doe[e]):t;class foe{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 moe=[" ",",","?","!",";"],poe=new foe(20),goe=(t,e,n)=>{e=e||"",n=n||"";const r=moe.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=poe.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},Zj=(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},S0=t=>t?.replace("_","-"),xoe={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 Mw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||xoe,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:(hn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Mw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Mw(this.logger,e)}}var Fl=new Mw;let KM=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 lz extends KM{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):hn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=Sw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!hn(r)?c:Zj(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),oz(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)(hn(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=Sw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?pq(c,r,a):c={...c,...r},oz(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 gq={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 xq=Symbol("i18next/PATH_KEY");function boe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===xq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Qj(t,e){const{[xq]:n}=t(boe());return n.join(e?.keySeparator??".")}const cz={},KA=t=>!hn(t)&&typeof t!="boolean"&&typeof t!="number";class Ew extends KM{constructor(e,n={}){super(),ooe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Fl.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=KA(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&&!goe(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:hn(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:hn(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=Qj(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,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?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 p=this.resolve(e,i);let b=p?.res;const y=p?.usedKey||l,x=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,M=!this.i18nFormat||this.i18nFormat.handleAsObject,N=i.count!==void 0&&!hn(i.count),A=Ew.hasDefaultValue(i),k=N?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&N?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=N&&!i.ordinal&&i.count===0,T=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${C}`]||i.defaultValue;let R=b;M&&!b&&A&&(R=T);const U=KA(R),O=Object.prototype.toString.apply(R);if(M&&R&&U&&v.indexOf(O)<0&&!(hn(S)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(o){const q=Array.isArray(R),j=q?[]:{},W=q?x:y;for(const K in R)if(Object.prototype.hasOwnProperty.call(R,K)){const G=`${W}${o}${K}`;A&&!b?j[K]=this.translate(G,{...i,defaultValue:KA(T)?T[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),j[K]===G&&(j[K]=R[K])}b=j}}else if(M&&hn(S)&&Array.isArray(b))b=b.join(S),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,j=!1;!this.isValidLookup(b)&&A&&(q=!0,b=T),this.isValidLookup(b)||(j=!0,b=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:b,G=A&&T!==b&&this.options.updateMissing;if(j||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?T:b),o){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let J=[];const ie=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ie&&ie[0])for(let z=0;z<ie.length;z++)J.push(ie[z]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const re=(z,V,Z)=>{const ne=A&&Z!==b?Z:K;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,V,ne,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,V,ne,G,i),this.emit("missingKey",z,u,V,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?J.forEach(z=>{const V=this.pluralResolver.getSuffixes(z,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(Z=>{re([z],l+Z,i[`defaultValue${Z}`]||T)})}):re(J,l,T))}b=this.extendTranslation(b,e,i,p,r),j&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(j||q)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?b:void 0,i))}return a?(p.res=b,p.usedParams=this.getUsedParamsDetails(i),p):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=hn(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&&!hn(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),m=f&&f.length;u<m&&(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=hn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=gq.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 hn(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 m=n.count!==void 0&&!hn(n.count),p=m&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(hn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!cz[`${y[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(cz[`${y[0]}-${x}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,x,n);else{let N;m&&(N=this.pluralResolver.getSuffix(v,n.count,n));const A=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(k)===0&&S.push(d+N.replace(k,this.options.pluralSeparator)),S.push(d+N),p&&S.push(d+A)),b){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(C),m&&(n.ordinal&&N.indexOf(k)===0&&S.push(C+N.replace(k,this.options.pluralSeparator)),S.push(C+N),p&&S.push(C+A))}}let M;for(;M=S.pop();)this.isValidLookup(r)||(a=M,r=this.getResource(v,x,M,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&&!hn(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 uz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Fl.create("languageUtils")}getScriptPartFromCode(e){if(e=S0(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=S0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(hn(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)),hn(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 hn(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))):hn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const dz={zero:0,one:1,two:2,few:3,many:4,other:5},hz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class yoe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Fl.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=S0(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!"),hz;if(!e.match(/-|_/))return hz;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)=>dz[i]-dz[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 fz=(t,e,n,r=".",i=!0)=>{let a=uoe(t,e,n);return!a&&i&&hn(n)&&(a=Zj(t,n,r),a===void 0&&(a=Zj(e,n,r))),a},XA=t=>t.replace(/\$/g,"$$$$");class mz{constructor(e={}){this.logger=Fl.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:m,nestingPrefixEscaped:p,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:hoe,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Wm(a):o||"{{",this.suffix=l?Wm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Wm(m):p||Wm("$t("),this.nestingSuffix=b?Wm(b):y||Wm(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=v||1e3,this.alwaysFormat=S!==void 0?S:!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=p=>{if(p.indexOf(this.formatSeparator)<0){const v=fz(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const b=p.split(this.formatSeparator),y=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(fz(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:y})};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:p=>XA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?XA(this.escape(p)):XA(p)}].forEach(p=>{for(l=0;a=p.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=hn(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!hn(o)&&!this.useRawValueToEscape&&(o=iz(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.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 m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),b=m.match(/"/g);((p?.length??0)%2===0&&!b||b.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${m}`}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&&!hn(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&&!hn(a))return a;hn(a)||(a=iz(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 voe=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}},pz=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(S0(r),i),e[o]=l),l(n)}},_oe=t=>(e,n,r)=>t(S0(n),r)(e);class woe{constructor(e={}){this.logger=Fl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?pz:_oe;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()]=pz(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}=voe(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},p=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Soe=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Moe extends KM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Fl.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 m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),a[m]===void 0&&(a[m]=!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=>{coe(c.loaded,[a],o),Soe(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();hn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),hn(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 YA=()=>({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]),hn(t[1])&&(e.defaultValue=t[1]),hn(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}),gz=t=>(hn(t.ns)&&(t.ns=[t.ns]),hn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),hn(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),u_=()=>{},Eoe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class e0 extends KM{constructor(e={},n){if(super(),this.options=gz(e),this.services={},this.logger=Fl,this.modules={external:[]},Eoe(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&&(hn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=YA();this.options={...r,...this.options,...gz(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),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=r.overloadTranslationOptionHandler),this.options.debug===!0&&typeof console<"u"&&console.warn("i18next is maintained with support from locize.com — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com");const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Fl.init(i(this.modules.logger),this.options):Fl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=woe;const d=new uz(this.options);this.store=new lz(this.options.resources,this.options);const f=this.services;f.logger=Fl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new yoe(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 mz(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Moe(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...b)=>{this.emit(p,...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 Ew(this.services,this.options),this.translator.on("*",(p,...b)=>{this.emit(p,...b)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=u_),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=ab(),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=u_){let r=n;const i=hn(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=ab();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=u_),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"&&gq.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=ab();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=hn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(hn(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=Qj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Qj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return hn(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=ab();return this.options.ns?(hn(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=ab();hn(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 uz(YA());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 e0(e,n);return r.createInstance=e0.createInstance,r}cloneInstance(e={},n=u_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new e0(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 lz(l,i),a.services.resourceStore=a.store}if(e.interpolation){const c={...YA().interpolation,...this.options.interpolation,...e.interpolation},u={...i,interpolation:c};a.services.interpolator=new mz(u)}return a.translator=new Ew(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 ns=e0.createInstance();ns.createInstance;ns.dir;ns.init;ns.loadResources;ns.reloadResources;ns.use;ns.changeLanguage;ns.getFixedT;ns.t;ns.exists;ns.setDefaultNamespace;ns.hasLoadedNamespace;ns.loadNamespaces;ns.loadLanguages;const Noe=(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);Rf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},xz={},bq=(t,e,n,r)=>{Rf(n)&&xz[n]||(Rf(n)&&(xz[n]=new Date),Noe(t,e,n,r))},yq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Jj=(t,e,n)=>{t.loadNamespaces(e,yq(t,n))},bz=(t,e,n,r)=>{if(Rf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Jj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,yq(t,r))},Aoe=(t,e,n={})=>!e.languages||!e.languages.length?(bq(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}}),Rf=t=>typeof t=="string",Toe=t=>typeof t=="object"&&t!==null,Coe=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,koe={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},joe=t=>koe[t],Poe=t=>t.replace(Coe,joe);let eP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Poe,transDefaultProps:void 0};const Roe=(t={})=>{eP={...eP,...t}},Doe=()=>eP;let vq;const Ooe=t=>{vq=t},Loe=()=>vq,Ioe={type:"3rdParty",init(t){Roe(t.options.react),Ooe(t)}},Foe=w.createContext();class Uoe{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var ZA={exports:{}},QA={};var yz;function zoe(){if(yz)return QA;yz=1;var t=Vg();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),b=r({inst:{value:p,getSnapshot:m}}),y=b[0].inst,x=b[1];return a(function(){y.value=p,y.getSnapshot=m,c(y)&&x({inst:y})},[f,p,m]),i(function(){return c(y)&&x({inst:y}),f(function(){c(y)&&x({inst:y})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return QA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,QA}var vz;function _q(){return vz||(vz=1,ZA.exports=zoe()),ZA.exports}var yD=_q();const Boe=(t,e)=>Rf(e)?e:Toe(e)&&Rf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,$oe={t:Boe,ready:!1},Hoe=()=>()=>{},Gg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Foe)||{},a=n||r||Loe();a&&!a.reportNamespaces&&(a.reportNamespaces=new Uoe),a||bq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Doe(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=Rf(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(T=>{if(!a)return Hoe;const{bindI18n:R,bindI18nStore:U}=o,O=()=>{m.current+=1,T()};return R&&a.on(R,O),U&&a.store.on(U,O),()=>{R&&R.split(" ").forEach(q=>a.off(q,O)),U&&U.split(" ").forEach(q=>a.store.off(q,O))}},[a,o]),b=w.useRef(),y=w.useCallback(()=>{if(!a)return $oe;const T=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>Aoe(W,a,o)),R=e.lng||a.language,U=m.current,O=b.current;if(O&&O.ready===T&&O.lng===R&&O.keyPrefix===c&&O.revision===U)return O;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:T,lng:R,keyPrefix:c,revision:U};return b.current=j,j},[a,f,c,o,e.lng]),[x,v]=w.useState(0),{t:S,ready:M}=yD.useSyncExternalStore(p,y,y);w.useEffect(()=>{if(a&&!M&&!l){const T=()=>v(R=>R+1);e.lng?bz(a,e.lng,f,T):Jj(a,f,T)}},[a,e.lng,f,M,l,x]);const N=a||{},A=w.useRef(null),k=w.useRef(),C=T=>{const R=Object.getOwnPropertyDescriptors(T);R.__original&&delete R.__original;const U=Object.create(Object.getPrototypeOf(T),R);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:T,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},D=w.useMemo(()=>{const T=N,R=T?.language;let U=T;T&&(A.current&&A.current.__original===T?k.current!==R?(U=C(T),A.current=U,k.current=R):U=A.current:(U=C(T),A.current=U,k.current=R));const O=[S,U,M];return O.t=S,O.i18n=U,O.ready=M,O},[S,N,M,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!M)throw new Promise(T=>{const R=()=>T();e.lng?bz(a,e.lng,f,R):Jj(a,f,R)});return D},{slice:Voe,forEach:Goe}=[];function Woe(t){return Goe.call(Voe.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function qoe(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 _z=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Koe=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(!_z.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!_z.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},wz={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=Koe(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 Xoe={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return wz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&wz.create(n,t,r,i,a)}},Yoe={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}},Zoe={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 qm=null;const Sz=()=>{if(qm!==null)return qm;try{if(qm=typeof window<"u"&&window.localStorage!==null,!qm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{qm=!1}return qm};var Qoe={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Sz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Sz()&&window.localStorage.setItem(n,t)}};let Km=null;const Mz=()=>{if(Km!==null)return Km;try{if(Km=typeof window<"u"&&window.sessionStorage!==null,!Km)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Km=!1}return Km};var Joe={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Mz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Mz()&&window.sessionStorage.setItem(n,t)}},ele={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}},tle={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}},nle={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}},rle={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 wq=!1;try{document.cookie,wq=!0}catch{}const Sq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];wq||Sq.splice(1,1);const ile=()=>({order:Sq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Mq{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=Woe(n,this.options||{},ile()),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(Xoe),this.addDetector(Yoe),this.addDetector(Qoe),this.addDetector(Joe),this.addDetector(ele),this.addDetector(tle),this.addDetector(nle),this.addDetector(rle),this.addDetector(Zoe)}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&&!qoe(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)}))}}Mq.type="languageDetector";const ale={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",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?"}},sle={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",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?"}},ole={en:{translation:ale},de:{translation:sle}};ns.use(Mq).use(Ioe).init({resources:ole,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Ez=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var Nz="popstate";function lle(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return tP("",{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:M0(i)}return ule(e,n,null,t)}function Lr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function jo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function cle(){return Math.random().toString(36).substring(2,10)}function Az(t,e){return{usr:t.state,key:t.key,idx:e}}function tP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Wg(e):e,state:n,key:e&&e.key||r||cle()}}function M0({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 Wg(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 ule(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(),v=x==null?null:x-u;u=x,c&&c({action:l,location:y.location,delta:v})}function m(x,v){l="PUSH";let S=tP(y.location,x,v);u=d()+1;let M=Az(S,u),N=y.createHref(S);try{o.pushState(M,"",N)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(N)}a&&c&&c({action:l,location:y.location,delta:1})}function p(x,v){l="REPLACE";let S=tP(y.location,x,v);u=d();let M=Az(S,u),N=y.createHref(S);o.replaceState(M,"",N),a&&c&&c({action:l,location:y.location,delta:0})}function b(x){return dle(x)}let y={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(Nz,f),c=x,()=>{i.removeEventListener(Nz,f),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let v=b(x);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:p,go(x){return o.go(x)}};return y}function dle(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Lr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:M0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Eq(t,e,n="/"){return hle(t,e,n,!1)}function hle(t,e,n,r){let i=typeof e=="string"?Wg(e):e,a=cu(i.pathname||"/",n);if(a==null)return null;let o=Nq(t);fle(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Mle(a);l=wle(o[c],u,r)}return l}function Nq(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;Lr(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=tu([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Lr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Nq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:vle(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Aq(o.path))a(o,l,!0,c)}),e}function Aq(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=Aq(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 fle(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:_le(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var mle=/^:[\w-]+$/,ple=3,gle=2,xle=1,ble=10,yle=-2,Tz=t=>t==="*";function vle(t,e){let n=t.split("/"),r=n.length;return n.some(Tz)&&(r+=yle),e&&(r+=gle),n.filter(i=>!Tz(i)).reduce((i,a)=>i+(mle.test(a)?ple:a===""?xle:ble),r)}function _le(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 wle(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=Nw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=Nw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:tu([a,f.pathname]),pathnameBase:Tle(tu([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=tu([a,f.pathnameBase]))}return o}function Nw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Sle(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},m)=>{if(d==="*"){let b=l[m]||"";o=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const p=l[m];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function Sle(t,e=!1,n=!0){jo(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 Mle(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return jo(!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 cu(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 Ele=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Nle(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Wg(t):t,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=Cz(n.substring(1),"/"):a=Cz(n,e)):a=e,{pathname:a,search:Cle(r),hash:kle(i)}}function Cz(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 JA(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 Ale(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function vD(t){let e=Ale(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function _D(t,e,n,r=!1){let i;typeof t=="string"?i=Wg(t):(i={...t},Lr(!i.pathname||!i.pathname.includes("?"),JA("?","pathname","search",i)),Lr(!i.pathname||!i.pathname.includes("#"),JA("#","pathname","hash",i)),Lr(!i.search||!i.search.includes("#"),JA("#","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 m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=Nle(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var tu=t=>t.join("/").replace(/\/\/+/g,"/"),Tle=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Cle=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,kle=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,jle=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ple(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Rle(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Tq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Cq(t,e){let n=t;if(typeof n!="string"||!Ele.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Tq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=cu(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{jo(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var kq=["POST","PUT","PATCH","DELETE"];new Set(kq);var Dle=["GET",...kq];new Set(Dle);var qg=w.createContext(null);qg.displayName="DataRouter";var XM=w.createContext(null);XM.displayName="DataRouterState";var Ole=w.createContext(!1),jq=w.createContext({isTransitioning:!1});jq.displayName="ViewTransition";var Lle=w.createContext(new Map);Lle.displayName="Fetchers";var Ile=w.createContext(null);Ile.displayName="Await";var Zs=w.createContext(null);Zs.displayName="Navigation";var gy=w.createContext(null);gy.displayName="Location";var Oo=w.createContext({outlet:null,matches:[],isDataRoute:!1});Oo.displayName="Route";var wD=w.createContext(null);wD.displayName="RouteError";var Pq="REACT_ROUTER_ERROR",Fle="REDIRECT",Ule="ROUTE_ERROR_RESPONSE";function zle(t){if(t.startsWith(`${Pq}:${Fle}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function Ble(t){if(t.startsWith(`${Pq}:${Ule}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new jle(e.status,e.statusText,e.data)}catch{}}function $le(t,{relative:e}={}){Lr(Kg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(Zs),{hash:i,pathname:a,search:o}=xy(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:tu([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Kg(){return w.useContext(gy)!=null}function oc(){return Lr(Kg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(gy).location}var Rq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Dq(t){w.useContext(Zs).static||w.useLayoutEffect(t)}function ml(){let{isDataRoute:t}=w.useContext(Oo);return t?rce():Hle()}function Hle(){Lr(Kg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(qg),{basename:e,navigator:n}=w.useContext(Zs),{matches:r}=w.useContext(Oo),{pathname:i}=oc(),a=JSON.stringify(vD(r)),o=w.useRef(!1);return Dq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(jo(o.current,Rq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=_D(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:tu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Vle=w.createContext(null);function Gle(t){let e=w.useContext(Oo).outlet;return w.useMemo(()=>e&&w.createElement(Vle.Provider,{value:t},e),[e,t])}function SD(){let{matches:t}=w.useContext(Oo),e=t[t.length-1];return e?e.params:{}}function xy(t,{relative:e}={}){let{matches:n}=w.useContext(Oo),{pathname:r}=oc(),i=JSON.stringify(vD(n));return w.useMemo(()=>_D(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Wle(t,e){return Oq(t,e)}function Oq(t,e,n,r,i){Lr(Kg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(Zs),{matches:o}=w.useContext(Oo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let S=f&&f.path||"";Iq(u,!f||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) 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.
  10. Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let m=oc(),p;if(e){let S=typeof e=="string"?Wg(e):e;Lr(d==="/"||S.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 "${S.pathname}" was given in the \`location\` prop.`),p=S}else p=m;let b=p.pathname||"/",y=b;if(d!=="/"){let S=d.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(S.length).join("/")}let x=Eq(t,{pathname:y});jo(f||x!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),jo(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 "${p.pathname}${p.search}${p.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 v=Zle(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:tu([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:tu([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(gy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function qle(){let t=nce(),e=Ple(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=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:a},"ErrorBoundary")," or"," ",w.createElement("code",{style:a},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var Kle=w.createElement(qle,null),Lq=class extends w.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(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=Ble(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Oo.Provider,{value:this.props.routeContext},w.createElement(wD.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Xle,{error:t},e):e}};Lq.contextType=Ole;var eT=new WeakMap;function Xle({children:t,error:e}){let{basename:n}=w.useContext(Zs);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=zle(e.digest);if(r){let i=eT.get(e);if(i)throw i;let a=Cq(r.location,n);if(Tq&&!eT.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw eT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Yle({routeContext:t,match:e,children:n}){let r=w.useContext(qg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Oo.Provider,{value:t},n)}function Zle(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);Lr(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:m,errors:p}=n,b=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!p||p[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??{},unstable_pattern:Rle(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,m)=>{let p,b=!1,y=null,x=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||Kle,l&&(c<0&&m===0?(Iq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):c===m&&(b=!0,x=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,m+1)),S=()=>{let M;return p?M=y:b?M=x:f.route.Component?M=w.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=d,w.createElement(Yle,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:M})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(Lq,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function MD(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qle(t){let e=w.useContext(qg);return Lr(e,MD(t)),e}function Jle(t){let e=w.useContext(XM);return Lr(e,MD(t)),e}function ece(t){let e=w.useContext(Oo);return Lr(e,MD(t)),e}function ED(t){let e=ece(t),n=e.matches[e.matches.length-1];return Lr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function tce(){return ED("useRouteId")}function nce(){let t=w.useContext(wD),e=Jle("useRouteError"),n=ED("useRouteError");return t!==void 0?t:e.errors?.[n]}function rce(){let{router:t}=Qle("useNavigate"),e=ED("useNavigate"),n=w.useRef(!1);return Dq(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{jo(n.current,Rq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var kz={};function Iq(t,e,n){!e&&!kz[t]&&(kz[t]=!0,jo(!1,n))}w.memo(ice);function ice({routes:t,future:e,state:n,onError:r}){return Oq(t,void 0,n,r,e)}function Aw({to:t,replace:e,state:n,relative:r}){Lr(Kg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(Zs);jo(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=w.useContext(Oo),{pathname:o}=oc(),l=ml(),c=_D(t,vD(a),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function ace(t){return Gle(t.context)}function zi(t){Lr(!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 sce({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){Lr(!Kg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=Wg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,b=w.useMemo(()=>{let y=cu(u,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:p},navigationType:r}},[l,u,d,f,m,p,r]);return jo(b!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:w.createElement(Zs.Provider,{value:c},w.createElement(gy.Provider,{children:e,value:b}))}function oce({children:t,location:e}){return Wle(nP(t),e)}function nP(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let a=[...e,i];if(r.type===w.Fragment){n.push.apply(n,nP(r.props.children,a));return}Lr(r.type===zi,`[${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>`),Lr(!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=nP(r.props.children,a)),n.push(o)}),n}var X1="get",Y1="application/x-www-form-urlencoded";function YM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function lce(t){return YM(t)&&t.tagName.toLowerCase()==="button"}function cce(t){return YM(t)&&t.tagName.toLowerCase()==="form"}function uce(t){return YM(t)&&t.tagName.toLowerCase()==="input"}function dce(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function hce(t,e){return t.button===0&&(!e||e==="_self")&&!dce(t)}function rP(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 fce(t,e){let n=rP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var d_=null;function mce(){if(d_===null)try{new FormData(document.createElement("form"),0),d_=!1}catch{d_=!0}return d_}var pce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function tT(t){return t!=null&&!pce.has(t)?(jo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Y1}"`),null):t}function gce(t,e){let n,r,i,a,o;if(cce(t)){let l=t.getAttribute("action");r=l?cu(l,e):null,n=t.getAttribute("method")||X1,i=tT(t.getAttribute("enctype"))||Y1,a=new FormData(t)}else if(lce(t)||uce(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?cu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||X1,i=tT(t.getAttribute("formenctype"))||tT(l.getAttribute("enctype"))||Y1,a=new FormData(l,t),!mce()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,f)}}else{if(YM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=X1,r=null,i=Y1,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 ND(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function xce(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&cu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function bce(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 yce(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 vce(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await bce(a,n);return o.links?o.links():[]}return[]}));return Mce(r.flat(1).filter(yce).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function jz(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 _ce(t,e,{includeHydrateFallback:n}={}){return wce(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 wce(t){return[...new Set(t)]}function Sce(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Mce(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Sce(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Fq(){let t=w.useContext(qg);return ND(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ece(){let t=w.useContext(XM);return ND(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var AD=w.createContext(void 0);AD.displayName="FrameworkContext";function Uq(){let t=w.useContext(AD);return ND(t,"You must render this element inside a <HydratedRouter> element"),t}function Nce(t,e){let n=w.useContext(AD),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(S=>{o(S.isIntersecting)})},x=new IntersectionObserver(y,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:sb(l,p),onBlur:sb(c,b),onMouseEnter:sb(u,p),onMouseLeave:sb(d,b),onTouchStart:sb(f,p)}]:[!1,m,{}]}function sb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Ace({page:t,...e}){let{router:n}=Fq(),r=w.useMemo(()=>Eq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Cce,{page:t,matches:r,...e}):null}function Tce(t){let{manifest:e,routeModules:n}=Uq(),[r,i]=w.useState([]);return w.useEffect(()=>{let a=!1;return vce(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Cce({page:t,matches:e,...n}){let r=oc(),{future:i,manifest:a,routeModules:o}=Uq(),{basename:l}=Fq(),{loaderData:c,matches:u}=Ece(),d=w.useMemo(()=>jz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>jz(t,e,u,a,r,"assets"),[t,e,u,a,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,x=!1;if(e.forEach(S=>{let M=a.routes[S.route.id];!M||!M.hasLoader||(!d.some(N=>N.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||M.hasClientLoader?x=!0:y.add(S.route.id))}),y.size===0)return[];let v=xce(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return x&&y.size>0&&v.searchParams.set("_routes",e.filter(S=>y.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),p=w.useMemo(()=>_ce(f,a),[f,a]),b=Tce(f);return w.createElement(w.Fragment,null,m.map(y=>w.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),p.map(y=>w.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),b.map(({key:y,link:x})=>w.createElement("link",{key:y,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function kce(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var jce=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{jce&&(window.__reactRouterVersion="7.13.0")}catch{}function Pce({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=lle({window:r,v5Compat:!0}));let a=i.current,[o,l]=w.useState({action:a.action,location:a.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>a.listen(c),[a,c]),w.createElement(sce,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var zq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,hs=w.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,unstable_defaultShouldRevalidate:m,...p},b){let{basename:y,unstable_useTransitions:x}=w.useContext(Zs),v=typeof u=="string"&&zq.test(u),S=Cq(u,y);u=S.to;let M=$le(u,{relative:i}),[N,A,k]=Nce(r,p),C=Oce(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:x});function D(R){e&&e(R),R.defaultPrevented||C(R)}let T=w.createElement("a",{...p,...k,href:S.absoluteURL||M,onClick:S.isExternal||a?e:D,ref:kce(b,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return N&&!v?w.createElement(w.Fragment,null,T,w.createElement(Ace,{page:M})):T});hs.displayName="Link";var Ob=w.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=xy(o,{relative:u.relative}),m=oc(),p=w.useContext(XM),{navigator:b,basename:y}=w.useContext(Zs),x=p!=null&&zce(f)&&l===!0,v=b.encodeLocation?b.encodeLocation(f).pathname:f.pathname,S=m.pathname,M=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(S=S.toLowerCase(),M=M?M.toLowerCase():null,v=v.toLowerCase()),M&&y&&(M=cu(M,y)||M);const N=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let A=S===v||!i&&S.startsWith(v)&&S.charAt(N)==="/",k=M!=null&&(M===v||!i&&M.startsWith(v)&&M.charAt(v.length)==="/"),C={isActive:A,isPending:k,isTransitioning:x},D=A?e:void 0,T;typeof r=="function"?T=r(C):T=[r,A?"active":null,k?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(C):a;return w.createElement(hs,{...u,"aria-current":D,className:T,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(C):c)});Ob.displayName="NavLink";var Rce=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=X1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b)=>{let{unstable_useTransitions:y}=w.useContext(Zs),x=Fce(),v=Uce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&zq.test(l),N=A=>{if(c&&c(A),A.defaultPrevented)return;A.preventDefault();let k=A.nativeEvent.submitter,C=k?.getAttribute("formmethod")||o,D=()=>x(k||A.currentTarget,{fetcherKey:e,method:C,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});y&&n!==!1?w.startTransition(()=>D()):D()};return w.createElement("form",{ref:b,method:S,action:v,onSubmit:r?c:N,...p,"data-discover":!M&&t==="render"?"true":void 0})});Rce.displayName="Form";function Dce(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bq(t){let e=w.useContext(qg);return Lr(e,Dce(t)),e}function Oce(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=ml(),d=oc(),f=xy(t,{relative:a});return w.useCallback(m=>{if(hce(m,e)){m.preventDefault();let p=n!==void 0?n:M0(d)===M0(f),b=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>b()):b()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function $q(t){jo(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=w.useRef(rP(t)),n=w.useRef(!1),r=oc(),i=w.useMemo(()=>fce(r.search,n.current?null:e.current),[r.search]),a=ml(),o=w.useCallback((l,c)=>{const u=rP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Lce=0,Ice=()=>`__${String(++Lce)}__`;function Fce(){let{router:t}=Bq("useSubmit"),{basename:e}=w.useContext(Zs),n=tce(),r=t.fetch,i=t.navigate;return w.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=gce(a,e);if(o.navigate===!1){let m=o.fetcherKey||Ice();await r(m,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function Uce(t,{relative:e}={}){let{basename:n}=w.useContext(Zs),r=w.useContext(Oo);Lr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...xy(t||".",{relative:e})},o=oc();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:tu([n,a.pathname])),M0(a)}function zce(t,{relative:e}={}){let n=w.useContext(jq);Lr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Bq("useViewTransitionState"),i=xy(t,{relative:e});if(!n.isTransitioning)return!1;let a=cu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=cu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Nw(i.pathname,o)!=null||Nw(i.pathname,a)!=null}var Xc=mq();const Bce=fl(Xc);var sm=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(){}},$ce={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Hce=class{#t=$ce;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},sf=new Hce;function Vce(t){setTimeout(t,0)}var Df=typeof window>"u"||"Deno"in globalThis;function Ra(){}function Gce(t,e){return typeof t=="function"?t(e):t}function iP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Hq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Dd(t,e){return typeof t=="function"?t(e):t}function xo(t,e){return typeof t=="function"?t(e):t}function Pz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==TD(o,e.options))return!1}else if(!E0(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 Rz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Of(e.options.mutationKey)!==Of(a))return!1}else if(!E0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function TD(t,e){return(e?.queryKeyHashFn||Of)(t)}function Of(t){return JSON.stringify(t,(e,n)=>aP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function E0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>E0(t[n],e[n])):!1}var Wce=Object.prototype.hasOwnProperty;function CD(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Dz(t)&&Dz(e);if(!r&&!(aP(t)&&aP(e)))return e;const a=(r?t:Object.keys(t)).length,o=r?e:Object.keys(e),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d<l;d++){const f=r?d:o[d],m=t[f],p=e[f];if(m===p){c[f]=m,(r?d<a:Wce.call(t,f))&&u++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}const b=CD(m,p,n+1);c[f]=b,b===m&&u++}return a===l&&u===a?t:c}function N0(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 Dz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function aP(t){if(!Oz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Oz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Oz(t){return Object.prototype.toString.call(t)==="[object Object]"}function qce(t){return new Promise(e=>{sf.setTimeout(e,t)})}function sP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?CD(t,e):e}function Kce(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Xce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var kD=Symbol();function Vq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===kD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function jD(t,e){return typeof t=="function"?t(...e):!!t}function Yce(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var Zce=class extends sm{#t;#e;#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.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},PD=new Zce;function oP(){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 Qce=Vce;function Jce(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Qce;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 ei=Jce(),eue=class extends sm{#t=!0;#e;#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.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},Tw=new eue;function tue(t){return Math.min(1e3*2**t,3e4)}function Gq(t){return(t??"online")==="online"?Tw.isOnline():!0}var lP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Wq(t){let e=!1,n=0,r;const i=oP(),a=()=>i.status!=="pending",o=y=>{if(!a()){const x=new lP(y);m(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>PD.isFocused()&&(t.networkMode==="always"||Tw.isOnline())&&t.canRun(),d=()=>Gq(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},p=()=>new Promise(y=>{r=x=>{(a()||u())&&y(x)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let y;const x=n===0?t.initialPromise:void 0;try{y=x??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(a())return;const S=t.retry??(Df?0:3),M=t.retryDelay??tue,N=typeof M=="function"?M(n,v):M,A=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!A){m(v);return}n++,t.onFail?.(n,v),qce(N).then(()=>u()?void 0:p()).then(()=>{e?m(v):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():p().then(b),i)}}var qq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),iP(this.gcTime)&&(this.#t=sf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Df?1/0:300*1e3))}clearGcTimeout(){this.#t&&(sf.clearTimeout(this.#t),this.#t=void 0)}},nue=class extends qq{#t;#e;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=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.#t=Iz(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Iz(this.options);e.data!==void 0&&(this.setState(Lz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=sP(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Ra).catch(Ra):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>xo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===kD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Dd(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:!Hq(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.#s({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=Vq(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.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Wq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof lP&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({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 lP){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(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,...Kq(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Lz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=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",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),ei.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function Kq(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Lz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Iz(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 RD=class extends sm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=oP(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#d;#h;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Fz(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!N0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Uz(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||xo(this.options.enabled,this.#e)!==xo(e.enabled,this.#e)||Dd(this.options.staleTime,this.#e)!==Dd(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||xo(this.options.enabled,this.#e)!==xo(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return iue(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.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.#f.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#p({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#p(t){this.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ra)),e}#g(){this.#v();const t=Dd(this.options.staleTime,this.#e);if(Df||this.#i.isStale||!iP(t))return;const n=Hq(this.#i.dataUpdatedAt,t)+1;this.#c=sf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Df||xo(this.options.enabled,this.#e)===!1||!iP(this.#l)||this.#l===0)&&(this.#u=sf.setInterval(()=>{(this.options.refetchIntervalInBackground||PD.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(sf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(sf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const D=this.hasListeners(),T=!D&&Fz(t,e),R=D&&Uz(t,n,e,r);(T||R)&&(d={...d,...Kq(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:y}=d;m=d.data;let x=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,x=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(y="success",m=sP(i?.data,D,e),f=!0)}if(e.select&&m!==void 0&&!x)if(i&&m===a?.data&&e.select===this.#m)m=this.#d;else try{this.#m=e.select,m=e.select(m),m=sP(i?.data,m,e),this.#d=m,this.#s=null}catch(D){this.#s=D}this.#s&&(p=this.#s,m=this.#d,b=Date.now(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",M=y==="error",N=S&&v,A=m!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:M,isInitialLoading:N,isLoading:N,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,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:v,isRefetching:v&&!S,isLoadingError:M&&!A,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:M&&A,isStale:DD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:xo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=C.data!==void 0,T=C.status==="error"&&!D,R=q=>{T?q.reject(C.error):D&&q.resolve(C.data)},U=()=>{const q=this.#o=C.promise=oP();R(q)},O=this.#o;switch(O.status){case"pending":t.queryHash===n.queryHash&&R(O);break;case"fulfilled":(T||C.data!==O.value)&&U();break;case"rejected":(!T||C.error!==O.reason)&&U();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),N0(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.#f.size)return!0;const a=new Set(i??this.#f);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.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){ei.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function rue(t,e){return xo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Fz(t,e){return rue(t,e)||t.state.data!==void 0&&cP(t,e,e.refetchOnMount)}function cP(t,e,n){if(xo(e.enabled,t)!==!1&&Dd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&DD(t,e)}return!1}function Uz(t,e,n,r){return(t!==e||xo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&DD(t,n)}function DD(t,e){return xo(e.enabled,t)!==!1&&t.isStaleByTime(Dd(e.staleTime,t))}function iue(t,e){return!N0(t.getCurrentResult(),e)}function zz(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=>{Yce(b,()=>e.signal,()=>d=!0)},m=Vq(e.options,e.fetchOptions),p=async(b,y,x)=>{if(d)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:x?"backward":"forward",meta:e.options.meta};return f(k),k})(),M=await m(S),{maxPages:N}=e.options,A=x?Xce:Kce;return{pages:A(b.pages,M,N),pageParams:A(b.pageParams,y,N)}};if(i&&a.length){const b=i==="backward",y=b?aue:Bz,x={pages:a,pageParams:o},v=y(r,x);l=await p(x,v,b)}else{const b=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:Bz(r,l);if(c>0&&y==null)break;l=await p(l,y),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 Bz(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 aue(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var sue=class extends qq{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||Xq(),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.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.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.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=Wq({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}),this.#n.config.onMutate&&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{await this.#n.config.onError?.(a,t,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onError?.(a,t,this.state.context,n)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,a,t,this.state.context,n)}catch(o){Promise.reject(o)}throw this.#r({type:"error",error:a}),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),ei.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function Xq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var oue=class extends sm{constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(t,e,n){const r=new sue({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=h_(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=h_(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=h_(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=h_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ei.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Rz(e,n))}findAll(t={}){return this.getAll().filter(e=>Rz(t,e))}notify(t){ei.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ei.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ra))))}};function h_(t){return t.options.scope?.id}var lue=class extends sm{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=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.#t.defaultMutationOptions(e),N0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Of(n.mutationKey)!==Of(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.#a(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??Xq();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ei.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#i.onSuccess?.(e.data,n,r,i)}catch(a){Promise.reject(a)}try{this.#i.onSettled?.(e.data,null,n,r,i)}catch(a){Promise.reject(a)}}else if(e?.type==="error"){try{this.#i.onError?.(e.error,n,r,i)}catch(a){Promise.reject(a)}try{this.#i.onSettled?.(void 0,e.error,n,r,i)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}};function $z(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function cue(t,e,n){const r=t.slice(0);return r[e]=n,r}var uue=class extends sm{#t;#e;#n;#i;#r;#a;#o;#s;#m;#d=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#l(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,ei.batch(()=>{const n=this.#r,r=this.#u(this.#n);r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const m=this.#e[f];return!m||!N0(d,m)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=a,this.hasListeners()&&(c&&($z(n,i).forEach(d=>{d.destroy()}),$z(i,n).forEach(d=>{d.subscribe(f=>{this.#l(d,f)})})),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#u(t),r=n.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),i=n.map(a=>a.defaultedQueryOptions.queryHash);return[r,a=>this.#c(a??r,e,i),()=>this.#h(r,n)]}#h(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#c(t,e,n){if(e){const r=this.#m,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((a,o)=>a!==r[o]));return(!this.#a||this.#e!==this.#s||i||e!==this.#o)&&(this.#o=e,this.#s=this.#e,n!==void 0&&(this.#m=n),this.#a=CD(this.#a,e(t))),this.#a}return t}#u(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const a=e.get(i);a?a.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new RD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=cue(this.#e,n,e),this.#f())}#f(){if(this.hasListeners()){const t=this.#a,e=this.#h(this.#e,this.#d),n=this.#c(e,this.#i?.combine);t!==n&&ei.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},due=class extends sm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??TD(r,e);let a=this.get(i);return a||(a=new nue({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ei.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>Pz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Pz(t,n)):e}notify(t){ei.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ei.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ei.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},hue=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new due,this.#e=t.mutationCache||new oue,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=PD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=Tw.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Dd(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.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.#t.get(r.queryHash)?.state.data,o=Gce(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return ei.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;ei.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return ei.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ei.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ra).catch(Ra)}invalidateQueries(t,e={}){return ei.batch(()=>(this.#t.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=ei.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ra)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ra)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Dd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ra).catch(Ra)}fetchInfiniteQuery(t){return t.behavior=zz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ra).catch(Ra)}ensureInfiniteQueryData(t){return t.behavior=zz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Tw.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Of(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{E0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Of(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{E0(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=TD(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===kD&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},Yq=w.createContext(void 0),un=t=>{const e=w.useContext(Yq);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},fue=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(Yq.Provider,{value:t,children:e})),Zq=w.createContext(!1),Qq=()=>w.useContext(Zq);Zq.Provider;function mue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var pue=w.createContext(mue()),Jq=()=>w.useContext(pue),eK=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?jD(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},tK=t=>{w.useEffect(()=>{t.clearReset()},[t])},nK=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||jD(n,[t.error,r])),rK=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))}},iK=(t,e)=>t.isLoading&&t.isFetching&&!e,uP=(t,e)=>t?.suspense&&e.isPending,Cw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function gue({queries:t,...e},n){const r=un(),i=Qq(),a=Jq(),o=w.useMemo(()=>t.map(y=>{const x=r.defaultQueryOptions(y);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(y=>{rK(y);const x=r.getQueryCache().get(y.queryHash);eK(y,a,x)}),tK(a);const[l]=w.useState(()=>new uue(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(ei.batchCalls(y)):Ra,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((y,x)=>uP(o[x],y))?c.flatMap((y,x)=>{const v=o[x];if(v){const S=new RD(r,v);if(uP(v,y))return Cw(v,S,a);iK(y,i)&&Cw(v,S,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const b=c.find((y,x)=>{const v=o[x];return v&&nK({result:y,errorResetBoundary:a,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(b?.error)throw b.error;return u(d())}function xue(t,e,n){const r=Qq(),i=Jq(),a=un(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",rK(o),eK(o,i,l),tK(i);const c=!a.getQueryCache().get(o.queryHash),[u]=w.useState(()=>new e(a,o)),d=u.getOptimisticResult(o),f=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(m=>{const p=f?u.subscribe(ei.batchCalls(m)):Ra;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(o)},[o,u]),uP(o,d))throw Cw(o,u,i);if(nK({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Df&&iK(d,r)&&(c?Cw(o,u,i):l?.promise)?.catch(Ra).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ut(t,e){return xue(t,RD)}function ht(t,e){const n=un(),[r]=w.useState(()=>new lue(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(ei.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Ra)},[r]);if(i.error&&jD(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const aK=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const bue=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const yue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Hz=t=>{const e=yue(t);return e.charAt(0).toUpperCase()+e.slice(1)};var vue={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 _ue=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const wue=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...vue,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:aK("lucide",i),...!a&&!_ue(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ke=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(wue,{ref:a,iconNode:e,className:aK(`lucide-${bue(Hz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Hz(t),n};const Sue=[["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"}]],Mue=Ke("air-vent",Sue);const Eue=[["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"}]],Xa=Ke("archive",Eue);const Nue=[["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"}]],Aue=Ke("arrow-down-wide-narrow",Nue);const Tue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],A0=Ke("arrow-down",Tue);const Cue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],sK=Ke("arrow-left",Cue);const kue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dP=Ke("arrow-right",kue);const jue=[["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"}]],oK=Ke("arrow-up-down",jue);const Pue=[["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"}]],Rue=Ke("arrow-up-narrow-wide",Pue);const Due=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hg=Ke("arrow-up",Due);const Oue=[["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"}]],yf=Ke("bell",Oue);const Lue=[["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"}]],Iue=Ke("bold",Lue);const Fue=[["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"}]],Uue=Ke("book",Fue);const zue=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],Bue=Ke("bookmark",zue);const $ue=[["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"}]],Fs=Ke("box",$ue);const Hue=[["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"}]],lK=Ke("briefcase",Hue);const Vue=[["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"}]],ZM=Ke("bug",Vue);const Gue=[["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"}]],Wue=Ke("cable",Gue);const que=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Kue=Ke("calculator",que);const Xue=[["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"}]],Yue=Ke("calendar-days",Xue);const Zue=[["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"}]],ti=Ke("calendar",Zue);const Que=[["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"}]],fg=Ke("camera",Que);const Jue=[["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"}]],ede=Ke("chart-column",Jue);const tde=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ws=Ke("check",tde);const nde=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Zi=Ke("chevron-down",nde);const rde=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Lf=Ke("chevron-left",rde);const ide=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ks=Ke("chevron-right",ide);const ade=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],uu=Ke("chevron-up",ade);const sde=[["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"}]],Qi=Ke("circle-alert",sde);const ode=[["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"}]],nT=Ke("circle-arrow-up",ode);const lde=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Gn=Ke("circle-check-big",lde);const cde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],QM=Ke("circle-check",cde);const ude=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],dde=Ke("circle-dot",ude);const hde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],fde=Ke("circle-stop",hde);const mde=[["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"}]],Ya=Ke("circle-x",mde);const pde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],hP=Ke("circle",pde);const gde=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Yn=Ke("clock",gde);const xde=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],JM=Ke("cloud",xde);const bde=[["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"}]],yde=Ke("code-xml",bde);const vde=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],cK=Ke("code",vde);const _de=[["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"}]],wde=Ke("coffee",_de);const Sde=[["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"}]],Mde=Ke("cog",Sde);const Ede=[["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"}]],Nde=Ke("compass",Ede);const Ade=[["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"}]],rl=Ke("copy",Ade);const Tde=[["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"}]],f_=Ke("cpu",Tde);const Cde=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],kde=Ke("cylinder",Cde);const jde=[["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"}]],mg=Ke("database",jde);const Pde=[["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"}]],fP=Ke("dollar-sign",Pde);const Rde=[["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"}]],Ir=Ke("download",Rde);const Dde=[["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"}]],OD=Ke("droplet",Dde);const Ode=[["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"}]],LD=Ke("droplets",Ode);const Lde=[["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"}]],Od=Ke("ellipsis-vertical",Lde);const Ide=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],rT=Ke("equal",Ide);const Fde=[["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"}]],zr=Ke("external-link",Fde);const Ude=[["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"}]],eE=Ke("eye-off",Ude);const zde=[["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"}]],If=Ke("eye",zde);const Bde=[["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"}]],uK=Ke("fan",Bde);const $de=[["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"}]],vf=Ke("file-box",$de);const Hde=[["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"}]],kw=Ke("file-code",Hde);const Vde=[["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"}]],Gde=Ke("file-exclamation-point",Vde);const Wde=[["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"}]],jw=Ke("file-spreadsheet",Wde);const qde=[["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"}]],Wa=Ke("file-text",qde);const Kde=[["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"}]],tE=Ke("file",Kde);const Xde=[["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"}]],Ld=Ke("film",Xde);const Yde=[["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"}]],Zde=Ke("flame",Yde);const Qde=[["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"}]],wa=Ke("folder-kanban",Qde);const Jde=[["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"}]],il=Ke("folder-open",Jde);const ehe=[["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"}]],the=Ke("folder-plus",ehe);const nhe=[["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"}]],rhe=Ke("folder-tree",nhe);const ihe=[["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"}]],dK=Ke("folder",ihe);const ahe=[["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"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],she=Ke("fullscreen",ahe);const ohe=[["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"}]],nE=Ke("funnel",ohe);const lhe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],rE=Ke("gauge",lhe);const che=[["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"}]],uhe=Ke("gift",che);const dhe=[["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"}]],Zp=Ke("git-compare",dhe);const hhe=[["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"}]],Vz=Ke("github",hhe);const fhe=[["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"}]],Id=Ke("globe",fhe);const mhe=[["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"}]],pg=Ke("grip-vertical",mhe);const phe=[["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"}]],hK=Ke("hand",phe);const ghe=[["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"}]],iE=Ke("hard-drive",ghe);const xhe=[["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"}]],bhe=Ke("hash",xhe);const yhe=[["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"}]],vhe=Ke("headphones",yhe);const _he=[["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"}]],whe=Ke("heart",_he);const She=[["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"}]],Pw=Ke("history",She);const Mhe=[["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"}]],aE=Ke("house",Mhe);const Ehe=[["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"}]],by=Ke("image",Ehe);const Nhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Yl=Ke("info",Nhe);const Ahe=[["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"}]],The=Ke("italic",Ahe);const Che=[["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"}]],of=Ke("key",Che);const khe=[["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"}]],mP=Ke("keyboard",khe);const jhe=[["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"}]],al=Ke("layers",jhe);const Phe=[["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"}]],sE=Ke("layout-grid",Phe);const Rhe=[["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"}]],Dhe=Ke("link-2-off",Rhe);const Ohe=[["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"}]],Vl=Ke("link-2",Ohe);const Lhe=[["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"}]],Xg=Ke("link",Lhe);const Ihe=[["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"}]],fK=Ke("list-ordered",Ihe);const Fhe=[["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"}]],pP=Ke("list-todo",Fhe);const Uhe=[["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"}]],oE=Ke("list",Uhe);const zhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],dt=Ke("loader-circle",zhe);const Bhe=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Gz=Ke("lock-open",Bhe);const $he=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],iT=Ke("lock",$he);const Hhe=[["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"}]],Wz=Ke("log-in",Hhe);const Vhe=[["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"}]],gP=Ke("log-out",Vhe);const Ghe=[["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"}]],Whe=Ke("mail",Ghe);const qhe=[["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"}]],Khe=Ke("map",qhe);const Xhe=[["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"}]],mK=Ke("maximize-2",Xhe);const Yhe=[["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"}]],Zhe=Ke("maximize",Yhe);const Qhe=[["path",{d:"M12 12v-2",key:"fwoke6"}],["path",{d:"M12 18v-2",key:"qj6yno"}],["path",{d:"M16 12v-2",key:"heuere"}],["path",{d:"M16 18v-2",key:"s1ct0w"}],["path",{d:"M2 11h1.5",key:"15p63e"}],["path",{d:"M20 18v-2",key:"12ehxp"}],["path",{d:"M20.5 11H22",key:"khsy7a"}],["path",{d:"M4 18v-2",key:"1c3oqr"}],["path",{d:"M8 12v-2",key:"1mwtfd"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["rect",{x:"2",y:"6",width:"20",height:"10",rx:"2",key:"1qcswk"}]],Jhe=Ke("memory-stick",Qhe);const efe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],tfe=Ke("menu",efe);const nfe=[["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"}]],pK=Ke("minimize-2",nfe);const rfe=[["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"}]],gK=Ke("minimize",rfe);const ife=[["path",{d:"M5 12h14",key:"1ays0h"}]],xP=Ke("minus",ife);const afe=[["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"}]],sfe=Ke("monitor",afe);const ofe=[["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"}]],Rw=Ke("moon",ofe);const lfe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],cfe=Ke("move-right",lfe);const ufe=[["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"}]],bP=Ke("music",ufe);const dfe=[["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"}]],Zl=Ke("package",dfe);const hfe=[["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"}]],ID=Ke("palette",hfe);const ffe=[["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"}]],FD=Ke("pause",ffe);const mfe=[["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"}]],Ff=Ke("pen-line",mfe);const pfe=[["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"}]],lE=Ke("pen",pfe);const gfe=[["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"}]],Ia=Ke("pencil",gfe);const xfe=[["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"}]],bfe=Ke("phone",xfe);const yfe=[["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"}]],sl=Ke("play",yfe);const vfe=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Hs=Ke("plug",vfe);const _fe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Qn=Ke("plus",_fe);const wfe=[["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"}]],cE=Ke("power-off",wfe);const Sfe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],_u=Ke("power",Sfe);const Mfe=[["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"}]],Br=Ke("printer",Mfe);const Efe=[["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"}]],xK=Ke("qr-code",Efe);const Nfe=[["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"}]],Mr=Ke("refresh-cw",Nfe);const Afe=[["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"}]],om=Ke("rotate-ccw",Afe);const Tfe=[["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"}]],Cfe=Ke("ruler",Tfe);const kfe=[["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"}]],ps=Ke("save",kfe);const jfe=[["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"}]],bK=Ke("scan-search",jfe);const Pfe=[["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"}]],Rfe=Ke("scissors",Pfe);const Dfe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],va=Ke("search",Dfe);const Ofe=[["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"}]],UD=Ke("send",Ofe);const Lfe=[["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"}]],qh=Ke("server",Lfe);const Ife=[["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"}]],qd=Ke("settings-2",Ife);const Ffe=[["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"}]],uE=Ke("settings",Ffe);const Ufe=[["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"}]],yP=Ke("shield",Ufe);const zfe=[["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"}]],yK=Ke("shopping-cart",zfe);const Bfe=[["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"}]],$fe=Ke("signal",Bfe);const Hfe=[["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"}]],Vfe=Ke("skip-back",Hfe);const Gfe=[["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"}]],Dw=Ke("skip-forward",Gfe);const Wfe=[["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"}]],qz=Ke("sliders-vertical",Wfe);const qfe=[["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"}]],T0=Ke("sparkles",qfe);const Kfe=[["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"}]],ol=Ke("square-check-big",Kfe);const Xfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Yfe=Ke("square-minus",Xfe);const Zfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ll=Ke("square",Zfe);const Qfe=[["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"}]],Uf=Ke("star",Qfe);const Jfe=[["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"}]],vK=Ke("sticky-note",Jfe);const eme=[["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"}]],Kz=Ke("sun",eme);const tme=[["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"}]],gg=Ke("tag",tme);const nme=[["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"}]],_K=Ke("target",nme);const rme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],wK=Ke("terminal",rme);const ime=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],ame=Ke("text-align-center",ime);const sme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ome=Ke("text-align-end",sme);const lme=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],cme=Ke("text-align-start",lme);const ume=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],dE=Ke("thermometer",ume);const dme=[["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"}]],Nd=Ke("timer",dme);const hme=[["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"}]],fn=Ke("trash-2",hme);const fme=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],SK=Ke("trending-down",fme);const mme=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],MK=Ke("trending-up",mme);const pme=[["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"}]],Rn=Ke("triangle-alert",pme);const gme=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],xme=Ke("underline",gme);const bme=[["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"}]],zD=Ke("unlink",bme);const yme=[["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"}]],oi=Ke("upload",yme);const vme=[["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"}]],vP=Ke("user",vme);const _me=[["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"}]],lf=Ke("users",_me);const wme=[["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"}]],BD=Ke("video",wme);const Sme=[["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"}]],Mme=Ke("volume-2",Sme);const Eme=[["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"}]],Nme=Ke("volume-x",Eme);const Ame=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Tme=Ke("wand-sparkles",Ame);const Cme=[["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"}]],Yg=Ke("wifi-off",Cme);const kme=[["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"}]],Qp=Ke("wifi",kme);const jme=[["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"}]],EK=Ke("wind",jme);const Pme=[["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"}]],Kd=Ke("wrench",Pme);const Rme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=Ke("x",Rme);const Dme=[["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"}]],zf=Ke("zap",Dme);const Ome=[["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"}]],$D=Ke("zoom-in",Ome);const Lme=[["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"}]],HD=Ke("zoom-out",Lme),yn="/api/v1";let Ow=localStorage.getItem("auth_token");function Lb(t){Ow=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Xz(){return Ow}async function ke(t,e={}){const n={"Content-Type":"application/json",...e.headers};Ow&&(n.Authorization=`Bearer ${Ow}`);const r=await fetch(`${yn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Lb(null);const a=(await r.json().catch(()=>({}))).detail,o=typeof a=="string"?a:a?JSON.stringify(a):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const pe={getAuthStatus:()=>ke("/auth/status"),setupAuth:t=>ke("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>ke("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>ke("/auth/logout",{method:"POST"}),getCurrentUser:()=>ke("/auth/me"),disableAuth:()=>ke("/auth/disable",{method:"POST"}),getUsers:()=>ke("/users/"),getUser:t=>ke(`/users/${t}`),createUser:t=>ke("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>ke(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>ke(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>ke("/printers/"),getPrinter:t=>ke(`/printers/${t}`),createPrinter:t=>ke("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>ke(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>ke(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>ke(`/printers/${t}/status`),refreshPrinterStatus:t=>ke(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>ke(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>ke(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>ke(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>ke(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>ke(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>ke(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>ke(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>ke(`/printers/${t}/print/objects`),skipObjects:(t,e)=>ke(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>ke(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>ke(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>ke(`/printers/${t}/logging`),clearMQTTLogs:t=>ke(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>ke(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${yn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${yn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>ke(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>ke(`/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)),ke(`/archives/?${i}`)},getArchive:t=>ke(`/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)),ke(`/archives/search?${n}`)},rebuildSearchIndex:()=>ke("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>ke(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>ke(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>ke(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>ke("/archives/stats"),recalculateCosts:()=>ke("/archives/recalculate-costs",{method:"POST"}),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)),ke(`/archives/analysis/failures?${e}`)},compareArchives:t=>ke(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>ke(`/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(`${yn}/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(`${yn}/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=>ke(`/archives/${t}/duplicates`),backfillContentHashes:()=>ke("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${yn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${yn}/archives/${t}/download`,getArchiveGcode:t=>`${yn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${yn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${yn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>ke(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>ke(`/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(`${yn}/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=>ke(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>ke(`/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(`${yn}/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)=>`${yn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${yn}/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)=>ke(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${yn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${yn}/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(`${yn}/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=>ke(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${yn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${yn}/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=>ke(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${yn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>ke(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>ke(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>ke(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${yn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${yn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>ke(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>ke(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>ke(`/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?`${yn}/archives/upload?printer_id=${e}`:`${yn}/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?`${yn}/archives/upload-bulk?printer_id=${e}`:`${yn}/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:()=>ke("/settings/"),updateSettings:t=>ke("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>ke("/settings/mqtt/status"),resetSettings:()=>ke("/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=`${yn}/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=`${yn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>ke("/settings/check-ffmpeg"),getCloudStatus:()=>ke("/cloud/status"),cloudLogin:(t,e,n="global")=>ke("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>ke("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>ke("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>ke("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>ke(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>ke(`/cloud/settings/${t}`),createCloudSetting:t=>ke("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>ke(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>ke(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>ke("/cloud/devices"),getCloudFields:t=>ke(`/cloud/fields/${t}`),getAllCloudFields:()=>ke("/cloud/fields"),getFilamentInfo:t=>ke("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>ke("/smart-plugs/"),getSmartPlug:t=>ke(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>ke(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>ke("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>ke(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>ke(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>ke(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>ke(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>ke("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${yn}/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:()=>ke("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${yn}/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:()=>ke("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>ke("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return ke(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>ke("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),ke(`/queue/?${n}`)},getQueueItem:t=>ke(`/queue/${t}`),addToQueue:t=>ke("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>ke(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>ke(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>ke("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>ke(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>ke(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>ke(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>ke(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>ke(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>ke(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>ke(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>ke(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>ke(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>ke(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>ke(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>ke(`/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()),ke(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>ke("/filaments/"),getFilament:t=>ke(`/filaments/${t}`),getFilamentsByType:t=>ke(`/filaments/by-type/${t}`),getNotificationProviders:()=>ke("/notifications/"),getNotificationProvider:t=>ke(`/notifications/${t}`),createNotificationProvider:t=>ke("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>ke(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>ke(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>ke(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>ke("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>ke("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>ke("/notification-templates"),getNotificationTemplate:t=>ke(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>ke(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>ke(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>ke("/notification-templates/variables"),previewTemplate:t=>ke("/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)),ke(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>ke(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>ke(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>ke("/spoolman/status"),connectSpoolman:()=>ke("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>ke("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>ke(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>ke("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>ke("/spoolman/spools"),getSpoolmanFilaments:()=>ke("/spoolman/filaments"),getUnlinkedSpools:()=>ke("/spoolman/spools/unlinked"),linkSpool:(t,e)=>ke(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>ke("/updates/version"),checkForUpdates:()=>ke("/updates/check"),applyUpdate:()=>ke("/updates/apply",{method:"POST"}),getUpdateStatus:()=>ke("/updates/status"),getMaintenanceTypes:()=>ke("/maintenance/types"),createMaintenanceType:t=>ke("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>ke(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>ke(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>ke("/maintenance/overview"),getPrinterMaintenance:t=>ke(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>ke(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>ke(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>ke(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>ke("/maintenance/summary"),setPrinterHours:(t,e)=>ke(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>ke(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>ke(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${yn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${yn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>ke(`/printers/${t}/camera/test`),getExternalLinks:()=>ke("/external-links/"),getExternalLink:t=>ke(`/external-links/${t}`),createExternalLink:t=>ke("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>ke(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>ke(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>ke("/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(`${yn}/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=>ke(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${yn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),ke(`/projects/?${e}`)},getProject:t=>ke(`/projects/${t}`),createProject:t=>ke("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>ke(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>ke(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>ke(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>ke(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>ke(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>ke(`/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(`${yn}/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)=>`${yn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>ke(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>ke(`/projects/${t}/bom`),createBOMItem:(t,e)=>ke(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>ke(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>ke(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>ke("/projects/templates/"),createTemplateFromProject:t=>ke(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>ke(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>ke(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>ke(`/projects/${t}/export?format=json`),importProject:t=>ke("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>ke("/api-keys/"),createAPIKey:t=>ke("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>ke(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>ke(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>ke(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>ke("/system/info"),getLibraryFolders:()=>ke("/library/folders"),createLibraryFolder:t=>ke("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>ke(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>ke(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>ke(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>ke(`/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)),ke(`/library/files?${n}`)},getLibraryFile:t=>ke(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${yn}/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()},extractZipFile:async(t,e,n=!0,r=!1)=>{const i=new FormData;i.append("file",t);const a=new URLSearchParams;e&&a.set("folder_id",String(e)),a.set("preserve_structure",String(n)),a.set("create_folder_from_zip",String(r));const o=await fetch(`${yn}/library/files/extract-zip?${a}`,{method:"POST",body:i});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},updateLibraryFile:(t,e)=>ke(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>ke(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${yn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${yn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${yn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>ke("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>ke("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>ke("/library/stats"),addLibraryFilesToQueue:t=>ke("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>ke(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>ke(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>ke(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`)},Sl={getInfo:()=>ke("/discovery/info"),getStatus:()=>ke("/discovery/status"),startDiscovery:(t=10)=>ke(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>ke("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>ke("/discovery/printers"),startSubnetScan:(t,e=1)=>ke("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>ke("/discovery/scan/status"),stopSubnetScan:()=>ke("/discovery/scan/stop",{method:"POST"})},Z1={getSettings:()=>ke("/settings/virtual-printer"),getModels:()=>ke("/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),ke(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Fp={list:()=>ke("/pending-uploads/"),getCount:()=>ke("/pending-uploads/count"),get:t=>ke(`/pending-uploads/${t}`),archive:(t,e)=>ke(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>ke(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>ke("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>ke("/pending-uploads/discard-all",{method:"DELETE"})},Q1={checkUpdates:()=>ke("/firmware/updates"),checkPrinterUpdate:t=>ke(`/firmware/updates/${t}`),prepareUpload:t=>ke(`/firmware/updates/${t}/prepare`),startUpload:t=>ke(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>ke(`/firmware/updates/${t}/upload/status`)},Jp={getDebugLoggingState:()=>ke("/support/debug-logging"),setDebugLogging:t=>ke("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${yn}/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)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return ke(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>ke("/support/logs",{method:"DELETE"})},NK=w.createContext(void 0);function Ime({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return C||D||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,b]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{pe.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(d(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(m(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(b(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.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"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${a}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${u}`),C.classList.add(`bg-${f}`),C.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(C=>C==="dark"?"light":"dark"),x=C=>n(C),v=C=>{i(C),localStorage.setItem("dark-style",C),pe.updateSettings({dark_style:C}).catch(()=>{})},S=C=>{o(C),localStorage.setItem("dark-background",C),pe.updateSettings({dark_background:C}).catch(()=>{})},M=C=>{c(C),localStorage.setItem("dark-accent",C),pe.updateSettings({dark_accent:C}).catch(()=>{})},N=C=>{d(C),localStorage.setItem("light-style",C),pe.updateSettings({light_style:C}).catch(()=>{})},A=C=>{m(C),localStorage.setItem("light-background",C),pe.updateSettings({light_background:C}).catch(()=>{})},k=C=>{b(C),localStorage.setItem("light-accent",C),pe.updateSettings({light_accent:C}).catch(()=>{})};return s.jsx(NK.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:y,setMode:x,setDarkStyle:v,setDarkBackground:S,setDarkAccent:M,setLightStyle:N,setLightBackground:A,setLightAccent:k},children:t})}function sh(){const t=w.useContext(NK);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Et({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 wr({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function At({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function Fme(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 Yz({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 Ume({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Gg(),i=Fme(n,e,r);return w.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(Et,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(At,{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(mP,{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(Wt,{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(zr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Yz,{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(Yz,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({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",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,a]);const d={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:a?void 0:c,children:s.jsx(Et,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:s.jsxs(At,{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 ${d.icon}`,children:s.jsx(Rn,{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(Me,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(Me,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function zme({plug:t}){const e=un(),[n,r]=w.useState(null),{data:i,isLoading:a}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ht({mutationFn:f=>pe.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(Hs,{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(dt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Qp,{className:"w-3 h-3 text-status-ok"}),s.jsx("span",{className:l?"text-status-ok":"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(zf,{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(Yg,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",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(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_u,{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(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(cE,{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 Zz({onClose:t}){const{data:e,isLoading:n}=ut({queryKey:["smart-plugs"],queryFn:pe.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(Hs,{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(dt,{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(Hs,{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(zme,{plug:i},i.id))})})]})}const AK=[{name:"globe",icon:Id},{name:"link",icon:Xg},{name:"external-link",icon:zr},{name:"book",icon:Uue},{name:"file-text",icon:Wa},{name:"home",icon:aE},{name:"star",icon:Uf},{name:"heart",icon:whe},{name:"bookmark",icon:Bue},{name:"shopping-cart",icon:yK},{name:"music",icon:bP},{name:"video",icon:BD},{name:"image",icon:by},{name:"camera",icon:fg},{name:"map",icon:Khe},{name:"compass",icon:Nde},{name:"coffee",icon:wde},{name:"gift",icon:uhe},{name:"wrench",icon:Kd},{name:"zap",icon:zf},{name:"cloud",icon:JM},{name:"database",icon:mg},{name:"folder",icon:dK},{name:"mail",icon:Whe},{name:"phone",icon:bfe},{name:"user",icon:vP},{name:"users",icon:lf},{name:"server",icon:qh},{name:"terminal",icon:wK},{name:"code",icon:cK}];function hE(t){return AK.find(n=>n.name===t)?.icon||Xg}function Bme({value:t,onChange:e}){const[n,r]=w.useState(!1),i=hE(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:AK.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 Qz=768;function TK(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<Qz:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Qz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const CK=w.createContext(void 0);function $me({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=async()=>{try{const y=await pe.getAuthStatus();if(i(y.auth_enabled),o(y.requires_setup),y.auth_enabled)if(Xz())try{const v=await pe.getCurrentUser();n(v)}catch{Lb(null),n(null)}else n(null);else n(null)}catch{i(!1),n(null)}finally{c(!1)}};w.useEffect(()=>{d()},[]),w.useEffect(()=>{if(!l&&a&&!r){const y=window.location.pathname;y!=="/setup"&&!y.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const f=async(y,x)=>{const v=await pe.login({username:y,password:x});Lb(v.access_token),n(v.user)},m=()=>{Lb(null),n(null),pe.logout().catch(()=>{}),window.location.href="/login"},p=async()=>{if(r&&Xz())try{const y=await pe.getCurrentUser();n(y)}catch{Lb(null),n(null)}},b=async()=>{await d()};return s.jsx(CK.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:f,logout:m,refreshUser:p,refreshAuth:b},children:t})}function oh(){const t=w.useContext(CK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const C0=[{id:"printers",to:"/",icon:Br,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Xa,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ti,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:ede,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:JM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Kd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:wa,labelKey:"nav.projects"},{id:"files",to:"/files",icon:il,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:uE,labelKey:"nav.settings"}];function Hme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return C0.map(e=>e.id)}return C0.map(e=>e.id)}function Vme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function aT(t){return t.startsWith("ext-")}function kK(){return localStorage.getItem("defaultView")||"/"}function Gme(t){localStorage.setItem("defaultView",t)}function Wme(){const t=ml(),e=oc(),{mode:n,toggleMode:r}=sh(),{t:i}=Gg(),a=TK(),{user:o,authEnabled:l,logout:c}=oh(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(Hme),[M,N]=w.useState(null),[A,k]=w.useState(null),C=w.useRef(!1),[D,T]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:R}=ut({queryKey:["version"],queryFn:pe.getVersion,staleTime:1/0}),{data:U}=ut({queryKey:["settings"],queryFn:pe.getSettings,staleTime:300*1e3}),{data:O}=ut({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,enabled:U?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:q}=ut({queryKey:["external-links"],queryFn:pe.getExternalLinks}),{data:j}=ut({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs,staleTime:30*1e3}),W=j?.some(B=>B.show_in_switchbar)??!1,{data:K}=ut({queryKey:["debugLogging"],queryFn:Jp.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:G}=ut({queryKey:["queue","pending"],queryFn:()=>pe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),J=G?.length??0,{data:ie}=ut({queryKey:["pending-uploads","count"],queryFn:Fp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),re=ie?.count??0,[z,V]=w.useState(null);w.useEffect(()=>{if(!K?.enabled||!K.enabled_at){V(null);return}const B=new Date(K.enabled_at).getTime(),te=()=>{V(Math.floor((Date.now()-B)/1e3))};te();const Y=setInterval(te,1e3);return()=>clearInterval(Y)},[K?.enabled,K?.enabled_at]);const Z=w.useMemo(()=>new Map(C0.map(B=>[B.id,B])),[]),ne=w.useMemo(()=>new Map((q||[]).map(B=>[`ext-${B.id}`,B])),[q]),he=(()=>{const B=[],te=new Set,Y=l&&o?.role==="user";for(const H of v)Y&&H==="settings"||(Z.has(H)||ne.has(H))&&(B.push(H),te.add(H));for(const H of C0)Y&&H.id==="settings"||te.has(H.id)||(B.push(H.id),te.add(H.id));for(const H of q||[]){const F=`ext-${H.id}`;te.has(F)||(B.push(F),te.add(F))}return B})(),fe=(B,te)=>{N(te),B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",te)},le=(B,te)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",k(te)},Ee=()=>{k(null)},me=(B,te)=>{if(B.preventDefault(),M===null||M===te){N(null),k(null);return}const Y=[...he],H=Y.indexOf(M),F=Y.indexOf(te);if(H===-1||F===-1){N(null),k(null);return}Y.splice(H,1),Y.splice(F,0,M),S(Y),Vme(Y),N(null),k(null)},we=()=>{N(null),k(null)},De=O?.update_available&&O.latest_version&&O.latest_version!==D,ee=()=>{O?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",O.latest_version),T(O.latest_version))};w.useEffect(()=>{if(!C.current&&e.pathname==="/"){const B=kK();B!=="/"&&(C.current=!0,t(B,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]);const Qe=w.useCallback(B=>{const te=B.target;if(!(te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.isContentEditable)&&!B.metaKey&&!B.ctrlKey&&!B.altKey){const Y=parseInt(B.key);if(Y>=1&&Y<=he.length&&Y<=9){const H=he[Y-1];if(B.preventDefault(),aT(H)){const F=H.replace("ext-","");t(`/external/${F}`)}else{const F=Z.get(H);F&&t(F.to)}return}switch(B.key){case"?":B.preventDefault(),b(!0);break;case"Escape":b(!1);break}}},[t,he,Z]);return w.useEffect(()=>(document.addEventListener("keydown",Qe),()=>document.removeEventListener("keydown",Qe)),[Qe]),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:()=>m(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(tfe,{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&&f&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>m(!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 ${f?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${u?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||u?"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||u?"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:he.map(B=>{if(aT(B)){const Y=ne.get(B);if(!Y)return null;const H=Y.custom_icon?null:hE(Y.icon);return s.jsx("li",{draggable:!0,onDragStart:F=>fe(F,B),onDragOver:F=>le(F,B),onDragLeave:Ee,onDrop:F=>me(F,B),onDragEnd:we,className:`relative ${M===B?"opacity-50":""} ${A===B&&M!==B?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ob,{to:`/external/${Y.id}`,className:({isActive:F})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${F?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?Y.name:void 0,children:[u&&!a&&s.jsx(pg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),Y.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${Y.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):H&&s.jsx(H,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:Y.name})]})},B)}else{const Y=Z.get(B);if(!Y)return null;const{to:H,icon:F,labelKey:de}=Y,Ae=B==="queue"&&J>0,Le=B==="archives"&&re>0,Se=Ae?J:Le?re:0,$=Ae||Le;return s.jsx("li",{draggable:!0,onDragStart:L=>fe(L,B),onDragOver:L=>le(L,B),onDragLeave:Ee,onDrop:L=>me(L,B),onDragEnd:we,className:`relative ${M===B?"opacity-50":""} ${A===B&&M!==B?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Ob,{to:H,className:({isActive:L})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${L?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(de):void 0,children:[u&&!a&&s.jsx(pg,{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(F,{className:"w-5 h-5 flex-shrink-0"}),$&&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 ${Le?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Se>99?"99+":Se})]}),(a||u)&&s.jsx("span",{children:i(de)})]})},B)}})})}),!a&&s.jsx("button",{onClick:()=>d(!u),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(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?s.jsx(Lf,{className:"w-5 h-5"}):s.jsx(Ks,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[W&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Hs,{className:"w-5 h-5"})}),y&&s.jsx(Zz,{onClose:()=>x(!1)})]}),s.jsx(Ob,{to:"/system",className:({isActive:B})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${B?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Yl,{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(Vz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>b(!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(mP,{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(Kz,{className:"w-5 h-5"}):s.jsx(Rw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(gP,{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",R?.version||"..."]}),O?.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:O.latest_version}),children:[s.jsx(nT,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[O?.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:O.latest_version}),children:s.jsx(nT,{className:"w-5 h-5"})}),W&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Hs,{className:"w-5 h-5"})}),y&&s.jsx(Zz,{onClose:()=>x(!1)})]}),s.jsx(Ob,{to:"/system",className:({isActive:B})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${B?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Yl,{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(Vz,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>b(!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(mP,{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(Kz,{className:"w-5 h-5"}):s.jsx(Rw,{className:"w-5 h-5"})}),l&&o&&s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(gP,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":u?"ml-64":"ml-16"}`,children:[K?.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(ZM,{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"}),z!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(z/60),"m ",z%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"})})]})}),De&&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(nT,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:O?.latest_version,defaultValue:`Version ${O?.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:ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Wt,{className:"w-4 h-4"})})]}),s.jsx(ace,{})]}),p&&s.jsx(Ume,{onClose:()=>b(!1),sidebarItems:he.map(B=>{if(aT(B)){const te=ne.get(B);return te?{type:"external",label:te.name}:null}else{const te=Z.get(B);return te?{type:"nav",label:te.labelKey,labelKey:te.labelKey}:null}}).filter(Boolean)})]})}function t0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function gi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function xg(t,e){const n=gi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function bg(t,e="system",n){const r=gi(t);if(!r)return"";const a=t0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function qme(t,e="system",n){const i=t0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const jK=w.createContext(void 0);function qn(){const t=w.useContext(jK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Kme={success:s.jsx(Gn,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Ya,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(Qi,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Yl,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(dt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Xme={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 Yme({children:t}){const[e,n]=w.useState([]),r=w.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=w.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=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(jK.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 ${Xme[o.type]}`,children:[Kme[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(Wt,{className:"w-4 h-4"})})]},o.id))})]})}function Zme(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 Jz(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 Qme(t,e){if(e)return dK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return vf;case"gcode":return Wa;case"mp4":case"avi":return Ld;case"png":case"jpg":case"jpeg":return by;default:return tE}}const Jme=[{value:"name-asc",label:"Name (A-Z)"},{value:"name-desc",label:"Name (Z-A)"},{value:"size-asc",label:"Size (smallest)"},{value:"size-desc",label:"Size (largest)"},{value:"date-asc",label:"Date (oldest)"},{value:"date-desc",label:"Date (newest)"}];function epe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=qn(),i=un(),[a,o]=w.useState("/"),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[f,m]=w.useState([]),[p,b]=w.useState("name-asc"),[y,x]=w.useState(null);w.useEffect(()=>{const j=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]);const{data:v,isLoading:S,refetch:M}=ut({queryKey:["printerFiles",t,a],queryFn:()=>pe.getPrinterFiles(t,a)}),{data:N}=ut({queryKey:["printerStorage",t],queryFn:()=>pe.getPrinterStorage(t),staleTime:3e4}),A=ht({mutationFn:async j=>{for(const W of j)await pe.deletePrinterFile(t,W)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:j=>{r(`Delete failed: ${j.message}`,"error")}}),k=j=>{o(j),c(new Set)},C=()=>{if(a==="/")return;const j=a.split("/").filter(Boolean);j.pop(),o(j.length?"/"+j.join("/"):"/"),c(new Set)},D=(j,W)=>{W.stopPropagation(),c(K=>{const G=new Set(K);return G.has(j)?G.delete(j):G.add(j),G})},T=()=>{if(!v?.files)return;const j=v.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);c(new Set(j))},R=()=>{c(new Set)},U=async()=>{if(l.size===0)return;const j=Array.from(l);if(j.length===1){window.open(pe.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}x({current:0,total:j.length});try{const W=await pe.downloadPrinterFilesAsZip(t,j),K=URL.createObjectURL(W),G=document.createElement("a");G.href=K,G.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(K),r(`Downloaded ${j.length} files as ZIP`),c(new Set)}catch(W){r(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{x(null)}},O=()=>{l.size!==0&&m(Array.from(l))},q=[{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:j=>j.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(iE,{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:[N&&(N.used_bytes!=null||N.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[N.used_bytes!=null&&s.jsxs("span",{children:["Used: ",Jz(N.used_bytes)]}),N.used_bytes!=null&&N.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),N.free_bytes!=null&&s.jsxs("span",{children:["Free: ",Jz(N.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Wt,{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:[q.map(j=>s.jsx("button",{onClick:()=>{k(j.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===j.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:j.label},j.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{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:j=>d(j.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.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(oK,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:j=>b(j.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:Jme.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>M(),disabled:S,children:s.jsx(Mr,{className:`w-4 h-4 ${S?"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:C,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(Lf,{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:S?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v?.files?.length?s.jsx("div",{className:"space-y-1",children:[...v.files].filter(j=>!u||j.name.toLowerCase().includes(u.toLowerCase())).sort((j,W)=>{if(j.is_directory&&!W.is_directory)return-1;if(!j.is_directory&&W.is_directory)return 1;switch(p){case"name-asc":return j.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(j.name);case"size-asc":return j.size-W.size;case"size-desc":return W.size-j.size;case"date-asc":{const K=j.mtime?new Date(j.mtime).getTime():0,G=W.mtime?new Date(W.mtime).getTime():0;return K-G}case"date-desc":{const K=j.mtime?new Date(j.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-K}default:return j.name.localeCompare(W.name)}}).map(j=>{const W=Qme(j.name,j.is_directory),K=l.has(j.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:()=>{j.is_directory&&k(j.path)},children:[j.is_directory?null:s.jsx("button",{onClick:G=>D(j.path,G),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:K?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5"})}),s.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${j.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:j.name}),!j.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:Zme(j.size)}),j.is_directory&&s.jsx(Lf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},j.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.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:l.size>0?`${l.size} selected`:u?`${v?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.files?.some(j=>!j.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:l.size>0?s.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Yfe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:T,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",disabled:l.size===0||y!==null,onClick:U,children:y?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):s.jsxs(s.Fragment,{children:[s.jsx(Ir,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),s.jsxs(Me,{variant:"secondary",disabled:l.size===0||A.isPending,onClick:O,className:"text-red-400 hover:text-red-300",children:[A.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&s.jsx(Un,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{A.mutate(f)},onCancel:()=>m([])})]})}const tpe="embeddedCameraState_",eB=5,npe=2e3,rpe=3e4,ipe=5e3,sT={x:window.innerWidth-420,y:20,width:400,height:300};function ape({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${tpe}${t}`,a=()=>{try{const ye=localStorage.getItem(i);if(ye){const Ce=JSON.parse(ye);return{x:Math.min(Math.max(0,Ce.x),window.innerWidth-100),y:Math.min(Math.max(0,Ce.y),window.innerHeight-100),width:Math.max(200,Math.min(Ce.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ce.height,window.innerHeight-20))}}}catch{}const oe=n*30;return{...sT,x:Math.max(0,sT.x-oe),y:Math.max(0,sT.y+oe)}},[o,l]=w.useState(a),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState({x:0,y:0}),[b,y]=w.useState(!1),[x,v]=w.useState(!1),[S,M]=w.useState(1),[N,A]=w.useState({x:0,y:0}),[k,C]=w.useState(!1),[D,T]=w.useState({x:0,y:0}),[R,U]=w.useState(null),[O,q]=w.useState(null),[j,W]=w.useState(!1),[K,G]=w.useState(!0),[J,ie]=w.useState(Date.now()),[re,z]=w.useState(0),[V,Z]=w.useState(!1),[ne,he]=w.useState(0),fe=w.useRef(null),le=w.useRef(null),Ee=w.useRef(null),me=w.useRef(null),we=w.useRef(null),{data:De}=ut({queryKey:["printer",t],queryFn:()=>pe.getPrinter(t),enabled:t>0});w.useEffect(()=>{const oe=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(oe)},[o,i]);const ee=w.useRef(!1);w.useEffect(()=>{ee.current=!1;const oe=`/api/v1/printers/${t}/camera/stop`,ye=()=>{t>0&&!ee.current&&(ee.current=!0,navigator.sendBeacon(oe))},Ce=le.current;return()=>{Ce&&(Ce.src=""),ye(),Ee.current&&clearTimeout(Ee.current),me.current&&clearInterval(me.current),we.current&&clearInterval(we.current)}},[t]),w.useEffect(()=>{if(K){const oe=setTimeout(()=>G(!1),3e3);return()=>clearTimeout(oe)}},[K,J]);const Qe=w.useCallback(()=>{if(re>=eB){Z(!1),W(!0);return}const oe=Math.min(npe*Math.pow(2,re),rpe);Z(!0),he(Math.ceil(oe/1e3)),me.current=setInterval(()=>{he(ye=>ye<=1?(me.current&&clearInterval(me.current),0):ye-1)},1e3),Ee.current=setTimeout(()=>{z(ye=>ye+1),Z(!1),G(!0),W(!1),le.current&&(le.current.src=""),ie(Date.now())},oe)},[re]);w.useEffect(()=>{if(K||V||b){we.current&&(clearInterval(we.current),we.current=null);return}return we.current=setInterval(async()=>{try{const oe=await fetch(`/api/v1/printers/${t}/camera/status`);if(oe.ok){const ye=await oe.json();(ye.stalled||!ye.active&&!j)&&(we.current&&(clearInterval(we.current),we.current=null),G(!1),Qe())}}catch{}},ipe),()=>{we.current&&(clearInterval(we.current),we.current=null)}},[K,j,V,b,t,Qe]),w.useEffect(()=>{const oe=()=>{const ye=!!document.fullscreenElement;v(ye),ye||(M(1),A({x:0,y:0}))};return document.addEventListener("fullscreenchange",oe),()=>document.removeEventListener("fullscreenchange",oe)},[]);const B=()=>{fe.current&&(document.fullscreenElement?document.exitFullscreen():fe.current.requestFullscreen())},te=()=>{M(oe=>Math.min(oe+.5,4))},Y=()=>{M(oe=>{const ye=Math.max(oe-.5,1);return ye===1&&A({x:0,y:0}),ye})},H=oe=>{oe.preventDefault(),oe.deltaY<0?te():Y()},F=oe=>{S>1&&(oe.preventDefault(),C(!0),T({x:oe.clientX-N.x,y:oe.clientY-N.y}))},de=w.useCallback(()=>{if(!fe.current||!le.current)return{x:200,y:150};const oe=fe.current.getBoundingClientRect(),ye=oe.width*(S-1)/2,Ce=oe.height*(S-1)/2;return{x:Math.max(50,ye),y:Math.max(50,Ce)}},[S]),Ae=oe=>{if(k&&S>1){const ye=oe.clientX-D.x,Ce=oe.clientY-D.y,$e=de();A({x:Math.max(-$e.x,Math.min($e.x,ye)),y:Math.max(-$e.y,Math.min($e.y,Ce))})}},Le=()=>{C(!1)},Se=oe=>{if(oe.length<2)return 0;const ye=oe[0].clientX-oe[1].clientX,Ce=oe[0].clientY-oe[1].clientY;return Math.sqrt(ye*ye+Ce*Ce)},$=oe=>oe.length<2?{x:oe[0].clientX,y:oe[0].clientY}:{x:(oe[0].clientX+oe[1].clientX)/2,y:(oe[0].clientY+oe[1].clientY)/2},L=oe=>{oe.touches.length===2?(oe.preventDefault(),U(Se(oe.touches)),q($(oe.touches))):oe.touches.length===1&&S>1&&(oe.preventDefault(),C(!0),T({x:oe.touches[0].clientX-N.x,y:oe.touches[0].clientY-N.y}))},X=oe=>{if(oe.touches.length===2&&R!==null){oe.preventDefault();const ye=Se(oe.touches),Ce=ye/R;M(lt=>{const se=Math.max(1,Math.min(4,lt*Ce));return se===1&&A({x:0,y:0}),se}),U(ye);const $e=$(oe.touches);if(O){const lt=de();A(se=>({x:Math.max(-lt.x,Math.min(lt.x,se.x+($e.x-O.x))),y:Math.max(-lt.y,Math.min(lt.y,se.y+($e.y-O.y)))}))}q($e)}else if(oe.touches.length===1&&k&&S>1){oe.preventDefault();const ye=oe.touches[0].clientX-D.x,Ce=oe.touches[0].clientY-D.y,$e=de();A({x:Math.max(-$e.x,Math.min($e.x,ye)),y:Math.max(-$e.y,Math.min($e.y,Ce))})}},xe=oe=>{oe.touches.length<2&&(U(null),q(null)),oe.touches.length===0&&C(!1)},_e=()=>{M(1),A({x:0,y:0})},ae=()=>{G(!1),re<eB?Qe():W(!0)},Te=()=>{G(!1),W(!1),z(0),Z(!1),Ee.current&&clearTimeout(Ee.current),me.current&&clearInterval(me.current)},Pe=()=>{G(!0),W(!1),z(0),Z(!1),Ee.current&&clearTimeout(Ee.current),me.current&&clearInterval(me.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),le.current&&(le.current.src=""),setTimeout(()=>ie(Date.now()),100)},Xe=oe=>{oe.target.closest(".no-drag")||(u(!0),p({x:oe.clientX-o.x,y:oe.clientY-o.y}))},Je=oe=>{oe.stopPropagation(),f(!0)};w.useEffect(()=>{const oe=Ce=>{if(c)l($e=>({...$e,x:Math.max(0,Math.min(Ce.clientX-m.x,window.innerWidth-$e.width)),y:Math.max(0,Math.min(Ce.clientY-m.y,window.innerHeight-$e.height))}));else if(d&&fe.current){const $e=fe.current.getBoundingClientRect();l(lt=>({...lt,width:Math.max(200,Math.min(Ce.clientX-$e.left,window.innerWidth-lt.x-10)),height:Math.max(150,Math.min(Ce.clientY-$e.top,window.innerHeight-lt.y-10))}))}},ye=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ye),()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ye)}},[c,d,m]);const Ze=`/api/v1/printers/${t}/camera/stream?fps=10&t=${J}`;return s.jsxs("div",{ref:fe,className:`${x?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:x?void 0:{left:o.x,top:o.y,width:b?200:o.width,height:b?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Xe,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(pg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:De?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Pe,disabled:K||V,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(Mr,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"animate-spin":""}`})}),s.jsx("button",{onClick:B,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Exit fullscreen":"Fullscreen",children:x?s.jsx(gK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(she,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>y(!b),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Expand":"Minimize",children:b?s.jsx(mK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(pK,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Wt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!b&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:H,onMouseMove:Ae,onMouseUp:Le,onMouseLeave:Le,onTouchStart:L,onTouchMove:X,onTouchEnd:xe,style:{touchAction:"none"},children:[K&&!V&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(Mr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),V&&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-2",children:[s.jsx(Yg,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ne,"s..."]})]})}),j&&!V&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Rn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:Pe,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:le,src:Ze,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${N.x/S}px, ${N.y/S}px)`,cursor:S>1?k?"grabbing":"grab":"default"},onError:ae,onLoad:Te,onMouseDown:F,draggable:!1},J),s.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[s.jsx("button",{onClick:Y,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(HD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:_e,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),s.jsx("button",{onClick:te,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx($D,{className:"w-3.5 h-3.5 text-white"})})]}),!x&&s.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:Je,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function spe({printerId:t,printerName:e,onClose:n}){const r=un(),[i,a]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:p,isLoading:b,refetch:y}=ut({queryKey:["mqtt-logs",t],queryFn:()=>pe.getMQTTLogs(t),refetchInterval:1e3}),x=ht({mutationFn:()=>pe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=ht({mutationFn:()=>pe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=ht({mutationFn:()=>pe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const T=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const M=T=>{l(R=>{const U=new Set(R);return U.has(T)?U.delete(T):U.add(T),U})},N=T=>new Date(T).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(T,R)=>{if(T==null)return"<empty>";const U=typeof T=="string"?JSON.parse(T):T,O=JSON.stringify(U,null,R?2:0);return!R&&O.length>100?O.substring(0,100)+"...":O},k=p?.logging_enabled??!1,C=w.useMemo(()=>p?.logs??[],[p?.logs]),D=w.useMemo(()=>C.filter(T=>{if(d!=="all"&&T.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),U=T.topic.toLowerCase().includes(R),q=JSON.stringify(T.payload).toLowerCase().includes(R);return U||q}return!0}),[C,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(Wt,{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:[k?s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(ll,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Me,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(sl,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||C.length===0,children:[s.jsx(fn,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:s.jsx(Mr,{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:T=>a(T.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",C.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(va,{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:T=>u(T.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(Wt,{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(A0,{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(hg,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.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"}),!k&&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((T,R)=>{const U=o.has(R),O=T.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${U?"bg-bambu-dark-secondary":""}`,onClick:()=>M(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:N(T.timestamp)}),s.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?s.jsx(A0,{className:"w-3 h-3"}):s.jsx(hg,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:T.topic})]}),U?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:A(T.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(T.payload,!1)})]},R)})})}),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:k?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(Me,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const _P={"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 ope(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Rn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Rn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Qi};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Yl}}}function wP(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 lpe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=wP(e.attr,n);return _P[r]!==void 0})}function cpe(){return"https://wiki.bambulab.com/en/hms/home"}function upe({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=wP(i.attr,a);return _P[o]!==void 0});return w.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(Rn,{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(Wt,{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(Qi,{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}=ope(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=wP(i.attr,d),m=_P[f],p=cpe(),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:m}),s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(zr,{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 dpe(t){if(!t)return"ASAP";const e=gi(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 hpe({printerId:t}){const{data:e}=ut({queryKey:["queue",t,"pending"],queryFn:()=>pe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(hs,{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(ti,{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(Yn,{className:"w-3 h-3"}),dpe(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(Ks,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function PK(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=PK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function zn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=PK(t))&&(r&&(r+=" "),r+=e);return r}var fpe=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function VD(t){if(typeof t!="string")return!1;var e=fpe;return e.includes(t)}var mpe=["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"],ppe=new Set(mpe);function RK(t){return typeof t!="string"?!1:ppe.has(t)}function DK(t){return typeof t=="string"&&t.startsWith("data-")}function Qa(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(RK(n)||DK(n))&&(e[n]=t[n]);return e}function Bf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Qa(e)}return typeof t=="object"&&!Array.isArray(t)?Qa(t):null}function Sa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(RK(n)||DK(n)||VD(n))&&(e[n]=t[n]);return e}function gpe(t){return t==null?null:w.isValidElement(t)?Sa(t.props):typeof t=="object"&&!Array.isArray(t)?Sa(t):null}var xpe=["children","width","height","viewBox","className","style","title","desc"];function SP(){return SP=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},SP.apply(null,arguments)}function bpe(t,e){if(t==null)return{};var n,r,i=ype(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 ype(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 GD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=bpe(t,xpe),f=a||{width:r,height:i,x:0,y:0},m=zn("recharts-surface",o);return w.createElement("svg",SP({},Sa(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),vpe=["children","className"];function MP(){return MP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MP.apply(null,arguments)}function _pe(t,e){if(t==null)return{};var n,r,i=wpe(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 wpe(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 $r=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=_pe(t,vpe),a=zn("recharts-layer",r);return w.createElement("g",MP({className:a},Sa(i),{ref:e}),n)}),OK=w.createContext(null),Spe=()=>w.useContext(OK);function Sr(t){return function(){return t}}const LK=Math.cos,Lw=Math.sin,pl=Math.sqrt,Iw=Math.PI,fE=2*Iw,EP=Math.PI,NP=2*EP,Kh=1e-6,Mpe=NP-Kh;function IK(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Epe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return IK;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 Npe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?IK:Epe(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,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>Kh)if(!(Math.abs(f*c-u*d)>Kh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,b=i-l,y=c*c+u*u,x=p*p+b*b,v=Math.sqrt(y),S=Math.sqrt(m),M=a*Math.tan((EP-Math.acos((y+m-x)/(2*v*S)))/2),N=M/S,A=M/v;Math.abs(N-1)>Kh&&this._append`L${e+N*d},${n+N*f}`,this._append`A${a},${a},0,0,${+(f*p>d*b)},${this._x1=e+A*c},${this._y1=n+A*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,m=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Kh||Math.abs(this._y1-d)>Kh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%NP+NP),m>Mpe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>Kh&&this._append`A${r},${r},0,${+(m>=EP)},${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 WD(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 Npe(e)}function qD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function FK(t){this._context=t}FK.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 mE(t){return new FK(t)}function UK(t){return t[0]}function zK(t){return t[1]}function BK(t,e){var n=Sr(!0),r=null,i=mE,a=null,o=WD(l);t=typeof t=="function"?t:t===void 0?UK:Sr(t),e=typeof e=="function"?e:e===void 0?zK:Sr(e);function l(c){var u,d=(c=qD(c)).length,f,m=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Sr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Sr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Sr(!!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 m_(t,e,n){var r=null,i=Sr(!0),a=null,o=mE,l=null,c=WD(u);t=typeof t=="function"?t:t===void 0?UK:Sr(+t),e=typeof e=="function"?e:Sr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?zK:Sr(+n);function u(f){var m,p,b,y=(f=qD(f)).length,x,v=!1,S,M=new Array(y),N=new Array(y);for(a==null&&(l=o(S=c())),m=0;m<=y;++m){if(!(m<y&&i(x=f[m],m,f))===v)if(v=!v)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=m-1;b>=p;--b)l.point(M[b],N[b]);l.lineEnd(),l.areaEnd()}v&&(M[m]=+t(x,m,f),N[m]=+e(x,m,f),l.point(r?+r(x,m,f):M[m],n?+n(x,m,f):N[m]))}if(S)return l=null,S+""||null}function d(){return BK().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Sr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Sr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Sr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Sr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Sr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Sr(+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:Sr(!!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 $K{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 Ape(t){return new $K(t,!0)}function Tpe(t){return new $K(t,!1)}const KD={draw(t,e){const n=pl(e/Iw);t.moveTo(n,0),t.arc(0,0,n,0,fE)}},Cpe={draw(t,e){const n=pl(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()}},HK=pl(1/3),kpe=HK*2,jpe={draw(t,e){const n=pl(e/kpe),r=n*HK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ppe={draw(t,e){const n=pl(e),r=-n/2;t.rect(r,r,n,n)}},Rpe=.8908130915292852,VK=Lw(Iw/10)/Lw(7*Iw/10),Dpe=Lw(fE/10)*VK,Ope=-LK(fE/10)*VK,Lpe={draw(t,e){const n=pl(e*Rpe),r=Dpe*n,i=Ope*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=fE*a/5,l=LK(o),c=Lw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},oT=pl(3),Ipe={draw(t,e){const n=-pl(e/(oT*3));t.moveTo(0,n*2),t.lineTo(-oT*n,-n),t.lineTo(oT*n,-n),t.closePath()}},lo=-.5,co=pl(3)/2,AP=1/pl(12),Fpe=(AP/2+1)*3,Upe={draw(t,e){const n=pl(e/Fpe),r=n/2,i=n*AP,a=r,o=n*AP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(lo*r-co*i,co*r+lo*i),t.lineTo(lo*a-co*o,co*a+lo*o),t.lineTo(lo*l-co*c,co*l+lo*c),t.lineTo(lo*r+co*i,lo*i-co*r),t.lineTo(lo*a+co*o,lo*o-co*a),t.lineTo(lo*l+co*c,lo*c-co*l),t.closePath()}};function zpe(t,e){let n=null,r=WD(i);t=typeof t=="function"?t:Sr(t||KD),e=typeof e=="function"?e:Sr(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:Sr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Sr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Fw(){}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 GK(t){this._context=t}GK.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 Bpe(t){return new GK(t)}function WK(t){this._context=t}WK.prototype={areaStart:Fw,areaEnd:Fw,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 $pe(t){return new WK(t)}function qK(t){this._context=t}qK.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 Hpe(t){return new qK(t)}function KK(t){this._context=t}KK.prototype={areaStart:Fw,areaEnd:Fw,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 Vpe(t){return new KK(t)}function tB(t){return t<0?-1:1}function nB(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(tB(a)+tB(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function rB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function lT(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 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=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:lT(this,this._t0,rB(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,lT(this,rB(this,n=nB(this,t,e)),n);break;default:lT(this,this._t0,n=nB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function XK(t){this._context=new YK(t)}(XK.prototype=Object.create(zw.prototype)).point=function(t,e){zw.prototype.point.call(this,e,t)};function YK(t){this._context=t}YK.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 Gpe(t){return new zw(t)}function Wpe(t){return new XK(t)}function ZK(t){this._context=t}ZK.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=iB(t),i=iB(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 iB(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 qpe(t){return new ZK(t)}function pE(t,e){this._context=t,this._t=e}pE.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 Kpe(t){return new pE(t,.5)}function Xpe(t){return new pE(t,0)}function Ype(t){return new pE(t,1)}function $f(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 TP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Zpe(t,e){return t[e]}function Qpe(t){const e=[];return e.key=t,e}function Jpe(){var t=Sr([]),e=TP,n=$f,r=Zpe;function i(a){var o=Array.from(t.apply(this,arguments),Qpe),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=qD(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:Sr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Sr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?TP:typeof a=="function"?a:Sr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??$f,i):n},i}function ege(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}$f(t,e)}}function tge(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}$f(t,e)}}function nge(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,m=d[r-1][1]||0,p=(f-m)/2,b=0;b<l;++b){var y=t[e[b]],x=y[r][1]||0,v=y[r-1][1]||0;p+=x-v}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,$f(t,e)}}var cT={},uT={},aB;function rge(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(uT)),uT}var dT={},sB;function QK(){return sB||(sB=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})(dT)),dT}var hT={},oB;function XD(){return oB||(oB=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})(hT)),hT}var fT={},mT={},lB;function ige(){return lB||(lB=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})(mT)),mT}var cB;function YD(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ige(),n=XD();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})(fT)),fT}var uB;function ZD(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rge(),n=QK(),r=XD(),i=YD();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})(cT)),cT}var pT,dB;function age(){return dB||(dB=1,pT=ZD().get),pT}var sge=age();const Hf=fl(sge);var oge=4;function Ad(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:oge,n=10**e,r=Math.round(t*n)/n;return Object.is(r,-0)?0:r}function Zr(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.reduce((i,a,o)=>{var l=n[o-1];return typeof l=="string"?i+l+a:l!==void 0?i+Ad(l)+a:i+a},"")}var Wi=t=>t===0?0:t>0?1:-1,cl=t=>typeof t=="number"&&t!=+t,Vf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ut=t=>(typeof t=="number"||t instanceof Number)&&!cl(t),Po=t=>Ut(t)||typeof t=="string",lge=0,k0=t=>{var e=++lge;return"".concat(t||"").concat(e)},La=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(!Ut(e)&&typeof e!="string")return r;var a;if(Vf(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return cl(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},JK=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[String(t[r])])n[String(t[r])]=!0;else return!0;return!1};function Zn(t,e,n){return Ut(t)&&Ut(e)?Ad(t+n*(e-t)):e}function eX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Hf(r,e))===n)}var Fr=t=>t===null||typeof t>"u",yy=t=>Fr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function gs(t){return t!=null}function lh(){}var cge=["type","size","sizeType"];function CP(){return CP=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},CP.apply(null,arguments)}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 fB(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){uge(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 uge(t,e,n){return(e=dge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dge(t){var e=hge(t,"string");return typeof e=="symbol"?e:e+""}function hge(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 fge(t,e){if(t==null)return{};var n,r,i=mge(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 mge(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 tX={symbolCircle:KD,symbolCross:Cpe,symbolDiamond:jpe,symbolSquare:Ppe,symbolStar:Lpe,symbolTriangle:Ipe,symbolWye:Upe},pge=Math.PI/180,gge=t=>{var e="symbol".concat(yy(t));return tX[e]||KD},xge=(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*pge;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}},bge=(t,e)=>{tX["symbol".concat(yy(t))]=e},QD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=fge(t,cge),a=fB(fB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=gge(o),p=zpe().type(m).size(xge(n,r,o)),b=p();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=Sa(a);return Ut(u)&&Ut(d)&&Ut(n)?w.createElement("path",CP({},f,{className:zn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};QD.registerSymbol=bge;var nX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,JD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{VD(i)&&(r[i]=(a=>n[i](n,a)))}),r},yge=(t,e,n)=>r=>(t(e,n,r),null),vy=(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];VD(i)&&typeof a=="function"&&(r||(r={}),r[i]=yge(a,e,n))}),r};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 vge(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){_ge(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 _ge(t,e,n){return(e=wge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wge(t){var e=Sge(t,"string");return typeof e=="symbol"?e:e+""}function Sge(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 Hr(t,e){var n=vge({},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 Bw(){return Bw=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},Bw.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 Mge(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){Ege(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 Ege(t,e,n){return(e=Nge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nge(t){var e=Age(t,"string");return typeof e=="symbol"?e:e+""}function Age(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 po=32,Tge={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Cge(t){var{data:e,iconType:n,inactiveColor:r}=t,i=po/2,a=po/6,o=po/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.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:po,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
  12. H`).concat(po,"M").concat(2*o,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(po/8,"h").concat(po,"v").concat(po*3/4,"h").concat(-po,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Mge({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(QD,{fill:l,cx:i,cy:i,size:po,sizeType:"diameter",type:c})}function kge(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:po,height:po},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=zn({"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,y=m?m(d.value,d,f):d.value;return w.createElement("li",Bw({className:p,style:c,key:"legend-item-".concat(f)},vy(t,d,f)),w.createElement(GD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(Cge,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var jge=t=>{var e=Hr(t,Tge),{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 w.createElement("ul",{className:"recharts-default-legend",style:a},w.createElement(kge,Bw({},e,{payload:n})))},gT={},xT={},gB;function Pge(){return gB||(gB=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,a,n);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(xT)),xT}var bT={},xB;function Rge(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return function(...i){return n.apply(this,i.slice(0,r))}}t.ary=e})(bT)),bT}var yT={},bB;function rX(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(yT)),yT}var vT={},_T={},wT={},yB;function Dge(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(wT)),wT}var vB;function eO(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dge();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(_T)),_T}var ST={},_B;function Oge(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(ST)),ST}var wB;function Lge(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eO(),n=Oge();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(vT)),vT}var MT={},ET={},SB;function Ige(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ET)),ET}var NT={},AT={},TT={},CT={},MB;function iX(){return MB||(MB=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})(CT)),CT}var kT={},EB;function aX(){return EB||(EB=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})(kT)),kT}var jT={},NB;function sX(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.isEqualsSameValueZero=e})(jT)),jT}var AB;function Fge(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iX(),n=aX(),r=sX();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(b,y,x,v,S,M){const N=m(b,y,x,v,S,M);return N!==void 0?!!N:a(b,y,p,M)},new Map)}function a(d,f,m,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,p);case"function":return Object.keys(f).length>0?a(d,{...f},m,p):r.isEqualsSameValueZero(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.isEqualsSameValueZero(d,f)}}function o(d,f,m,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,p);if(f instanceof Map)return l(d,f,m,p);if(f instanceof Set)return u(d,f,m,p);const b=Object.keys(f);if(d==null||n.isPrimitive(d))return b.length===0;if(b.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let y=0;y<b.length;y++){const x=b[y];if(!n.isPrimitive(d)&&!(x in d)||f[x]===void 0&&d[x]!==void 0||f[x]===null&&d[x]!==null||!m(d[x],f[x],x,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,m,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[b,y]of f.entries()){const x=d.get(b);if(m(x,y,b,d,f,p)===!1)return!1}return!0}function c(d,f,m,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const b=new Set;for(let y=0;y<f.length;y++){const x=f[y];let v=!1;for(let S=0;S<d.length;S++){if(b.has(S))continue;const M=d[S];let N=!1;if(m(M,x,y,d,f,p)&&(N=!0),N){b.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,f,m,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,p):!1}t.isMatchWith=i,t.isSetMatch=u})(TT)),TT}var TB;function oX(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fge();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(AT)),AT}var PT={},RT={},DT={},CB;function Uge(){return CB||(CB=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})(DT)),DT}var OT={},kB;function tO(){return kB||(kB=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})(OT)),OT}var LT={},jB;function lX(){return jB||(jB=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]",m="[object ArrayBuffer]",p="[object Object]",b="[object Error]",y="[object DataView]",x="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",M="[object Uint32Array]",N="[object BigUint64Array]",A="[object Int8Array]",k="[object Int16Array]",C="[object Int32Array]",D="[object BigInt64Array]",T="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=N,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=T,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=C,t.int8ArrayTag=A,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=M,t.uint8ArrayTag=x,t.uint8ClampedArrayTag=v})(LT)),LT}var IT={},PB;function zge(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(IT)),IT}var RB;function cX(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uge(),n=tO(),r=lX(),i=aX(),a=zge();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,p=new Map,b=void 0){const y=b?.(d,f,m,p);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const x=new Array(d.length);p.set(d,x);for(let v=0;v<d.length;v++)x[v]=l(d[v],v,m,p,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;p.set(d,x);for(const[v,S]of d)x.set(v,l(S,v,m,p,b));return x}if(d instanceof Set){const x=new Set;p.set(d,x);for(const v of d)x.add(l(v,void 0,m,p,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);p.set(d,x);for(let v=0;v<d.length;v++)x[v]=l(d[v],v,m,p,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 p.set(d,x),c(x,d,m,p,b),x}if(typeof File<"u"&&d instanceof File){const x=new File([d],d.name,{type:d.type});return p.set(d,x),c(x,d,m,p,b),x}if(typeof Blob<"u"&&d instanceof Blob){const x=new Blob([d],{type:d.type});return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof Error){const x=new d.constructor;return p.set(d,x),x.message=d.message,x.name=d.name,x.stack=d.stack,x.cause=d.cause,c(x,d,m,p,b),x}if(d instanceof Boolean){const x=new Boolean(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof Number){const x=new Number(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(d instanceof String){const x=new String(d.valueOf());return p.set(d,x),c(x,d,m,p,b),x}if(typeof d=="object"&&u(d)){const x=Object.create(Object.getPrototypeOf(d));return p.set(d,x),c(x,d,m,p,b),x}return d}function c(d,f,m=d,p,b){const y=[...Object.keys(f),...e.getSymbols(f)];for(let x=0;x<y.length;x++){const v=y[x],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(f[v],v,m,p,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})(RT)),RT}var DB;function Bge(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(PT)),PT}var OB;function $ge(){return OB||(OB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oX(),n=Bge();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(NT)),NT}var FT={},UT={},zT={},LB;function Hge(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cX(),n=tO(),r=lX();function i(a,o){return e.cloneDeepWith(a,(l,c,u,d)=>{const f=o?.(l,c,u,d);if(f!==void 0)return f;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const m={};return d.set(a,m),e.copyProperties(m,a,u,d),m}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const m=new a.constructor(a?.valueOf());return e.copyProperties(m,a),m}case r.argumentsTag:{const m={};return e.copyProperties(m,a),m.length=a.length,m[Symbol.iterator]=a[Symbol.iterator],m}default:return}}})}t.cloneDeepWith=i})(zT)),zT}var IB;function Vge(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hge();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(UT)),UT}var BT={},$T={},FB;function uX(){return FB||(FB=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})($T)),$T}var HT={},UB;function Gge(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tO();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(HT)),HT}var zB;function Wge(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QK(),n=uX(),r=Gge(),i=YD();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})(BT)),BT}var BB;function qge(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oX(),n=XD(),r=Vge(),i=ZD(),a=Wge();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})(FT)),FT}var $B;function Kge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rX(),n=Ige(),r=$ge(),i=qge();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})(MT)),MT}var HB;function Xge(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pge(),n=Rge(),r=rX(),i=Lge(),a=Kge();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(a.iteratee(c),1)):[]}t.uniqBy=o})(gT)),gT}var VT,VB;function Yge(){return VB||(VB=1,VT=Xge().uniqBy),VT}var Zge=Yge();const GB=fl(Zge);function dX(t,e,n){return e===!0?GB(t,n):typeof e=="function"?GB(t,e):t}var GT={exports:{}},WT={};var WB;function Qge(){if(WB)return WT;WB=1;var t=Vg(),e=_q();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 WT.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var b=a(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=l(function(){function v(k){if(!S){if(S=!0,M=k,k=m(k),p!==void 0&&y.hasValue){var C=y.value;if(p(C,k))return N=C}return N=k}if(C=N,r(M,k))return C;var D=m(k);return p!==void 0&&p(C,D)?(M=k,C):(M=k,N=D)}var S=!1,M,N,A=f===void 0?null:f;return[function(){return v(d())},A===null?void 0:function(){return v(A())}]},[d,f,m,p]);var x=i(u,b[0],b[1]);return o(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},WT}var qB;function Jge(){return qB||(qB=1,GT.exports=Qge()),GT.exports}var hX=Jge(),nO=w.createContext(null),exe=t=>t,vr=()=>{var t=w.useContext(nO);return t?t.store.dispatch:exe},J1=()=>{},txe=()=>J1,nxe=(t,e)=>t===e;function Ht(t){var e=w.useContext(nO),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:J1,[e,t]);return hX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:txe,e?e.store.getState:J1,e?e.store.getState:J1,n,nxe)}function rxe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function ixe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function axe(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 KB=t=>Array.isArray(t)?t:[t];function sxe(t){const e=Array.isArray(t[0])?t[0]:t;return axe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function oxe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var lxe=class{constructor(t){this.value=t}deref(){return this.value}},cxe=typeof WeakRef<"u"?WeakRef:lxe,uxe=0,XB=1;function p_(){return{s:uxe,v:void 0,o:null,p:null}}function fX(t,e={}){let n=p_();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let b=l.o;b===null&&(l.o=b=new WeakMap);const y=b.get(p);y===void 0?(l=p_(),b.set(p,l)):l=y}else{let b=l.p;b===null&&(l.p=b=new Map);const y=b.get(p);y===void 0?(l=p_(),b.set(p,l)):l=y}}const u=l;let d;if(l.s===XB)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 cxe(d):d}return u.s=XB,u.v=d,d}return o.clearCache=()=>{n=p_(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function dxe(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()),rxe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=fX,argsMemoizeOptions:b=[]}=d,y=KB(m),x=KB(b),v=sxe(i),S=f(function(){return a++,u.apply(null,arguments)},...y),M=p(function(){o++;const A=oxe(v,arguments);return l=S.apply(null,A),l},...x);return Object.assign(M,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var tt=dxe(fX),hxe=Object.assign((t,e=tt)=>{ixe(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:()=>hxe}),qT={},KT={},XT={},YB;function fxe(){return YB||(YB=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})(XT)),XT}var YT={},ZT={},ZB;function mX(){return ZB||(ZB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(ZT)),ZT}var QB;function mxe(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX(),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})(YT)),YT}var JB;function pxe(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fxe(),n=mxe(),r=YD();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(p=>String(p));const u=(p,b)=>{let y=p;for(let x=0;x<b.length&&y!=null;++x)y=y[b[x]];return y},d=(p,b)=>b==null||p==null?b:typeof p=="object"&&"key"in p?Object.hasOwn(b,p.key)?b[p.key]:u(b,p.path):typeof p=="function"?p(b):Array.isArray(p)?u(b,p):typeof b=="object"?b[p]:b,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(b=>d(b,p))})).slice().sort((p,b)=>{for(let y=0;y<f.length;y++){const x=e.compareValues(p.criteria[y],b.criteria[y],l[y]);if(x!==0)return x}return 0}).map(p=>p.original)}t.orderBy=i})(KT)),KT}var QT={},e8;function gxe(){return e8||(e8=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})(QT)),QT}var JT={},t8;function pX(){return t8||(t8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX(),n=eO(),r=iX(),i=sX();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.isEqualsSameValueZero(c[l],o):!1}t.isIterateeCall=a})(JT)),JT}var n8;function xxe(){return n8||(n8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pxe(),n=gxe(),r=pX();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})(qT)),qT}var eC,r8;function bxe(){return r8||(r8=1,eC=xxe().sortBy),eC}var yxe=bxe();const gE=fl(yxe);var gX=t=>t.legend.settings,vxe=t=>t.legend.size,_xe=t=>t.legend.payload,wxe=tt([_xe,gX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?gE(r,n):r});function Sxe(){return Ht(wxe)}var g_=1;function xX(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.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)>g_||Math.abs(o.left-e.left)>g_||Math.abs(o.top-e.top)>g_||Math.abs(o.width-e.width)>g_)&&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 ha(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 Mxe=typeof Symbol=="function"&&Symbol.observable||"@@observable",i8=Mxe,tC=()=>Math.random().toString(36).substring(7).split("").join("."),Exe={INIT:`@@redux/INIT${tC()}`,REPLACE:`@@redux/REPLACE${tC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${tC()}`},$w=Exe;function rO(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 bX(t,e,n){if(typeof t!="function")throw new Error(ha(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ha(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ha(1));return n(bX)(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,v)=>{o.set(v,x)}))}function d(){if(c)throw new Error(ha(3));return i}function f(x){if(typeof x!="function")throw new Error(ha(4));if(c)throw new Error(ha(5));let v=!0;u();const S=l++;return o.set(S,x),function(){if(v){if(c)throw new Error(ha(6));v=!1,u(),o.delete(S),a=null}}}function m(x){if(!rO(x))throw new Error(ha(7));if(typeof x.type>"u")throw new Error(ha(8));if(typeof x.type!="string")throw new Error(ha(17));if(c)throw new Error(ha(9));try{c=!0,i=r(i,x)}finally{c=!1}return(a=o).forEach(S=>{S()}),x}function p(x){if(typeof x!="function")throw new Error(ha(10));r=x,m({type:$w.REPLACE})}function b(){const x=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ha(11));function S(){const N=v;N.next&&N.next(d())}return S(),{unsubscribe:x(S)}},[i8](){return this}}}return m({type:$w.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[i8]:b}}function Nxe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:$w.INIT})>"u")throw new Error(ha(12));if(typeof n(void 0,{type:$w.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ha(13))})}function yX(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{Nxe(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],m=n[f],p=o[f],b=m(p,l);if(typeof b>"u")throw l&&l.type,new Error(ha(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Hw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Axe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ha(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Hw(...l)(i.dispatch),{...i,dispatch:a}}}function vX(t){return rO(t)&&"type"in t&&typeof t.type=="string"}var _X=Symbol.for("immer-nothing"),a8=Symbol.for("immer-draftable"),Ja=Symbol.for("immer-state");function Ko(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var $s=Object,yg=$s.getPrototypeOf,Vw="constructor",xE="prototype",kP="configurable",Gw="enumerable",ew="writable",j0="value",du=t=>!!t&&!!t[Ja];function ul(t){return t?wX(t)||yE(t)||!!t[a8]||!!t[Vw]?.[a8]||vE(t)||_E(t):!1}var Txe=$s[xE][Vw].toString(),s8=new WeakMap;function wX(t){if(!t||!iO(t))return!1;const e=yg(t);if(e===null||e===$s[xE])return!0;const n=$s.hasOwnProperty.call(e,Vw)&&e[Vw];if(n===Object)return!0;if(!Up(n))return!1;let r=s8.get(n);return r===void 0&&(r=Function.toString.call(n),s8.set(n,r)),r===Txe}function bE(t,e,n=!0){_y(t)===0?(n?Reflect.ownKeys(t):$s.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function _y(t){const e=t[Ja];return e?e.type_:yE(t)?1:vE(t)?2:_E(t)?3:0}var o8=(t,e,n=_y(t))=>n===2?t.has(e):$s[xE].hasOwnProperty.call(t,e),jP=(t,e,n=_y(t))=>n===2?t.get(e):t[e],Ww=(t,e,n,r=_y(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Cxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var yE=Array.isArray,vE=t=>t instanceof Map,_E=t=>t instanceof Set,iO=t=>typeof t=="object",Up=t=>typeof t=="function",nC=t=>typeof t=="boolean";function kxe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Gc=t=>t.copy_||t.base_,aO=t=>t.modified_?t.copy_:t.base_;function PP(t,e){if(vE(t))return new Map(t);if(_E(t))return new Set(t);if(yE(t))return Array[xE].slice.call(t);const n=wX(t);if(e===!0||e==="class_only"&&!n){const r=$s.getOwnPropertyDescriptors(t);delete r[Ja];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[ew]===!1&&(l[ew]=!0,l[kP]=!0),(l.get||l.set)&&(r[o]={[kP]:!0,[ew]:!0,[Gw]:l[Gw],[j0]:t[o]})}return $s.create(yg(t),r)}else{const r=yg(t);if(r!==null&&n)return{...t};const i=$s.create(r);return $s.assign(i,t)}}function sO(t,e=!1){return wE(t)||du(t)||!ul(t)||(_y(t)>1&&$s.defineProperties(t,{set:x_,add:x_,clear:x_,delete:x_}),$s.freeze(t),e&&bE(t,(n,r)=>{sO(r,!0)},!1)),t}function jxe(){Ko(2)}var x_={[j0]:jxe};function wE(t){return t===null||!iO(t)?!0:$s.isFrozen(t)}var qw="MapSet",RP="Patches",l8="ArrayMethods",SX={};function Gf(t){const e=SX[t];return e||Ko(0,t),e}var c8=t=>!!SX[t],P0,MX=()=>P0,Pxe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:c8(qw)?Gf(qw):void 0,arrayMethodsPlugin_:c8(l8)?Gf(l8):void 0});function u8(t,e){e&&(t.patchPlugin_=Gf(RP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function DP(t){OP(t),t.drafts_.forEach(Rxe),t.drafts_=null}function OP(t){t===P0&&(P0=t.parent_)}var d8=t=>P0=Pxe(P0,t);function Rxe(t){const e=t[Ja];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function h8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ja].modified_&&(DP(e),Ko(4)),ul(t)&&(t=f8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ja].base_,t,e)}else t=f8(e,n);return Dxe(e,t,!0),DP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==_X?t:void 0}function f8(t,e){if(wE(e))return e;const n=e[Ja];if(!n)return Kw(e,t.handledSet_,t);if(!SE(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);AX(n,t)}return n.copy_}function Dxe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&sO(e,n)}function EX(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var SE=(t,e)=>t.scope_===e,Oxe=[];function NX(t,e,n,r){const i=Gc(t),a=t.type_;if(r!==void 0&&jP(i,r,a)===e){Ww(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;bE(i,(c,u)=>{if(du(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Oxe;for(const l of o)Ww(i,l,n,a)}function Lxe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!SE(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=aO(a);NX(t,a.draft_??a,o,n),AX(a,i)})}function AX(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}EX(t)}}function Ixe(t,e,n){const{scope_:r}=t;if(du(n)){const i=n[Ja];SE(i,r)&&i.callbacks_.push(function(){tw(t);const o=aO(i);NX(t,n,o,e)})}else ul(n)&&t.callbacks_.push(function(){const a=Gc(t);t.type_===3?a.has(n)&&Kw(n,r.handledSet_,r):jP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Kw(jP(t.copy_,e,t.type_),r.handledSet_,r)})}function Kw(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||du(t)||e.has(t)||!ul(t)||wE(t)||(e.add(t),bE(t,(r,i)=>{if(du(i)){const a=i[Ja];if(SE(a,n)){const o=aO(a);Ww(t,r,o,t.type_),EX(a)}}else ul(i)&&Kw(i,e,n)})),t}function Fxe(t,e){const n=yE(t),r={type_:n?1:0,scope_:e?e.scope_:MX(),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=Xw;n&&(i=[r],a=R0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var Xw={get(t,e){if(e===Ja)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n?.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const i=Gc(t);if(!o8(i,e,t.type_))return Uxe(t,i,e);const a=i[e];if(t.finalized_||!ul(a)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&kxe(e))return a;if(a===rC(t.base_,e)){tw(t);const o=t.type_===1?+e:e,l=IP(t.scope_,a,t,o);return t.copy_[o]=l}return a},has(t,e){return e in Gc(t)},ownKeys(t){return Reflect.ownKeys(Gc(t))},set(t,e,n){const r=TX(Gc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=rC(Gc(t),e),a=i?.[Ja];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Cxe(n,i)&&(n!==void 0||o8(t.base_,e,t.type_)))return!0;tw(t),LP(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),Ixe(t,e,n)),!0},deleteProperty(t,e){return tw(t),rC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),LP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Gc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[ew]:!0,[kP]:t.type_!==1||e!=="length",[Gw]:r[Gw],[j0]:n[e]}},defineProperty(){Ko(11)},getPrototypeOf(t){return yg(t.base_)},setPrototypeOf(){Ko(12)}},R0={};for(let t in Xw){let e=Xw[t];R0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}R0.deleteProperty=function(t,e){return R0.set.call(this,t,e,void 0)};R0.set=function(t,e,n){return Xw.set.call(this,t[0],e,n,t[0])};function rC(t,e){const n=t[Ja];return(n?Gc(n):t)[e]}function Uxe(t,e,n){const r=TX(e,n);return r?j0 in r?r[j0]:r.get?.call(t.draft_):void 0}function TX(t,e){if(!(e in t))return;let n=yg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=yg(n)}}function LP(t){t.modified_||(t.modified_=!0,t.parent_&&LP(t.parent_))}function tw(t){t.copy_||(t.assigned_=new Map,t.copy_=PP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var zxe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Up(n)&&!Up(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}Up(r)||Ko(6),i!==void 0&&!Up(i)&&Ko(7);let a;if(ul(n)){const o=d8(this),l=IP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?DP(o):OP(o)}return u8(o,i),h8(a,o)}else if(!n||!iO(n)){if(a=r(n),a===void 0&&(a=n),a===_X&&(a=void 0),this.autoFreeze_&&sO(a,!0),i){const o=[],l=[];Gf(RP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Ko(1,n)},this.produceWithPatches=(n,r)=>{if(Up(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]},nC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),nC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),nC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ul(e)||Ko(8),du(e)&&(e=nl(e));const n=d8(this),r=IP(n,e,void 0);return r[Ja].isManual_=!0,OP(n),r}finishDraft(e,n){const r=e&&e[Ja];(!r||!r.isManual_)&&Ko(9);const{scope_:i}=r;return u8(i,n),h8(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=Gf(RP).applyPatches_;return du(e)?i(e,n):this.produce(e,a=>i(a,n))}};function IP(t,e,n,r){const[i,a]=vE(e)?Gf(qw).proxyMap_(e,n):_E(e)?Gf(qw).proxySet_(e,n):Fxe(e,n);return(n?.scope_??MX()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Lxe(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 nl(t){return du(t)||Ko(10,t),CX(t)}function CX(t){if(!ul(t)||wE(t))return t;const e=t[Ja];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=PP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=PP(t,!0);return bE(n,(i,a)=>{Ww(n,i,CX(a))},r),e&&(e.finalized_=!1),n}var Bxe=new zxe,kX=Bxe.produce;function jX(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var $xe=jX(),Hxe=jX,Vxe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Hw:Hw.apply(null,arguments)};function Ro(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Vs(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=>vX(r)&&r.type===t,n}var PX=class Ib extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Ib.prototype)}static get[Symbol.species](){return Ib}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Ib(...e[0].concat(this)):new Ib(...e.concat(this))}};function m8(t){return ul(t)?kX(t,()=>{}):t}function b_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Gxe(t){return typeof t=="boolean"}var Wxe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new PX;return n&&(Gxe(n)?o.push($xe):o.push(Hxe(n.extraArgument))),o},RX="RTK_autoBatch",Rr=()=>t=>({payload:t,meta:{[RX]:!0}}),p8=t=>e=>{setTimeout(e,t)},DX=(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:p8(10):t.type==="callback"?t.queueNotification:p8(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[RX],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},qxe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new PX(t);return r&&i.push(DX(typeof r=="object"?r:void 0)),i};function Kxe(t){const e=Wxe(),{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(rO(n))l=yX(n);else throw new Error(Vs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Hw;i&&(u=Vxe({trace:!1,...typeof i=="object"&&i}));const d=Axe(...c),f=qxe(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return bX(l,a,p)}function OX(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Vs(28));if(l in e)throw new Error(Vs(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 Xxe(t){return typeof t=="function"}function Yxe(t,e){let[n,r,i]=OX(e),a;if(Xxe(t))a=()=>m8(t());else{const l=m8(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(du(d)){const p=f(d,c);return p===void 0?d:p}else{if(ul(d))return kX(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=a,o}var Zxe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Qxe=(t=21)=>{let e="",n=t;for(;n--;)e+=Zxe[Math.random()*64|0];return e},Jxe=Symbol.for("rtk-slice-createasyncthunk");function ebe(t,e){return`${t}/${e}`}function tbe({creators:t}={}){const e=t?.asyncThunk?.[Jxe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Vs(11));const o=(typeof r.reducers=="function"?r.reducers(rbe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(M,N){const A=typeof M=="string"?M:M.type;if(!A)throw new Error(Vs(12));if(A in c.sliceCaseReducersByType)throw new Error(Vs(13));return c.sliceCaseReducersByType[A]=N,u},addMatcher(M,N){return c.sliceMatchers.push({matcher:M,reducer:N}),u},exposeAction(M,N){return c.actionCreators[M]=N,u},exposeCaseReducer(M,N){return c.sliceCaseReducersByName[M]=N,u}};l.forEach(M=>{const N=o[M],A={reducerName:M,type:ebe(i,M),createNotation:typeof r.reducers=="function"};abe(N)?obe(A,N,u,e):ibe(A,N,u)});function d(){const[M={},N=[],A=void 0]=typeof r.extraReducers=="function"?OX(r.extraReducers):[r.extraReducers],k={...M,...c.sliceCaseReducersByType};return Yxe(r.initialState,C=>{for(let D in k)C.addCase(D,k[D]);for(let D of c.sliceMatchers)C.addMatcher(D.matcher,D.reducer);for(let D of N)C.addMatcher(D.matcher,D.reducer);A&&C.addDefaultCase(A)})}const f=M=>M,m=new Map,p=new WeakMap;let b;function y(M,N){return b||(b=d()),b(M,N)}function x(){return b||(b=d()),b.getInitialState()}function v(M,N=!1){function A(C){let D=C[M];return typeof D>"u"&&N&&(D=b_(p,A,x)),D}function k(C=f){const D=b_(m,N,()=>new WeakMap);return b_(D,C,()=>{const T={};for(const[R,U]of Object.entries(r.selectors??{}))T[R]=nbe(U,C,()=>b_(p,C,x),N);return T})}return{reducerPath:M,getSelectors:k,get selectors(){return k(A)},selectSlice:A}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...v(a),injectInto(M,{reducerPath:N,...A}={}){const k=N??a;return M.inject({reducerPath:k,reducer:y},A),{...S,...v(k,!0)}}};return S}}function nbe(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 Ss=tbe();function rbe(){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 ibe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!sbe(r))throw new Error(Vs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Ro(t,o):Ro(t))}function abe(t){return t._reducerDefinitionType==="asyncThunk"}function sbe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function obe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Vs(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||y_,pending:l||y_,rejected:c||y_,settled:u||y_})}function y_(){}var lbe="task",LX="listener",IX="completed",oO="cancelled",cbe=`task-${oO}`,ube=`task-${IX}`,FP=`${LX}-${oO}`,dbe=`${LX}-${IX}`,ME=class{constructor(t){this.code=t,this.message=`${lbe} ${oO} (reason: ${t})`}name="TaskAbortError";message},lO=(t,e)=>{if(typeof t!="function")throw new TypeError(Vs(32))},Yw=()=>{},FX=(t,e=Yw)=>(t.catch(e),t),UX=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),_f=t=>{if(t.aborted)throw new ME(t.reason)};function zX(t,e){let n=Yw;return new Promise((r,i)=>{const a=()=>i(new ME(t.reason));if(t.aborted){a();return}n=UX(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Yw})}var hbe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof ME?"cancelled":"rejected",error:n}}finally{e?.()}},Zw=t=>e=>FX(zX(t,e).then(n=>(_f(t),n))),BX=t=>{const e=Zw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:eg}=Object,g8={},EE="listenerMiddleware",fbe=(t,e)=>{const n=r=>UX(t,()=>r.abort(t.reason));return(r,i)=>{lO(r);const a=new AbortController;n(a);const o=hbe(async()=>{_f(t),_f(a.signal);const l=await r({pause:Zw(a.signal),delay:BX(a.signal),signal:a.signal});return _f(a.signal),l},()=>a.abort(ube));return i?.autoJoin&&e.push(o.catch(Yw)),{result:Zw(t)(o),cancel(){a.abort(cbe)}}}},mbe=(t,e)=>{const n=async(r,i)=>{_f(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await zX(e,Promise.race(l));return _f(e),c}finally{a()}};return(r,i)=>FX(n(r,i))},$X=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Ro(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Vs(21));return lO(a),{predicate:i,type:e,effect:a}},HX=eg(t=>{const{type:e,predicate:n,effect:r}=$X(t);return{id:Qxe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Vs(22))}}},{withTypes:()=>HX}),x8=(t,e)=>{const{type:n,effect:r,predicate:i}=$X(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},UP=t=>{t.pending.forEach(e=>{e.abort(FP)})},pbe=(t,e)=>()=>{for(const n of e.keys())UP(n);t.clear()},b8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},VX=eg(Ro(`${EE}/add`),{withTypes:()=>VX}),gbe=Ro(`${EE}/removeAll`),GX=eg(Ro(`${EE}/remove`),{withTypes:()=>GX}),xbe=(...t)=>{console.error(`${EE}/error`,...t)},wy=(t={})=>{const e=new Map,n=new Map,r=p=>{const b=n.get(p)??0;n.set(p,b+1)},i=p=>{const b=n.get(p)??1;b===1?n.delete(p):n.set(p,b-1)},{extra:a,onError:o=xbe}=t;lO(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&UP(p)}),c=p=>{const b=x8(e,p)??HX(p);return l(b)};eg(c,{withTypes:()=>c});const u=p=>{const b=x8(e,p);return b&&(b.unsubscribe(),p.cancelActive&&UP(b)),!!b};eg(u,{withTypes:()=>u});const d=async(p,b,y,x)=>{const v=new AbortController,S=mbe(c,v.signal),M=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(b,eg({},y,{getOriginalState:x,condition:(N,A)=>S(N,A).then(Boolean),take:S,delay:BX(v.signal),pause:Zw(v.signal),extra:a,signal:v.signal,fork:fbe(v.signal,M),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((N,A,k)=>{N!==v&&(N.abort(FP),k.delete(N))})},cancel:()=>{v.abort(FP),p.pending.delete(v)},throwIfCancelled:()=>{_f(v.signal)}})))}catch(N){N instanceof ME||b8(o,N,{raisedBy:"effect"})}finally{await Promise.all(M),v.abort(dbe),i(p),p.pending.delete(v)}},f=pbe(e,n);return{middleware:p=>b=>y=>{if(!vX(y))return b(y);if(VX.match(y))return c(y.payload);if(gbe.match(y)){f();return}if(GX.match(y))return u(y.payload);let x=p.getState();const v=()=>{if(x===g8)throw new Error(Vs(23));return x};let S;try{if(S=b(y),e.size>0){const M=p.getState(),N=Array.from(e.values());for(const A of N){let k=!1;try{k=A.predicate(y,M,x)}catch(C){k=!1,b8(o,C,{raisedBy:"predicate"})}k&&d(A,y,p,v)}}}finally{x=g8}return S},startListening:c,stopListening:u,clearListeners:f}};function Vs(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 bbe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},WX=Ss({name:"chartLayout",initialState:bbe,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:ybe,setLayout:vbe,setChartSize:_be,setScale:wbe}=WX.actions,Sbe=WX.reducer;function qX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function gn(t){return Number.isFinite(t)}function Ql(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}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 Gp(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){Mbe(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 Mbe(t,e,n){return(e=Ebe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ebe(t){var e=Nbe(t,"string");return typeof e=="symbol"?e:e+""}function Nbe(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 Fr(t)||Fr(e)?n:Po(e)?Hf(t,e,n):typeof e=="function"?e(t):n}var Abe=(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"&&Ut(t[a]))return Gp(Gp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Ut(t[o]))return Gp(Gp({},t),{},{[o]:t[o]+(i||0)})}return t},gl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",KX=(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},XX=(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:m,axisType:p}=t;if(!o)return null;var b=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/b:0;if(y=p==="angleAxis"&&a&&a.length>=2?Wi(a[0]-a[1])*2*y:y,f||m){var x=(f||m||[]).map((v,S)=>{var M=r?r.indexOf(v):v,N=o.map(M);return gn(N)?{coordinate:N+y,value:v,offset:y,index:S}:null}).filter(gs);return x}return c&&u?u.map((v,S)=>{var M=o.map(v);return gn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(gs):o.ticks&&d!=null?o.ticks(d).map((v,S)=>{var M=o.map(v);return gn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(gs):o.domain().map((v,S)=>{var M=o.map(v);return gn(M)?{coordinate:M+y,value:r?r[v]:v,index:S,offset:y}:null}).filter(gs)},Tbe=(t,e)=>{if(!e||e.length!==2||!Ut(e[0])||!Ut(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(!Ut(t[0])||t[0]<n)&&(i[0]=n),(!Ut(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Cbe=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0,l=0;l<n;++l){var c=t[l],u=c?.[i];if(u!=null){var d=u[1],f=u[0],m=cl(d)?f:d;m>=0?(u[0]=a,a+=m,u[1]=a):(u[0]=o,o+=m,u[1]=o)}}}},kbe=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0;o<n;++o){var l=t[o],c=l?.[i];if(c!=null){var u=cl(c[1])?c[0]:c[1];u>=0?(c[0]=a,a+=u,c[1]=a):(c[0]=0,c[1]=0)}}}},jbe={sign:Cbe,expand:ege,none:$f,silhouette:tge,wiggle:nge,positive:kbe},Pbe=(t,e,n)=>{var r,i=(r=jbe[n])!==null&&r!==void 0?r:$f,a=Jpe().keys(e).value((l,c)=>Number(Jn(l,c,0))).order(TP).offset(i),o=a(t);return o.forEach((l,c)=>{l.forEach((u,d)=>{var f=Jn(t[d],e[c],0);Array.isArray(f)&&f.length===2&&Ut(f[0])&&Ut(f[1])&&(u[0]=f[0],u[1]=f[1])})}),o};function YX(t){return t==null?void 0:String(t)}function Qw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Fr(i[e.dataKey])){var l=eX(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=Jn(i,Fr(o)?e.dataKey:o),u=e.scale.map(c);return Ut(u)?u:null}var v8=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]);if(Fr(l))return null;var c=e.scale.map(l);return Ut(c)?c-i/2+r:null},Rbe=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]},Dbe=t=>{var e=t.flat(2).filter(Ut);return[Math.min(...e),Math.max(...e)]},Obe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Lbe=(t,e,n)=>{if(t!=null)return Obe(Object.keys(t).reduce((r,i)=>{var a=t[i];if(!a)return r;var{stackedData:o}=a,l=o.reduce((c,u)=>{var d=qX(u,e,n),f=Dbe(d);return!gn(f[0])||!gn(f[1])?c:[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]))},_8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,w8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Xd=(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=gE(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 S8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Gp(Gp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function ch(t,e){if(t)return String(t);if(typeof e=="string")return e}var Ibe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Fbe=(t,e)=>e==="centric"?t.angle:t.radius,wu=t=>t.layout.width,Su=t=>t.layout.height,Ube=t=>t.layout.scale,ZX=t=>t.layout.margin,NE=tt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),AE=tt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),QX="data-recharts-item-index",JX="data-recharts-item-id",Sy=60;function M8(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 v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(r){zbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zbe(t,e,n){return(e=Bbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bbe(t){var e=$be(t,"string");return typeof e=="symbol"?e:e+""}function $be(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 Hbe=t=>t.brush.height;function Vbe(t){var e=AE(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Sy;return n+i}return n},0)}function Gbe(t){var e=AE(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Sy;return n+i}return n},0)}function Wbe(t){var e=NE(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function qbe(t){var e=NE(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Pi=tt([wu,Su,ZX,Hbe,Vbe,Gbe,Wbe,qbe,gX,vxe],(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},m=v_(v_({},f),d),p=m.bottom;m.bottom+=r,m=Abe(m,c,u);var b=t-m.left-m.right,y=e-m.top-m.bottom;return v_(v_({brushBottom:p},m),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Kbe=tt(Pi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),cO=tt(wu,Su,(t,e)=>({x:0,y:0,width:t,height:e})),Xbe=w.createContext(null),Ri=()=>w.useContext(Xbe)!=null,TE=t=>t.brush,CE=tt([TE,Pi,ZX],(t,e,n)=>({height:t.height,x:Ut(t.x)?t.x:e.left,y:Ut(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ut(t.width)?t.width:e.width})),iC={},aC={},sC={},E8;function Ybe(){return E8||(E8=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(),y()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},b=()=>{m!==null&&(clearTimeout(m),m=null)},y=()=>{b(),o=void 0,l=null},x=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const M=m==null;p(),c&&M&&d()};return v.schedule=p,v.cancel=y,v.flush=x,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(sC)),sC}var N8;function Zbe(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ybe();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 m=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),p=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,y),d)},b=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=b,p}t.debounce=n})(aC)),aC}var A8;function Qbe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zbe();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})(iC)),iC}var oC,T8;function Jbe(){return T8||(T8=1,oC=Qbe().throttle),oC}var e0e=Jbe();const t0e=fl(e0e);var Jw=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++]))}},Ul={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},eY=(t,e,n)=>{var{width:r=Ul.width,height:i=Ul.height,aspect:a,maxHeight:o}=n,l=Vf(r)?t:Number(r),c=Vf(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}},n0e={width:0,height:0,overflow:"visible"},r0e={width:0,overflowX:"visible"},i0e={height:0,overflowY:"visible"},a0e={},s0e=t=>{var{width:e,height:n}=t,r=Vf(e),i=Vf(n);return r&&i?n0e:r?r0e:i?i0e:a0e};function o0e(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i=Ul.width,a=Ul.height):i===void 0?i=r&&r>0?void 0:Ul.width:a===void 0&&(a=r&&r>0?void 0:Ul.height),{width:i,height:a}}function zP(){return zP=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},zP.apply(null,arguments)}function C8(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 k8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C8(Object(n),!0).forEach(function(r){l0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function l0e(t,e,n){return(e=c0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c0e(t){var e=u0e(t,"string");return typeof e=="symbol"?e:e+""}function u0e(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 tY=w.createContext(Ul.initialDimension);function d0e(t){return Ql(t.width)&&Ql(t.height)}function nY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return d0e(i)?w.createElement(tY.Provider,{value:i},e):null}var uO=()=>w.useContext(tY),h0e=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=Ul.initialDimension,width:i,height:a,minWidth:o=Ul.minWidth,minHeight:l,maxHeight:c,children:u,debounce:d=Ul.debounce,id:f,className:m,onResize:p,style:b={}}=t,y=w.useRef(null),x=w.useRef();x.current=p,w.useImperativeHandle(e,()=>y.current);var[v,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),M=w.useCallback((D,T)=>{S(R=>{var U=Math.round(D),O=Math.round(T);return R.containerWidth===U&&R.containerHeight===O?R:{containerWidth:U,containerHeight:O}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return lh;var D=O=>{var q,j=O[0];if(j!=null){var{width:W,height:K}=j.contentRect;M(W,K),(q=x.current)===null||q===void 0||q.call(x,W,K)}};d>0&&(D=t0e(D,d,{trailing:!0,leading:!1}));var T=new ResizeObserver(D),{width:R,height:U}=y.current.getBoundingClientRect();return M(R,U),T.observe(y.current),()=>{T.disconnect()}},[M,d]);var{containerWidth:N,containerHeight:A}=v;Jw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:C}=eY(N,A,{width:i,height:a,aspect:n,maxHeight:c});return Jw(k!=null&&k>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,k,C,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:zn("recharts-responsive-container",m),style:k8(k8({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:s0e({width:i,height:a})},w.createElement(nY,{width:k,height:C},u)))}),nw=w.forwardRef((t,e)=>{var n=uO();if(Ql(n.width)&&Ql(n.height))return t.children;var{width:r,height:i}=o0e({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=eY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ut(a)&&Ut(o)?w.createElement(nY,{width:a,height:o},t.children):w.createElement(h0e,zP({},t,{width:r,height:i,ref:e}))});function dO(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 My=()=>{var t,e=Ri(),n=Ht(Kbe),r=Ht(CE),i=(t=Ht(TE))===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}},f0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},rY=()=>{var t;return(t=Ht(Pi))!==null&&t!==void 0?t:f0e},hO=()=>Ht(wu),fO=()=>Ht(Su),m0e=()=>Ht(t=>t.layout.margin),Fn=t=>t.layout.layoutType,uh=()=>Ht(Fn),mO=()=>{var t=uh();if(t==="horizontal"||t==="vertical")return t},iY=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},p0e=()=>{var t=uh();return t!==void 0},Ey=t=>{var e=vr(),n=Ri(),{width:r,height:i}=t,a=uO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Ql(o)&&Ql(l)&&e(_be({width:o,height:l}))},[e,n,o,l]),null},aY=Symbol.for("immer-nothing"),j8=Symbol.for("immer-draftable"),Xs=Symbol.for("immer-state");function Xo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var D0=Object.getPrototypeOf;function vg(t){return!!t&&!!t[Xs]}function Wf(t){return t?sY(t)||Array.isArray(t)||!!t[j8]||!!t.constructor?.[j8]||Ny(t)||jE(t):!1}var g0e=Object.prototype.constructor.toString(),P8=new WeakMap;function sY(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=P8.get(n);return r===void 0&&(r=Function.toString.call(n),P8.set(n,r)),r===g0e}function eS(t,e,n=!0){kE(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 kE(t){const e=t[Xs];return e?e.type_:Array.isArray(t)?1:Ny(t)?2:jE(t)?3:0}function BP(t,e){return kE(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function oY(t,e,n){const r=kE(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function x0e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ny(t){return t instanceof Map}function jE(t){return t instanceof Set}function Xh(t){return t.copy_||t.base_}function $P(t,e){if(Ny(t))return new Map(t);if(jE(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=sY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Xs];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(D0(t),r)}else{const r=D0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function pO(t,e=!1){return PE(t)||vg(t)||!Wf(t)||(kE(t)>1&&Object.defineProperties(t,{set:__,add:__,clear:__,delete:__}),Object.freeze(t),e&&Object.values(t).forEach(n=>pO(n,!0))),t}function b0e(){Xo(2)}var __={value:b0e};function PE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var y0e={};function qf(t){const e=y0e[t];return e||Xo(0,t),e}var O0;function lY(){return O0}function v0e(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function R8(t,e){e&&(qf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function HP(t){VP(t),t.drafts_.forEach(_0e),t.drafts_=null}function VP(t){t===O0&&(O0=t.parent_)}function D8(t){return O0=v0e(O0,t)}function _0e(t){const e=t[Xs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function O8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Xs].modified_&&(HP(e),Xo(4)),Wf(t)&&(t=tS(e,t),e.parent_||nS(e,t)),e.patches_&&qf("Patches").generateReplacementPatches_(n[Xs].base_,t,e.patches_,e.inversePatches_)):t=tS(e,n,[]),HP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==aY?t:void 0}function tS(t,e,n){if(PE(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Xs];if(!i)return eS(e,(a,o)=>L8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return nS(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),eS(o,(c,u)=>L8(t,i,a,c,u,n,l),r),nS(t,a,!1),n&&t.patches_&&qf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function L8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=PE(i);if(!(l&&!o)){if(vg(i)){const c=a&&e&&e.type_!==3&&!BP(e.assigned_,r)?a.concat(r):void 0,u=tS(t,i,c);if(oY(n,r,u),vg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Wf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;tS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ny(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&nS(t,i)}}}function nS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&pO(e,n)}function w0e(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:lY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=gO;n&&(i=[r],a=L0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var gO={get(t,e){if(e===Xs)return t;const n=Xh(t);if(!BP(n,e))return S0e(t,n,e);const r=n[e];return t.finalized_||!Wf(r)?r:r===lC(t.base_,e)?(cC(t),t.copy_[e]=WP(r,t)):r},has(t,e){return e in Xh(t)},ownKeys(t){return Reflect.ownKeys(Xh(t))},set(t,e,n){const r=cY(Xh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=lC(Xh(t),e),a=i?.[Xs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(x0e(n,i)&&(n!==void 0||BP(t.base_,e)))return!0;cC(t),GP(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 lC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,cC(t),GP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Xh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Xo(11)},getPrototypeOf(t){return D0(t.base_)},setPrototypeOf(){Xo(12)}},L0={};eS(gO,(t,e)=>{L0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});L0.deleteProperty=function(t,e){return L0.set.call(this,t,e,void 0)};L0.set=function(t,e,n){return gO.set.call(this,t[0],e,n,t[0])};function lC(t,e){const n=t[Xs];return(n?Xh(n):t)[e]}function S0e(t,e,n){const r=cY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function cY(t,e){if(!(e in t))return;let n=D0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=D0(n)}}function GP(t){t.modified_||(t.modified_=!0,t.parent_&&GP(t.parent_))}function cC(t){t.copy_||(t.copy_=$P(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var M0e=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"&&Xo(6),r!==void 0&&typeof r!="function"&&Xo(7);let i;if(Wf(e)){const a=D8(this),o=WP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?HP(a):VP(a)}return R8(a,r),O8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===aY&&(i=void 0),this.autoFreeze_&&pO(i,!0),r){const a=[],o=[];qf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Xo(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){Wf(t)||Xo(8),vg(t)&&(t=E0e(t));const e=D8(this),n=WP(t,void 0);return n[Xs].isManual_=!0,VP(e),n}finishDraft(t,e){const n=t&&t[Xs];(!n||!n.isManual_)&&Xo(9);const{scope_:r}=n;return R8(r,e),O8(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=qf("Patches").applyPatches_;return vg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function WP(t,e){const n=Ny(t)?qf("MapSet").proxyMap_(t,e):jE(t)?qf("MapSet").proxySet_(t,e):w0e(t,e);return(e?e.scope_:lY()).drafts_.push(n),n}function E0e(t){return vg(t)||Xo(10,t),uY(t)}function uY(t){if(!Wf(t)||PE(t))return t;const e=t[Xs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=$P(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=$P(t,!0);return eS(n,(i,a)=>{oY(n,i,uY(a))},r),e&&(e.finalized_=!1),n}var N0e=new M0e;N0e.produce;var A0e={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},dY=Ss({name:"legend",initialState:A0e,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:Rr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=nl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Rr()},removeLegendPayload:{reducer(t,e){var n=nl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Rr()}}}),{setLegendSize:I8,setLegendSettings:T0e,addLegendPayload:hY,replaceLegendPayload:fY,removeLegendPayload:mY}=dY.actions,C0e=dY.reducer,k0e=["contextPayload"];function qP(){return qP=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},qP.apply(null,arguments)}function F8(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 _g(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F8(Object(n),!0).forEach(function(r){j0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j0e(t,e,n){return(e=P0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P0e(t){var e=R0e(t,"string");return typeof e=="symbol"?e:e+""}function R0e(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 D0e(t,e){if(t==null)return{};var n,r,i=O0e(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 O0e(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 L0e(t){return t.value}function I0e(t){var{contextPayload:e}=t,n=D0e(t,k0e),r=dX(e,t.payloadUniqBy,L0e),i=_g(_g({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(jge,i)}function F0e(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}),_g(_g({},u),d)}function U0e(t){var e=vr();return w.useEffect(()=>{e(T0e(t))},[e,t]),null}function z0e(t){var e=vr();return w.useEffect(()=>(e(I8(t)),()=>{e(I8({width:0,height:0}))}),[e,t]),null}function B0e(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var $0e={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function xO(t){var e=Hr(t,$0e),n=Sxe(),r=Spe(),i=m0e(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=xX([n]),f=hO(),m=fO();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),b=B0e(e.layout,o,a,p),y=c?l:_g(_g({position:"absolute",width:b?.width||a||"auto",height:b?.height||o||"auto"},F0e(l,e,i,f,m,u)),l),x=c??r;if(x==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},w.createElement(U0e,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(z0e,{width:u.width,height:u.height}),w.createElement(I0e,qP({},e,b,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Xc.createPortal(v,x)}xO.displayName="Legend";function KP(){return KP=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},KP.apply(null,arguments)}function U8(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 ob(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U8(Object(n),!0).forEach(function(r){H0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H0e(t,e,n){return(e=V0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V0e(t){var e=G0e(t,"string");return typeof e=="symbol"?e:e+""}function G0e(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 W0e(t){return Array.isArray(t)&&Po(t[0])&&Po(t[1])?t.join(" ~ "):t}var Xm={separator:" : ",contentStyle:{margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},itemStyle:{display:"block",paddingTop:4,paddingBottom:4,color:"#000"},labelStyle:{},accessibilityLayer:!1},q0e=t=>{var{separator:e=Xm.separator,contentStyle:n,itemStyle:r,labelStyle:i=Xm.labelStyle,payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=Xm.accessibilityLayer}=t,p=()=>{if(a&&a.length){var A={padding:0,margin:0},k=(l?gE(a,l):a).map((C,D)=>{if(C.type==="none")return null;var T=C.formatter||o||W0e,{value:R,name:U}=C,O=R,q=U;if(T){var j=T(R,U,C,D,a);if(Array.isArray(j))[O,q]=j;else if(j!=null)O=j;else return null}var W=ob(ob({},Xm.itemStyle),{},{color:C.color||Xm.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:W},Po(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Po(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},O),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:A},k)}return null},b=ob(ob({},Xm.contentStyle),n),y=ob({margin:0},i),x=!Fr(d),v=x?d:"",S=zn("recharts-default-tooltip",c),M=zn("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(v=f(d,a));var N=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",KP({className:S,style:b},N),w.createElement("p",{className:M,style:y},w.isValidElement(v)?v:"".concat(v)),p())},lb="recharts-tooltip-wrapper",K0e={visibility:"hidden"};function X0e(t){var{coordinate:e,translateX:n,translateY:r}=t;return zn(lb,{["".concat(lb,"-right")]:Ut(n)&&e&&Ut(e.x)&&n>=e.x,["".concat(lb,"-left")]:Ut(n)&&e&&Ut(e.x)&&n<e.x,["".concat(lb,"-bottom")]:Ut(r)&&e&&Ut(e.y)&&r>=e.y,["".concat(lb,"-top")]:Ut(r)&&e&&Ut(e.y)&&r<e.y})}function z8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Ut(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 m=c[r];if(m==null)return 0;if(o[r]){var p=d,b=m;return p<b?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var y=f+l,x=m+u;return y>x?Math.max(d,m):Math.max(f,m)}function Y0e(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 Z0e(t){var{allowEscapeViewBox:e,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:l,useTranslate3d:c,viewBox:u}=t,d,f,m;return l.height>0&&l.width>0&&n?(f=z8({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),m=z8({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=Y0e({translateX:f,translateY:m,useTranslate3d:c})):d=K0e,{cssProperties:d,cssClasses:X0e({translateX:f,translateY:m,coordinate:n})}}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 w_(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){XP(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 XP(t,e,n){return(e=Q0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q0e(t){var e=J0e(t,"string");return typeof e=="symbol"?e:e+""}function J0e(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 eye extends w.PureComponent{constructor(){super(...arguments),XP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),XP(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:m,viewBox:p,wrapperStyle:b,lastBoundingBox:y,innerRef:x,hasPortalFromProps:v}=this.props,S=typeof u=="number"?u:u.x,M=typeof u=="number"?u:u.y,{cssClasses:N,cssProperties:A}=Z0e({allowEscapeViewBox:n,coordinate:o,offsetLeft:S,offsetTop:M,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:m,viewBox:p}),k=v?{}:w_(w_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},A),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),C=w_(w_({},k),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:N,style:C,ref:x},a)}}var pY=()=>{var t;return(t=Ht(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function YP(){return YP=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},YP.apply(null,arguments)}function $8(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 H8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$8(Object(n),!0).forEach(function(r){tye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tye(t,e,n){return(e=nye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nye(t){var e=rye(t,"string");return typeof e=="symbol"?e:e+""}function rye(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 V8={curveBasisClosed:$pe,curveBasisOpen:Hpe,curveBasis:Bpe,curveBumpX:Ape,curveBumpY:Tpe,curveLinearClosed:Vpe,curveLinear:mE,curveMonotoneX:Gpe,curveMonotoneY:Wpe,curveNatural:qpe,curveStep:Kpe,curveStepAfter:Ype,curveStepBefore:Xpe},rS=t=>gn(t.x)&&gn(t.y),G8=t=>t.base!=null&&rS(t.base)&&rS(t),cb=t=>t.x,ub=t=>t.y,iye=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(yy(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=V8["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return V8[n]||mE},W8={connectNulls:!1,type:"linear"},aye=t=>{var{type:e=W8.type,points:n=[],baseLine:r,layout:i,connectNulls:a=W8.connectNulls}=t,o=iye(e,i),l=a?n.filter(rS):n;if(Array.isArray(r)){var c,u=n.map((b,y)=>H8(H8({},b),{},{base:r[y]}));i==="vertical"?c=m_().y(ub).x1(cb).x0(b=>b.base.x):c=m_().x(cb).y1(ub).y0(b=>b.base.y);var d=c.defined(G8).curve(o),f=a?u.filter(G8):u;return d(f)}var m;i==="vertical"&&Ut(r)?m=m_().y(ub).x1(cb).x0(r):Ut(r)?m=m_().x(cb).y1(ub).y0(r):m=BK().x(cb).y(ub);var p=m.defined(rS).curve(o);return p(l)},tg=t=>{var{className:e,points:n,path:r,pathRef:i}=t,a=uh();if((!n||!n.length)&&!r)return null;var o={type:t.type,points:t.points,baseLine:t.baseLine,layout:t.layout||a,connectNulls:t.connectNulls},l=n&&n.length?aye(o):r;return w.createElement("path",YP({},Qa(t),JD(t),{className:zn("recharts-curve",e),d:l===null?void 0:l,ref:i}))},sye=["x","y","top","left","width","height","className"];function ZP(){return ZP=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},ZP.apply(null,arguments)}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 oye(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){lye(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 lye(t,e,n){return(e=cye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cye(t){var e=uye(t,"string");return typeof e=="symbol"?e:e+""}function uye(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 dye(t,e){if(t==null)return{};var n,r,i=hye(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 hye(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 fye=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),mye=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=dye(t,sye),u=oye({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Ut(e)||!Ut(n)||!Ut(a)||!Ut(o)||!Ut(r)||!Ut(i)?null:w.createElement("path",ZP({},Sa(u),{className:zn("recharts-cross",l),d:fye(e,n,a,o,r,i)}))};function pye(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 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){gye(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 gye(t,e,n){return(e=xye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xye(t){var e=bye(t,"string");return typeof e=="symbol"?e:e+""}function bye(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 yye=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),gY=(t,e,n)=>t.map(r=>"".concat(yye(r)," ").concat(e,"ms ").concat(n)).join(","),vye=(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)=>X8(X8({},n),{},{[r]:t(r,e[r])}),{});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 Ni(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){_ye(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 _ye(t,e,n){return(e=wye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wye(t){var e=Sye(t,"string");return typeof e=="symbol"?e:e+""}function Sye(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 iS=(t,e,n)=>t+(e-t)*n,QP=t=>{var{from:e,to:n}=t;return e!==n},xY=(t,e,n)=>{var r=I0((i,a)=>{if(QP(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ni(Ni({},a),{},{from:o,velocity:l})}return a},e);return n<1?I0((i,a)=>QP(a)&&r[i]!=null?Ni(Ni({},a),{},{velocity:iS(a.velocity,r[i].velocity,n),from:iS(a.from,r[i].from,n)}):a,e):xY(t,r,n-1)};function Mye(t,e,n,r,i,a){var o,l=r.reduce((m,p)=>Ni(Ni({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>I0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(QP).length,d=null,f=m=>{o||(o=m);var p=m-o,b=p/n.dt;l=xY(n,l,b),i(Ni(Ni(Ni({},t),e),c())),o=m,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function Eye(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,m)=>{var p=t[m],b=e[m];return p==null||b==null?f:Ni(Ni({},f),{},{[m]:[p,b]})},{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=I0((y,x)=>iS(...x,n(m)),c);if(a(Ni(Ni(Ni({},t),e),p)),m<1)l=o.setTimeout(d);else{var b=I0((y,x)=>iS(...x,n(1)),c);a(Ni(Ni(Ni({},t),e),b))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const Nye=(t,e,n,r,i,a)=>{var o=vye(t,e);return n==null?()=>(i(Ni(Ni({},t),e)),()=>{}):n.isStepper===!0?Mye(t,e,n,o,i,a):Eye(t,e,n,r,o,i,a)};var aS=1e-4,bY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],yY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),Z8=(t,e)=>n=>{var r=bY(t,e);return yY(r,n)},Aye=(t,e)=>n=>{var r=bY(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return yY(i,n)},Tye=t=>{var e,n=t.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(e=n[1])===null||e===void 0||(e=e.split(")")[0])===null||e===void 0?void 0:e.split(",");if(r==null||r.length!==4)return null;var i=r.map(a=>parseFloat(a));return[i[0],i[1],i[2],i[3]]},Cye=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=Tye(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},kye=(t,e,n,r)=>{var i=Z8(t,n),a=Z8(e,r),o=Aye(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var p=i(f)-d,b=o(f);if(Math.abs(p-d)<aS||b<aS)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},Q8=function(){return kye(...Cye(...arguments))},jye=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,m=c*i/1e3+o;return Math.abs(m-l)<aS&&Math.abs(f)<aS?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},Pye=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Q8(t);case"spring":return jye();default:if(t.split("(")[0]==="cubic-bezier")return Q8(t)}return typeof t=="function"?t:null};function Rye(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 Dye{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 Oye(){return Rye(new Dye)}var Lye=w.createContext(Oye);function Iye(t,e){var n=w.useContext(Lye);return w.useMemo(()=>e??n(t),[t,e,n])}var Fye=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ay={isSsr:Fye()},Uye={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},J8={t:0},uC={t:1};function Zg(t){var e=Hr(t,Uye),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Ay.isSsr:n,f=Iye(e.animationId,e.animationManager),[m,p]=w.useState(d?J8:uC),b=w.useRef(null);return w.useEffect(()=>{d||p(uC)},[d]),w.useEffect(()=>{if(!d||!r)return lh;var y=Nye(J8,uC,Pye(a),i,p,f.getTimeoutController()),x=()=>{b.current=y()};return f.start([c,o,x,i,l]),()=>{f.stop(),b.current&&b.current(),l()}},[d,r,i,a,o,c,l,f]),u(m.t)}function Qg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(k0(e)),r=w.useRef(t);return r.current!==t&&(n.current=k0(e),r.current=t),n.current}var zye=["radius"],Bye=["radius"],e6,t6,n6,r6,i6,a6,s6,o6,l6,c6;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 d6(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){$ye(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 $ye(t,e,n){return(e=Hye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hye(t){var e=Vye(t,"string");return typeof e=="symbol"?e:e+""}function Vye(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 sS(){return sS=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},sS.apply(null,arguments)}function h6(t,e){if(t==null)return{};var n,r,i=Gye(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 Gye(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 Ml(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var f6=(t,e,n,r,i)=>{var a=Ad(n),o=Ad(r),l=Math.min(Math.abs(a)/2,Math.abs(o)/2),c=o>=0?1:-1,u=a>=0?1:-1,d=o>=0&&a>=0||o<0&&a<0?1:0,f;if(l>0&&Array.isArray(i)){for(var m=[0,0,0,0],p=0,b=4;p<b;p++){var y,x=(y=i[p])!==null&&y!==void 0?y:0;m[p]=x>l?l:x}f=Zr(e6||(e6=Ml(["M",",",""])),t,e+c*m[0]),m[0]>0&&(f+=Zr(t6||(t6=Ml(["A ",",",",0,0,",",",",",""])),m[0],m[0],d,t+u*m[0],e)),f+=Zr(n6||(n6=Ml(["L ",",",""])),t+n-u*m[1],e),m[1]>0&&(f+=Zr(r6||(r6=Ml(["A ",",",",0,0,",`,
  17. `,",",""])),m[1],m[1],d,t+n,e+c*m[1])),f+=Zr(i6||(i6=Ml(["L ",",",""])),t+n,e+r-c*m[2]),m[2]>0&&(f+=Zr(a6||(a6=Ml(["A ",",",",0,0,",`,
  18. `,",",""])),m[2],m[2],d,t+n-u*m[2],e+r)),f+=Zr(s6||(s6=Ml(["L ",",",""])),t+u*m[3],e+r),m[3]>0&&(f+=Zr(o6||(o6=Ml(["A ",",",",0,0,",`,
  19. `,",",""])),m[3],m[3],d,t,e+r-c*m[3])),f+="Z"}else if(l>0&&i===+i&&i>0){var v=Math.min(l,i);f=Zr(l6||(l6=Ml(["M ",",",`
  20. A `,",",",0,0,",",",",",`
  21. L `,",",`
  22. A `,",",",0,0,",",",",",`
  23. L `,",",`
  24. A `,",",",0,0,",",",",",`
  25. L `,",",`
  26. A `,",",",0,0,",",",","," Z"])),t,e+c*v,v,v,d,t+u*v,e,t+n-u*v,e,v,v,d,t+n,e+c*v,t+n,e+r-c*v,v,v,d,t+n-u*v,e+r,t+u*v,e+r,v,v,d,t,e+r-c*v)}else f=Zr(c6||(c6=Ml(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return f},m6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},vY=t=>{var e=Hr(t,m6),n=w.useRef(null),[r,i]=w.useState(-1);w.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:m,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:y}=e,x=w.useRef(l),v=w.useRef(c),S=w.useRef(a),M=w.useRef(o),N=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),A=Qg(N,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=zn("recharts-rectangle",d);if(!y){var C=Sa(e),{radius:D}=C,T=h6(C,zye);return w.createElement("path",sS({},T,{x:Ad(a),y:Ad(o),width:Ad(l),height:Ad(c),radius:typeof u=="number"?u:void 0,className:k,d:f6(a,o,l,c,u)}))}var R=x.current,U=v.current,O=S.current,q=M.current,j="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=gY(["strokeDasharray"],m,typeof f=="string"?f:m6.animationEasing);return w.createElement(Zg,{animationId:A,key:A,canBegin:r>0,duration:m,easing:f,isActive:y,begin:p},G=>{var J=Zn(R,l,G),ie=Zn(U,c,G),re=Zn(O,a,G),z=Zn(q,o,G);n.current&&(x.current=J,v.current=ie,S.current=re,M.current=z);var V;b?G>0?V={transition:K,strokeDasharray:W}:V={strokeDasharray:j}:V={strokeDasharray:W};var Z=Sa(e),{radius:ne}=Z,he=h6(Z,Bye);return w.createElement("path",sS({},he,{radius:typeof u=="number"?u:void 0,className:k,d:f6(re,z,J,ie,u),ref:n,style:d6(d6({},V),e.style)}))})};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 g6(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){Wye(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 Wye(t,e,n){return(e=qye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qye(t){var e=Kye(t,"string");return typeof e=="symbol"?e:e+""}function Kye(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 oS=Math.PI/180,Xye=t=>t*180/Math.PI,bi=(t,e,n,r)=>({x:t+Math.cos(-oS*r)*n,y:e+Math.sin(-oS*r)*n}),_Y=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},Yye=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Zye=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=Yye({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:Xye(c),angleInRadian:c}},Qye=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}},Jye=(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},eve=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Zye({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Qye(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?g6(g6({},e),{},{radius:i,angle:Jye(d,e)}):null};function wY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=bi(e,n,r,i),l=bi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}var x6,b6,y6,v6,_6,w6,S6;function JP(){return JP=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},JP.apply(null,arguments)}function cf(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var tve=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},S_=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)/oS,f=c?i:i+a*d,m=bi(e,n,u,f),p=bi(e,n,r,f),b=c?i-a*d:i,y=bi(e,n,u*Math.cos(d*oS),b);return{center:m,circleTangency:p,lineTangency:y,theta:d}},SY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=tve(a,o),c=a+l,u=bi(e,n,i,a),d=bi(e,n,i,c),f=Zr(x6||(x6=cf(["M ",",",`
  27. A `,",",`,0,
  28. `,",",`,
  29. `,",",`
  30. `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(a>c),d.x,d.y);if(r>0){var m=bi(e,n,r,a),p=bi(e,n,r,c);f+=Zr(b6||(b6=cf(["L ",",",`
  31. A `,",",`,0,
  32. `,",",`,
  33. `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(a<=c),m.x,m.y)}else f+=Zr(y6||(y6=cf(["L ",","," Z"])),e,n);return f},nve=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Wi(u-c),{circleTangency:f,lineTangency:m,theta:p}=S_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:y,theta:x}=S_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-x;if(v<0)return o?Zr(v6||(v6=cf(["M ",",",`
  34. a`,",",",0,0,1,",`,0
  35. a`,",",",0,0,1,",`,0
  36. `])),m.x,m.y,a,a,a*2,a,a,-a*2):SY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S=Zr(_6||(_6=cf(["M ",",",`
  37. A`,",",",0,0,",",",",",`
  38. A`,",",",0,",",",",",",",`
  39. A`,",",",0,0,",",",",",`
  40. `])),m.x,m.y,a,a,+(d<0),f.x,f.y,i,i,+(v>180),+(d<0),b.x,b.y,a,a,+(d<0),y.x,y.y);if(r>0){var{circleTangency:M,lineTangency:N,theta:A}=S_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:C,theta:D}=S_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),T=l?Math.abs(c-u):Math.abs(c-u)-A-D;if(T<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+=Zr(w6||(w6=cf(["L",",",`
  41. A`,",",",0,0,",",",",",`
  42. A`,",",",0,",",",",",",",`
  43. A`,",",",0,0,",",",",","Z"])),C.x,C.y,a,a,+(d<0),k.x,k.y,r,r,+(T>180),+(d>0),M.x,M.y,a,a,+(d<0),N.x,N.y)}else S+=Zr(S6||(S6=cf(["L",",","Z"])),e,n);return S},rve={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},MY=t=>{var e=Hr(t,rve),{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 m=zn("recharts-sector",f),p=a-i,b=La(o,p,0,!0),y;return b>0&&Math.abs(u-d)<360?y=nve({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=SY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",JP({},Sa(e),{className:m,d:y}))};function ive(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(nX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=bi(r,i,a,l),u=bi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return wY(e)}}var dC={},hC={},fC={},M6;function ave(){return M6||(M6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(fC)),fC}var E6;function sve(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ave();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})(hC)),hC}var N6;function ove(){return N6||(N6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pX(),n=sve();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})(dC)),dC}var mC,A6;function lve(){return A6||(A6=1,mC=ove().range),mC}var cve=lve();const EY=fl(cve);function Fd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function uve(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function bO(t){let e,n,r;t.length!==2?(e=Fd,n=(l,c)=>Fd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Fd||t===uve?t:dve,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 dve(){return 0}function NY(t){return t===null?NaN:+t}function*hve(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const fve=bO(Fd),Ty=fve.right;bO(NY).center;class T6 extends Map{constructor(e,n=gve){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(C6(this,e))}has(e){return super.has(C6(this,e))}set(e,n){return super.set(mve(this,e),n)}delete(e){return super.delete(pve(this,e))}}function C6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function mve({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function pve({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function gve(t){return t!==null&&typeof t=="object"?t.valueOf():t}function xve(t=Fd){if(t===Fd)return AY;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 AY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const bve=Math.sqrt(50),yve=Math.sqrt(10),vve=Math.sqrt(2);function lS(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>=bve?10:a>=yve?5:a>=vve?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?lS(t,e,n*2):[l,c,u]}function e3(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?lS(e,t,n):lS(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 t3(t,e,n){return e=+e,t=+t,n=+n,lS(t,e,n)[2]}function n3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?t3(e,t,n):t3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function k6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function j6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function TY(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?AY:xve(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),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+m)),b=Math.min(r,Math.floor(e+(c-u)*f/c+m));TY(t,e,p,b,i)}const a=t[e];let o=n,l=r;for(db(t,n,e),i(t[r],a)>0&&db(t,n,r);o<l;){for(db(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?db(t,n,l):(++l,db(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function db(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function _ve(t,e,n){if(t=Float64Array.from(hve(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return j6(t);if(e>=1)return k6(t);var r,i=(r-1)*e,a=Math.floor(i),o=k6(TY(t,a).subarray(0,a+1)),l=j6(t.subarray(a+1));return o+(l-o)*(i-a)}}function wve(t,e,n=NY){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 Sve(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 Lo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Mu(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 r3=Symbol("implicit");function yO(){var t=new T6,e=[],n=[],r=r3;function i(a){let o=t.get(a);if(o===void 0){if(r!==r3)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 T6;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 yO(e,n).unknown(r)},Lo.apply(i,arguments),i}function vO(){var t=yO().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 m=e().length,p=i<r,b=p?i:r,y=p?r:i;a=(y-b)/Math.max(1,m-c+u*2),l&&(a=Math.floor(a)),b+=(y-b-a*(m-c))*d,o=a*(1-c),l&&(b=Math.round(b),o=Math.round(o));var x=Sve(m).map(function(v){return b+a*v});return n(p?x.reverse():x)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return vO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Lo.apply(f(),arguments)}function CY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return CY(e())},t}function Mve(){return CY(vO.apply(null,arguments).paddingInner(1))}function _O(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function kY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Cy(){}var F0=.7,cS=1/F0,ng="\\s*([+-]?\\d+)\\s*",U0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Eve=/^#([0-9a-f]{3,8})$/,Nve=new RegExp(`^rgb\\(${ng},${ng},${ng}\\)$`),Ave=new RegExp(`^rgb\\(${Gl},${Gl},${Gl}\\)$`),Tve=new RegExp(`^rgba\\(${ng},${ng},${ng},${U0}\\)$`),Cve=new RegExp(`^rgba\\(${Gl},${Gl},${Gl},${U0}\\)$`),kve=new RegExp(`^hsl\\(${U0},${Gl},${Gl}\\)$`),jve=new RegExp(`^hsla\\(${U0},${Gl},${Gl},${U0}\\)$`),P6={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};_O(Cy,z0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:R6,formatHex:R6,formatHex8:Pve,formatHsl:Rve,formatRgb:D6,toString:D6});function R6(){return this.rgb().formatHex()}function Pve(){return this.rgb().formatHex8()}function Rve(){return jY(this).formatHsl()}function D6(){return this.rgb().formatRgb()}function z0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Eve.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?O6(e):n===3?new xs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?M_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?M_(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=Nve.exec(t))?new xs(e[1],e[2],e[3],1):(e=Ave.exec(t))?new xs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Tve.exec(t))?M_(e[1],e[2],e[3],e[4]):(e=Cve.exec(t))?M_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=kve.exec(t))?F6(e[1],e[2]/100,e[3]/100,1):(e=jve.exec(t))?F6(e[1],e[2]/100,e[3]/100,e[4]):P6.hasOwnProperty(t)?O6(P6[t]):t==="transparent"?new xs(NaN,NaN,NaN,0):null}function O6(t){return new xs(t>>16&255,t>>8&255,t&255,1)}function M_(t,e,n,r){return r<=0&&(t=e=n=NaN),new xs(t,e,n,r)}function Dve(t){return t instanceof Cy||(t=z0(t)),t?(t=t.rgb(),new xs(t.r,t.g,t.b,t.opacity)):new xs}function i3(t,e,n,r){return arguments.length===1?Dve(t):new xs(t,e,n,r??1)}function xs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}_O(xs,i3,kY(Cy,{brighter(t){return t=t==null?cS:Math.pow(cS,t),new xs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?F0:Math.pow(F0,t),new xs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new xs(wf(this.r),wf(this.g),wf(this.b),uS(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:L6,formatHex:L6,formatHex8:Ove,formatRgb:I6,toString:I6}));function L6(){return`#${uf(this.r)}${uf(this.g)}${uf(this.b)}`}function Ove(){return`#${uf(this.r)}${uf(this.g)}${uf(this.b)}${uf((isNaN(this.opacity)?1:this.opacity)*255)}`}function I6(){const t=uS(this.opacity);return`${t===1?"rgb(":"rgba("}${wf(this.r)}, ${wf(this.g)}, ${wf(this.b)}${t===1?")":`, ${t})`}`}function uS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function wf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function uf(t){return t=wf(t),(t<16?"0":"")+t.toString(16)}function F6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Yo(t,e,n,r)}function jY(t){if(t instanceof Yo)return new Yo(t.h,t.s,t.l,t.opacity);if(t instanceof Cy||(t=z0(t)),!t)return new Yo;if(t instanceof Yo)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 Yo(o,l,c,t.opacity)}function Lve(t,e,n,r){return arguments.length===1?jY(t):new Yo(t,e,n,r??1)}function Yo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}_O(Yo,Lve,kY(Cy,{brighter(t){return t=t==null?cS:Math.pow(cS,t),new Yo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?F0:Math.pow(F0,t),new Yo(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 xs(pC(t>=240?t-240:t+120,i,r),pC(t,i,r),pC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Yo(U6(this.h),E_(this.s),E_(this.l),uS(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=uS(this.opacity);return`${t===1?"hsl(":"hsla("}${U6(this.h)}, ${E_(this.s)*100}%, ${E_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function U6(t){return t=(t||0)%360,t<0?t+360:t}function E_(t){return Math.max(0,Math.min(1,t||0))}function pC(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 wO=t=>()=>t;function Ive(t,e){return function(n){return t+n*e}}function Fve(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 Uve(t){return(t=+t)==1?PY:function(e,n){return n-e?Fve(e,n,t):wO(isNaN(e)?n:e)}}function PY(t,e){var n=e-t;return n?Ive(t,n):wO(isNaN(t)?e:t)}const z6=(function t(e){var n=Uve(e);function r(i,a){var o=n((i=i3(i)).r,(a=i3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=PY(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 zve(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 Bve(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function $ve(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]=Jg(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 Hve(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function dS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Vve(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]=Jg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var a3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gC=new RegExp(a3.source,"g");function Gve(t){return function(){return t}}function Wve(t){return function(e){return t(e)+""}}function qve(t,e){var n=a3.lastIndex=gC.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=a3.exec(t))&&(i=gC.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:dS(r,i)})),n=gC.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Wve(c[0].x):Gve(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 Jg(t,e){var n=typeof e,r;return e==null||n==="boolean"?wO(e):(n==="number"?dS:n==="string"?(r=z0(e))?(e=r,z6):qve:e instanceof z0?z6:e instanceof Date?Hve:Bve(e)?zve:Array.isArray(e)?$ve:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Vve:dS)(t,e)}function SO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Kve(t,e){e===void 0&&(e=t,t=Jg);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 Xve(t){return function(){return t}}function hS(t){return+t}var B6=[0,1];function qa(t){return t}function s3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Xve(isNaN(e)?NaN:.5)}function Yve(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Zve(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=s3(i,r),a=n(o,a)):(r=s3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Qve(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]=s3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Ty(t,l,1,r)-1;return a[c](i[c](l))}}function ky(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function RE(){var t=B6,e=B6,n=Jg,r,i,a,o=qa,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==qa&&(o=Yve(t[0],t[m-1])),l=m>2?Qve:Zve,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?a:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),dS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,hS),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=SO,d()},f.clamp=function(m){return arguments.length?(o=m?!0:qa,d()):o!==qa},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,p){return r=m,i=p,d()}}function MO(){return RE()(qa,qa)}function Jve(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function fS(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function wg(t){return t=fS(Math.abs(t)),t?t[1]:NaN}function e_e(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 t_e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var n_e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function B0(t){if(!(e=n_e.exec(t)))throw new Error("invalid format: "+t);var e;return new EO({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]})}B0.prototype=EO.prototype;function EO(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+""}EO.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 r_e(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 mS;function i_e(t,e){var n=fS(t,e);if(!n)return mS=void 0,t.toPrecision(e);var r=n[0],i=n[1],a=i-(mS=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")+fS(t,Math.max(0,e+a-1))[0]}function $6(t,e){var n=fS(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 H6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Jve,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)=>$6(t*100,e),r:$6,s:i_e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function V6(t){return t}var G6=Array.prototype.map,W6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function a_e(t){var e=t.grouping===void 0||t.thousands===void 0?V6:e_e(G6.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?V6:t_e(G6.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,m){f=B0(f);var p=f.fill,b=f.align,y=f.sign,x=f.symbol,v=f.zero,S=f.width,M=f.comma,N=f.precision,A=f.trim,k=f.type;k==="n"?(M=!0,k="g"):H6[k]||(N===void 0&&(N=12),A=!0,k="g"),(v||p==="0"&&b==="=")&&(v=!0,p="0",b="=");var C=(m&&m.prefix!==void 0?m.prefix:"")+(x==="$"?n:x==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():""),D=(x==="$"?r:/[%p]/.test(k)?o:"")+(m&&m.suffix!==void 0?m.suffix:""),T=H6[k],R=/[defgprs%]/.test(k);N=N===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function U(O){var q=C,j=D,W,K,G;if(k==="c")j=T(O)+j,O="";else{O=+O;var J=O<0||1/O<0;if(O=isNaN(O)?c:T(Math.abs(O),N),A&&(O=r_e(O)),J&&+O==0&&y!=="+"&&(J=!1),q=(J?y==="("?y:l:y==="-"||y==="("?"":y)+q,j=(k==="s"&&!isNaN(O)&&mS!==void 0?W6[8+mS/3]:"")+j+(J&&y==="("?")":""),R){for(W=-1,K=O.length;++W<K;)if(G=O.charCodeAt(W),48>G||G>57){j=(G===46?i+O.slice(W+1):O.slice(W))+j,O=O.slice(0,W);break}}}M&&!v&&(O=e(O,1/0));var ie=q.length+O.length+j.length,re=ie<S?new Array(S-ie+1).join(p):"";switch(M&&v&&(O=e(re+O,re.length?S-j.length:1/0),re=""),b){case"<":O=q+O+j+re;break;case"=":O=q+re+O+j;break;case"^":O=re.slice(0,ie=re.length>>1)+q+O+j+re.slice(ie);break;default:O=re+q+O+j;break}return a(O)}return U.toString=function(){return f+""},U}function d(f,m){var p=Math.max(-8,Math.min(8,Math.floor(wg(m)/3)))*3,b=Math.pow(10,-p),y=u((f=B0(f),f.type="f",f),{suffix:W6[8+p/3]});return function(x){return y(b*x)}}return{format:u,formatPrefix:d}}var N_,NO,RY;s_e({thousands:",",grouping:[3],currency:["$",""]});function s_e(t){return N_=a_e(t),NO=N_.format,RY=N_.formatPrefix,N_}function o_e(t){return Math.max(0,-wg(Math.abs(t)))}function l_e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(wg(e)/3)))*3-wg(Math.abs(t)))}function c_e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,wg(e)-wg(t))+1}function DY(t,e,n,r){var i=n3(t,e,n),a;switch(r=B0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=l_e(i,o))&&(r.precision=a),RY(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=c_e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=o_e(i))&&(r.precision=a-(r.type==="%")*2);break}}return NO(r)}function dh(t){var e=t.domain;return t.ticks=function(n){var r=e();return e3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return DY(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=t3(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 OY(){var t=MO();return t.copy=function(){return ky(t,OY())},Lo.apply(t,arguments),dh(t)}function LY(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,hS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return LY(t).unknown(e)},t=arguments.length?Array.from(t,hS):[0,1],dh(n)}function IY(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 q6(t){return Math.log(t)}function K6(t){return Math.exp(t)}function u_e(t){return-Math.log(-t)}function d_e(t){return-Math.exp(-t)}function h_e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function f_e(t){return t===10?h_e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function m_e(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 X6(t){return(e,n)=>-t(-e,n)}function AO(t){const e=t(q6,K6),n=e.domain;let r=10,i,a;function o(){return i=m_e(r),a=f_e(r),n()[0]<0?(i=X6(i),a=X6(a),t(u_e,d_e)):t(q6,K6),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 m=i(u),p=i(d),b,y;const x=l==null?10:+l;let v=[];if(!(r%1)&&p-m<x){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(b=1;b<r;++b)if(y=m<0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}}else for(;m<=p;++m)for(b=r-1;b>=1;--b)if(y=m>0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}v.length*2<x&&(v=e3(u,d,x))}else v=e3(m,p,Math.min(p-m,x)).map(a);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=B0(c)).precision==null&&(c.trim=!0),c=NO(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(IY(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function FY(){const t=AO(RE()).domain([1,10]);return t.copy=()=>ky(t,FY()).base(t.base()),Lo.apply(t,arguments),t}function Y6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Z6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function TO(t){var e=1,n=t(Y6(e),Z6(e));return n.constant=function(r){return arguments.length?t(Y6(e=+r),Z6(e)):e},dh(n)}function UY(){var t=TO(RE());return t.copy=function(){return ky(t,UY()).constant(t.constant())},Lo.apply(t,arguments)}function Q6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function p_e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function g_e(t){return t<0?-t*t:t*t}function CO(t){var e=t(qa,qa),n=1;function r(){return n===1?t(qa,qa):n===.5?t(p_e,g_e):t(Q6(n),Q6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},dh(e)}function kO(){var t=CO(RE());return t.copy=function(){return ky(t,kO()).exponent(t.exponent())},Lo.apply(t,arguments),t}function x_e(){return kO.apply(null,arguments).exponent(.5)}function J6(t){return Math.sign(t)*t*t}function b_e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function zY(){var t=MO(),e=[0,1],n=!1,r;function i(a){var o=b_e(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(J6(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,hS)).map(J6)),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 zY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Lo.apply(i,arguments),dh(i)}function BY(){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]=wve(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Ty(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(Fd),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 BY().domain(t).range(e).unknown(r)},Lo.apply(a,arguments)}function $Y(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Ty(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 $Y().domain([t,e]).range(i).unknown(a)},Lo.apply(dh(o),arguments)}function HY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Ty(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 HY().domain(t).range(e).unknown(n)},Lo.apply(i,arguments)}const xC=new Date,bC=new Date;function Di(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=>Di(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)=>(xC.setTime(+a),bC.setTime(+o),t(xC),t(bC),Math.floor(n(xC,bC))),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 pS=Di(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);pS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Di(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):pS);pS.range;const Yc=1e3,No=Yc*60,Zc=No*60,hu=Zc*24,jO=hu*7,e$=hu*30,yC=hu*365,df=Di(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Yc)},(t,e)=>(e-t)/Yc,t=>t.getUTCSeconds());df.range;const PO=Di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Yc)},(t,e)=>{t.setTime(+t+e*No)},(t,e)=>(e-t)/No,t=>t.getMinutes());PO.range;const RO=Di(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*No)},(t,e)=>(e-t)/No,t=>t.getUTCMinutes());RO.range;const DO=Di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Yc-t.getMinutes()*No)},(t,e)=>{t.setTime(+t+e*Zc)},(t,e)=>(e-t)/Zc,t=>t.getHours());DO.range;const OO=Di(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Zc)},(t,e)=>(e-t)/Zc,t=>t.getUTCHours());OO.range;const jy=Di(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*No)/hu,t=>t.getDate()-1);jy.range;const DE=Di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hu,t=>t.getUTCDate()-1);DE.range;const VY=Di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hu,t=>Math.floor(t/hu));VY.range;function lm(t){return Di(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())*No)/jO)}const OE=lm(0),gS=lm(1),y_e=lm(2),v_e=lm(3),Sg=lm(4),__e=lm(5),w_e=lm(6);OE.range;gS.range;y_e.range;v_e.range;Sg.range;__e.range;w_e.range;function cm(t){return Di(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)/jO)}const LE=cm(0),xS=cm(1),S_e=cm(2),M_e=cm(3),Mg=cm(4),E_e=cm(5),N_e=cm(6);LE.range;xS.range;S_e.range;M_e.range;Mg.range;E_e.range;N_e.range;const LO=Di(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());LO.range;const IO=Di(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());IO.range;const fu=Di(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());fu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Di(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)});fu.range;const mu=Di(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());mu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Di(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)});mu.range;function GY(t,e,n,r,i,a){const o=[[df,1,Yc],[df,5,5*Yc],[df,15,15*Yc],[df,30,30*Yc],[a,1,No],[a,5,5*No],[a,15,15*No],[a,30,30*No],[i,1,Zc],[i,3,3*Zc],[i,6,6*Zc],[i,12,12*Zc],[r,1,hu],[r,2,2*hu],[n,1,jO],[e,1,e$],[e,3,3*e$],[t,1,yC]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),b=p?p.range(u,+d+1):[];return m?b.reverse():b}function c(u,d,f){const m=Math.abs(d-u)/f,p=bO(([,,x])=>x).right(o,m);if(p===o.length)return t.every(n3(u/yC,d/yC,f));if(p===0)return pS.every(Math.max(n3(u,d,f),1));const[b,y]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return b.every(y)}return[l,c]}const[A_e,T_e]=GY(mu,IO,LE,VY,OO,RO),[C_e,k_e]=GY(fu,LO,OE,jy,DO,PO);function vC(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 _C(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 hb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function j_e(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=fb(i),d=mb(i),f=fb(a),m=mb(a),p=fb(o),b=mb(o),y=fb(l),x=mb(l),v=fb(c),S=mb(c),M={a:G,A:J,b:ie,B:re,c:null,d:s$,e:s$,f:e1e,g:u1e,G:h1e,H:Z_e,I:Q_e,j:J_e,L:WY,m:t1e,M:n1e,p:z,q:V,Q:c$,s:u$,S:r1e,u:i1e,U:a1e,V:s1e,w:o1e,W:l1e,x:null,X:null,y:c1e,Y:d1e,Z:f1e,"%":l$},N={a:Z,A:ne,b:he,B:fe,c:null,d:o$,e:o$,f:x1e,g:A1e,G:C1e,H:m1e,I:p1e,j:g1e,L:KY,m:b1e,M:y1e,p:le,q:Ee,Q:c$,s:u$,S:v1e,u:_1e,U:w1e,V:S1e,w:M1e,W:E1e,x:null,X:null,y:N1e,Y:T1e,Z:k1e,"%":l$},A={a:R,A:U,b:O,B:q,c:j,d:i$,e:i$,f:q_e,g:r$,G:n$,H:a$,I:a$,j:H_e,L:W_e,m:$_e,M:V_e,p:T,q:B_e,Q:X_e,s:Y_e,S:G_e,u:L_e,U:I_e,V:F_e,w:O_e,W:U_e,x:W,X:K,y:r$,Y:n$,Z:z_e,"%":K_e};M.x=k(n,M),M.X=k(r,M),M.c=k(e,M),N.x=k(n,N),N.X=k(r,N),N.c=k(e,N);function k(me,we){return function(De){var ee=[],Qe=-1,B=0,te=me.length,Y,H,F;for(De instanceof Date||(De=new Date(+De));++Qe<te;)me.charCodeAt(Qe)===37&&(ee.push(me.slice(B,Qe)),(H=t$[Y=me.charAt(++Qe)])!=null?Y=me.charAt(++Qe):H=Y==="e"?" ":"0",(F=we[Y])&&(Y=F(De,H)),ee.push(Y),B=Qe+1);return ee.push(me.slice(B,Qe)),ee.join("")}}function C(me,we){return function(De){var ee=hb(1900,void 0,1),Qe=D(ee,me,De+="",0),B,te;if(Qe!=De.length)return null;if("Q"in ee)return new Date(ee.Q);if("s"in ee)return new Date(ee.s*1e3+("L"in ee?ee.L:0));if(we&&!("Z"in ee)&&(ee.Z=0),"p"in ee&&(ee.H=ee.H%12+ee.p*12),ee.m===void 0&&(ee.m="q"in ee?ee.q:0),"V"in ee){if(ee.V<1||ee.V>53)return null;"w"in ee||(ee.w=1),"Z"in ee?(B=_C(hb(ee.y,0,1)),te=B.getUTCDay(),B=te>4||te===0?xS.ceil(B):xS(B),B=DE.offset(B,(ee.V-1)*7),ee.y=B.getUTCFullYear(),ee.m=B.getUTCMonth(),ee.d=B.getUTCDate()+(ee.w+6)%7):(B=vC(hb(ee.y,0,1)),te=B.getDay(),B=te>4||te===0?gS.ceil(B):gS(B),B=jy.offset(B,(ee.V-1)*7),ee.y=B.getFullYear(),ee.m=B.getMonth(),ee.d=B.getDate()+(ee.w+6)%7)}else("W"in ee||"U"in ee)&&("w"in ee||(ee.w="u"in ee?ee.u%7:"W"in ee?1:0),te="Z"in ee?_C(hb(ee.y,0,1)).getUTCDay():vC(hb(ee.y,0,1)).getDay(),ee.m=0,ee.d="W"in ee?(ee.w+6)%7+ee.W*7-(te+5)%7:ee.w+ee.U*7-(te+6)%7);return"Z"in ee?(ee.H+=ee.Z/100|0,ee.M+=ee.Z%100,_C(ee)):vC(ee)}}function D(me,we,De,ee){for(var Qe=0,B=we.length,te=De.length,Y,H;Qe<B;){if(ee>=te)return-1;if(Y=we.charCodeAt(Qe++),Y===37){if(Y=we.charAt(Qe++),H=A[Y in t$?we.charAt(Qe++):Y],!H||(ee=H(me,De,ee))<0)return-1}else if(Y!=De.charCodeAt(ee++))return-1}return ee}function T(me,we,De){var ee=u.exec(we.slice(De));return ee?(me.p=d.get(ee[0].toLowerCase()),De+ee[0].length):-1}function R(me,we,De){var ee=p.exec(we.slice(De));return ee?(me.w=b.get(ee[0].toLowerCase()),De+ee[0].length):-1}function U(me,we,De){var ee=f.exec(we.slice(De));return ee?(me.w=m.get(ee[0].toLowerCase()),De+ee[0].length):-1}function O(me,we,De){var ee=v.exec(we.slice(De));return ee?(me.m=S.get(ee[0].toLowerCase()),De+ee[0].length):-1}function q(me,we,De){var ee=y.exec(we.slice(De));return ee?(me.m=x.get(ee[0].toLowerCase()),De+ee[0].length):-1}function j(me,we,De){return D(me,e,we,De)}function W(me,we,De){return D(me,n,we,De)}function K(me,we,De){return D(me,r,we,De)}function G(me){return o[me.getDay()]}function J(me){return a[me.getDay()]}function ie(me){return c[me.getMonth()]}function re(me){return l[me.getMonth()]}function z(me){return i[+(me.getHours()>=12)]}function V(me){return 1+~~(me.getMonth()/3)}function Z(me){return o[me.getUTCDay()]}function ne(me){return a[me.getUTCDay()]}function he(me){return c[me.getUTCMonth()]}function fe(me){return l[me.getUTCMonth()]}function le(me){return i[+(me.getUTCHours()>=12)]}function Ee(me){return 1+~~(me.getUTCMonth()/3)}return{format:function(me){var we=k(me+="",M);return we.toString=function(){return me},we},parse:function(me){var we=C(me+="",!1);return we.toString=function(){return me},we},utcFormat:function(me){var we=k(me+="",N);return we.toString=function(){return me},we},utcParse:function(me){var we=C(me+="",!0);return we.toString=function(){return me},we}}}var t$={"-":"",_:" ",0:"0"},Ji=/^\s*\d+/,P_e=/^%/,R_e=/[\\^$*+?|[\]().{}]/g;function Wn(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 D_e(t){return t.replace(R_e,"\\$&")}function fb(t){return new RegExp("^(?:"+t.map(D_e).join("|")+")","i")}function mb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function O_e(t,e,n){var r=Ji.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function L_e(t,e,n){var r=Ji.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function I_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function F_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function U_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function n$(t,e,n){var r=Ji.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function r$(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function z_e(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 B_e(t,e,n){var r=Ji.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function $_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function i$(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function H_e(t,e,n){var r=Ji.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function a$(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function V_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function G_e(t,e,n){var r=Ji.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function W_e(t,e,n){var r=Ji.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function q_e(t,e,n){var r=Ji.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function K_e(t,e,n){var r=P_e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function X_e(t,e,n){var r=Ji.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Y_e(t,e,n){var r=Ji.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function s$(t,e){return Wn(t.getDate(),e,2)}function Z_e(t,e){return Wn(t.getHours(),e,2)}function Q_e(t,e){return Wn(t.getHours()%12||12,e,2)}function J_e(t,e){return Wn(1+jy.count(fu(t),t),e,3)}function WY(t,e){return Wn(t.getMilliseconds(),e,3)}function e1e(t,e){return WY(t,e)+"000"}function t1e(t,e){return Wn(t.getMonth()+1,e,2)}function n1e(t,e){return Wn(t.getMinutes(),e,2)}function r1e(t,e){return Wn(t.getSeconds(),e,2)}function i1e(t){var e=t.getDay();return e===0?7:e}function a1e(t,e){return Wn(OE.count(fu(t)-1,t),e,2)}function qY(t){var e=t.getDay();return e>=4||e===0?Sg(t):Sg.ceil(t)}function s1e(t,e){return t=qY(t),Wn(Sg.count(fu(t),t)+(fu(t).getDay()===4),e,2)}function o1e(t){return t.getDay()}function l1e(t,e){return Wn(gS.count(fu(t)-1,t),e,2)}function c1e(t,e){return Wn(t.getFullYear()%100,e,2)}function u1e(t,e){return t=qY(t),Wn(t.getFullYear()%100,e,2)}function d1e(t,e){return Wn(t.getFullYear()%1e4,e,4)}function h1e(t,e){var n=t.getDay();return t=n>=4||n===0?Sg(t):Sg.ceil(t),Wn(t.getFullYear()%1e4,e,4)}function f1e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Wn(e/60|0,"0",2)+Wn(e%60,"0",2)}function o$(t,e){return Wn(t.getUTCDate(),e,2)}function m1e(t,e){return Wn(t.getUTCHours(),e,2)}function p1e(t,e){return Wn(t.getUTCHours()%12||12,e,2)}function g1e(t,e){return Wn(1+DE.count(mu(t),t),e,3)}function KY(t,e){return Wn(t.getUTCMilliseconds(),e,3)}function x1e(t,e){return KY(t,e)+"000"}function b1e(t,e){return Wn(t.getUTCMonth()+1,e,2)}function y1e(t,e){return Wn(t.getUTCMinutes(),e,2)}function v1e(t,e){return Wn(t.getUTCSeconds(),e,2)}function _1e(t){var e=t.getUTCDay();return e===0?7:e}function w1e(t,e){return Wn(LE.count(mu(t)-1,t),e,2)}function XY(t){var e=t.getUTCDay();return e>=4||e===0?Mg(t):Mg.ceil(t)}function S1e(t,e){return t=XY(t),Wn(Mg.count(mu(t),t)+(mu(t).getUTCDay()===4),e,2)}function M1e(t){return t.getUTCDay()}function E1e(t,e){return Wn(xS.count(mu(t)-1,t),e,2)}function N1e(t,e){return Wn(t.getUTCFullYear()%100,e,2)}function A1e(t,e){return t=XY(t),Wn(t.getUTCFullYear()%100,e,2)}function T1e(t,e){return Wn(t.getUTCFullYear()%1e4,e,4)}function C1e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Mg(t):Mg.ceil(t),Wn(t.getUTCFullYear()%1e4,e,4)}function k1e(){return"+0000"}function l$(){return"%"}function c$(t){return+t}function u$(t){return Math.floor(+t/1e3)}var Ym,YY,ZY;j1e({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 j1e(t){return Ym=j_e(t),YY=Ym.format,Ym.parse,ZY=Ym.utcFormat,Ym.utcParse,Ym}function P1e(t){return new Date(t)}function R1e(t){return t instanceof Date?+t:+new Date(+t)}function FO(t,e,n,r,i,a,o,l,c,u){var d=MO(),f=d.invert,m=d.domain,p=u(".%L"),b=u(":%S"),y=u("%I:%M"),x=u("%I %p"),v=u("%a %d"),S=u("%b %d"),M=u("%B"),N=u("%Y");function A(k){return(c(k)<k?p:l(k)<k?b:o(k)<k?y:a(k)<k?x:r(k)<k?i(k)<k?v:S:n(k)<k?M:N)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,R1e)):m().map(P1e)},d.ticks=function(k){var C=m();return t(C[0],C[C.length-1],k??10)},d.tickFormat=function(k,C){return C==null?A:u(C)},d.nice=function(k){var C=m();return(!k||typeof k.range!="function")&&(k=e(C[0],C[C.length-1],k??10)),k?m(IY(C,k)):d},d.copy=function(){return ky(d,FO(t,e,n,r,i,a,o,l,c,u))},d}function D1e(){return Lo.apply(FO(C_e,k_e,fu,LO,OE,jy,DO,PO,df,YY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function O1e(){return Lo.apply(FO(A_e,T_e,mu,IO,LE,DE,OO,RO,df,ZY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function IE(){var t=0,e=1,n,r,i,a,o=qa,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(m){var p,b;return arguments.length?([p,b]=m,o=f(p,b),u):[o(0),o(1)]}}return u.range=d(Jg),u.rangeRound=d(SO),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 hh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function QY(){var t=dh(IE()(qa));return t.copy=function(){return hh(t,QY())},Mu.apply(t,arguments)}function JY(){var t=AO(IE()).domain([1,10]);return t.copy=function(){return hh(t,JY()).base(t.base())},Mu.apply(t,arguments)}function eZ(){var t=TO(IE());return t.copy=function(){return hh(t,eZ()).constant(t.constant())},Mu.apply(t,arguments)}function UO(){var t=CO(IE());return t.copy=function(){return hh(t,UO()).exponent(t.exponent())},Mu.apply(t,arguments)}function L1e(){return UO.apply(null,arguments).exponent(.5)}function tZ(){var t=[],e=qa;function n(r){if(r!=null&&!isNaN(r=+r))return e((Ty(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(Fd),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)=>_ve(t,a/r))},n.copy=function(){return tZ(e).domain(t)},Mu.apply(n,arguments)}function FE(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=qa,d,f=!1,m;function p(y){return isNaN(y=+y)?m:(y=.5+((y=+d(y))-a)*(r*y<r*a?l:c),u(f?Math.max(0,Math.min(1,y)):y))}p.domain=function(y){return arguments.length?([t,e,n]=y,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,p):[t,e,n]},p.clamp=function(y){return arguments.length?(f=!!y,p):f},p.interpolator=function(y){return arguments.length?(u=y,p):u};function b(y){return function(x){var v,S,M;return arguments.length?([v,S,M]=x,u=Kve(y,[v,S,M]),p):[u(0),u(.5),u(1)]}}return p.range=b(Jg),p.rangeRound=b(SO),p.unknown=function(y){return arguments.length?(m=y,p):m},function(y){return d=y,i=y(t),a=y(e),o=y(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function nZ(){var t=dh(FE()(qa));return t.copy=function(){return hh(t,nZ())},Mu.apply(t,arguments)}function rZ(){var t=AO(FE()).domain([.1,1,10]);return t.copy=function(){return hh(t,rZ()).base(t.base())},Mu.apply(t,arguments)}function iZ(){var t=TO(FE());return t.copy=function(){return hh(t,iZ()).constant(t.constant())},Mu.apply(t,arguments)}function zO(){var t=CO(FE());return t.copy=function(){return hh(t,zO()).exponent(t.exponent())},Mu.apply(t,arguments)}function I1e(){return zO.apply(null,arguments).exponent(.5)}const Fb=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:vO,scaleDiverging:nZ,scaleDivergingLog:rZ,scaleDivergingPow:zO,scaleDivergingSqrt:I1e,scaleDivergingSymlog:iZ,scaleIdentity:LY,scaleImplicit:r3,scaleLinear:OY,scaleLog:FY,scaleOrdinal:yO,scalePoint:Mve,scalePow:kO,scaleQuantile:BY,scaleQuantize:$Y,scaleRadial:zY,scaleSequential:QY,scaleSequentialLog:JY,scaleSequentialPow:UO,scaleSequentialQuantile:tZ,scaleSequentialSqrt:L1e,scaleSequentialSymlog:eZ,scaleSqrt:x_e,scaleSymlog:UY,scaleThreshold:HY,scaleTime:D1e,scaleUtc:O1e,tickFormat:DY},Symbol.toStringTag,{value:"Module"}));var Eu=t=>t.chartData,UE=tt([Eu],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),BO=(t,e,n,r)=>r?UE(t):Eu(t),aZ=(t,e,n)=>n?UE(t):Eu(t);function pu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(gn(e)&&gn(n))return!0}return!1}function d$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function sZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(gn(n))i=n;else if(typeof n=="function")return;if(gn(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(pu(o))return o}}function F1e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(pu(r))return d$(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(Ut(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&_8.test(i)){var c=_8.exec(i);if(c==null||c[1]==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(Ut(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&w8.test(a)){var d=w8.exec(a);if(d==null||d[1]==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(pu(m))return e==null?m:d$(m,e,n)}}}var ex=1e9,U1e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},HO,Or=!0,Do="[DecimalError] ",Sf=Do+"Invalid argument: ",$O=Do+"Exponent out of range: ",tx=Math.floor,Yh=Math.pow,z1e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Us,Hi=1e7,jr=7,oZ=9007199254740991,bS=tx(oZ/jr),qt={};qt.absoluteValue=qt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};qt.comparedTo=qt.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};qt.decimalPlaces=qt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*jr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};qt.dividedBy=qt.div=function(t){return nu(this,new this.constructor(t))};qt.dividedToIntegerBy=qt.idiv=function(t){var e=this,n=e.constructor;return yr(nu(e,new n(t),0,1),n.precision)};qt.equals=qt.eq=function(t){return!this.cmp(t)};qt.exponent=function(){return vi(this)};qt.greaterThan=qt.gt=function(t){return this.cmp(t)>0};qt.greaterThanOrEqualTo=qt.gte=function(t){return this.cmp(t)>=0};qt.isInteger=qt.isint=function(){return this.e>this.d.length-2};qt.isNegative=qt.isneg=function(){return this.s<0};qt.isPositive=qt.ispos=function(){return this.s>0};qt.isZero=function(){return this.s===0};qt.lessThan=qt.lt=function(t){return this.cmp(t)<0};qt.lessThanOrEqualTo=qt.lte=function(t){return this.cmp(t)<1};qt.logarithm=qt.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(Us))throw Error(Do+"NaN");if(n.s<1)throw Error(Do+(n.s?"NaN":"-Infinity"));return n.eq(Us)?new r(0):(Or=!1,e=nu($0(n,a),$0(t,a),a),Or=!0,yr(e,i))};qt.minus=qt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?uZ(e,t):lZ(e,(t.s=-t.s,t))};qt.modulo=qt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Do+"NaN");return n.s?(Or=!1,e=nu(n,t,0,1).times(t),Or=!0,n.minus(e)):yr(new r(n),i)};qt.naturalExponential=qt.exp=function(){return cZ(this)};qt.naturalLogarithm=qt.ln=function(){return $0(this)};qt.negated=qt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};qt.plus=qt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?lZ(e,t):uZ(e,(t.s=-t.s,t))};qt.precision=qt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Sf+t);if(e=vi(i)+1,r=i.d.length-1,n=r*jr+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};qt.squareRoot=qt.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(Do+"NaN")}for(t=vi(l),Or=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=zl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=tx((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(nu(l,a,o+2)).times(.5),zl(a.d).slice(0,o)===(e=zl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(yr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Or=!0,yr(r,n)};qt.times=qt.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,m=d.d,p=(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=m.length,u=p.length,c<u&&(a=m,m=p,p=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]+p[r]*m[i-r-1]+e,a[i--]=l%Hi|0,e=l/Hi|0;a[i]=(a[i]+e)%Hi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Or?yr(t,f.precision):t};qt.toDecimalPlaces=qt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Jl(t,0,ex),e===void 0?e=r.rounding:Jl(e,0,8),yr(n,t+vi(n)+1,e))};qt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Kf(r,!0):(Jl(t,0,ex),e===void 0?e=i.rounding:Jl(e,0,8),r=yr(new i(r),t+1,e),n=Kf(r,!0,t+1)),n};qt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Kf(i):(Jl(t,0,ex),e===void 0?e=a.rounding:Jl(e,0,8),r=yr(new a(i),t+vi(i)+1,e),n=Kf(r.abs(),!1,t+vi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};qt.toInteger=qt.toint=function(){var t=this,e=t.constructor;return yr(new e(t),vi(t)+1,e.rounding)};qt.toNumber=function(){return+this};qt.toPower=qt.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(Us);if(l=new c(l),!l.s){if(t.s<1)throw Error(Do+"Infinity");return l}if(l.eq(Us))return l;if(r=c.precision,t.eq(Us))return yr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=oZ){for(i=new c(Us),e=Math.ceil(r/jr+4),Or=!1;n%2&&(i=i.times(l),f$(i.d,e)),n=tx(n/2),n!==0;)l=l.times(l),f$(l.d,e);return Or=!0,t.s<0?new c(Us).div(i):yr(i,r)}}else if(a<0)throw Error(Do+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Or=!1,i=t.times($0(l,r+u)),Or=!0,i=cZ(i),i.s=a,i};qt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=vi(i),r=Kf(i,n<=a.toExpNeg||n>=a.toExpPos)):(Jl(t,1,ex),e===void 0?e=a.rounding:Jl(e,0,8),i=yr(new a(i),t,e),n=vi(i),r=Kf(i,t<=n||n<=a.toExpNeg,t)),r};qt.toSignificantDigits=qt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Jl(t,1,ex),e===void 0?e=r.rounding:Jl(e,0,8)),yr(new r(n),t,e)};qt.toString=qt.valueOf=qt.val=qt.toJSON=qt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=vi(t),n=t.constructor;return Kf(t,e<=n.toExpNeg||e>=n.toExpPos)};function lZ(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)),Or?yr(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/jr),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)/Hi|0,c[a]%=Hi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Or?yr(e,f):e}function Jl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Sf+t)}function zl(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=jr-r.length,n&&(a+=md(n)),a+=r;o=t[e],r=o+"",n=jr-r.length,n&&(a+=md(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var nu=(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%Hi|0,o=a/Hi|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*Hi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,m,p,b,y,x,v,S,M,N,A,k,C,D,T=r.constructor,R=r.s==i.s?1:-1,U=r.d,O=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(Do+"Division by zero");for(c=r.e-i.e,C=O.length,A=U.length,p=new T(R),b=p.d=[],u=0;O[u]==(U[u]||0);)++u;if(O[u]>(U[u]||0)&&--c,a==null?S=a=T.precision:o?S=a+(vi(r)-vi(i))+1:S=a,S<0)return new T(0);if(S=S/jr+2|0,u=0,C==1)for(d=0,O=O[0],S++;(u<A||d)&&S--;u++)M=d*Hi+(U[u]||0),b[u]=M/O|0,d=M%O|0;else{for(d=Hi/(O[0]+1)|0,d>1&&(O=t(O,d),U=t(U,d),C=O.length,A=U.length),N=C,y=U.slice(0,C),x=y.length;x<C;)y[x++]=0;D=O.slice(),D.unshift(0),k=O[0],O[1]>=Hi/2&&++k;do d=0,l=e(O,y,C,x),l<0?(v=y[0],C!=x&&(v=v*Hi+(y[1]||0)),d=v/k|0,d>1?(d>=Hi&&(d=Hi-1),f=t(O,d),m=f.length,x=y.length,l=e(f,y,m,x),l==1&&(d--,n(f,C<m?D:O,m))):(d==0&&(l=d=1),f=O.slice()),m=f.length,m<x&&f.unshift(0),n(y,f,x),l==-1&&(x=y.length,l=e(O,y,C,x),l<1&&(d++,n(y,C<x?D:O,x))),x=y.length):l===0&&(d++,y=[0]),b[u++]=d,l&&y[0]?y[x++]=U[N]||0:(y=[U[N]],x=1);while((N++<A||y[0]!==void 0)&&S--)}return b[0]||b.shift(),p.e=c,yr(p,o?a+vi(p)+1:a)}})();function cZ(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(vi(t)>16)throw Error($O+vi(t));if(!t.s)return new d(Us);for(Or=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Yh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Us),d.precision=l;;){if(i=yr(i.times(t),l),n=n.times(++c),o=a.plus(nu(i,n,l)),zl(o.d).slice(0,l)===zl(a.d).slice(0,l)){for(;u--;)a=yr(a.times(a),l);return d.precision=f,e==null?(Or=!0,yr(a,f)):a}a=o}}function vi(t){for(var e=t.e*jr,n=t.d[0];n>=10;n/=10)e++;return e}function wC(t,e,n){if(e>t.LN10.sd())throw Or=!0,n&&(t.precision=n),Error(Do+"LN10 precision limit exceeded");return yr(new t(t.LN10),e)}function md(t){for(var e="";t--;)e+="0";return e}function $0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,p=t,b=p.d,y=p.constructor,x=y.precision;if(p.s<1)throw Error(Do+(p.s?"NaN":"-Infinity"));if(p.eq(Us))return new y(0);if(e==null?(Or=!1,u=x):u=e,p.eq(10))return e==null&&(Or=!0),wC(y,u);if(u+=m,y.precision=u,n=zl(b),r=n.charAt(0),a=vi(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=zl(p.d),r=n.charAt(0),f++;a=vi(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=wC(y,u+2,x).times(a+""),p=$0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=x,e==null?(Or=!0,yr(p,x)):p;for(l=o=p=nu(p.minus(Us),p.plus(Us),u),d=yr(p.times(p),u),i=3;;){if(o=yr(o.times(d),u),c=l.plus(nu(o,new y(i),u)),zl(c.d).slice(0,u)===zl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(wC(y,u+2,x).times(a+""))),l=nu(l,new y(f),u),y.precision=x,e==null?(Or=!0,yr(l,x)):l;l=c,i+=2}}function h$(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=tx(n/jr),t.d=[],r=(n+1)%jr,n<0&&(r+=jr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=jr;r<i;)t.d.push(+e.slice(r,r+=jr));e=e.slice(r),r=jr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Or&&(t.e>bS||t.e<-bS))throw Error($O+n)}else t.s=0,t.e=0,t.d=[0];return t}function yr(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+=jr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/jr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=jr,i=r-jr+o}if(n!==void 0&&(a=Yh(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/Yh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=vi(t),f.length=1,e=e-a-1,f[0]=Yh(10,(jr-e%jr)%jr),t.e=tx(-e/jr)||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=Yh(10,jr-r),f[d]=i>0?(u/Yh(10,o-i)%Yh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Hi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Hi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Or&&(t.e>bS||t.e<-bS))throw Error($O+vi(t));return t}function uZ(t,e){var n,r,i,a,o,l,c,u,d,f,m=t.constructor,p=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),Or?yr(e,p):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(p/jr),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]=Hi-1;--c[a],c[i]+=Hi}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,Or?yr(e,p):e):new m(0)}function Kf(t,e,n){var r,i=vi(t),a=zl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+md(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+md(-i-1)+a,n&&(r=n-o)>0&&(a+=md(r))):i>=o?(a+=md(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+md(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=md(r))),t.s<0?"-"+a:a}function f$(t,e){if(t.length>e)return t.length=e,!0}function dZ(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(Sf+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 h$(o,a.toString())}else if(typeof a!="string")throw Error(Sf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,z1e.test(a))h$(o,a);else throw Error(Sf+a)}if(i.prototype=qt,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=dZ,i.config=i.set=B1e,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 B1e(t){if(!t||typeof t!="object")throw Error(Do+"Object expected");var e,n,r,i=["precision",1,ex,"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(tx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Sf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Sf+n+": "+r);return this}var HO=dZ(U1e);Us=new HO(1);const sr=HO;function hZ(t){var e;return t===0?e=1:e=Math.floor(new sr(t).abs().log(10).toNumber())+1,e}function fZ(t,e,n){for(var r=new sr(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var mZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},pZ=(t,e,n)=>{if(t.lte(0))return new sr(0);var r=hZ(t.toNumber()),i=new sr(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new sr(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new sr(c.toNumber()):new sr(Math.ceil(c.toNumber()))},$1e=(t,e,n)=>{var r=new sr(1),i=new sr(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new sr(10).pow(hZ(t)-1),i=new sr(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new sr(Math.floor(t)))}else t===0?i=new sr(Math.floor((e-1)/2)):n||(i=new sr(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new sr(c-o).mul(r)).toNumber());return l},gZ=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 sr(0),tickMin:new sr(0),tickMax:new sr(0)};var o=pZ(new sr(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new sr(0):(l=new sr(e).add(n).div(2),l=l.sub(new sr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new sr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?gZ(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 sr(c).mul(o)),tickMax:l.add(new sr(u).mul(o))})},H1e=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]=mZ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),c];return n>r?u.reverse():u}if(l===c)return $1e(l,i,a);var{step:d,tickMin:f,tickMax:m}=gZ(l,c,o,a,0),p=fZ(f,m.add(new sr(.1).mul(d)),d);return n>r?p.reverse():p},V1e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=mZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=pZ(new sr(l).sub(o).div(c-1),a,0),d=[...fZ(new sr(o),new sr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?d.reverse():d},xZ=t=>t.rootProps.maxBarSize,G1e=t=>t.rootProps.barGap,bZ=t=>t.rootProps.barCategoryGap,W1e=t=>t.rootProps.barSize,Py=t=>t.rootProps.stackOffset,yZ=t=>t.rootProps.reverseStackOrder,VO=t=>t.options.chartName,GO=t=>t.rootProps.syncId,vZ=t=>t.rootProps.syncMethod,WO=t=>t.options.eventEmitter,q1e=t=>t.rootProps.baseValue,ni={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Dh={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},El={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},zE=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function BE(t,e,n){if(n!=="auto")return n;if(t!=null)return gl(t,e)?"category":"number"}function m$(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 yS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m$(Object(n),!0).forEach(function(r){K1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K1e(t,e,n){return(e=X1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X1e(t){var e=Y1e(t,"string");return typeof e=="symbol"?e:e+""}function Y1e(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 p$={allowDataOverflow:Dh.allowDataOverflow,allowDecimals:Dh.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Dh.angleAxisId,includeHidden:!1,name:void 0,reversed:Dh.reversed,scale:Dh.scale,tick:Dh.tick,tickCount:void 0,ticks:void 0,type:Dh.type,unit:void 0},g$={allowDataOverflow:El.allowDataOverflow,allowDecimals:El.allowDecimals,allowDuplicatedCategory:El.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:El.radiusAxisId,includeHidden:El.includeHidden,name:void 0,reversed:El.reversed,scale:El.scale,tick:El.tick,tickCount:El.tickCount,ticks:void 0,type:El.type,unit:void 0},Z1e=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},qO=tt([Z1e,iY],(t,e)=>{var n;if(t!=null)return t;var r=(n=BE(e,"angleAxis",p$.type))!==null&&n!==void 0?n:"category";return yS(yS({},p$),{},{type:r})}),Q1e=(t,e)=>t.polarAxis.radiusAxis[e],KO=tt([Q1e,iY],(t,e)=>{var n;if(t!=null)return t;var r=(n=BE(e,"radiusAxis",g$.type))!==null&&n!==void 0?n:"category";return yS(yS({},g$),{},{type:r})}),$E=t=>t.polarOptions,XO=tt([wu,Su,Pi],_Y),_Z=tt([$E,XO],(t,e)=>{if(t!=null)return La(t.innerRadius,e,0)}),wZ=tt([$E,XO],(t,e)=>{if(t!=null)return La(t.outerRadius,e,e*.8)}),J1e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},SZ=tt([$E],J1e);tt([qO,SZ],zE);var MZ=tt([XO,_Z,wZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});tt([KO,MZ],zE);var EZ=tt([Fn,$E,_Z,wZ,wu,Su],(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:La(o,i,i/2),cy:La(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Vr=(t,e)=>e,Ry=(t,e,n)=>n;function HE(t){return t?.id}function NZ(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=HE(l);u.forEach((f,m)=>{var p=a==null||i?m:String(Jn(f,a,null)),b=Jn(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:b}),o.set(p,y)})}}),Array.from(o.values())}function VE(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var GE=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function WE(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function ewe(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 ea=t=>{var e=Fn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},nx=t=>t.tooltip.settings.axisId;function twe(t){if(t in Fb)return Fb[t]();var e="scale".concat(yy(t));if(e in Fb)return Fb[e]()}function x$(t){var e=t.ticks,n=t.bandwidth,r=t.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>t.domain(),range:(function(a){function o(){return a.apply(this,arguments)}return o.toString=function(){return a.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(a){var o=i[0],l=i[1];return o<=l?a>=o&&a<=l:a>=l&&a<=o},bandwidth:n?()=>n.call(t):void 0,ticks:e?a=>e.call(t,a):void 0,map:(a,o)=>{var l=t(a);if(l!=null){if(t.bandwidth&&o!==null&&o!==void 0&&o.position){var c=t.bandwidth();switch(o.position){case"middle":l+=c/2;break;case"end":l+=c;break}}return l}}}}function b$(t,e,n){if(typeof t=="function")return x$(t.copy().domain(e).range(n));if(t!=null){var r=twe(t);if(r!=null)return r.domain(e).range(n),x$(r)}}var AZ=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!pu(e)){for(var n,r,i=0;i<e.length;i++){var a=e[i];gn(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return e}default:return e}};function y$(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 vS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y$(Object(n),!0).forEach(function(r){nwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nwe(t,e,n){return(e=rwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rwe(t){var e=iwe(t,"string");return typeof e=="symbol"?e:e+""}function iwe(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 o3=[0,"auto"],Bi={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},TZ=(t,e)=>t.cartesianAxis.xAxis[e],lc=(t,e)=>{var n=TZ(t,e);return n??Bi},$i={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:o3,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:Sy},CZ=(t,e)=>t.cartesianAxis.yAxis[e],cc=(t,e)=>{var n=CZ(t,e);return n??$i},awe={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:""},YO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??awe},ii=(t,e,n)=>{switch(e){case"xAxis":return lc(t,n);case"yAxis":return cc(t,n);case"zAxis":return YO(t,n);case"angleAxis":return qO(t,n);case"radiusAxis":return KO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},swe=(t,e,n)=>{switch(e){case"xAxis":return lc(t,n);case"yAxis":return cc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},rx=(t,e,n)=>{switch(e){case"xAxis":return lc(t,n);case"yAxis":return cc(t,n);case"angleAxis":return qO(t,n);case"radiusAxis":return KO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},kZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function ZO(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 Dy=t=>t.graphicalItems.cartesianItems,owe=tt([Vr,Ry],ZO),QO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Oy=tt([Dy,ii,owe],QO,{memoizeOptions:{resultEqualityCheck:WE}}),jZ=tt([Oy],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(VE)),PZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),lwe=tt([Oy],PZ),JO=t=>t.map(e=>e.data).filter(Boolean).flat(1),cwe=tt([Oy],JO,{memoizeOptions:{resultEqualityCheck:WE}}),e4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},t4=tt([cwe,BO],e4),n4=(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})),qE=tt([t4,ii,Oy],n4);function RZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function rw(t){if(Po(t)||t instanceof Date){var e=Number(t);if(gn(e))return e}}function v$(t){if(Array.isArray(t)){var e=[rw(t[0]),rw(t[1])];return pu(e)?e:void 0}var n=rw(t);if(n!=null)return[n,n]}function gu(t){return t.map(rw).filter(gs)}function uwe(t,e,n){return!n||typeof e!="number"||cl(e)?[]:n.length?gu(n.flatMap(r=>{var i=Jn(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!gn(a)||!gn(o)))return[e-a,e+o]})):[]}var Oi=t=>{var e=ea(t),n=nx(t);return rx(t,e,n)},Ly=tt([Oi],t=>t?.dataKey),dwe=tt([jZ,BO,Oi],NZ),DZ=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>{if(l.stackId==null)return o;var c=o[l.stackId];return c==null&&(c=[]),c.push(l),o[l.stackId]=c,o},i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(HE);return[l,{stackedData:Pbe(t,d,n),graphicalItems:u}]}))},_S=tt([dwe,jZ,Py,yZ],DZ),OZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Lbe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},hwe=tt([ii],t=>t.allowDataOverflow),r4=t=>{var e;if(t==null||!("domain"in t))return o3;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=gu(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:o3},i4=tt([ii],r4),a4=tt([i4,hwe],sZ),fwe=tt([_S,Eu,Vr,a4],OZ,{memoizeOptions:{resultEqualityCheck:GE}}),KE=t=>t.errorBars,mwe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>RZ(n,r)),wS=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]}},s4=(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(v=>RZ(i,v)),m=Jn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=uwe(l,m,f);if(p.length>=2){var b=Math.min(...p),y=Math.max(...p);(a==null||b<a)&&(a=b),(o==null||y>o)&&(o=y)}var x=v$(m);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=v$(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]))}),gn(a)&&gn(o))return[a,o]},pwe=tt([t4,ii,lwe,KE,Vr],s4,{memoizeOptions:{resultEqualityCheck:GE}});function gwe(t){var{value:e}=t;if(Po(e)||e instanceof Date)return e}var xwe=(t,e,n)=>{var r=t.map(gwe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&JK(r))?EY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},LZ=t=>t.referenceElements.dots,ix=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),bwe=tt([LZ,Vr,Ry],ix),IZ=t=>t.referenceElements.areas,ywe=tt([IZ,Vr,Ry],ix),FZ=t=>t.referenceElements.lines,vwe=tt([FZ,Vr,Ry],ix),UZ=(t,e)=>{if(t!=null){var n=gu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},_we=tt(bwe,Vr,UZ),zZ=(t,e)=>{if(t!=null){var n=gu(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)]}},wwe=tt([ywe,Vr],zZ);function Swe(t){var e;if(t.x!=null)return gu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:gu(n)}function Mwe(t){var e;if(t.y!=null)return gu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:gu(n)}var BZ=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?Swe(r):Mwe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Ewe=tt([vwe,Vr],BZ),Nwe=tt(_we,Ewe,wwe,(t,e,n)=>wS(t,n,e)),o4=(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?wS(r,a,i):wS(a,i);return F1e(e,u,t.allowDataOverflow)},Awe=tt([ii,i4,a4,fwe,pwe,Nwe,Fn,Vr],o4,{memoizeOptions:{resultEqualityCheck:GE}}),Twe=[0,1],l4=(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=gl(e,a);if(u&&l==null){var d;return EY(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?xwe(r,t,u):i==="expand"?Twe:o}},c4=tt([ii,Fn,t4,qE,Py,Vr,Awe],l4);function Cwe(t){return t in Fb}var $Z=(t,e,n)=>{if(t!=null){var{scale:r,type:i}=t;if(r==="auto")return i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!e)?"point":i==="category"?"band":"linear";if(typeof r=="string"){var a="scale".concat(yy(r));return Cwe(a)?a:"point"}}},fh=tt([ii,kZ,VO],$Z);function u4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?b$(t.scale,n,r):b$(e,n,r)}var d4=(t,e,n)=>{var r=r4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&pu(t))return H1e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&pu(t))return V1e(t,e.tickCount,e.allowDecimals)}},h4=tt([c4,rx,fh],d4),f4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&pu(e)&&Array.isArray(n)&&n.length>0){var i,a,o=e[0],l=(i=n[0])!==null&&i!==void 0?i:0,c=e[1],u=(a=n[n.length-1])!==null&&a!==void 0?a:0;return[Math.min(o,l),Math.max(c,u)]}return e},kwe=tt([ii,c4,h4,Vr],f4),jwe=tt(qE,ii,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(gu(t.map(f=>f.value))).sort((f,m)=>f-m),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var l=0;l<r.length-1;l++){var c=r[l],u=r[l+1];if(!(c==null||u==null)){var d=u-c;n=Math.min(n,d)}}return n/o}}),HZ=tt(jwe,Fn,bZ,Pi,(t,e,n,r,i)=>i,(t,e,n,r,i)=>{if(!gn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=La(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),Pwe=(t,e,n)=>{var r=lc(t,e);return r==null||typeof r.padding!="string"?0:HZ(t,"xAxis",e,n,r.padding)},Rwe=(t,e,n)=>{var r=cc(t,e);return r==null||typeof r.padding!="string"?0:HZ(t,"yAxis",e,n,r.padding)},Dwe=tt(lc,Pwe,(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}}),Owe=tt(cc,Rwe,(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}}),Lwe=tt([Pi,Dwe,CE,TE,(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]}),Iwe=tt([Pi,Fn,Owe,CE,TE,(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]}),Iy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Lwe(t,n,r);case"yAxis":return Iwe(t,n,r);case"zAxis":return(i=YO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return SZ(t);case"radiusAxis":return MZ(t,n);default:return}},VZ=tt([ii,Iy],zE),Fwe=tt([fh,kwe],AZ),Eg=tt([ii,fh,Fwe,VZ],u4);tt([Oy,KE,Vr],mwe);function GZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var XE=(t,e)=>e,YE=(t,e,n)=>n,Uwe=tt(NE,XE,YE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(GZ)),zwe=tt(AE,XE,YE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(GZ)),WZ=(t,e)=>({width:t.width,height:e.height}),Bwe=(t,e)=>{var n=typeof e.width=="number"?e.width:Sy;return{width:n,height:t.height}},qZ=tt(Pi,lc,WZ),$we=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Hwe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Vwe=tt(Su,Pi,Uwe,XE,YE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=WZ(e,l);o==null&&(o=$we(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}),Gwe=tt(wu,Pi,zwe,XE,YE,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=Bwe(e,l);o==null&&(o=Hwe(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}),Wwe=(t,e)=>{var n=lc(t,e);if(n!=null)return Vwe(t,n.orientation,n.mirror)},qwe=tt([Pi,lc,Wwe,(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}}}),Kwe=(t,e)=>{var n=cc(t,e);if(n!=null)return Gwe(t,n.orientation,n.mirror)},Xwe=tt([Pi,cc,Kwe,(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}}}),KZ=tt(Pi,cc,(t,e)=>{var n=typeof e.width=="number"?e.width:Sy;return{width:n,height:t.height}}),_$=(t,e,n)=>{switch(e){case"xAxis":return qZ(t,n).width;case"yAxis":return KZ(t,n).height;default:return}},XZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=gl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&JK(c))return c}},m4=tt([Fn,qE,ii,Vr],XZ),YZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=gl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},p4=tt([Fn,qE,rx,Vr],YZ),w$=tt([Fn,swe,fh,Eg,m4,p4,Iy,h4,Vr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=gl(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}}}),Ywe=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=gl(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/p:0;b=c==="angleAxis"&&a!=null&&a.length>=2?Wi(a[0]-a[1])*2*b:b;var y=f||i;return y?y.map((x,v)=>{var S=o?o.indexOf(x):x,M=r.map(S);return gn(M)?{index:v,coordinate:M+b,value:x,offset:b}:null}).filter(gs):u&&l?l.map((x,v)=>{var S=r.map(x);return gn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(gs):r.ticks?r.ticks(m).map((x,v)=>{var S=r.map(x);return gn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(gs):r.domain().map((x,v)=>{var S=r.map(x);return gn(S)?{coordinate:S+b,value:o?o[x]:x,index:v,offset:b}:null}).filter(gs)}},ZZ=tt([Fn,rx,fh,Eg,h4,Iy,m4,p4,Vr],Ywe),Zwe=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=gl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Wi(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>{var m=n.map(d);return gn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(gs):n.ticks?n.ticks(c).map((d,f)=>{var m=n.map(d);return gn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(gs):n.domain().map((d,f)=>{var m=n.map(d);return gn(m)?{coordinate:m+u,value:i?i[d]:d,index:f,offset:u}:null}).filter(gs)}},ec=tt([Fn,rx,Eg,Iy,m4,p4,Vr],Zwe),tc=tt(ii,Eg,(t,e)=>{if(!(t==null||e==null))return vS(vS({},t),{},{scale:e})}),Qwe=tt([ii,fh,c4,VZ],u4);tt((t,e,n)=>YO(t,n),Qwe,(t,e)=>{if(!(t==null||e==null))return vS(vS({},t),{},{scale:e})});var Jwe=tt([Fn,NE,AE],(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}}),QZ=t=>t.options.defaultTooltipEventType,JZ=t=>t.options.validateTooltipEventTypes;function eQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function g4(t,e){var n=QZ(t),r=JZ(t);return eQ(e,n,r)}function eSe(t){return Ht(e=>g4(e,t))}var tQ=(t,e)=>{var n,r=Number(e);if(!(cl(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},tSe=t=>t.tooltip.settings,wd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},nSe={itemInteraction:{click:wd,hover:wd},axisInteraction:{click:wd,hover:wd},keyboardInteraction:wd,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}},nQ=Ss({name:"tooltip",initialState:nSe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Rr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=nl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Rr()},removeTooltipEntrySettings:{reducer(t,e){var n=nl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Rr()},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}}}),{addTooltipEntrySettings:rSe,replaceTooltipEntrySettings:iSe,removeTooltipEntrySettings:aSe,setTooltipSettingsState:sSe,setActiveMouseOverItemIndex:rQ,mouseLeaveItem:oSe,mouseLeaveChart:iQ,setActiveClickItemIndex:lSe,setMouseOverAxisIndex:aQ,setMouseClickAxisIndex:cSe,setSyncInteraction:l3,setKeyboardInteraction:c3}=nQ.actions,uSe=nQ.reducer;function S$(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?S$(Object(n),!0).forEach(function(r){dSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dSe(t,e,n){return(e=hSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hSe(t){var e=fSe(t,"string");return typeof e=="symbol"?e:e+""}function fSe(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 mSe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function pSe(t){return t.index!=null}var sQ=(t,e,n,r)=>{if(e==null)return wd;var i=mSe(t,e,n);if(i==null)return wd;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(pSe(i)){if(a)return A_(A_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return A_(A_({},wd),{},{coordinate:i.coordinate})};function gSe(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 xSe(t,e){var n=gSe(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 bSe(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!pu(n)?!0:xSe(r,n)}var x4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!gn(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||bSe(u,n,r)?String(c):null},oQ=(t,e,n,r,i,a,o)=>{if(a!=null){var l=o[0],c=l?.getPosition(a);if(c!=null)return c;var u=i?.[Number(a)];if(u)return n==="horizontal"?{x:u.coordinate,y:(r.top+e)/2}:{x:(r.left+t)/2,y:u.coordinate}}},lQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=t.itemInteraction.hover.graphicalItemId:i=t.itemInteraction.click.graphicalItemId,i==null&&r!=null){var a=t.tooltipItemPayloads[0];return a!=null?[a]:[]}return t.tooltipItemPayloads.filter(o=>{var l;return((l=o.settings)===null||l===void 0?void 0:l.graphicalItemId)===i})},cQ=t=>t.options.tooltipPayloadSearcher,ax=t=>t.tooltip;function M$(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 E$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M$(Object(n),!0).forEach(function(r){ySe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ySe(t,e,n){return(e=vSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vSe(t){var e=_Se(t,"string");return typeof e=="symbol"?e:e+""}function _Se(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 wSe(t,e){return t??e}var uQ=(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((m,p)=>{var b,{dataDefinedOnItem:y,settings:x}=p,v=wSe(y,l),S=Array.isArray(v)?qX(v,u,d):v,M=(b=x?.dataKey)!==null&&b!==void 0?b:r,N=x?.nameKey,A;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?A=eX(S,r,i):A=a(S,e,c,N),Array.isArray(A))A.forEach(C=>{var D=E$(E$({},x),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});m.push(S8({tooltipEntrySettings:D,dataKey:C.dataKey,payload:C.payload,value:Jn(C.payload,C.dataKey),name:C.name}))});else{var k;m.push(S8({tooltipEntrySettings:x,dataKey:M,payload:A,value:Jn(A,M),name:(k=Jn(A,N))!==null&&k!==void 0?k:x?.name}))}return m},f)}},b4=tt([Oi,kZ,VO],$Z),SSe=tt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),MSe=tt([ea,nx],ZO),sx=tt([SSe,Oi,MSe],QO,{memoizeOptions:{resultEqualityCheck:WE}}),ESe=tt([sx],t=>t.filter(VE)),NSe=tt([sx],JO,{memoizeOptions:{resultEqualityCheck:WE}}),ox=tt([NSe,Eu],e4),ASe=tt([ESe,Eu,Oi],NZ),y4=tt([ox,Oi,sx],n4),dQ=tt([Oi],r4),TSe=tt([Oi],t=>t.allowDataOverflow),hQ=tt([dQ,TSe],sZ),CSe=tt([sx],t=>t.filter(VE)),kSe=tt([ASe,CSe,Py,yZ],DZ),jSe=tt([kSe,Eu,ea,hQ],OZ),PSe=tt([sx],PZ),RSe=tt([ox,Oi,PSe,KE,ea],s4,{memoizeOptions:{resultEqualityCheck:GE}}),DSe=tt([LZ,ea,nx],ix),OSe=tt([DSe,ea],UZ),LSe=tt([IZ,ea,nx],ix),ISe=tt([LSe,ea],zZ),FSe=tt([FZ,ea,nx],ix),USe=tt([FSe,ea],BZ),zSe=tt([OSe,USe,ISe],wS),BSe=tt([Oi,dQ,hQ,jSe,RSe,zSe,Fn,ea],o4),Fy=tt([Oi,Fn,ox,y4,Py,ea,BSe],l4),$Se=tt([Fy,Oi,b4],d4),HSe=tt([Oi,Fy,$Se,ea],f4),fQ=t=>{var e=ea(t),n=nx(t),r=!1;return Iy(t,e,n,r)},mQ=tt([Oi,fQ],zE),pQ=tt([Oi,b4,HSe,mQ],u4),VSe=tt([Fn,y4,Oi,ea],XZ),GSe=tt([Fn,y4,Oi,ea],YZ),WSe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=gl(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?Wi(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>{var b=r.map(m);return gn(b)?{coordinate:b+f,value:m,index:p,offset:f}:null}).filter(gs):r.domain().map((m,p)=>{var b=r.map(m);return gn(b)?{coordinate:b+f,value:a?a[m]:m,index:p,offset:f}:null}).filter(gs)}}},Nu=tt([Fn,Oi,b4,pQ,fQ,VSe,GSe,ea],WSe),v4=tt([QZ,JZ,tSe],(t,e,n)=>eQ(n.shared,t,e)),gQ=t=>t.tooltip.settings.trigger,_4=t=>t.tooltip.settings.defaultIndex,Uy=tt([ax,v4,gQ,_4],sQ),Yd=tt([Uy,ox,Ly,Fy],x4),xQ=tt([Nu,Yd],tQ),w4=tt([Uy],t=>{if(t)return t.dataKey}),qSe=tt([Uy],t=>{if(t)return t.graphicalItemId}),bQ=tt([ax,v4,gQ,_4],lQ),KSe=tt([wu,Su,Fn,Pi,Nu,_4,bQ],oQ),XSe=tt([Uy,KSe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),YSe=tt([Uy],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),ZSe=tt([bQ,Yd,Eu,Ly,xQ,cQ,v4],uQ),QSe=tt([ZSe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});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 A$(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){JSe(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 JSe(t,e,n){return(e=eMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eMe(t){var e=tMe(t,"string");return typeof e=="symbol"?e:e+""}function tMe(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 nMe=()=>Ht(Oi),rMe=()=>{var t=nMe(),e=Ht(Nu),n=Ht(pQ);return Xd(!t||!n?void 0:A$(A$({},t),{},{scale:n}),e)};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 Zm(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){iMe(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 iMe(t,e,n){return(e=aMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aMe(t){var e=sMe(t,"string");return typeof e=="symbol"?e:e+""}function sMe(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 oMe=(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}},lMe=(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 Zm(Zm(Zm({},r),bi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Zm(Zm(Zm({},r),bi(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 cMe(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 yQ=(t,e,n,r,i)=>{var a,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var c,u,d,f,m,p=l>0?(c=n[l-1])===null||c===void 0?void 0:c.coordinate:(u=n[o-1])===null||u===void 0?void 0:u.coordinate,b=(d=n[l])===null||d===void 0?void 0:d.coordinate,y=l>=o-1?(f=n[0])===null||f===void 0?void 0:f.coordinate:(m=n[l+1])===null||m===void 0?void 0:m.coordinate,x=void 0;if(!(p==null||b==null||y==null))if(Wi(b-p)!==Wi(y-b)){var v=[];if(Wi(y-b)===Wi(i[1]-i[0])){x=y;var S=b+i[1]-i[0];v[0]=Math.min(S,(S+p)/2),v[1]=Math.max(S,(S+p)/2)}else{x=p;var M=y+i[1]-i[0];v[0]=Math.min(b,(M+b)/2),v[1]=Math.max(b,(M+b)/2)}var N=[Math.min(b,(x+b)/2),Math.max(b,(x+b)/2)];if(t>N[0]&&t<=N[1]||t>=v[0]&&t<=v[1]){var A;return(A=n[l])===null||A===void 0?void 0:A.index}}else{var k=Math.min(p,y),C=Math.max(p,y);if(t>(k+b)/2&&t<=(C+b)/2){var D;return(D=n[l])===null||D===void 0?void 0:D.index}}}else if(e)for(var T=0;T<o;T++){var R=e[T];if(R!=null){var U=e[T+1],O=e[T-1];if(T===0&&U!=null&&t<=(R.coordinate+U.coordinate)/2||T===o-1&&O!=null&&t>(R.coordinate+O.coordinate)/2||T>0&&T<o-1&&O!=null&&U!=null&&t>(R.coordinate+O.coordinate)/2&&t<=(R.coordinate+U.coordinate)/2)return R.index}}return-1},vQ=()=>Ht(VO),S4=(t,e)=>e,_Q=(t,e,n)=>n,M4=(t,e,n,r)=>r,uMe=tt(Nu,t=>gE(t,e=>e.coordinate)),E4=tt([ax,S4,_Q,M4],sQ),N4=tt([E4,ox,Ly,Fy],x4),dMe=(t,e,n)=>{if(e!=null){var r=ax(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},wQ=tt([ax,S4,_Q,M4],lQ),SS=tt([wu,Su,Fn,Pi,Nu,M4,wQ],oQ),hMe=tt([E4,SS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),SQ=tt([Nu,N4],tQ),fMe=tt([wQ,N4,Eu,Ly,SQ,cQ,S4],uQ),mMe=tt([E4,N4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),pMe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&cMe(t,o)){var l=Ibe(t,e),c=yQ(l,a,i,n,r),u=oMe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},gMe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=eve(t,n);if(l){var c=Fbe(l,e),u=yQ(c,o,a,r,i),d=lMe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},xMe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?pMe(t,e,r,i,a,o,l):gMe(t,e,n,r,i,a,o)},bMe=tt(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.panoramaElement:r.element}}),yMe=tt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(ni)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:ewe}});function C$(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 k$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C$(Object(n),!0).forEach(function(r){vMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vMe(t,e,n){return(e=_Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Me(t){var e=wMe(t,"string");return typeof e=="symbol"?e:e+""}function wMe(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 SMe={},MMe={zIndexMap:Object.values(ni).reduce((t,e)=>k$(k$({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),SMe)},EMe=new Set(Object.values(ni));function NMe(t){return EMe.has(t)}var MQ=Ss({name:"zIndex",initialState:MMe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:Rr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!NMe(n)&&delete t.zIndexMap[n])},prepare:Rr()},registerZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n,element:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElement=r:t.zIndexMap[n].element=r:t.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:Rr()},unregisterZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElement=void 0:t.zIndexMap[n].element=void 0)},prepare:Rr()}}}),{registerZIndexPortal:AMe,unregisterZIndexPortal:TMe,registerZIndexPortalElement:CMe,unregisterZIndexPortalElement:kMe}=MQ.actions,jMe=MQ.reducer;function Fa(t){var{zIndex:e,children:n}=t,r=p0e(),i=r&&e!==void 0&&e!==0,a=Ri(),o=vr();w.useLayoutEffect(()=>i?(o(AMe({zIndex:e})),()=>{o(TMe({zIndex:e}))}):lh,[o,e,i]);var l=Ht(c=>bMe(c,e,a));return i?l?Xc.createPortal(n,l):null:n}function u3(){return u3=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},u3.apply(null,arguments)}function j$(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 T_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j$(Object(n),!0).forEach(function(r){PMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PMe(t,e,n){return(e=RMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RMe(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 OMe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function LMe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var b,y,x;if(d==="ScatterChart")b=f,y=mye,x=ni.cursorLine;else if(d==="BarChart")b=pye(l,f,a,o),y=vY,x=ni.cursorRectangle;else if(l==="radial"&&nX(f)){var{cx:v,cy:S,radius:M,startAngle:N,endAngle:A}=wY(f);b={cx:v,cy:S,startAngle:N,endAngle:A,innerRadius:M,outerRadius:M},y=MY,x=ni.cursorLine}else b={points:ive(l,f,a)},y=tg,x=ni.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,C=T_(T_(T_(T_({stroke:"#ccc",pointerEvents:"none"},a),b),Bf(c)),{},{payload:m,payloadIndex:p,className:zn("recharts-tooltip-cursor",k)});return w.createElement(Fa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},w.createElement(OMe,{cursor:c,cursorComp:y,cursorProps:C}))}function IMe(t){var e=rMe(),n=rY(),r=uh(),i=vQ();return e==null||n==null||r==null||i==null?null:w.createElement(LMe,u3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var EQ=w.createContext(null),FMe=()=>w.useContext(EQ),SC={exports:{}},P$;function UMe(){return P$||(P$=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,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],p]:c._events[b].push(p):(c._events[b]=p,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 m=0,p=f.length,b=new Array(p);m<p;m++)b[m]=f[m].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,m,p,b){var y=n?n+u:u;if(!this._events[y])return!1;var x=this._events[y],v=arguments.length,S,M;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),v){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,m),!0;case 5:return x.fn.call(x.context,d,f,m,p),!0;case 6:return x.fn.call(x.context,d,f,m,p,b),!0}for(M=1,S=new Array(v-1);M<v;M++)S[M-1]=arguments[M];x.fn.apply(x.context,S)}else{var N=x.length,A;for(M=0;M<N;M++)switch(x[M].once&&this.removeListener(u,x[M].fn,void 0,!0),v){case 1:x[M].fn.call(x[M].context);break;case 2:x[M].fn.call(x[M].context,d);break;case 3:x[M].fn.call(x[M].context,d,f);break;case 4:x[M].fn.call(x[M].context,d,f,m);break;default:if(!S)for(A=1,S=new Array(v-1);A<v;A++)S[A-1]=arguments[A];x[M].fn.apply(x[M].context,S)}}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,m){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var b=this._events[p];if(b.fn)b.fn===d&&(!m||b.once)&&(!f||b.context===f)&&o(this,p);else{for(var y=0,x=[],v=b.length;y<v;y++)(b[y].fn!==d||m&&!b[y].once||f&&b[y].context!==f)&&x.push(b[y]);x.length?this._events[p]=x.length===1?x[0]:x:o(this,p)}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})(SC)),SC.exports}var zMe=UMe();const BMe=fl(zMe);var H0=new BMe,d3="recharts.syncEvent.tooltip",R$="recharts.syncEvent.brush",ZE=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!cl(n))return t[n]}},$Me={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},NQ=Ss({name:"options",initialState:$Me,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),HMe=NQ.reducer,{createEventEmitter:VMe}=NQ.actions;function GMe(t){return t.tooltip.syncInteraction}var WMe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},AQ=Ss({name:"chartData",initialState:WMe,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:D$,setDataStartEndIndexes:qMe,setComputedData:YZe}=AQ.actions,KMe=AQ.reducer,XMe=["x","y"];function O$(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 Qm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O$(Object(n),!0).forEach(function(r){YMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YMe(t,e,n){return(e=ZMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZMe(t){var e=QMe(t,"string");return typeof e=="symbol"?e:e+""}function QMe(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 JMe(t,e){if(t==null)return{};var n,r,i=eEe(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 eEe(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 tEe(){var t=Ht(GO),e=Ht(WO),n=vr(),r=Ht(vZ),i=Ht(Nu),a=uh(),o=My(),l=Ht(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return lh;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x:b,y}=p,x=JMe(p,XMe),{x:v,y:S,width:M,height:N}=d.payload.sourceViewBox,A=Qm(Qm({},x),{},{x:o.x+(M?(b-v)/M:0)*o.width,y:o.y+(N?(y-S)/N:0)*o.height});n(Qm(Qm({},d),{},{payload:Qm(Qm({},d.payload),{},{coordinate:A})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var C={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,C);k=i[D]}else r==="value"&&(k=i.find(K=>String(K.value)===d.payload.label));var{coordinate:T}=d.payload;if(k==null||d.payload.active===!1||T==null||o==null){n(l3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:U}=T,O=Math.min(R,o.x+o.width),q=Math.min(U,o.y+o.height),j={x:a==="horizontal"?k.coordinate:O,y:a==="horizontal"?q:k.coordinate},W=l3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return H0.on(d3,c),()=>{H0.off(d3,c)}},[l,n,e,t,r,i,a,o])}function nEe(){var t=Ht(GO),e=Ht(WO),n=vr();w.useEffect(()=>{if(t==null)return lh;var r=(i,a,o)=>{e!==o&&t===i&&n(qMe(a))};return H0.on(R$,r),()=>{H0.off(R$,r)}},[n,e,t])}function rEe(){var t=vr();w.useEffect(()=>{t(VMe())},[t]),tEe(),nEe()}function iEe(t,e,n,r,i,a){var o=Ht(p=>dMe(p,t,e)),l=Ht(WO),c=Ht(GO),u=Ht(vZ),d=Ht(GMe),f=d?.active,m=My();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=l3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});H0.emit(d3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function L$(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?L$(Object(n),!0).forEach(function(r){aEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aEe(t,e,n){return(e=sEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sEe(t){var e=oEe(t,"string");return typeof e=="symbol"?e:e+""}function oEe(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 lEe(t){return t.dataKey}function cEe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(q0e,e)}var F$=[],uEe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function iw(t){var e,n,r=Hr(t,uEe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:b,useTranslate3d:y,wrapperStyle:x,cursor:v,shared:S,trigger:M,defaultIndex:N,portal:A,axisId:k}=r,C=vr(),D=typeof N=="number"?String(N):N;w.useEffect(()=>{C(sSe({shared:S,trigger:M,axisId:k,active:i,defaultIndex:D}))},[C,S,M,k,i,D]);var T=My(),R=pY(),U=eSe(S),{activeIndex:O,isActive:q}=(e=Ht(le=>mMe(le,U,M,D)))!==null&&e!==void 0?e:{},j=Ht(le=>fMe(le,U,M,D)),W=Ht(le=>SQ(le,U,M,D)),K=Ht(le=>hMe(le,U,M,D)),G=j,J=FMe(),ie=(n=i??q)!==null&&n!==void 0?n:!1,[re,z]=xX([G,ie]),V=U==="axis"?W:void 0;iEe(U,M,K,V,O,ie);var Z=A??J;if(Z==null||T==null||U==null)return null;var ne=G??F$;ie||(ne=F$),u&&ne.length&&(ne=dX(ne.filter(le=>le.value!=null&&(le.hide!==!0||r.includeHidden)),m,lEe));var he=ne.length>0,fe=w.createElement(eye,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:ie,coordinate:K,hasPayload:he,offset:f,position:p,reverseDirection:b,useTranslate3d:y,viewBox:T,wrapperStyle:x,lastBoundingBox:re,innerRef:z,hasPortalFromProps:!!A},cEe(c,I$(I$({},r),{},{payload:ne,label:V,active:ie,activeIndex:O,coordinate:K,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Xc.createPortal(fe,Z),ie&&w.createElement(IMe,{cursor:v,tooltipEventType:U,coordinate:K,payload:ne,index:O}))}var zy=t=>null;zy.displayName="Cell";function dEe(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=fEe(t,"string");return typeof e=="symbol"?e:e+""}function fEe(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 mEe{constructor(e){dEe(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 U$(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 pEe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U$(Object(n),!0).forEach(function(r){gEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gEe(t,e,n){return(e=xEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xEe(t){var e=bEe(t,"string");return typeof e=="symbol"?e:e+""}function bEe(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 yEe={cacheSize:2e3,enableCache:!0},TQ=pEe({},yEe),z$=new mEe(TQ.cacheSize),vEe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},B$="recharts_measurement_span";function _Ee(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 $$=(t,e)=>{try{var n=document.getElementById(B$);n||(n=document.createElement("span"),n.setAttribute("id",B$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,vEe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},n0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Ay.isSsr)return{width:0,height:0};if(!TQ.enableCache)return $$(e,n);var r=_Ee(e,n),i=z$.get(r);if(i)return i;var a=$$(e,n);return z$.set(r,a),a},CQ;function wEe(t,e,n){return(e=SEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SEe(t){var e=MEe(t,"string");return typeof e=="symbol"?e:e+""}function MEe(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 H$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,V$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,EEe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,NEe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,AEe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},TEe=["cm","mm","pt","pc","in","Q","px"];function CEe(t){return TEe.includes(t)}var Wp="NaN";function kEe(t,e){return t*AEe[e]}class ma{static parse(e){var n,[,r,i]=(n=NEe.exec(e))!==null&&n!==void 0?n:[];return r==null?ma.NaN:new ma(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,cl(e)&&(this.unit=""),n!==""&&!EEe.test(n)&&(this.num=NaN,this.unit=""),CEe(n)&&(this.num=kEe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ma(NaN,""):new ma(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ma(NaN,""):new ma(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ma(NaN,""):new ma(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ma(NaN,""):new ma(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return cl(this.num)}}CQ=ma;wEe(ma,"NaN",new CQ(NaN,""));function kQ(t){if(t==null||t.includes(Wp))return Wp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=H$.exec(e))!==null&&n!==void 0?n:[],o=ma.parse(r??""),l=ma.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Wp;e=e.replace(H$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=V$.exec(e))!==null&&u!==void 0?u:[],p=ma.parse(d??""),b=ma.parse(m??""),y=f==="+"?p.add(b):p.subtract(b);if(y.isNaN())return Wp;e=e.replace(V$,y.toString())}return e}var G$=/\(([^()]*)\)/;function jEe(t){for(var e=t,n;(n=G$.exec(e))!=null;){var[,r]=n;e=e.replace(G$,kQ(r))}return e}function PEe(t){var e=t.replace(/\s+/g,"");return e=jEe(e),e=kQ(e),e}function REe(t){try{return PEe(t)}catch{return Wp}}function MC(t){var e=REe(t.slice(5,-1));return e===Wp?"":e}var DEe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],OEe=["dx","dy","angle","className","breakAll"];function h3(){return h3=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},h3.apply(null,arguments)}function W$(t,e){if(t==null)return{};var n,r,i=LEe(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 LEe(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 jQ=/[ \f\n\r\t\v\u2028\u2029]+/,PQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Fr(e)||(n?i=e.toString().split(""):i=e.toString().split(jQ));var a=i.map(l=>({word:l,width:n0(l,r).width})),o=n?0:n0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function IEe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var RQ=(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},[]),DQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),FEe="…",q$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=PQ({breakAll:n,style:r,children:c+FEe});if(!u)return[!1,[]];var d=RQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||DQ(d).width>Number(a);return[f,d]},UEe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Ut(a),d=String(o),f=RQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||DQ(f).width>Number(r);if(!m)return f;for(var p=0,b=d.length-1,y=0,x;p<=b&&y<=d.length-1;){var v=Math.floor((p+b)/2),S=v-1,[M,N]=q$(d,S,c,l,a,r,n,i),[A]=q$(d,v,c,l,a,r,n,i);if(!M&&!A&&(p=v+1),M&&A&&(b=v-1),!M&&A){x=N;break}y++}return x||f},K$=t=>{var e=Fr(t)?[]:t.toString().split(jQ);return[{words:e,width:void 0}]},zEe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Ay.isSsr){var l,c,u=PQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return K$(r);return UEe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return K$(r)},OQ="#808080",BEe={angle:0,breakAll:!1,capHeight:"0.71em",fill:OQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},QE=w.forwardRef((t,e)=>{var n=Hr(t,BEe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=W$(n,DEe),m=w.useMemo(()=>zEe({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:p,dy:b,angle:y,className:x,breakAll:v}=f,S=W$(f,OEe);if(!Po(r)||!Po(i)||m.length===0)return null;var M=Number(r)+(Ut(p)?p:0),N=Number(i)+(Ut(b)?b:0);if(!gn(M)||!gn(N))return null;var A;switch(d){case"start":A=MC("calc(".concat(o,")"));break;case"middle":A=MC("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:A=MC("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[],C=m[0];if(c&&C!=null){var D=C.width,{width:T}=f;k.push("scale(".concat(Ut(T)&&Ut(D)?T/D:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(M,", ").concat(N,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",h3({},Sa(S),{ref:e,x:M,y:N,className:zn("recharts-text",x),textAnchor:u,fill:l.includes("url")?OQ:l}),m.map((R,U)=>{var O=R.words.join(v?"":" ");return w.createElement("tspan",{x:M,dy:U===0?A:a,key:"".concat(O,"-").concat(U)},O)}))});QE.displayName="Text";function X$(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 Nl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(r){$Ee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(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=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:a,y:o,height:l,upperWidth:c,lowerWidth:u}=dO(e),d=a,f=a+(c-u)/2,m=(d+f)/2,p=(c+u)/2,b=d+c/2,y=l>=0?1:-1,x=y*r,v=y>0?"end":"start",S=y>0?"start":"end",M=c>=0?1:-1,N=M*r,A=M>0?"end":"start",k=M>0?"start":"end",C=i;if(n==="top"){var D={x:d+c/2,y:o-x,horizontalAnchor:"middle",verticalAnchor:v};return C&&(D.height=Math.max(o-C.y,0),D.width=c),D}if(n==="bottom"){var T={x:f+u/2,y:o+l+x,horizontalAnchor:"middle",verticalAnchor:S};return C&&(T.height=Math.max(C.y+C.height-(o+l),0),T.width=u),T}if(n==="left"){var R={x:m-N,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"};return C&&(R.width=Math.max(R.x-C.x,0),R.height=l),R}if(n==="right"){var U={x:m+p+N,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"};return C&&(U.width=Math.max(C.x+C.width-U.x,0),U.height=l),U}var O=C?{width:p,height:l}:{};return n==="insideLeft"?Nl({x:m+N,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},O):n==="insideRight"?Nl({x:m+p-N,y:o+l/2,horizontalAnchor:A,verticalAnchor:"middle"},O):n==="insideTop"?Nl({x:d+c/2,y:o+x,horizontalAnchor:"middle",verticalAnchor:S},O):n==="insideBottom"?Nl({x:f+u/2,y:o+l-x,horizontalAnchor:"middle",verticalAnchor:v},O):n==="insideTopLeft"?Nl({x:d+N,y:o+x,horizontalAnchor:k,verticalAnchor:S},O):n==="insideTopRight"?Nl({x:d+c-N,y:o+x,horizontalAnchor:A,verticalAnchor:S},O):n==="insideBottomLeft"?Nl({x:f+N,y:o+l-x,horizontalAnchor:k,verticalAnchor:v},O):n==="insideBottomRight"?Nl({x:f+u-N,y:o+l-x,horizontalAnchor:A,verticalAnchor:v},O):n&&typeof n=="object"&&(Ut(n.x)||Vf(n.x))&&(Ut(n.y)||Vf(n.y))?Nl({x:a+La(n.x,p),y:o+La(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},O):Nl({x:b,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},O)},WEe=["labelRef"],qEe=["content"];function Y$(t,e){if(t==null)return{};var n,r,i=KEe(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 KEe(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 Z$(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 Ub(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z$(Object(n),!0).forEach(function(r){XEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XEe(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(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 Wc(){return Wc=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},Wc.apply(null,arguments)}var LQ=w.createContext(null),IQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return w.createElement(LQ.Provider,{value:c},l)},FQ=()=>{var t=w.useContext(LQ),e=My();return t||(e?dO(e):void 0)},QEe=w.createContext(null),JEe=()=>{var t=w.useContext(QEe),e=Ht(EZ);return t||e},eNe=t=>{var{value:e,formatter:n}=t,r=Fr(t.children)?e:t.children;return typeof n=="function"?n(r):r},A4=t=>t!=null&&typeof t=="function",tNe=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},nNe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:p}=i,b=(u+d)/2,y=tNe(f,m),x=y>=0?1:-1,v,S;switch(e){case"insideStart":v=f+x*a,S=p;break;case"insideEnd":v=m-x*a,S=!p;break;case"end":v=m+x*a,S=p;break;default:throw new Error("Unsupported position ".concat(e))}S=y<=0?S:!S;var M=bi(l,c,b,v),N=bi(l,c,b,v+(S?1:-1)*359),A="M".concat(M.x,",").concat(M.y,`
  44. A`).concat(b,",").concat(b,",0,1,").concat(S?0:1,`,
  45. `).concat(N.x,",").concat(N.y),k=Fr(t.id)?k0("recharts-radial-line-"):t.id;return w.createElement("text",Wc({},r,{dominantBaseline:"central",className:zn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:A})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},rNe=(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}=bi(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 m=(a+o)/2,{x:p,y:b}=bi(r,i,m,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},aw=t=>t!=null&&"cx"in t&&Ut(t.cx),iNe={angle:0,offset:5,zIndex:ni.label,position:"middle",textBreakAll:!1};function aNe(t){if(!aw(t))return t;var{cx:e,cy:n,outerRadius:r}=t,i=r*2;return{x:e-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function pd(t){var e=Hr(t,iNe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,f=JEe(),m=FQ(),p=i==="center"?m:f??m,b,y,x;n==null?b=p:aw(n)?b=n:b=dO(n);var v=aNe(b);if(!b||Fr(a)&&Fr(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var S=Ub(Ub({},e),{},{viewBox:b});if(w.isValidElement(l)){var{labelRef:M}=S,N=Y$(S,WEe);return w.cloneElement(l,N)}if(typeof l=="function"){var{content:A}=S,k=Y$(S,qEe);if(y=w.createElement(l,k),w.isValidElement(y))return y}else y=eNe(e);var C=Sa(e);if(aw(b)){if(i==="insideStart"||i==="insideEnd"||i==="end")return nNe(e,i,y,C,b);x=rNe(b,e.offset,e.position)}else{if(!v)return null;var D=GEe({viewBox:v,position:i,offset:e.offset,parentViewBox:aw(r)?void 0:r});x=Ub(Ub({x:D.x,y:D.y,textAnchor:D.horizontalAnchor,verticalAnchor:D.verticalAnchor},D.width!==void 0?{width:D.width}:{}),D.height!==void 0?{height:D.height}:{})}return w.createElement(Fa,{zIndex:e.zIndex},w.createElement(QE,Wc({ref:d,className:zn("recharts-label",c)},C,x,{textAnchor:IEe(C.textAnchor)?C.textAnchor:x.textAnchor,breakAll:u}),y))}pd.displayName="Label";var sNe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(pd,Wc({key:"label-implicit"},r)):Po(t)?w.createElement(pd,Wc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===pd?w.cloneElement(t,Ub({key:"label-implicit"},r)):w.createElement(pd,Wc({key:"label-implicit",content:t},r)):A4(t)?w.createElement(pd,Wc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(pd,Wc({},t,{key:"label-implicit"},r)):null};function UQ(t){var{label:e,labelRef:n}=t,r=FQ();return sNe(e,r,n)||null}var EC={},NC={},Q$;function oNe(){return Q$||(Q$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(NC)),NC}var AC={},J$;function lNe(){return J$||(J$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(AC)),AC}var eH;function cNe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oNe(),n=lNe(),r=eO();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(EC)),EC}var TC,tH;function uNe(){return tH||(tH=1,TC=cNe().last),TC}var dNe=uNe();const hNe=fl(dNe);var fNe=["valueAccessor"],mNe=["dataKey","clockWise","id","textBreakAll","zIndex"];function MS(){return MS=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},MS.apply(null,arguments)}function nH(t,e){if(t==null)return{};var n,r,i=pNe(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 pNe(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 gNe=t=>Array.isArray(t.value)?hNe(t.value):t.value,zQ=w.createContext(void 0),T4=zQ.Provider,BQ=w.createContext(void 0),xNe=BQ.Provider;function bNe(){return w.useContext(zQ)}function yNe(){return w.useContext(BQ)}function sw(t){var{valueAccessor:e=gNe}=t,n=nH(t,fNe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=nH(n,mNe),u=bNe(),d=yNe(),f=u||d;return!f||!f.length?null:w.createElement(Fa,{zIndex:l??ni.label},w.createElement($r,{className:"recharts-label-list"},f.map((m,p)=>{var b,y=Fr(r)?e(m,p):Jn(m.payload,r),x=Fr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(pd,MS({key:"label-".concat(p)},Sa(m),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:m.fill,parentViewBox:m.parentViewBox,value:y,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}sw.displayName="LabelList";function JE(t){var{label:e}=t;return e?e===!0?w.createElement(sw,{key:"labelList-implicit"}):w.isValidElement(e)||A4(e)?w.createElement(sw,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(sw,MS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function f3(){return f3=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},f3.apply(null,arguments)}var $Q=t=>{var{cx:e,cy:n,r,className:i}=t,a=zn("recharts-dot",i);return Ut(e)&&Ut(n)&&Ut(r)?w.createElement("circle",f3({},Qa(t),JD(t),{className:a,cx:e,cy:n,r})):null},HQ=t=>t.graphicalItems.polarItems,vNe=tt([Vr,Ry],ZO),eN=tt([HQ,ii,vNe],QO),_Ne=tt([eN],JO),tN=tt([_Ne,UE],e4),wNe=tt([tN,ii,eN],n4);tt([tN,ii,eN],(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 rH=()=>{},SNe=tt([tN,ii,eN,KE,Vr],s4),MNe=tt([ii,i4,a4,rH,SNe,rH,Fn,Vr],o4),VQ=tt([ii,Fn,tN,wNe,Py,Vr,MNe],l4),ENe=tt([VQ,rx,fh],d4),NNe=tt([ii,VQ,ENe,Vr],f4);tt([fh,NNe],AZ);var ANe={radiusAxis:{},angleAxis:{}},GQ=Ss({name:"polarAxis",initialState:ANe,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:ZZe,removeRadiusAxis:QZe,addAngleAxis:JZe,removeAngleAxis:eQe}=GQ.actions,TNe=GQ.reducer;function WQ(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function iH(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 aH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iH(Object(n),!0).forEach(function(r){CNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CNe(t,e,n){return(e=kNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kNe(t){var e=jNe(t,"string");return typeof e=="symbol"?e:e+""}function jNe(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 PNe=(t,e)=>e,C4=tt([HQ,PNe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),RNe=[],k4=(t,e,n)=>n?.length===0?RNe:n,qQ=tt([UE,C4,k4],(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=>aH(aH({},e.presentationProps),a.props))),i!=null)return i}}),DNe=tt([qQ,C4,k4],(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:ch(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),ONe=tt([qQ,C4,k4,Pi],(t,e,n,r)=>{if(!(e==null||t==null))return L2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),CC={exports:{}},ur={};var sH;function LNe(){if(sH)return ur;sH=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"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var x=y.$$typeof;switch(x){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case m:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return x}}case e:return x}}}return ur.ContextConsumer=a,ur.ContextProvider=o,ur.Element=t,ur.ForwardRef=l,ur.Fragment=n,ur.Lazy=f,ur.Memo=d,ur.Portal=e,ur.Profiler=i,ur.StrictMode=r,ur.Suspense=c,ur.SuspenseList=u,ur.isContextConsumer=function(y){return b(y)===a},ur.isContextProvider=function(y){return b(y)===o},ur.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},ur.isForwardRef=function(y){return b(y)===l},ur.isFragment=function(y){return b(y)===n},ur.isLazy=function(y){return b(y)===f},ur.isMemo=function(y){return b(y)===d},ur.isPortal=function(y){return b(y)===e},ur.isProfiler=function(y){return b(y)===i},ur.isStrictMode=function(y){return b(y)===r},ur.isSuspense=function(y){return b(y)===c},ur.isSuspenseList=function(y){return b(y)===u},ur.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===o||y.$$typeof===a||y.$$typeof===l||y.$$typeof===p||y.getModuleId!==void 0)},ur.typeOf=b,ur}var oH;function INe(){return oH||(oH=1,CC.exports=LNe()),CC.exports}var FNe=INe(),lH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",cH=null,kC=null,KQ=t=>{if(t===cH&&Array.isArray(kC))return kC;var e=[];return w.Children.forEach(t,n=>{Fr(n)||(FNe.isFragment(n)?e=e.concat(KQ(n.props.children)):e.push(n))}),kC=e,cH=t,e};function j4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>lH(i)):r=[lH(e)],KQ(t).forEach(i=>{var a=Hf(i,"type.displayName")||Hf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var P4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,jC={},uH;function UNe(){return uH||(uH=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})(jC)),jC}var PC,dH;function zNe(){return dH||(dH=1,PC=UNe().isPlainObject),PC}var BNe=zNe();const $Ne=fl(BNe);var hH,fH,mH,pH,gH;function xH(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 bH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xH(Object(n),!0).forEach(function(r){HNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xH(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 ES(){return ES=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},ES.apply(null,arguments)}function pb(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var yH=(t,e,n,r,i)=>{var a=n-r,o;return o=Zr(hH||(hH=pb(["M ",",",""])),t,e),o+=Zr(fH||(fH=pb(["L ",",",""])),t+n,e),o+=Zr(mH||(mH=pb(["L ",",",""])),t+n-a/2,e+i),o+=Zr(pH||(pH=pb(["L ",",",""])),t+n-a/2-r,e+i),o+=Zr(gH||(gH=pb(["L ",","," Z"])),t,e),o},WNe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},qNe=t=>{var e=Hr(t,WNe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[p,b]=w.useState(-1),y=w.useRef(i),x=w.useRef(a),v=w.useRef(o),S=w.useRef(n),M=w.useRef(r),N=Qg(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&b(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var A=zn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",ES({},Sa(e),{className:A,d:yH(n,r,i,a,o)})));var k=y.current,C=x.current,D=v.current,T=S.current,R=M.current,U="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),q=gY(["strokeDasharray"],u,c);return w.createElement(Zg,{animationId:N,key:N,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var W=Zn(k,i,j),K=Zn(C,a,j),G=Zn(D,o,j),J=Zn(T,n,j),ie=Zn(R,r,j);m.current&&(y.current=W,x.current=K,v.current=G,S.current=J,M.current=ie);var re=j>0?{transition:q,strokeDasharray:O}:{strokeDasharray:U};return w.createElement("path",ES({},Sa(e),{className:A,d:yH(J,ie,W,K,G),ref:m,style:bH(bH({},re),e.style)}))})},KNe=["option","shapeType","activeClassName"];function XNe(t,e){if(t==null)return{};var n,r,i=YNe(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 YNe(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 vH(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 NS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vH(Object(n),!0).forEach(function(r){ZNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZNe(t,e,n){return(e=QNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QNe(t){var e=JNe(t,"string");return typeof e=="symbol"?e:e+""}function JNe(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 e2e(t,e){return NS(NS({},e),t)}function t2e(t,e){return t==="symbols"}function _H(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(vY,n);case"trapezoid":return w.createElement(qNe,n);case"sector":return w.createElement(MY,n);case"symbols":if(t2e(e))return w.createElement(QD,n);break;case"curve":return w.createElement(tg,n);default:return null}}function n2e(t){return w.isValidElement(t)?t.props:t}function R4(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=XNe(t,KNe),a;if(w.isValidElement(e))a=w.cloneElement(e,NS(NS({},i),n2e(e)));else if(typeof e=="function")a=e(i,i.index);else if($Ne(e)&&typeof e!="boolean"){var o=e2e(e,i);a=w.createElement(_H,{shapeType:n,elementProps:o})}else{var l=i;a=w.createElement(_H,{shapeType:n,elementProps:l})}return i.isActive?w.createElement($r,{className:r},a):a}var D4=(t,e,n)=>{var r=vr();return(i,a)=>o=>{t?.(i,a,o),r(rQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},O4=t=>{var e=vr();return(n,r)=>i=>{t?.(n,r,i),e(oSe())}},L4=(t,e,n)=>{var r=vr();return(i,a)=>o=>{t?.(i,a,o),r(lSe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function nN(t){var{tooltipEntrySettings:e}=t,n=vr(),r=Ri(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(rSe(e)):i.current!==e&&n(iSe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(aSe(i.current)),i.current=null)},[n]),null}function I4(t){var{legendPayload:e}=t,n=vr(),r=Ri(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(hY(e)):i.current!==e&&n(fY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(mY(i.current)),i.current=null)},[n]),null}function r2e(t){var{legendPayload:e}=t,n=vr(),r=Ht(Fn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(hY(e)):i.current!==e&&n(fY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(mY(i.current)),i.current=null)},[n]),null}var RC,i2e=()=>{var[t]=w.useState(()=>k0("uid-"));return t},a2e=(RC=eoe.useId)!==null&&RC!==void 0?RC:i2e;function s2e(t,e){var n=a2e();return e||(t?"".concat(t,"-").concat(n):n)}var o2e=w.createContext(void 0),rN=t=>{var{id:e,type:n,children:r}=t,i=s2e("recharts-".concat(n),e);return w.createElement(o2e.Provider,{value:i},r(i))},l2e={cartesianItems:[],polarItems:[]},XQ=Ss({name:"graphicalItems",initialState:l2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Rr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=nl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Rr()},removeCartesianGraphicalItem:{reducer(t,e){var n=nl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Rr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Rr()},removePolarGraphicalItem:{reducer(t,e){var n=nl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Rr()}}}),{addCartesianGraphicalItem:c2e,replaceCartesianGraphicalItem:u2e,removeCartesianGraphicalItem:d2e,addPolarGraphicalItem:h2e,removePolarGraphicalItem:f2e}=XQ.actions,m2e=XQ.reducer,p2e=t=>{var e=vr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(c2e(t)):n.current!==t&&e(u2e({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(d2e(n.current)),n.current=null)},[e]),null},F4=w.memo(p2e);function g2e(t){var e=vr();return w.useLayoutEffect(()=>(e(h2e(t)),()=>{e(f2e(t))}),[e,t]),null}var x2e=["key"],b2e=["onMouseEnter","onClick","onMouseLeave"],y2e=["id"],v2e=["id"];function wH(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 Qr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wH(Object(n),!0).forEach(function(r){_2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _2e(t,e,n){return(e=w2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w2e(t){var e=S2e(t,"string");return typeof e=="symbol"?e:e+""}function S2e(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 Zd(){return Zd=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},Zd.apply(null,arguments)}function iN(t,e){if(t==null)return{};var n,r,i=M2e(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 M2e(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 E2e(t){var e=w.useMemo(()=>j4(t.children,zy),[t.children]),n=Ht(r=>DNe(r,t.id,e));return n==null?null:w.createElement(r2e,{legendPayload:n})}var N2e=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:r.map(m=>m.tooltipPayload),getPosition:m=>{var p;return(p=r[Number(m)])===null||p===void 0?void 0:p.tooltipPosition},settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:ch(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(nN,{tooltipEntrySettings:f})}),A2e=(t,e)=>t>e?"start":t<e?"end":"middle",T2e=(t,e,n)=>La(typeof e=="function"?e(t):e,n,n*.8),C2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=_Y(a,o),c=i+La(t.cx,a,a/2),u=r+La(t.cy,o,o/2),d=La(t.innerRadius,l,0),f=T2e(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},k2e=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},j2e=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=zn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=iN(e,x2e);return w.createElement(tg,Zd({},i,{type:"linear",className:n}))},P2e=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=zn("recharts-pie-label-text",WQ(t));return w.createElement(QE,Zd({},e,{alignmentBaseline:"middle",className:i}),r)};function R2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Qa(n),c=Bf(i),u=Bf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,p)=>{var b=(m.startAngle+m.endAngle)/2,y=bi(m.cx,m.cy,m.outerRadius+d,b),x=Qr(Qr(Qr(Qr({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:A2e(y.x,m.cx)},y),v=Qr(Qr(Qr(Qr({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[bi(m.cx,m.cy,m.outerRadius,b),y],key:"line"});return w.createElement(Fa,{zIndex:ni.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement($r,null,a&&j2e(a,v),P2e(i,x,Jn(m,o))))});return w.createElement($r,{className:"recharts-pie-labels"},f)}function D2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(JE,{label:i}):w.createElement(R2e,{sectors:e,props:n,showLabels:r})}function O2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Ht(Yd),c=Ht(w4),u=Ht(qSe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=iN(i,b2e),b=D4(d,i.dataKey,o),y=O4(m),x=L4(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var M=u==null||u===o,N=String(S)===l&&(c==null||i.dataKey===c)&&M,A=l?r:null,k=n&&N?n:A,C=Qr(Qr({},v),{},{stroke:v.stroke,tabIndex:-1,[QX]:S,[JX]:o});return w.createElement($r,Zd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},vy(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),w.createElement(R4,Zd({option:a??k,index:S,shapeType:"sector",isActive:N},C)))}))}function L2e(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,m=Math.abs(n.minAngle),p=k2e(l,c),b=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(k=>Jn(k,u,0)!==0).length,v=(b>=360?x:x-1)*y,S=b-x*m-v,M=r.reduce((k,C)=>{var D=Jn(C,u,0);return k+(Ut(D)?D:0)},0),N;if(M>0){var A;N=r.map((k,C)=>{var D=Jn(k,u,0),T=Jn(k,d,C),R=C2e(n,a,k),U=(Ut(D)?D:0)/M,O,q=Qr(Qr({},k),i&&i[C]&&i[C].props);C?O=A.endAngle+Wi(p)*y*(D!==0?1:0):O=l;var j=O+Wi(p)*((D!==0?m:0)+U*S),W=(O+j)/2,K=(R.innerRadius+R.outerRadius)/2,G=[{name:T,value:D,payload:q,dataKey:u,type:f,graphicalItemId:n.id}],J=bi(R.cx,R.cy,K,W);return A=Qr(Qr(Qr(Qr({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:T,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:J},q),R),{},{value:D,dataKey:u,startAngle:O,endAngle:j,payload:q,paddingAngle:Wi(p)*y}),A})}return N}function I2e(t){var{showLabels:e,sectors:n,children:r}=t,i=w.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 w.createElement(xNe,{value:e?i:void 0},r)}function F2e(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:m}=e,p=Qg(e,"recharts-pie-"),b=n.current,[y,x]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),x(!1)},[m]),S=w.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return w.createElement(I2e,{showLabels:!y,sectors:i},w.createElement(Zg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:v,key:p},M=>{var N,A=[],k=i&&i[0],C=(N=k?.startAngle)!==null&&N!==void 0?N:0;return i?.forEach((D,T)=>{var R=b&&b[T],U=T>0?Hf(D,"paddingAngle",0):0;if(R){var O=Zn(R.endAngle-R.startAngle,D.endAngle-D.startAngle,M),q=Qr(Qr({},D),{},{startAngle:C+U,endAngle:C+O+U});A.push(q),C=q.endAngle}else{var{endAngle:j,startAngle:W}=D,K=Zn(0,j-W,M),G=Qr(Qr({},D),{},{startAngle:C+U,endAngle:C+K+U});A.push(G),C=G.endAngle}}),n.current=A,w.createElement($r,null,w.createElement(O2e,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(D2e,{showLabels:!y,sectors:i,props:e}),e.children)}var U2e={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:ni.area};function z2e(t){var{id:e}=t,n=iN(t,y2e),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>j4(t.children,zy),[t.children]),l=Ht(d=>ONe(d,e,o)),c=w.useRef(null),u=zn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement($r,{tabIndex:a,className:u})):w.createElement(Fa,{zIndex:t.zIndex},w.createElement(N2e,{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,id:e}),w.createElement($r,{tabIndex:a,className:u},w.createElement(F2e,{props:Qr(Qr({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function YQ(t){var e=Hr(t,U2e),{id:n}=e,r=iN(e,v2e),i=Qa(r);return w.createElement(rN,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(g2e,{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}),w.createElement(E2e,Zd({},r,{id:a})),w.createElement(z2e,Zd({},r,{id:a}))))}YQ.displayName="Pie";var B2e=["points"];function SH(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 DC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SH(Object(n),!0).forEach(function(r){$2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $2e(t,e,n){return(e=H2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H2e(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 AS(){return AS=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},AS.apply(null,arguments)}function G2e(t,e){if(t==null)return{};var n,r,i=W2e(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 W2e(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 q2e(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=zn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=G2e(a,B2e);return w.createElement($Q,AS({},l,{className:i}))}function K2e(t,e){return t==null?!1:e?!0:t.length===1}function ZQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=ni.scatter}=t;if(!K2e(e,n))return null;var d=P4(n),f=gpe(n),m=e.map((b,y)=>{var x,v,S=DC(DC(DC({r:3},o),f),{},{index:y,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(v=b.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return w.createElement(q2e,{key:"dot-".concat(y),option:n,dotProps:S,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(Fa,{zIndex:u},w.createElement($r,AS({className:r},p),m))}function MH(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 EH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MH(Object(n),!0).forEach(function(r){X2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X2e(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=Z2e(t,"string");return typeof e=="symbol"?e:e+""}function Z2e(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 QQ=0,Q2e={xAxis:{},yAxis:{},zAxis:{}},JQ=Ss({name:"cartesianAxis",initialState:Q2e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Rr()},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:Rr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Rr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Rr()},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:Rr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Rr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Rr()},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:Rr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Rr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a,o=i.widthHistory||[];if(o.length===3&&o[0]===o[2]&&r===o[1]&&r!==i.width&&Math.abs(r-((a=o[0])!==null&&a!==void 0?a:0))<=1)return;var l=[...o,r].slice(-3);t.yAxis[n]=EH(EH({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:J2e,replaceXAxis:eAe,removeXAxis:tAe,addYAxis:nAe,replaceYAxis:rAe,removeYAxis:iAe,addZAxis:tQe,replaceZAxis:nQe,removeZAxis:rQe,updateYAxisWidth:aAe}=JQ.actions,sAe=JQ.reducer,oAe=tt([Pi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),lAe=tt([oAe,wu,Su],(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)}}),aN=()=>Ht(lAe),cAe=()=>Ht(QSe);function NH(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 OC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NH(Object(n),!0).forEach(function(r){uAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uAe(t,e,n){return(e=dAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dAe(t){var e=hAe(t,"string");return typeof e=="symbol"?e:e+""}function hAe(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 fAe=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=OC(OC(OC({},l),Bf(i)),JD(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement($Q,c),w.createElement($r,{className:"recharts-active-dot",clipPath:o},u)};function m3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=ni.activeDot}=t,l=Ht(Yd),c=cAe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Fr(u)?null:w.createElement(Fa,{zIndex:o},w.createElement(fAe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var AH=(t,e,n)=>{var r=n??t;if(!Fr(r))return La(r,e,0)},mAe=(t,e,n)=>{var r={},i=t.filter(VE),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>{var f=u[d.stackId];return f==null&&(f=[]),f.push(d),u[d.stackId]=f,u},r),l=Object.entries(o).map(u=>{var d,[f,m]=u,p=m.map(y=>y.dataKey),b=AH(e,n,(d=m[0])===null||d===void 0?void 0:d.barSize);return{stackId:f,dataKeys:p,barSize:b}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=AH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]};function TH(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 C_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TH(Object(n),!0).forEach(function(r){pAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pAe(t,e,n){return(e=gAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gAe(t){var e=xAe(t,"string");return typeof e=="symbol"?e:e+""}function xAe(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 bAe(t,e,n,r,i){var a,o=r.length;if(!(o<1)){var l=La(t,n,0,!0),c,u=[];if(gn((a=r[0])===null||a===void 0?void 0:a.barSize)){var d=!1,f=n/o,m=r.reduce((S,M)=>S+(M.barSize||0),0);m+=(o-1)*l,m>=n&&(m-=(o-1)*l,l=0),m>=n&&f>0&&(d=!0,f*=.9,m=o*f);var p=(n-m)/2>>0,b={offset:p-l,size:0};c=r.reduce((S,M)=>{var N,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b.offset+b.size+l,size:d?f:(N=M.barSize)!==null&&N!==void 0?N:0}},k=[...S,A];return b=A.position,k},u)}else{var y=La(e,n,0,!0);n-2*y-(o-1)*l<=0&&(l=0);var x=(n-2*y-(o-1)*l)/o;x>1&&(x>>=0);var v=gn(i)?Math.min(x,i):x;c=r.reduce((S,M,N)=>[...S,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:y+(x+l)*N+(x-v)/2,size:v}}],u)}return c}}var yAe=(t,e,n,r,i,a,o)=>{var l=Fr(o)?e:o,c=bAe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>C_(C_({},u),{},{position:C_(C_({},u.position),{},{offset:u.position.offset-i/2})}))),c},vAe=(t,e)=>{var n=HE(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)}}}},_Ae=(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}};function wAe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&gn(t.zIndex)?t.zIndex:e}var eJ=t=>{var{chartData:e}=t,n=vr(),r=Ri();return w.useEffect(()=>r?()=>{}:(n(D$(e)),()=>{n(D$(void 0))}),[e,n,r]),null},CH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},tJ=Ss({name:"brush",initialState:CH,reducers:{setBrushSettings(t,e){return e.payload==null?CH:e.payload}}}),{setBrushSettings:iQe}=tJ.actions,SAe=tJ.reducer,MAe=(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)}},EAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return MAe({x:e,y:n},{x:r,y:i})};function NAe(t){return(t%180+180)%180}var AAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=NAe(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)},TAe={dots:[],areas:[],lines:[]},nJ=Ss({name:"referenceElements",initialState:TAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=nl(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=nl(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=nl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:aQe,removeDot:sQe,addArea:oQe,removeArea:lQe,addLine:CAe,removeLine:kAe}=nJ.actions,jAe=nJ.reducer,rJ=w.createContext(void 0),PAe=t=>{var{children:e}=t,[n]=w.useState("".concat(k0("recharts"),"-clip")),r=aN();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(rJ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},RAe=()=>w.useContext(rJ);class DAe{constructor(e){var{x:n,y:r}=e;this.xAxisScale=n,this.yAxisScale=r}map(e,n){var r,i,{position:a}=n;return{x:(r=this.xAxisScale.map(e.x,{position:a}))!==null&&r!==void 0?r:0,y:(i=this.yAxisScale.map(e.y,{position:a}))!==null&&i!==void 0?i:0}}mapWithFallback(e,n){var r,i,{position:a,fallback:o}=n,l,c;return o==="rangeMin"?l=this.yAxisScale.rangeMin():o==="rangeMax"?l=this.yAxisScale.rangeMax():l=0,o==="rangeMin"?c=this.xAxisScale.rangeMin():o==="rangeMax"?c=this.xAxisScale.rangeMax():c=0,{x:(r=this.xAxisScale.map(e.x,{position:a}))!==null&&r!==void 0?r:c,y:(i=this.yAxisScale.map(e.y,{position:a}))!==null&&i!==void 0?i:l}}isInRange(e){var{x:n,y:r}=e,i=n==null||this.xAxisScale.isInRange(n),a=r==null||this.yAxisScale.isInRange(r);return i&&a}}function kH(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 jH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kH(Object(n),!0).forEach(function(r){OAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OAe(t,e,n){return(e=LAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LAe(t){var e=IAe(t,"string");return typeof e=="symbol"?e:e+""}function IAe(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 TS(){return TS=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},TS.apply(null,arguments)}var FAe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!gn(e.x1)||!gn(e.y1)||!gn(e.x2)||!gn(e.y2))return null;n=w.createElement("line",TS({},e,{className:"recharts-reference-line-line"}))}return n},UAe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.map(t,{position:n});if(!gn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},zAe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.map(t,{position:n});if(!gn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},BAe=(t,e,n,r)=>{var i=[r.mapWithFallback(t[0],{position:n,fallback:"rangeMin"}),r.mapWithFallback(t[1],{position:n,fallback:"rangeMax"})];return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},$Ae=(t,e,n,r,i,a,o)=>{var{x:l,y:c,segment:u,ifOverflow:d}=o,f=Po(l),m=Po(c);return m?UAe(c,d,r,a,e,n):f?zAe(l,d,r,i,t,n):u!=null&&u.length===2?BAe(u,d,r,new DAe({x:t,y:e})):null};function HAe(t){var e=vr();return w.useEffect(()=>(e(CAe(t)),()=>{e(kAe(t))})),null}function VAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Ri(),l=RAe(),c=Ht(C=>lc(C,e)),u=Ht(C=>cc(C,n)),d=Ht(C=>Eg(C,"xAxis",e,o)),f=Ht(C=>Eg(C,"yAxis",n,o)),m=My();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=$Ae(d,f,m,t.position,c.orientation,u.orientation,t);if(!p)return null;var b=p[0],y=p[1];if(b==null||y==null)return null;var{x,y:v}=b,{x:S,y:M}=y,N=a==="hidden"?"url(#".concat(l,")"):void 0,A=jH(jH({clipPath:N},Sa(t)),{},{x1:x,y1:v,x2:S,y2:M}),k=EAe({x1:x,y1:v,x2:S,y2:M});return w.createElement(Fa,{zIndex:t.zIndex},w.createElement($r,{className:zn("recharts-reference-line",i)},FAe(r,A),w.createElement(IQ,TS({},k,{lowerWidth:k.width,upperWidth:k.width}),w.createElement(UQ,{label:t.label}),t.children)))}var GAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:ni.line};function zb(t){var e=Hr(t,GAe);return w.createElement(w.Fragment,null,w.createElement(HAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(VAe,e))}zb.displayName="ReferenceLine";function iJ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e){var i=t[r];i!==void 0&&n.push(i)}return n}function WAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return AAe(r,n)}function qAe(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 V0(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 KAe(t,e){return iJ(t,e+1)}function XAe(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:iJ(r,u)};var y=c,x,v=()=>(x===void 0&&(x=n(b,y)),x),S=b.coordinate,M=c===0||V0(t,S,v,d,l);M||(c=0,d=o,u+=1),M&&(d=S+t*(v()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}function YAe(t,e,n,r,i){var a=(r||[]).slice(),o=a.length;if(o===0)return[];for(var{start:l,end:c}=e,u=1;u<=o;u++){for(var d=(o-1)%u,f=l,m=!0,p=function(){var N=r[y];if(N==null)return 0;var A=y,k,C=()=>(k===void 0&&(k=n(N,A)),k),D=N.coordinate,T=y===d||V0(t,D,C,f,c);if(!T)return m=!1,1;T&&(f=D+t*(C()/2+i))},b,y=d;y<o&&(b=p(),!(b!==0&&b===1));y+=u);if(m){for(var x=[],v=d;v<o;v+=u){var S=r[v];S!=null&&x.push(S)}return x}}return[]}function PH(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 ja(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){ZAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZAe(t,e,n){return(e=QAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QAe(t){var e=JAe(t,"string");return typeof e=="symbol"?e:e+""}function JAe(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 eTe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(m){var p=a[m];if(p==null)return 1;var b=p,y,x=()=>(y===void 0&&(y=n(p,m)),y);if(m===o-1){var v=t*(b.coordinate+t*x()/2-c);a[m]=b=ja(ja({},b),{},{tickCoord:v>0?b.coordinate-v*t:b.coordinate})}else a[m]=b=ja(ja({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var S=V0(t,b.tickCoord,x,l,c);S&&(c=b.tickCoord-t*(x()/2+i),a[m]=ja(ja({},b),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function tTe(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];if(d!=null){var f=n(d,l-1),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=ja(ja({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=V0(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=ja(ja({},d),{},{isShow:!0}))}}}for(var b=a?l-1:l,y=function(S){var M=o[S];if(M==null)return 1;var N=M,A,k=()=>(A===void 0&&(A=n(M,S)),A);if(S===0){var C=t*(N.coordinate-t*k()/2-c);o[S]=N=ja(ja({},N),{},{tickCoord:C<0?N.coordinate-C*t:N.coordinate})}else o[S]=N=ja(ja({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var D=V0(t,N.tickCoord,k,c,u);D&&(c=N.tickCoord+t*(k()/2+i),o[S]=ja(ja({},N),{},{isShow:!0}))}},x=0;x<b;x++)y(x);return o}function U4(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(Ut(c)||Ay.isSsr){var m;return(m=KAe(i,Ut(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",y=d&&b==="width"?n0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(A,k)=>{var C=typeof u=="function"?u(A.value,k):A.value;return b==="width"?WAe(n0(C,{fontSize:e,letterSpacing:n}),y,f):n0(C,{fontSize:e,letterSpacing:n})[b]},v=i[0],S=i[1],M=i.length>=2&&v!=null&&S!=null?Wi(S.coordinate-v.coordinate):1,N=qAe(a,M,b);return c==="equidistantPreserveStart"?XAe(M,N,x,i,o):c==="equidistantPreserveEnd"?YAe(M,N,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=tTe(M,N,x,i,o,c==="preserveStartEnd"):p=eTe(M,N,x,i,o),p.filter(A=>A.isShow))}var nTe=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},rTe=["axisLine","width","height","className","hide","ticks","axisType"];function iTe(t,e){if(t==null)return{};var n,r,i=aTe(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 aTe(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 Xf(){return Xf=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},Xf.apply(null,arguments)}function RH(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 Yr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){sTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sTe(t,e,n){return(e=oTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oTe(t){var e=lTe(t,"string");return typeof e=="symbol"?e:e+""}function lTe(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 ru={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:ni.axis};function cTe(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=Yr(Yr(Yr({},c),Qa(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=Yr(Yr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=Yr(Yr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",Xf({},u,{className:zn("recharts-cartesian-axis-line",Hf(l,"className"))}))}function uTe(t,e,n,r,i,a,o,l,c){var u,d,f,m,p,b,y=l?-1:1,x=t.tickSize||o,v=Ut(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-y*x,b=f-y*c,p=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*x,p=u-y*c,b=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*x,p=u+y*c,b=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*x,b=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:b}}}function dTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function hTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function fTe(t){var{option:e,tickProps:n,value:r}=t,i,a=zn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,Yr(Yr({},n),{},{className:a}));else if(typeof e=="function")i=e(Yr(Yr({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=zn(o,WQ(e))),i=w.createElement(QE,Xf({},n,{className:o}),r)}return i}var mTe=w.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:m,y:p,width:b,height:y,tickSize:x,tickMargin:v,fontSize:S,letterSpacing:M,getTicksConfig:N,events:A,axisType:k}=t,C=U4(Yr(Yr({},N),{},{ticks:n}),S,M),D=dTe(d,f),T=hTe(d,f),R=Qa(N),U=Bf(r),O={};typeof i=="object"&&(O=i);var q=Yr(Yr({},R),{},{fill:"none"},O),j=C.map(G=>Yr({entry:G},uTe(G,m,p,b,y,d,x,f,v))),W=j.map(G=>{var{entry:J,line:ie}=G;return w.createElement($r,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(J.value,"-").concat(J.coordinate,"-").concat(J.tickCoord)},i&&w.createElement("line",Xf({},q,ie,{className:zn("recharts-cartesian-axis-tick-line",Hf(i,"className"))})))}),K=j.map((G,J)=>{var ie,re,{entry:z,tick:V}=G,Z=Yr(Yr(Yr(Yr({verticalAnchor:T},R),{},{textAnchor:D,stroke:"none",fill:a},V),{},{index:J,payload:z,visibleTicksCount:C.length,tickFormatter:o,padding:c},u),{},{angle:(ie=(re=u?.angle)!==null&&re!==void 0?re:R.angle)!==null&&ie!==void 0?ie:0}),ne=Yr(Yr({},Z),U);return w.createElement($r,Xf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(z.value,"-").concat(z.coordinate,"-").concat(z.tickCoord)},vy(A,z,J)),r&&w.createElement(fTe,{option:r,tickProps:ne,value:"".concat(typeof o=="function"?o(z.value,J):z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&w.createElement(Fa,{zIndex:ni.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),pTe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=iTe(t,rTe),[d,f]=w.useState(""),[m,p]=w.useState(""),b=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return nTe({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=w.useCallback(x=>{if(x){var v=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=v;var S=v[0];if(S){var M=window.getComputedStyle(S),N=M.fontSize,A=M.letterSpacing;(N!==d||A!==m)&&(f(N),p(A))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(Fa,{zIndex:t.zIndex},w.createElement($r,{className:zn("recharts-cartesian-axis",a)},w.createElement(cTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Qa(t)}),w.createElement(mTe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(IQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(UQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),z4=w.forwardRef((t,e)=>{var n=Hr(t,ru);return w.createElement(pTe,Xf({},n,{ref:e}))});z4.displayName="CartesianAxis";var gTe=["x1","y1","x2","y2","key"],xTe=["offset"],bTe=["xAxisId","yAxisId"],yTe=["xAxisId","yAxisId"];function DH(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 Da(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DH(Object(n),!0).forEach(function(r){vTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vTe(t,e,n){return(e=_Te(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Te(t){var e=wTe(t,"string");return typeof e=="symbol"?e:e+""}function wTe(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 hf(){return hf=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},hf.apply(null,arguments)}function CS(t,e){if(t==null)return{};var n,r,i=STe(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 STe(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 MTe=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 w.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aJ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.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=CS(n,gTe),f=(i=Qa(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=CS(f,xTe);r=w.createElement("line",hf({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function ETe(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=CS(t,bTe),c=i.map((u,d)=>{var f=Da(Da({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(aJ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NTe(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=CS(t,yTe),c=i.map((u,d)=>{var f=Da(Da({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(aJ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function ATe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=u[m+1],b=p==null,y=b?i+o-f:p-f;if(y<=0)return null;var x=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:y,width:a,stroke:"none",fill:e[x],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function TTe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=u[m+1],b=p==null,y=b?i+o-f:p-f;if(y<=0)return null;var x=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:y,height:l,stroke:"none",fill:n[x],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var CTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return KX(U4(Da(Da(Da({},ru),n),{},{ticks:XX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},kTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return KX(U4(Da(Da(Da({},ru),n),{},{ticks:XX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},jTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:ni.grid};function kS(t){var e=hO(),n=fO(),r=rY(),i=Da(Da({},Hr(t,jTe)),{},{x:Ut(t.x)?t.x:r.left,y:Ut(t.y)?t.y:r.top,width:Ut(t.width)?t.width:r.width,height:Ut(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,b=Ri(),y=Ht(T=>w$(T,"xAxis",a,b)),x=Ht(T=>w$(T,"yAxis",o,b));if(!Ql(u)||!Ql(d)||!Ut(l)||!Ut(c))return null;var v=i.verticalCoordinatesGenerator||CTe,S=i.horizontalCoordinatesGenerator||kTe,{horizontalPoints:M,verticalPoints:N}=i;if((!M||!M.length)&&typeof S=="function"){var A=m&&m.length,k=S({yAxis:x?Da(Da({},x),{},{ticks:A?m:x.ticks}):void 0,width:e??u,height:n??d,offset:r},A?!0:f);Jw(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(M=k)}if((!N||!N.length)&&typeof v=="function"){var C=p&&p.length,D=v({xAxis:y?Da(Da({},y),{},{ticks:C?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);Jw(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(N=D)}return w.createElement(Fa,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(MTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(ATe,hf({},i,{horizontalPoints:M})),w.createElement(TTe,hf({},i,{verticalPoints:N})),w.createElement(ETe,hf({},i,{offset:r,horizontalPoints:M,xAxis:y,yAxis:x})),w.createElement(NTe,hf({},i,{offset:r,verticalPoints:N,xAxis:y,yAxis:x}))))}kS.displayName="CartesianGrid";var PTe={},sJ=Ss({name:"errorBars",initialState:PTe,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:cQe,replaceErrorBar:uQe,removeErrorBar:dQe}=sJ.actions,RTe=sJ.reducer,DTe=["children"];function OTe(t,e){if(t==null)return{};var n,r,i=LTe(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 LTe(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 ITe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},FTe=w.createContext(ITe);function oJ(t){var{children:e}=t,n=OTe(t,DTe);return w.createElement(FTe.Provider,{value:n},e)}function sN(t,e){var n,r,i=Ht(u=>lc(u,t)),a=Ht(u=>cc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Bi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:$i.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function B4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=aN(),{needClipX:a,needClipY:o,needClip:l}=sN(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}var lJ=(t,e,n,r)=>tc(t,"xAxis",e,r),cJ=(t,e,n,r)=>ec(t,"xAxis",e,r),uJ=(t,e,n,r)=>tc(t,"yAxis",n,r),dJ=(t,e,n,r)=>ec(t,"yAxis",n,r),UTe=tt([Fn,lJ,uJ,cJ,dJ],(t,e,n,r,i)=>gl(t,"xAxis")?Xd(e,r,!1):Xd(n,i,!1)),zTe=(t,e,n,r,i)=>i;function BTe(t){return t.type==="line"}var $Te=tt([Dy,zTe],(t,e)=>t.filter(BTe).find(n=>n.id===e)),HTe=tt([Fn,lJ,uJ,cJ,dJ,$Te,UTe,BO],(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:m}=a,p;if(m!=null&&m.length>0?p=m:p=c?.slice(u,d+1),p!=null)return CCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function hJ(t){var e=Bf(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 LC={exports:{}},IC={};var OH;function VTe(){if(OH)return IC;OH=1;var t=Vg();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 IC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=o(function(){function x(A){if(!v){if(v=!0,S=A,A=f(A),m!==void 0&&b.hasValue){var k=b.value;if(m(k,A))return M=k}return M=A}if(k=M,n(S,A))return k;var C=f(A);return m!==void 0&&m(k,C)?(S=A,k):(S=A,M=C)}var v=!1,S,M,N=d===void 0?null:d;return[function(){return x(u())},N===null?void 0:function(){return x(N())}]},[u,d,f,m]);var y=r(c,p[0],p[1]);return a(function(){b.hasValue=!0,b.value=y},[y]),l(y),y},IC}var LH;function GTe(){return LH||(LH=1,LC.exports=VTe()),LC.exports}GTe();function WTe(t){t()}function qTe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){WTe(()=>{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 IH={notify(){},get:()=>[]};function KTe(t,e){let n,r=IH,i=0,a=!1;function o(y){d();const x=r.subscribe(y);let v=!1;return()=>{v||(v=!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=qTe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=IH)}function m(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return b}var XTe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",YTe=XTe(),ZTe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",QTe=ZTe(),JTe=()=>YTe||QTe?w.useLayoutEffect:w.useEffect,eCe=JTe();function FH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function tCe(t,e){if(FH(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])||!FH(t[n[i]],e[n[i]]))return!1;return!0}var nCe=Symbol.for("react-redux-context"),rCe=typeof globalThis<"u"?globalThis:{};function iCe(){if(!w.createContext)return{};const t=rCe[nCe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var aCe=iCe();function sCe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=KTe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);eCe(()=>{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||aCe;return w.createElement(l.Provider,{value:a},e)}var oCe=sCe,lCe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function cCe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function By(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(lCe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!tCe(t[r],e[r]))return!1}else if(!cCe(t[r],e[r]))return!1;return!0}var uCe=["id"],dCe=["type","layout","connectNulls","needClip","shape"],hCe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function G0(){return G0=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},G0.apply(null,arguments)}function UH(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 Dl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UH(Object(n),!0).forEach(function(r){fCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fCe(t,e,n){return(e=mCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mCe(t){var e=pCe(t,"string");return typeof e=="symbol"?e:e+""}function pCe(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 $4(t,e){if(t==null)return{};var n,r,i=gCe(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 gCe(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 xCe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ch(n,e),payload:t}]},bCe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:n,getPosition:lh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:ch(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(nN,{tooltipEntrySettings:f})}),fJ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function yCe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var vCe=(t,e,n)=>{var r=n.reduce((p,b)=>p+b);if(!r)return fJ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=(d=n[c])!==null&&d!==void 0?d:0,++c){var d,f=n[c];if(f!=null&&u+f>a){l=[...n.slice(0,c),a-u];break}}var m=l.length%2===0?[0,o]:[o];return[...yCe(n,i),...l,...m].map(p=>"".concat(p,"px")).join(", ")};function _Ce(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=$4(r,uCe),u=Qa(c);return w.createElement(ZQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function wCe(t){var{showLabels:e,children:n,points:r}=t,i=w.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 Dl(Dl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(T4,{value:e?i:void 0},n)}function zH(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=$4(a,dCe),m=Dl(Dl({},Sa(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 w.createElement(w.Fragment,null,r?.length>1&&w.createElement(R4,G0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(_Ce,{points:r,clipPathId:e,props:a}))}function SCe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function MCe(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:m,width:p,height:b,onAnimationEnd:y,onAnimationStart:x}=n,v=i.current,S=Qg(o,"recharts-line-"),M=w.useRef(S),[N,A]=w.useState(!1),k=!N,C=w.useCallback(()=>{typeof y=="function"&&y(),A(!1)},[y]),D=w.useCallback(()=>{typeof x=="function"&&x(),A(!0)},[x]),T=SCe(r.current),R=w.useRef(0);M.current!==S&&(R.current=a.current,M.current=S);var U=R.current;return w.createElement(wCe,{points:o,showLabels:k},n.children,w.createElement(Zg,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:D,key:S},O=>{var q=Zn(U,T+U,O),j=Math.min(q,T),W;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(ie=>parseFloat(ie));W=vCe(j,T,K)}else W=fJ(T,j);else W=l==null?void 0:String(l);if(O>0&&T>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var G=v.length/o.length,J=O===1?o:o.map((ie,re)=>{var z=Math.floor(re*G);if(v[z]){var V=v[z];return Dl(Dl({},ie),{},{x:Zn(V.x,ie.x,O),y:Zn(V.y,ie.y,O)})}return m?Dl(Dl({},ie),{},{x:Zn(p*2,ie.x,O),y:Zn(b/2,ie.y,O)}):Dl(Dl({},ie),{},{x:ie.x,y:ie.y})});return i.current=J,w.createElement(zH,{props:n,points:J,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement(zH,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(JE,{label:n.label}))}function ECe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(MCe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var NCe=(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 ACe extends w.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:m,zIndex:p}=this.props;if(e)return null;var b=zn("recharts-line",i),y=f,{r:x,strokeWidth:v}=hJ(n),S=P4(n),M=x*2+v,N=m?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return w.createElement(Fa,{zIndex:p},w.createElement($r,{className:b},m&&w.createElement("defs",null,w.createElement(B4,{clipPathId:y,xAxisId:a,yAxisId:o}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:c-M/2,y:l-M/2,width:u+M,height:d+M}))),w.createElement(oJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:NCe,errorBarOffset:0},w.createElement(ECe,{props:this.props,clipPathId:y}))),w.createElement(m3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:N}))}}var mJ={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:ni.line,type:"linear"};function TCe(t){var e=Hr(t,mJ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:p,yAxisId:b,id:y}=e,x=$4(e,hCe),{needClip:v}=sN(p,b),S=aN(),M=uh(),N=Ri(),A=Ht(R=>HTe(R,p,b,N,y));if(M!=="horizontal"&&M!=="vertical"||A==null||S==null)return null;var{height:k,width:C,x:D,y:T}=S;return w.createElement(ACe,G0({},x,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:p,yAxisId:b,points:A,layout:M,height:k,width:C,left:D,top:T,needClip:v}))}function CCe(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 m=Qw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Fr(f)?null:r.scale.map(f);return{x:m,y:p??null,value:f,payload:u}}var b=Fr(f)?null:n.scale.map(f),y=Qw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return b==null||y==null?null:{x:b,y,value:f,payload:u}}).filter(Boolean)}function kCe(t){var e=Hr(t,mJ),n=Ri();return w.createElement(rN,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(I4,{legendPayload:xCe(e)}),w.createElement(bCe,{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,id:r}),w.createElement(F4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(TCe,G0({},e,{id:r}))))}var pJ=w.memo(kCe,By);pJ.displayName="Line";function uc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:QQ}function dc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:QQ}var gJ=(t,e,n)=>tc(t,"xAxis",uc(t,e),n),xJ=(t,e,n)=>ec(t,"xAxis",uc(t,e),n),bJ=(t,e,n)=>tc(t,"yAxis",dc(t,e),n),yJ=(t,e,n)=>ec(t,"yAxis",dc(t,e),n),jCe=tt([Fn,gJ,bJ,xJ,yJ],(t,e,n,r,i)=>gl(t,"xAxis")?Xd(e,r,!1):Xd(n,i,!1)),PCe=(t,e)=>e,vJ=tt([Dy,PCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),_J=t=>{var e=Fn(t),n=gl(e,"xAxis");return n?"yAxis":"xAxis"},RCe=(t,e)=>{var n=_J(t);return n==="yAxis"?dc(t,e):uc(t,e)},DCe=(t,e,n)=>_S(t,_J(t),RCe(t,e),n),OCe=tt([vJ,DCe],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=HE(t);if(!(r==null||i==null)){var a=(n=e[r])===null||n===void 0?void 0:n.stackedData,o=a?.find(l=>l.key===i);if(o!=null)return o.map(l=>[l[0],l[1]])}}}),LCe=tt([Fn,gJ,bJ,xJ,yJ,OCe,aZ,jCe,vJ,q1e],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=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:p}=c,b;if(p&&p.length>0?b=p:b=d?.slice(f,m+1),b!=null)return tke({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),ICe=["id"],FCe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];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 wJ(t,e){if(t==null)return{};var n,r,i=UCe(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 UCe(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 BH(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 qp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BH(Object(n),!0).forEach(function(r){zCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zCe(t,e,n){return(e=BCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BCe(t){var e=$Ce(t,"string");return typeof e=="symbol"?e:e+""}function $Ce(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 jS(t,e){return t&&t!=="none"?t:e}var HCe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:jS(r,i),value:ch(n,e),payload:t}]},VCe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,f={dataDefinedOnItem:n,getPosition:lh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:ch(o,e),hide:l,type:u,color:jS(r,a),unit:c,graphicalItemId:d}};return w.createElement(nN,{tooltipEntrySettings:f})});function GCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Qa(r);return w.createElement(ZQ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function WCe(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 qp(qp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(T4,{value:e?i:void 0},n)}function $H(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,m=wJ(a,ICe),p=Qa(m),b=Sa(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement($r,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(tg,Mf({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(tg,Mf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(tg,Mf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(GCe,{points:e,props:m,clipPathId:i}))}function qCe(t){var e,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=t,l=(e=a[0])===null||e===void 0?void 0:e.y,c=(n=a[a.length-1])===null||n===void 0?void 0:n.y;if(!gn(l)||!gn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.x||0));return Ut(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.x||0),d)),Ut(d)?w.createElement("rect",{x:0,y:l<c?l:l-u,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(u)}):null}function KCe(t){var e,n,{alpha:r,baseLine:i,points:a,strokeWidth:o}=t,l=(e=a[0])===null||e===void 0?void 0:e.x,c=(n=a[a.length-1])===null||n===void 0?void 0:n.x;if(!gn(l)||!gn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.y||0));return Ut(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.y||0),d)),Ut(d)?w.createElement("rect",{x:l<c?l:l-u,y:0,width:u,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function XCe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(qCe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(KCe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function YCe(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:m,onAnimationEnd:p}=r,b=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Qg(b,"recharts-area-"),x=mO(),[v,S]=w.useState(!1),M=!v,N=w.useCallback(()=>{typeof p=="function"&&p(),S(!1)},[p]),A=w.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);if(x==null)return null;var k=i.current,C=a.current;return w.createElement(WCe,{showLabels:M,points:o},r.children,w.createElement(Zg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:A,key:y},D=>{if(k){var T=k.length/o.length,R=D===1?o:o.map((O,q)=>{var j=Math.floor(q*T);if(k[j]){var W=k[j];return qp(qp({},O),{},{x:Zn(W.x,O.x,D),y:Zn(W.y,O.y,D)})}return O}),U;return Ut(l)?U=Zn(C,l,D):Fr(l)||cl(l)?U=Zn(C,0,D):U=l.map((O,q)=>{var j=Math.floor(q*T);if(Array.isArray(C)&&C[j]){var W=C[j];return qp(qp({},O),{},{x:Zn(W.x,O.x,D),y:Zn(W.y,O.y,D)})}return O}),D>0&&(i.current=R,a.current=U),w.createElement($H,{points:R,baseLine:U,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,a.current=l),w.createElement($r,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(XCe,{alpha:D,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),w.createElement($r,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement($H,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(JE,{label:r.label}))}function ZCe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(YCe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class QCe extends w.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:m,baseLine:p,zIndex:b}=this.props;if(e)return null;var y=zn("recharts-area",i),x=m,{r:v,strokeWidth:S}=hJ(n),M=P4(n),N=v*2+S,A=l?"url(#clipPath-".concat(M?"":"dots-").concat(x,")"):void 0;return w.createElement(Fa,{zIndex:b},w.createElement($r,{className:y},l&&w.createElement("defs",null,w.createElement(B4,{clipPathId:x,xAxisId:c,yAxisId:u}),!M&&w.createElement("clipPath",{id:"clipPath-dots-".concat(x)},w.createElement("rect",{x:o-N/2,y:a-N/2,width:d+N,height:f+N}))),w.createElement(ZCe,{needClip:l,clipPathId:x,props:this.props})),w.createElement(m3,{points:r,mainColor:jS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(p)&&w.createElement(m3,{points:p,mainColor:jS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var SJ={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:ni.area};function JCe(t){var e,n=Hr(t,SJ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:p,stroke:b,xAxisId:y,yAxisId:x}=n,v=wJ(n,FCe),S=uh(),M=vQ(),{needClip:N}=sN(y,x),A=Ri(),{points:k,isRange:C,baseLine:D}=(e=Ht(j=>LCe(j,t.id,A)))!==null&&e!==void 0?e:{},T=aN();if(S!=="horizontal"&&S!=="vertical"||T==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:R,width:U,x:O,y:q}=T;return!k||!k.length?null:w.createElement(QCe,Mf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:S,isAnimationActive:m==="auto"?!Ay.isSsr:m,isRange:C,legendType:p,needClip:N,points:k,stroke:b,width:U,left:O,top:q,xAxisId:y,yAxisId:x}))}var eke=(t,e,n,r,i)=>{var a=n??e;if(Ut(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 tke(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:m,bandSize:p}=t,b=i&&i.length,y=eke(a,o,n,l,c),x=a==="horizontal",v=!1,S=u.map((N,A)=>{var k,C,D,T;if(b)T=i[d+A];else{var R=Jn(N,r);Array.isArray(R)?(T=R,v=!0):T=[y,R]}var U=(k=(C=T)===null||C===void 0?void 0:C[1])!==null&&k!==void 0?k:null,O=U==null||b&&!e&&Jn(N,r)==null;if(x){var q;return{x:Qw({axis:l,ticks:f,bandSize:p,entry:N,index:A}),y:O?null:(q=c.scale.map(U))!==null&&q!==void 0?q:null,value:T,payload:N}}return{x:O?null:(D=l.scale.map(U))!==null&&D!==void 0?D:null,y:Qw({axis:c,ticks:m,bandSize:p,entry:N,index:A}),value:T,payload:N}}),M;return b||v?M=S.map(N=>{var A,k=Array.isArray(N.value)?N.value[0]:null;if(x){var C;return{x:N.x,y:k!=null&&N.y!=null&&(C=c.scale.map(k))!==null&&C!==void 0?C:null,payload:N.payload}}return{x:k!=null&&(A=l.scale.map(k))!==null&&A!==void 0?A:null,y:N.y,payload:N.payload}}):M=x?c.scale.map(y):l.scale.map(y),{points:S,baseLine:M??0,isRange:v}}function nke(t){var e=Hr(t,SJ),n=Ri();return w.createElement(rN,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(I4,{legendPayload:HCe(e)}),w.createElement(VCe,{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,id:r}),w.createElement(F4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:YX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(JCe,Mf({},e,{id:r}))))}var MJ=w.memo(nke,By);MJ.displayName="Area";var rke="Invariant failed";function ike(t,e){throw new Error(rke)}function p3(){return p3=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},p3.apply(null,arguments)}function PS(t){return w.createElement(R4,p3({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var ake=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ut(e))return e;var a=Ut(r)||Fr(r);return a?e(r,i):(a||ike(),n)}},ske=(t,e,n)=>n,oke=(t,e)=>e,$y=tt([Dy,oke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),lke=tt([$y],t=>t?.maxBarSize),cke=(t,e,n,r)=>r,uke=tt([Fn,Dy,uc,dc,ske],(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")),dke=(t,e,n)=>{var r=Fn(t),i=uc(t,e),a=dc(t,e);if(!(i==null||a==null))return r==="horizontal"?_S(t,"yAxis",a,n):_S(t,"xAxis",i,n)},hke=(t,e)=>{var n=Fn(t),r=uc(t,e),i=dc(t,e);if(!(r==null||i==null))return n==="horizontal"?_$(t,"xAxis",r):_$(t,"yAxis",i)},fke=tt([uke,W1e,hke],mAe),mke=(t,e,n)=>{var r,i,a=$y(t,e);if(a==null)return 0;var o=uc(t,e),l=dc(t,e);if(o==null||l==null)return 0;var c=Fn(t),u=xZ(t),{maxBarSize:d}=a,f=Fr(d)?u:d,m,p;return c==="horizontal"?(m=tc(t,"xAxis",o,n),p=ec(t,"xAxis",o,n)):(m=tc(t,"yAxis",l,n),p=ec(t,"yAxis",l,n)),(r=(i=Xd(m,p,!0))!==null&&i!==void 0?i:f)!==null&&r!==void 0?r:0},EJ=(t,e,n)=>{var r=Fn(t),i=uc(t,e),a=dc(t,e);if(!(i==null||a==null)){var o,l;return r==="horizontal"?(o=tc(t,"xAxis",i,n),l=ec(t,"xAxis",i,n)):(o=tc(t,"yAxis",a,n),l=ec(t,"yAxis",a,n)),Xd(o,l)}},pke=tt([fke,xZ,G1e,bZ,mke,EJ,lke],yAe),gke=(t,e,n)=>{var r=uc(t,e);if(r!=null)return tc(t,"xAxis",r,n)},xke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return tc(t,"yAxis",r,n)},bke=(t,e,n)=>{var r=uc(t,e);if(r!=null)return ec(t,"xAxis",r,n)},yke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return ec(t,"yAxis",r,n)},vke=tt([pke,$y],_Ae),_ke=tt([dke,$y],vAe),wke=tt([Pi,cO,gke,xke,bke,yke,vke,Fn,aZ,EJ,_ke,$y,cke],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:b,dataEndIndex:y}=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,v;if(x!=null&&x.length>0?v=x:v=p?.slice(b,y+1),v!=null)return Yke({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:m,dataStartIndex:b})}}),Ske=["index"];function g3(){return g3=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},g3.apply(null,arguments)}function Mke(t,e){if(t==null)return{};var n,r,i=Eke(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 Eke(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 NJ=w.createContext(void 0),Nke=t=>{var e=w.useContext(NJ);if(e!=null)return e.stackId;if(t!=null)return YX(t)},Ake=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),Tke=t=>{var e=w.useContext(NJ);if(e!=null){var{stackId:n}=e;return"url(#".concat(Ake(n,t),")")}},AJ=t=>{var{index:e}=t,n=Mke(t,Ske),r=Tke(e);return w.createElement($r,g3({className:"recharts-bar-stack-layer",clipPath:r},n))},Cke=["onMouseEnter","onMouseLeave","onClick"],kke=["value","background","tooltipPosition"],jke=["id"],Pke=["onMouseEnter","onClick","onMouseLeave"];function xu(){return xu=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},xu.apply(null,arguments)}function HH(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 Ga(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(r){Rke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rke(t,e,n){return(e=Dke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dke(t){var e=Oke(t,"string");return typeof e=="symbol"?e:e+""}function Oke(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 RS(t,e){if(t==null)return{};var n,r,i=Lke(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 Lke(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 Ike=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ch(n,e),payload:t}]},Fke=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c,id:u}=t,d={dataDefinedOnItem:void 0,getPosition:lh,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:ch(a,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(nN,{tooltipEntrySettings:d})});function Uke(t){var e=Ht(Yd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=RS(a,Cke),d=D4(o,r,a.id),f=O4(l),m=L4(c,r,a.id);if(!i||n==null)return null;var p=Bf(i);return w.createElement(Fa,{zIndex:wAe(i,ni.barBackground)},n.map((b,y)=>{var{value:x,background:v,tooltipPosition:S}=b,M=RS(b,kke);if(!v)return null;var N=d(b,y),A=f(b,y),k=m(b,y),C=Ga(Ga(Ga(Ga(Ga({option:i,isActive:String(y)===e},M),{},{fill:"#eee"},v),p),vy(u,b,y)),{},{onMouseEnter:N,onMouseLeave:A,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(PS,xu({key:"background-bar-".concat(y)},C))}))}function zke(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 Ga(Ga({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(T4,{value:e?i:void 0},n)}function Bke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Ht(Yd),c=Ht(w4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(Fa,{zIndex:ni.activeBar},w.createElement(AJ,{index:a},w.createElement(PS,xu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o})))):w.createElement(PS,xu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function $ke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(PS,xu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function Hke(t){var e,{data:n,props:r}=t,i=(e=Qa(r))!==null&&e!==void 0?e:{},{id:a}=i,o=RS(i,jke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=RS(r,Pke),b=D4(d,c,a),y=O4(m),x=L4(f,c,a);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(AJ,xu({index:S,key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},vy(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),u?w.createElement(Bke,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):w.createElement($ke,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function Vke(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,m=Qg(e,"recharts-bar-"),[p,b]=w.useState(!1),y=!p,x=w.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return w.createElement(zke,{showLabels:y,rects:r},w.createElement(Zg,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:v,key:m},S=>{var M=S===1?r:r?.map((N,A)=>{var k=f&&f[A];if(k)return Ga(Ga({},N),{},{x:Zn(k.x,N.x,S),y:Zn(k.y,N.y,S),width:Zn(k.width,N.width,S),height:Zn(k.height,N.height,S)});if(i==="horizontal"){var C=Zn(0,N.height,S),D=Zn(N.stackedBarStart,N.y,S);return Ga(Ga({},N),{},{y:D,height:C})}var T=Zn(0,N.width,S),R=Zn(N.stackedBarStart,N.x,S);return Ga(Ga({},N),{},{width:T,x:R})});return S>0&&(n.current=M??null),M==null?null:w.createElement($r,null,w.createElement(Hke,{props:e,data:M}))}),w.createElement(JE,{label:e.label}),e.children)}function Gke(t){var e=w.useRef(null);return w.createElement(Vke,{previousRectanglesRef:e,props:t})}var TJ=0,Wke=(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 qke extends w.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=zn("recharts-bar",i),f=u;return w.createElement($r,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(B4,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement($r,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(Uke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(Gke,this.props)))}}var Kke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:TJ,xAxisId:0,yAxisId:0,zIndex:ni.bar};function Xke(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}=sN(e,n),m=uh(),p=Ri(),b=j4(t.children,zy),y=Ht(S=>wke(S,t.id,p,b));if(m!=="vertical"&&m!=="horizontal")return null;var x,v=y?.[0];return v==null||v.height==null||v.width==null?x=0:x=m==="vertical"?v.height/2:v.width/2,w.createElement(oJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:Wke,errorBarOffset:x},w.createElement(qke,xu({},t,{layout:m,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function Yke(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:m,cells:p,parentViewBox:b,dataStartIndex:y}=t,x=e==="horizontal"?l:o,v=d?x.scale.domain():null,S=Rbe({numericAxis:x}),M=x.scale.map(S);return f.map((N,A)=>{var k,C,D,T,R,U;if(d){var O=d[A+y];if(O==null)return null;k=Tbe(O,v)}else k=Jn(N,n),Array.isArray(k)||(k=[S,k]);var q=ake(r,TJ)(k[1],A);if(e==="horizontal"){var j,W=l.scale.map(k[0]),K=l.scale.map(k[1]);if(W==null||K==null)return null;C=v8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:N,index:A}),D=(j=K??W)!==null&&j!==void 0?j:void 0,T=i.size;var G=W-K;if(R=cl(G)?0:G,U={x:C,y:m.top,width:T,height:m.height},Math.abs(q)>0&&Math.abs(R)<Math.abs(q)){var J=Wi(R||q)*(Math.abs(q)-Math.abs(R));D-=J,R+=J}}else{var ie=o.scale.map(k[0]),re=o.scale.map(k[1]);if(ie==null||re==null)return null;if(C=ie,D=v8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:N,index:A}),T=re-ie,R=i.size,U={x:m.left,y:D,width:m.width,height:R},Math.abs(q)>0&&Math.abs(T)<Math.abs(q)){var z=Wi(T||q)*(Math.abs(q)-Math.abs(T));T+=z}}if(C==null||D==null||T==null||R==null)return null;var V=Ga(Ga({},N),{},{stackedBarStart:M,x:C,y:D,width:T,height:R,value:d?k:k[1],payload:N,background:U,tooltipPosition:{x:C+T/2,y:D+R/2},parentViewBox:b},p&&p[A]&&p[A].props);return V}).filter(Boolean)}function Zke(t){var e=Hr(t,Kke),n=Nke(e.stackId),r=Ri();return w.createElement(rN,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(I4,{legendPayload:Ike(e)}),w.createElement(Fke,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType,id:i}),w.createElement(F4,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:n,hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:r}),w.createElement(Fa,{zIndex:e.zIndex},w.createElement(Xke,xu({},e,{id:i})))))}var CJ=w.memo(Zke,By);CJ.displayName="Bar";var Qke=["domain","range"],Jke=["domain","range"];function VH(t,e){if(t==null)return{};var n,r,i=eje(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 eje(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 GH(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 kJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=VH(t,Qke),{domain:a,range:o}=e,l=VH(e,Jke);return!GH(n,a)||!GH(r,o)?!1:By(i,l)}var tje=["type"],nje=["dangerouslySetInnerHTML","ticks","scale"],rje=["id","scale"];function x3(){return x3=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},x3.apply(null,arguments)}function WH(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 qH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WH(Object(n),!0).forEach(function(r){ije(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ije(t,e,n){return(e=aje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aje(t){var e=sje(t,"string");return typeof e=="symbol"?e:e+""}function sje(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 b3(t,e){if(t==null)return{};var n,r,i=oje(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 oje(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 lje(t){var e=vr(),n=w.useRef(null),r=mO(),{type:i}=t,a=b3(t,tje),o=BE(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return qH(qH({},a),{},{type:o})},[a,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(J2e(l)):n.current!==l&&e(eAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(tAe(n.current)),n.current=null)},[e]),null}var cje=t=>{var{xAxisId:e,className:n}=t,r=Ht(cO),i=Ri(),a="xAxis",o=Ht(v=>ZZ(v,a,e,i)),l=Ht(v=>qZ(v,e)),c=Ht(v=>qwe(v,e)),u=Ht(v=>TZ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:m}=t,p=b3(t,nje),{id:b,scale:y}=u,x=b3(u,rje);return w.createElement(z4,x3({},p,x,{x:c.x,y:c.y,width:l.width,height:l.height,className:zn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},uje={allowDataOverflow:Bi.allowDataOverflow,allowDecimals:Bi.allowDecimals,allowDuplicatedCategory:Bi.allowDuplicatedCategory,angle:Bi.angle,axisLine:ru.axisLine,height:Bi.height,hide:!1,includeHidden:Bi.includeHidden,interval:Bi.interval,label:!1,minTickGap:Bi.minTickGap,mirror:Bi.mirror,orientation:Bi.orientation,padding:Bi.padding,reversed:Bi.reversed,scale:Bi.scale,tick:Bi.tick,tickCount:Bi.tickCount,tickLine:ru.tickLine,tickSize:ru.tickSize,type:Bi.type,xAxisId:0},dje=t=>{var e=Hr(t,uje);return w.createElement(w.Fragment,null,w.createElement(lje,{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}),w.createElement(cje,e))},DS=w.memo(dje,kJ);DS.displayName="XAxis";var hje=["type"],fje=["dangerouslySetInnerHTML","ticks","scale"],mje=["id","scale"];function y3(){return y3=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},y3.apply(null,arguments)}function KH(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 XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KH(Object(n),!0).forEach(function(r){pje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pje(t,e,n){return(e=gje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gje(t){var e=xje(t,"string");return typeof e=="symbol"?e:e+""}function xje(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 v3(t,e){if(t==null)return{};var n,r,i=bje(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 bje(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 yje(t){var e=vr(),n=w.useRef(null),r=mO(),{type:i}=t,a=v3(t,hje),o=BE(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return XH(XH({},a),{},{type:o})},[o,a]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(nAe(l)):n.current!==l&&e(rAe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(iAe(n.current)),n.current=null)},[e]),null}function vje(t){var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Ht(cO),c=Ri(),u=vr(),d="yAxis",f=Ht(k=>KZ(k,e)),m=Ht(k=>Xwe(k,e)),p=Ht(k=>ZZ(k,d,e,c)),b=Ht(k=>CZ(k,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!f||A4(i)||w.isValidElement(i)||b==null)){var k=a.current;if(k){var C=k.getCalculatedWidth();Math.round(f.width)!==Math.round(C)&&u(aAe({id:e,width:C}))}}},[p,f,u,i,e,r,b]),f==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:x,scale:v}=t,S=v3(t,fje),{id:M,scale:N}=b,A=v3(b,mje);return w.createElement(z4,y3({},S,A,{ref:a,labelRef:o,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:f.width,height:f.height,className:zn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:p,axisType:d}))}var _je={allowDataOverflow:$i.allowDataOverflow,allowDecimals:$i.allowDecimals,allowDuplicatedCategory:$i.allowDuplicatedCategory,angle:$i.angle,axisLine:ru.axisLine,hide:!1,includeHidden:$i.includeHidden,interval:$i.interval,label:!1,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:ru.tickLine,tickSize:ru.tickSize,type:$i.type,width:$i.width,yAxisId:0},wje=t=>{var e=Hr(t,_je);return w.createElement(w.Fragment,null,w.createElement(yje,{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}),w.createElement(vje,e))},OS=w.memo(wje,kJ);OS.displayName="YAxis";var Sje=(t,e)=>e,H4=tt([Sje,Fn,EZ,ea,mQ,Nu,uMe,Pi],xMe),V4=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)}},jJ=Ro("mouseClick"),PJ=wy();PJ.startListening({actionCreator:jJ,effect:(t,e)=>{var n=t.payload,r=H4(e.getState(),V4(n));r?.activeIndex!=null&&e.dispatch(cSe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var _3=Ro("mouseMove"),RJ=wy(),k_=null;RJ.startListening({actionCreator:_3,effect:(t,e)=>{var n=t.payload;k_!==null&&cancelAnimationFrame(k_);var r=V4(n);k_=requestAnimationFrame(()=>{var i=e.getState(),a=g4(i,i.tooltip.settings.shared);if(a==="axis"){var o=H4(i,r);o?.activeIndex!=null?e.dispatch(aQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(iQ())}k_=null})}});function Mje(t,e){return e instanceof HTMLElement?"HTMLElement <".concat(e.tagName,' class="').concat(e.className,'">'):e===window?"global.window":t==="children"&&typeof e=="object"&&e!==null?"<<CHILDREN>>":e}var YH={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},DJ=Ss({name:"rootProps",initialState:YH,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:YH.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}}}),Eje=DJ.reducer,{updateOptions:Nje}=DJ.actions,Aje=null,Tje={updatePolarOptions:(t,e)=>e.payload},OJ=Ss({name:"polarOptions",initialState:Aje,reducers:Tje}),{updatePolarOptions:Cje}=OJ.actions,kje=OJ.reducer,LJ=Ro("keyDown"),IJ=Ro("focus"),G4=wy();G4.startListening({actionCreator:LJ,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=x4(i,ox(n),Ly(n),Fy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Nu(n);if(a==="Enter"){var u=SS(n,"axis","hover",String(i.index));e.dispatch(c3({active:!i.active,activeIndex:i.index,activeCoordinate:u}));return}var d=Jwe(n),f=d==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,p=l+m*f;if(!(c==null||p>=c.length||p<0)){var b=SS(n,"axis","hover",String(p));e.dispatch(c3({active:!0,activeIndex:p.toString(),activeCoordinate:b}))}}}}}});G4.startListening({actionCreator:IJ,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=SS(n,"axis","hover",String(a));e.dispatch(c3({active:!0,activeIndex:a,activeCoordinate:o}))}}}});var mo=Ro("externalEvent"),FJ=wy(),FC=new Map;FJ.startListening({actionCreator:mo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=FC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:XSe(l),activeDataKey:w4(l),activeIndex:Yd(l),activeLabel:xQ(l),activeTooltipIndex:Yd(l),isTooltipActive:YSe(l)};n(c,r)}finally{FC.delete(i)}});FC.set(i,o)}}});var jje=tt([ax],t=>t.tooltipItemPayloads),Pje=tt([jje,(t,e)=>e,(t,e,n)=>n],(t,e,n)=>{if(e!=null){var r=t.find(a=>a.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(e)}}}),UJ=Ro("touchMove"),zJ=wy();zJ.startListening({actionCreator:UJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=g4(r,r.tooltip.settings.shared);if(i==="axis"){var a=n.touches[0];if(a==null)return;var o=H4(r,V4({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(aQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i==="item"){var l,c=n.touches[0];if(document.elementFromPoint==null||c==null)return;var u=document.elementFromPoint(c.clientX,c.clientY);if(!u||!u.getAttribute)return;var d=u.getAttribute(QX),f=(l=u.getAttribute(JX))!==null&&l!==void 0?l:void 0,m=sx(r).find(y=>y.id===f);if(d==null||m==null||f==null)return;var{dataKey:p}=m,b=Pje(r,d,f);e.dispatch(rQ({activeDataKey:p,activeIndex:d,activeCoordinate:b,activeGraphicalItemId:f}))}}}});var Rje=yX({brush:SAe,cartesianAxis:sAe,chartData:KMe,errorBars:RTe,graphicalItems:m2e,layout:Sbe,legend:C0e,options:HMe,polarAxis:TNe,polarOptions:kje,referenceElements:jAe,rootProps:Eje,tooltip:uSe,zIndex:jMe}),Dje=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Kxe({reducer:Rje,preloadedState:e,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([PJ.middleware,RJ.middleware,G4.middleware,FJ.middleware,zJ.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(DX({type:"raf"}))},devTools:{serialize:{replacer:Mje},name:"recharts-".concat(n)}})};function BJ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Ri(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=Dje(e,r));var o=nO;return w.createElement(oCe,{context:o,store:a.current},n)}function Oje(t){var{layout:e,margin:n}=t,r=vr(),i=Ri();return w.useEffect(()=>{i||(r(vbe(e)),r(ybe(n)))},[r,i,e,n]),null}var $J=w.memo(Oje,By);function HJ(t){var e=vr();return w.useEffect(()=>{e(Nje(t))},[e,t]),null}function ZH(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=vr();return w.useLayoutEffect(()=>(r.current&&i(CMe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(kMe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function QH(t){var{children:e,isPanorama:n}=t,r=Ht(yMe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(ZH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(ZH,{key:o,zIndex:o,isPanorama:n})))}var Lje=["children"];function Ije(t,e){if(t==null)return{};var n,r,i=Fje(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 Fje(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 LS(){return LS=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},LS.apply(null,arguments)}var Uje={width:"100%",height:"100%",display:"block"},zje=w.forwardRef((t,e)=>{var n=hO(),r=fO(),i=pY();if(!Ql(n)||!Ql(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),w.createElement(GD,LS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:Uje,ref:e}),a)}),Bje=t=>{var{children:e}=t,n=Ht(CE);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(GD,{width:r,height:i,x:o,y:a},e)},JH=w.forwardRef((t,e)=>{var{children:n}=t,r=Ije(t,Lje),i=Ri();return i?w.createElement(Bje,null,w.createElement(QH,{isPanorama:!0},n)):w.createElement(zje,LS({ref:e},r),w.createElement(QH,{isPanorama:!1},n))});function $je(){var t=vr(),[e,n]=w.useState(null),r=Ht(Ube);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;gn(a)&&a!==r&&t(wbe(a))}},[e,t,r]),n}function eV(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 Hje(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eV(Object(n),!0).forEach(function(r){Vje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vje(t,e,n){return(e=Gje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gje(t){var e=Wje(t,"string");return typeof e=="symbol"?e:e+""}function Wje(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 Ud(){return Ud=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},Ud.apply(null,arguments)}var qje=()=>(rEe(),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 Kje=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.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=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),p=Math.round(d);return f.containerWidth===m&&f.containerHeight===p?f:{containerWidth:m,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=b=>{var y=b[0];if(y!=null){var{width:x,height:v}=y.contentRect;l(x,v)}},p=new ResizeObserver(m);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(Ey,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",Ud({ref:c},t)))}),Xje=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:IS(n),containerHeight:IS(r)}),o=w.useCallback((c,u)=>{a(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(Ey,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Ud({ref:l},t)))}),Yje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement("div",Ud({ref:e},t)))}),Zje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(Xje,Ud({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(Yje,Ud({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement("div",Ud({ref:e},t)))});function Qje(t){return t?Kje:Zje}var Jje=w.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:m,onTouchEnd:p,onTouchMove:b,onTouchStart:y,style:x,width:v,responsive:S,dispatchTouchEvents:M=!0}=t,N=w.useRef(null),A=vr(),[k,C]=w.useState(null),[D,T]=w.useState(null),R=$je(),U=uO(),O=U?.width>0?U.width:v,q=U?.height>0?U.height:i,j=w.useCallback(me=>{R(me),typeof e=="function"&&e(me),C(me),T(me),me!=null&&(N.current=me)},[R,e,C,T]),W=w.useCallback(me=>{A(jJ(me)),A(mo({handler:a,reactEvent:me}))},[A,a]),K=w.useCallback(me=>{A(_3(me)),A(mo({handler:u,reactEvent:me}))},[A,u]),G=w.useCallback(me=>{A(iQ()),A(mo({handler:d,reactEvent:me}))},[A,d]),J=w.useCallback(me=>{A(_3(me)),A(mo({handler:f,reactEvent:me}))},[A,f]),ie=w.useCallback(()=>{A(IJ())},[A]),re=w.useCallback(me=>{A(LJ(me.key))},[A]),z=w.useCallback(me=>{A(mo({handler:o,reactEvent:me}))},[A,o]),V=w.useCallback(me=>{A(mo({handler:l,reactEvent:me}))},[A,l]),Z=w.useCallback(me=>{A(mo({handler:c,reactEvent:me}))},[A,c]),ne=w.useCallback(me=>{A(mo({handler:m,reactEvent:me}))},[A,m]),he=w.useCallback(me=>{A(mo({handler:y,reactEvent:me}))},[A,y]),fe=w.useCallback(me=>{M&&A(UJ(me)),A(mo({handler:b,reactEvent:me}))},[A,M,b]),le=w.useCallback(me=>{A(mo({handler:p,reactEvent:me}))},[A,p]),Ee=Qje(S);return w.createElement(EQ.Provider,{value:k},w.createElement(OK.Provider,{value:D},w.createElement(Ee,{width:O??x?.width,height:q??x?.height,className:zn("recharts-wrapper",r),style:Hje({position:"relative",cursor:"default",width:O,height:q},x),onClick:W,onContextMenu:z,onDoubleClick:V,onFocus:ie,onKeyDown:re,onMouseDown:Z,onMouseEnter:K,onMouseLeave:G,onMouseMove:J,onMouseUp:ne,onTouchEnd:le,onTouchMove:fe,onTouchStart:he,ref:j},w.createElement(qje,null),n)))}),ePe=["width","height","responsive","children","className","style","compact","title","desc"];function tPe(t,e){if(t==null)return{};var n,r,i=nPe(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 nPe(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 VJ=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=tPe(t,ePe),m=Qa(f);return c?w.createElement(w.Fragment,null,w.createElement(Ey,{width:n,height:r}),w.createElement(JH,{otherAttributes:m,title:u,desc:d},a)):w.createElement(Jje,{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},w.createElement(JH,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(PAe,null,a)))});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 rPe={top:5,right:5,bottom:5,left:5},iPe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:rPe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},W4=w.forwardRef(function(e,n){var r,i=Hr(e.categoricalChartProps,iPe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(BJ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(eJ,{chartData:u.data}),w.createElement($J,{layout:i.layout,margin:i.margin}),w.createElement(HJ,{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}),w.createElement(VJ,w3({},i,{ref:n})))}),aPe=["axis"],sPe=w.forwardRef((t,e)=>w.createElement(W4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:aPe,tooltipPayloadSearcher:ZE,categoricalChartProps:t,ref:e})),oPe=["axis","item"],lPe=w.forwardRef((t,e)=>w.createElement(W4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:oPe,tooltipPayloadSearcher:ZE,categoricalChartProps:t,ref:e}));function cPe(t){var e=vr();return w.useEffect(()=>{e(Cje(t))},[e,t]),null}var uPe=["layout"];function S3(){return S3=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},S3.apply(null,arguments)}function dPe(t,e){if(t==null)return{};var n,r,i=hPe(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 hPe(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 fPe={top:5,right:5,bottom:5,left:5},GJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:fPe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},mPe=w.forwardRef(function(e,n){var r,i=Hr(e.categoricalChartProps,GJ),{layout:a}=i,o=dPe(i,uPe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(BJ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(eJ,{chartData:i.data}),w.createElement($J,{layout:a,margin:i.margin}),w.createElement(HJ,{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}),w.createElement(cPe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(VJ,S3({},o,{ref:n})))});function tV(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 nV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tV(Object(n),!0).forEach(function(r){pPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pPe(t,e,n){return(e=gPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gPe(t){var e=xPe(t,"string");return typeof e=="symbol"?e:e+""}function xPe(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 bPe=["item"],yPe=nV(nV({},GJ),{},{layout:"centric",startAngle:0,endAngle:360}),vPe=w.forwardRef((t,e)=>{var n=Hr(t,yPe);return w.createElement(mPe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:bPe,tooltipPayloadSearcher:ZE,categoricalChartProps:n,ref:e})}),_Pe=["axis"],wPe=w.forwardRef((t,e)=>w.createElement(W4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:_Pe,tooltipPayloadSearcher:ZE,categoricalChartProps:t,ref:e}));const rV=[{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 SPe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Gg(),{mode:u}=sh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),b=u==="dark",{data:y}=ut({queryKey:["settings"],queryFn:pe.getSettings}),x=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const ne=he=>{he.key==="Escape"&&e()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[t,e]);const v=rV.find(ne=>ne.value===d)?.hours||24,{data:S,isLoading:M,error:N}=ut({queryKey:["ams-history",n,i,v],queryFn:()=>pe.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const A=S?.data.map(ne=>{const he=gi(ne.recorded_at)||new Date,fe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:he.getTime(),humidity:ne.humidity,temperature:ne.temperature,timeLabel:he.toLocaleTimeString([],t0(fe,x))}})||[],k=l?.humidityGood||40,C=l?.humidityFair||60,D=l?.tempGood||30,T=l?.tempFair||35,R=A[A.length-1],U=R?.humidity,O=R?.temperature,q=ne=>{const he=ne.filter(De=>De!=null);if(he.length<4)return"stable";const fe=he.slice(0,Math.floor(he.length/4)),le=he.slice(-Math.floor(he.length/4)),Ee=fe.reduce((De,ee)=>De+ee,0)/fe.length,we=le.reduce((De,ee)=>De+ee,0)/le.length-Ee;return Math.abs(we)<2?"stable":we>0?"up":"down"},j=q(A.map(ne=>ne.humidity)),W=q(A.map(ne=>ne.temperature)),K=({trend:ne})=>ne==="up"?s.jsx(MK,{className:"w-4 h-4 text-red-400"}):ne==="down"?s.jsx(SK,{className:"w-4 h-4 text-green-400"}):s.jsx(xP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),G=ne=>ne==null?"#9ca3af":ne<=k?"#22a352":ne<=C?"#d4a017":"#c62828",J=ne=>ne==null?"#9ca3af":ne<=D?"#22a352":ne<=T?"#d4a017":"#c62828",ie=b?"#2d2d2d":"#ffffff",re=b?"#1d1d1d":"#f3f4f6",z=b?"#3d3d3d":"#e5e7eb",V=b?"#ffffff":"#111827",Z=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:ie},onClick:ne=>ne.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:z},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:V},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:Z},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:Z},children:s.jsx(Wt,{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:re},children:[s.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:Z}:void 0,children:[s.jsx(LD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:Z}:void 0,children:[s.jsx(dE,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:re},children:rV.map(ne=>s.jsx("button",{onClick:()=>f(ne.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ne.value?"bg-bambu-green text-white":""}`,style:d!==ne.value?{color:Z}:void 0,children:ne.label},ne.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},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(U)},children:U!=null?`${U}%`:"—"}),s.jsx(K,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},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:J(O)},children:O!=null?`${O}°C`:"—"}),s.jsx(K,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:Z},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:M?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:Z},children:c("common.loading","Loading...")}):N?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):A.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:Z},children:c("common.noData","No data available for this time range")}):s.jsx(nw,{width:"100%",height:300,children:s.jsxs(sPe,{data:A,children:[s.jsx(kS,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(DS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ne=>{const he=new Date(ne);return v>24?he.toLocaleDateString([],{day:"numeric",month:"short"}):he.toLocaleTimeString([],t0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(OS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ne=>m==="humidity"?`${ne}%`:`${ne}°C`}),s.jsx(iw,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:ne=>new Date(ne).toLocaleString(void 0,t0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:ne=>[m==="humidity"?`${ne??0}%`:`${ne??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(xO,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(zb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(zb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(zb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(zb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(pJ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:Z},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function UC({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),b=w.useRef(null),y=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{x(k)}):x(k))},x=k=>{const C=document.createElement("textarea");C.value=k,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};w.useEffect(()=>{if(o&&m.current&&p.current){const k=m.current.getBoundingClientRect(),C=p.current.offsetHeight,D=k.top,T=window.innerHeight-k.bottom;D<C+12&&T>D?u("bottom"):u("top")}},[o]);const v=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!0),80))},S=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const M=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",N=k=>{if(!k)return!1;const C=k.replace("#",""),D=parseInt(C.slice(0,2),16),T=parseInt(C.slice(2,4),16),R=parseInt(C.slice(4,6),16);return(.299*D+.587*T+.114*R)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:S,children:[e,o&&s.jsxs("div",{ref:p,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  48. animate-in fade-in-0 zoom-in-95 duration-150
  49. `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
  50. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  51. rounded-lg shadow-xl overflow-hidden
  52. backdrop-blur-sm
  53. `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:A||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${N(A)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),s.jsx("div",{className:`
  58. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  59. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  60. `,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(LD,{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:M(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:k=>{k.stopPropagation(),y()},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(ws,{className:"w-3 h-3 text-bambu-green"}):s.jsx(rl,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:k=>{k.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(Vl,{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:k=>{k.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(qd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
  61. absolute left-1/2 -translate-x-1/2 w-0 h-0
  62. border-l-[6px] border-l-transparent
  63. border-r-[6px] border-r-transparent
  64. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function iV({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),a=w.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 w.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&s.jsxs("div",{className:`
  66. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  67. animate-in fade-in-0 zoom-in-95 duration-150
  68. `,children:[s.jsxs("div",{className:`
  69. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg overflow-hidden
  71. `,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(qd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
  72. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  73. border-l-[5px] border-l-transparent
  74. border-r-[5px] border-r-transparent
  75. border-t-[5px] border-t-bambu-dark-tertiary
  76. `})]})]})}function MPe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=un(),[a,o]=w.useState(null),{data:l,isLoading:c}=ut({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:t}),u=ht({mutationFn:f=>pe.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(Vl,{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(Wt,{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(dt,{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(ws,{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(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Vl,{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 EPe(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 aV(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 NPe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function sV(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of NPe){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 zC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const APe={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"},TPe=[{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"}],CPe=[{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 kPe(t){const e=t.toLowerCase().trim();return APe[e]||null}function jPe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState(""),[b,y]=w.useState(""),[x,v]=w.useState(!1),[S,M]=w.useState(!1),{data:N,isLoading:A}=ut({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:t}),{data:k,isLoading:C}=ut({queryKey:["kprofiles",n,i],queryFn:()=>pe.getKProfiles(n,i),enabled:t&&!!n}),D=ht({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const J=N?.filament.find(me=>me.setting_id===o);if(!J)throw new Error("Selected preset not found");const ie=sV(J.name),re=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",V=J.name.replace(/@.+$/,"").trim();let Z=aV(o);if(!o.startsWith("GFS"))try{const me=await pe.getCloudSettingDetail(o);me.filament_id?Z=me.filament_id:me.base_id&&(Z=aV(me.base_id),console.log(`Derived tray_info_idx from base_id: ${me.base_id} -> ${Z}`))}catch(me){console.warn("Failed to fetch preset detail for filament_id:",me)}let ne=190,he=230;const fe=ie.material.toUpperCase();fe.includes("PLA")?(ne=190,he=230):fe.includes("PETG")?(ne=220,he=260):fe.includes("ABS")||fe.includes("ASA")?(ne=240,he=280):fe.includes("TPU")?(ne=200,he=240):fe.includes("PC")?(ne=260,he=300):(fe.includes("PA")||fe.includes("NYLON"))&&(ne=250,he=290);const le=c?.k_value?parseFloat(c.k_value):0,Ee=await pe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:Z,tray_type:ie.material||"PLA",tray_sub_brands:V,tray_color:z+"FF",nozzle_temp_min:ne,nozzle_temp_max:he,cali_idx:re,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:le});try{await pe.saveSlotPreset(n,r.amsId,r.trayId,o,V)}catch(me){console.warn("Failed to save slot preset mapping:",me)}return Ee},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),T=ht({mutationFn:async()=>pe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!N?.filament)return[];const J=b.toLowerCase();return N.filament.filter(ie=>J?ie.name.toLowerCase().includes(J):!0).sort((ie,re)=>{const z=zC(ie.setting_id),V=zC(re.setting_id);return z&&!V?-1:!z&&V?1:ie.name.localeCompare(re.name)})},[N?.filament,b]),U=w.useMemo(()=>{if(!o||!N?.filament)return null;const J=N.filament.find(z=>z.setting_id===o);if(!J)return null;let ie=J.name.replace(/@.+$/,"").trim();ie.startsWith("# ")&&(ie=ie.slice(2).trim());const re=sV(ie);return{fullName:ie,material:re.material,brand:re.brand}},[o,N?.filament]),O=U?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!U)return[];const{fullName:J,material:ie,brand:re}=U,z=J.toUpperCase(),V=ie.toUpperCase(),Z=re.toUpperCase();if(!V||V.length<2)return[];const ne=k.profiles.filter(fe=>{const le=fe.name.toUpperCase();if(Z)return!(!le.includes(Z)||!le.includes(V));if(le.includes(z)||le.includes(V))return!0;const me={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[V]||[];for(const we of me)if(le.includes(we))return!0;return!1}),he=new Map;for(const fe of ne){const le=`${fe.name}|${fe.k_value}`,Ee=he.get(le);Ee?fe.extruder_id===1&&Ee.extruder_id===0&&he.set(le,fe):he.set(le,fe)}return Array.from(he.values())},[k?.profiles,U]);w.useEffect(()=>{if(t&&N?.filament){if(r.trayInfoIdx){const J=N.filament.find(ie=>ie.setting_id===r.trayInfoIdx);J&&l(J.setting_id)}}else t||(l(""),u(null),f(""),p(""),y(""),v(!1))},[t,N?.filament,r.trayInfoIdx]),w.useEffect(()=>{q.length>0?u(q[0]):u(null)},[o,q]);const j=w.useCallback(J=>{J.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const W=A||C,K=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(qd,{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(Wt,{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(QM,{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:[EPe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),W?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{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:J=>y(J.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:R.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:N?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(J=>s.jsx("button",{onClick:()=>l(J.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===J.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:J.name}),zC(J.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},J.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",O&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",O]})]}),q.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:J=>{const ie=q.find(re=>re.name===J.target.value);u(ie||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)"}),q.map(J=>s.jsxs("option",{value:J.name,children:[J.name," (K=",J.k_value,")"]},`${J.name}-${J.extruder_id}`))]}),s.jsx(Zi,{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:[TPe.map(J=>s.jsx("button",{onClick:()=>{f(J.hex),p(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.hex)),s.jsx("button",{onClick:()=>M(!S),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:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:CPe.map(J=>s.jsx("button",{onClick:()=>{f(J.hex),p(J.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===J.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${J.hex}`},title:J.name},J.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:m,onChange:J=>{const ie=J.target.value;p(ie);const re=kPe(ie);if(re)f(re);else{const z=ie.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(V=>V+V).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(""),p("")},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(Me,{variant:"secondary",onClick:()=>T.mutate(),disabled:T.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:T.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(om,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:()=>D.mutate(),disabled:!K,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(qd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||T.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||T.error?.message})]})]})}function PPe({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 oV=({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"})]}),lV={"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"},RPe={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 BC(t){if(!t)return null;if(lV[t])return lV[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return RPe[n]||null}function $C(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,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-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 HC(t){return(t??.02).toFixed(3)}function cV({side:t}){const{mode:e}=sh(),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 uV({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 DPe({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 OPe({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 LPe({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 IPe({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 FPe({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 VC({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 dV({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=uV:a<=l?d=DPe:d=OPe,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 hV({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=LPe):t<=o?(l="#d4a017",c="Fair",u=IPe):(l="#c62828",c="Bad",u=FPe),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 Zu(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 fV(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function UPe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function zPe(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 BPe(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 $Pe(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 GC(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 HPe({url:t,printName:e}){const[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.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(Fs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Fs,{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 VPe({printers:t}){const e=un(),n=w.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]=w.useState(0);return w.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 mV(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 pV({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d}){const f=un(),m=ml(),{showToast:p}=qn(),[b,y]=w.useState(!1),[x,v]=w.useState(!1),[S,M]=w.useState(!0),[N,A]=w.useState(!1),[k,C]=w.useState(!1),[D,T]=w.useState(!1),[R,U]=w.useState(!1),[O,q]=w.useState(!1),[j,W]=w.useState(!1),[K,G]=w.useState(!1),[J,ie]=w.useState(!1),[re,z]=w.useState(!1),[V,Z]=w.useState(!1),[ne,he]=w.useState(null),[fe,le]=w.useState(null),[Ee,me]=w.useState(null),[we,De]=w.useState(!1),{data:ee}=ut({queryKey:["printerStatus",t.id],queryFn:()=>pe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Qe}=ut({queryKey:["firmwareUpdate",t.id],queryFn:()=>Q1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),B=w.useMemo(()=>{const vt=new Set;if(ee?.ams)for(const on of ee.ams)for(const Nn of on.tray||[])Nn.tray_info_idx&&vt.add(Nn.tray_info_idx);return ee?.vt_tray?.tray_info_idx&&vt.add(ee.vt_tray.tray_info_idx),Array.from(vt)},[ee?.ams,ee?.vt_tray]),{data:te}=ut({queryKey:["filamentInfo",B],queryFn:()=>pe.getFilamentInfo(B),enabled:B.length>0,staleTime:300*1e3}),{data:Y}=ut({queryKey:["slotPresets",t.id],queryFn:()=>pe.getSlotPresets(t.id),staleTime:120*1e3}),[H,F]=w.useState(null);w.useEffect(()=>{ee?.wifi_signal!=null&&F(ee.wifi_signal)},[ee?.wifi_signal]);const de=ee?.wifi_signal??H,Ae=w.useRef(void 0);w.useEffect(()=>{ee?.connected!==void 0&&(Ae.current=ee.connected)},[ee?.connected]);const Le=ee?.connected??Ae.current,Se=w.useRef({});w.useEffect(()=>{ee?.ams_extruder_map&&Object.keys(ee.ams_extruder_map).length>0&&(Se.current=ee.ams_extruder_map)},[ee?.ams_extruder_map]);const $=ee?.ams_extruder_map&&Object.keys(ee.ams_extruder_map).length>0?ee.ams_extruder_map:Se.current,L=w.useRef([]);w.useEffect(()=>{ee?.ams&&ee.ams.length>0&&(L.current=ee.ams)},[ee?.ams]);const X=ee?.ams&&ee.ams.length>0?ee.ams:L.current,xe=w.useRef(255),_e=ee?.tray_now;_e!==void 0&&_e!==255&&(xe.current=_e);const ae=_e===void 0||_e===255?xe.current:_e,{data:Te}=ut({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>pe.getSmartPlugByPrinter(t.id)}),{data:Pe}=ut({queryKey:["smartPlugStatus",Te?.id],queryFn:()=>Te?pe.getSmartPlugStatus(Te.id):null,enabled:!!Te,refetchInterval:1e4}),{data:Xe}=ut({queryKey:["queue",t.id,"pending"],queryFn:()=>pe.getQueue(t.id,"pending")}),Je=Xe?.length||0,{data:Ze}=ut({queryKey:["archives",t.id,"last"],queryFn:()=>pe.getArchives(t.id,1,0),enabled:ee?.connected&&ee?.state!=="RUNNING"}),oe=Ze?.[0],ye=e&&Le===!1,Ce=ht({mutationFn:vt=>pe.deletePrinter(t.id,vt.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),$e=ht({mutationFn:()=>pe.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),lt=ht({mutationFn:vt=>Te?pe.controlSmartPlug(Te.id,vt):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",Te?.id]})}}),se=ht({mutationFn:vt=>Te?pe.updateSmartPlug(Te.id,{auto_off:vt}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),ze=ht({mutationFn:()=>pe.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>p(vt.message||"Failed to stop print","error")}),ve=ht({mutationFn:()=>pe.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>p(vt.message||"Failed to pause print","error")}),He=ht({mutationFn:()=>pe.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>p(vt.message||"Failed to resume print","error")}),Oe=ht({mutationFn:vt=>pe.setChamberLight(t.id,vt),onMutate:async vt=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const on=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],Nn=>({...Nn,chamber_light:vt})),{previousStatus:on}},onSuccess:(vt,on)=>{p(`Chamber light ${on?"on":"off"}`)},onError:(vt,on,Nn)=>{Nn?.previousStatus&&f.setQueryData(["printerStatus",t.id],Nn.previousStatus),p(vt.message||"Failed to control chamber light","error")}}),Ne=(ee?.state==="RUNNING"||ee?.state==="PAUSE"||ee?.state==="PAUSED")&&(ee?.printable_objects_count??0)>=2,{data:Be,refetch:at}=ut({queryKey:["printableObjects",t.id],queryFn:()=>pe.getPrintableObjects(t.id),enabled:V||Ne,refetchInterval:V?5e3:Ne?3e4:!1}),Rt=ht({mutationFn:vt=>pe.skipObjects(t.id,vt),onSuccess:vt=>{p(vt.message||"Objects skipped"),at()},onError:vt=>p(vt.message||"Failed to skip objects","error")}),[Tt,nn]=w.useState(null),Lt=w.useRef(!1),ln=w.useRef(null),ft=w.useRef(!1),Xt=ht({mutationFn:({amsId:vt,slotId:on})=>pe.refreshAmsSlot(t.id,vt,on),onMutate:({amsId:vt,slotId:on})=>{ln.current&&clearTimeout(ln.current),Lt.current=!1,ft.current=!1,nn({amsId:vt,slotId:on}),setTimeout(()=>{ft.current=!0},2e3),ln.current=setTimeout(()=>{nn(null)},3e4)},onSuccess:vt=>{p(vt.message||"RFID re-read initiated")},onError:vt=>{p(vt.message||"Failed to re-read RFID","error"),ln.current&&clearTimeout(ln.current),nn(null)}}),tn=w.useRef(null);w.useEffect(()=>{if(!Tt)return;const vt=ee?.ams_status_main??0;return vt!==0&&(Lt.current=!0,tn.current&&(clearTimeout(tn.current),tn.current=null)),Lt.current&&vt===0&&(ft.current?(ln.current&&clearTimeout(ln.current),nn(null)):tn.current||(tn.current=setTimeout(()=>{ln.current&&clearTimeout(ln.current),nn(null)},2e3))),()=>{tn.current&&clearTimeout(tn.current)}},[ee?.ams_status_main,Tt]);const[wt,gr]=w.useState(null);if(ye)return null;const Nr=()=>{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"}},_r=()=>{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"}},er=()=>{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(Et,{className:"relative",children:[s.jsxs(At,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:er(),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:BPe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Nr()}`}),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 ${_r()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ee?.connected?"bg-status-ok":"bg-status-error"}`,title:ee?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ee?.nozzles&&ee.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ee.nozzles[0].nozzle_type||"Nozzle",children:["• ",ee.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(Yn,{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(Me,{variant:"ghost",size:"sm",onClick:()=>y(!b),children:s.jsx(Od,{className:"w-4 h-4"})}),b&&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:()=>{A(!0),y(!1)},children:[s.jsx(Ia,{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:()=>{$e.mutate(),y(!1)},children:[s.jsx(Mr,{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),y(!1)},children:[s.jsx(wK,{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),y(!1)},children:[s.jsx(fn,{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 ${ee?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ee?.connected?s.jsx(Xg,{className:"w-3 h-3"}):s.jsx(zD,{className:"w-3 h-3"}),ee?.connected?"Connected":"Offline"]}),ee?.connected&&de!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${de>=-50||de>=-60?"bg-status-ok/20 text-status-ok":de>=-70?"bg-status-warning/20 text-status-warning":de>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${de} dBm - ${$Pe(de).label}`,children:[s.jsx($fe,{className:"w-3 h-3"}),de,"dBm"]}),ee?.connected&&(()=>{const vt=ee.hms_errors?lpe(ee.hms_errors):[];return s.jsxs("button",{onClick:()=>W(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${vt.length>0?vt.some(on=>on.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:"Click to view HMS errors",children:[s.jsx(Rn,{className:"w-3 h-3"}),vt.length>0?vt.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>m("/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-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,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(Kd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Je>0&&s.jsxs("button",{onClick:()=>m("/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:`${Je} print${Je>1?"s":""} in queue`,children:[s.jsx(al,{className:"w-3 h-3"}),Je]}),Qe?.update_available&&s.jsxs("button",{onClick:()=>De(!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: ${Qe.current_version} → ${Qe.latest_version}`,children:[s.jsx(Ir,{className:"w-3 h-3"}),"Update"]})]})]}),x&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Et,{className:"w-full max-w-md mx-4",children:s.jsxs(At,{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(Rn,{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:S,onChange:vt=>M(vt.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:S?"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(Me,{variant:"secondary",onClick:()=>{v(!1),M(!0)},children:"Cancel"}),s.jsx(Me,{variant:"danger",onClick:()=>{Ce.mutate({deleteArchives:S}),v(!1),M(!0)},children:"Delete"})]})]})})}),ee?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ee.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:`${ee.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ee.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:mV(ee.state,ee.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:()=>Z(!0),disabled:!(ee.state==="RUNNING"||ee.state==="PAUSE"||ee.state==="PAUSED")||(ee.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ee.state==="RUNNING"||ee.state==="PAUSE"||ee.state==="PAUSED")&&(ee.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:ee.state==="RUNNING"||ee.state==="PAUSE"||ee.state==="PAUSED"?(ee.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(oV,{className:"w-4 h-4"}),Be&&Be.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:Be.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(HPe,{url:ee.state==="RUNNING"?ee.cover_url:null,printName:ee.state==="RUNNING"&&(ee.subtask_name||ee.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ee.current_print&&ee.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ee.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ee.subtask_name||ee.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:`${ee.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ee.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ee.remaining_time!=null&&ee.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Yn,{className:"w-3 h-3"}),UPe(ee.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",zPe(ee.remaining_time,c)]})]}),ee.layer_num!=null&&ee.total_layers!=null&&ee.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(al,{className:"w-3 h-3"}),ee.layer_num,"/",ee.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:mV(ee.state,ee.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:"—"})]}),oe?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:oe.print_name||oe.filename,children:["Last: ",oe.print_name||oe.filename,oe.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",xg(oe.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),ee.state!=="RUNNING"&&s.jsx(hpe,{printerId:t.id})]}),ee.temperatures&&r==="expanded"&&(()=>{const vt=ee.temperatures.nozzle_heating||ee.temperatures.nozzle_2_heating||!1,on=ee.temperatures.bed_heating||!1,Nn=ee.temperatures.chamber_heating||!1,ce=t.nozzle_count===2||ee.temperatures.nozzle_2!==void 0,Ue=ee.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(VC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:vt}),ee.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(ee.temperatures.nozzle||0),"° / ",Math.round(ee.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(ee.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(VC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:on}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ee.temperatures.bed||0),"°C"]})]}),ee.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(VC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Nn}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ee.temperatures.chamber||0),"°C"]})]}),ce&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Ue==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Ue==="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 ${Ue==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const vt=ee.state==="RUNNING",on=ee.state==="PAUSED"||ee.state==="PAUSE",Nn=vt||on,ce=ze.isPending||ve.isPending||He.isPending,Ue=ee.cooling_fan_speed,We=ee.big_fan1_speed,rt=ee.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 ${Ue&&Ue>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(uK,{className:`w-3.5 h-3.5 ${Ue&&Ue>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Ue&&Ue>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Ue??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${We&&We>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(EK,{className:`w-3.5 h-3.5 ${We&&We>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${We&&We>0?"text-blue-400":"text-bambu-gray/50"}`,children:[We??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${rt&&rt>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Mue,{className:`w-3.5 h-3.5 ${rt&&rt>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${rt&&rt>0?"text-green-400":"text-bambu-gray/50"}`,children:[rt??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>G(!0),disabled:!Nn||ce,className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${Nn?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  80. `,title:"Stop print",children:[s.jsx(ll,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>on?z(!0):ie(!0),disabled:!Nn||ce,className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${Nn?on?"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"}
  84. `,title:on?"Resume print":"Pause print",children:[on?s.jsx(sl,{className:"w-3 h-3"}):s.jsx(FD,{className:"w-3 h-3"}),on?"Resume":"Pause"]})]})]})]})})(),X&&X.length>0&&r==="expanded"&&(()=>{const vt=X.filter(ce=>ce.tray.length>1),on=X.filter(ce=>ce.tray.length===1),Nn=t.nozzle_count===2||ee?.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:[vt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:vt.map(ce=>{const Ue=$[String(ce.id)],We=ce.id>=128?ce.id-128:ce.id,rt=Ue!==void 0?Ue:We,et=rt===1,Ct=rt===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:Zu(ce.id,ce.tray.length)}),Nn&&(et||Ct)&&s.jsx(cV,{side:et?"L":"R"})]}),(ce.humidity!=null||ce.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[ce.humidity!=null&&s.jsx(dV,{humidity:ce.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ce.id,amsLabel:Zu(ce.id,ce.tray.length),mode:"humidity"}),compact:!0}),ce.temp!=null&&s.jsx(hV,{temp:ce.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ce.id,amsLabel:Zu(ce.id,ce.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(yt=>{const Mt=ce.tray[yt]||ce.tray.find(pt=>pt.id===yt),Vt=Mt?.tray_type&&Mt.remain>=0,ue=!Mt?.tray_type,je=ce.id*4+yt,Ge=ae===je,qe=Mt?.tray_info_idx?te?.[Mt.tray_info_idx]:null,Ve=Y?.[je],xt=Mt?.tray_type?{vendor:GC(Mt)?"Bambu Lab":"Generic",profile:qe?.name||Ve?.preset_name||Mt.tray_sub_brands||Mt.tray_type,colorName:BC(Mt.tray_id_name)||$C(Mt.tray_color),colorHex:Mt.tray_color||null,kFactor:HC(Mt.k),fillLevel:Vt?Mt.remain:null,trayUuid:Mt.tray_uuid||null}:null,Pt=Tt?.amsId===ce.id&&Tt?.slotId===yt,_t=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ue?"opacity-50":""} ${Ge?"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:Mt?.tray_color?`#${Mt.tray_color}`:Mt?.tray_type?"#333":"transparent",borderColor:ue?"#666":"rgba(255,255,255,0.1)",borderStyle:ue?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Mt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Vt&&Mt?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Mt.remain}%`,backgroundColor:fV(Mt.remain)}}):Mt?.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:[Pt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Mr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ee?.state!=="RUNNING"&&s.jsx("button",{onClick:pt=>{pt.stopPropagation(),gr(wt?.amsId===ce.id&&wt?.slotId===yt?null:{amsId:ce.id,slotId:yt})},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(Od,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ee?.state!=="RUNNING"&&wt?.amsId===ce.id&&wt?.slotId===yt&&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:pt=>{pt.stopPropagation(),Xt.mutate({amsId:ce.id,slotId:yt}),gr(null)},disabled:Pt,children:[s.jsx(Mr,{className:`w-3 h-3 ${Pt?"animate-spin":""}`}),"Re-read RFID"]})}),xt?s.jsx(UC,{data:xt,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&xt.trayUuid?pt=>{le({trayUuid:pt,trayInfo:{type:xt.profile,color:xt.colorHex||"",location:`${Zu(ce.id,ce.tray.length)} Slot ${yt+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:ce.id,trayId:yt,trayCount:ce.tray.length,trayType:Mt?.tray_type||void 0,trayColor:Mt?.tray_color||void 0,traySubBrands:Mt?.tray_sub_brands||void 0,trayInfoIdx:Mt?.tray_info_idx||void 0})},children:_t}):s.jsx(iV,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:ce.id,trayId:yt,trayCount:ce.tray.length})},children:_t})]},yt)})})]},ce.id)})}),(on.length>0||ee.vt_tray&&ee.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[on.map(ce=>{const Ue=$[String(ce.id)],We=ce.id>=128?ce.id-128:ce.id,rt=Ue!==void 0?Ue:We,et=rt===1,Ct=rt===0,yt=ce.tray[0],Mt=yt?.tray_type&&yt.remain>=0,Vt=!yt?.tray_type,ue=ce.id*4+(yt?.id??0),je=ae===ue,Ge=yt?.tray_info_idx?te?.[yt.tray_info_idx]:null,qe=Y?.[ue],Ve=yt?.tray_type?{vendor:GC(yt)?"Bambu Lab":"Generic",profile:Ge?.name||qe?.preset_name||yt.tray_sub_brands||yt.tray_type,colorName:BC(yt.tray_id_name)||$C(yt.tray_color),colorHex:yt.tray_color||null,kFactor:HC(yt.k),fillLevel:Mt?yt.remain:null,trayUuid:yt.tray_uuid||null}:null,xt=yt?.id??0,Pt=Tt?.amsId===ce.id&&Tt?.slotId===xt,_t=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Vt?"opacity-50":""} ${je?"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:yt?.tray_color?`#${yt.tray_color}`:yt?.tray_type?"#333":"transparent",borderColor:Vt?"#666":"rgba(255,255,255,0.1)",borderStyle:Vt?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:yt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Mt?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${yt.remain}%`,backgroundColor:fV(yt.remain)}}):yt?.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:Zu(ce.id,ce.tray.length)}),Nn&&(et||Ct)&&s.jsx(cV,{side:et?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Pt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Mr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ee?.state!=="RUNNING"&&s.jsx("button",{onClick:pt=>{pt.stopPropagation(),gr(wt?.amsId===ce.id&&wt?.slotId===xt?null:{amsId:ce.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(Od,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ee?.state!=="RUNNING"&&wt?.amsId===ce.id&&wt?.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:pt=>{pt.stopPropagation(),Xt.mutate({amsId:ce.id,slotId:xt}),gr(null)},disabled:Pt,children:[s.jsx(Mr,{className:`w-3 h-3 ${Pt?"animate-spin":""}`}),"Re-read RFID"]})}),Ve?s.jsx(UC,{data:Ve,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ve.trayUuid?pt=>{le({trayUuid:pt,trayInfo:{type:Ve.profile,color:Ve.colorHex||"",location:Zu(ce.id,ce.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:ce.id,trayId:xt,trayCount:ce.tray.length,trayType:yt?.tray_type||void 0,trayColor:yt?.tray_color||void 0,traySubBrands:yt?.tray_sub_brands||void 0,trayInfoIdx:yt?.tray_info_idx||void 0})},children:_t}):s.jsx(iV,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:ce.id,trayId:xt,trayCount:ce.tray.length})},children:_t})]}),(ce.humidity!=null||ce.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[ce.temp!=null&&s.jsx(hV,{temp:ce.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:ce.id,amsLabel:Zu(ce.id,ce.tray.length),mode:"temperature"}),compact:!0}),ce.humidity!=null&&s.jsx(dV,{humidity:ce.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:ce.id,amsLabel:Zu(ce.id,ce.tray.length),mode:"humidity"}),compact:!0})]})]})]},ce.id)}),ee.vt_tray&&ee.vt_tray.tray_type&&(()=>{const ce=ee.vt_tray,Ue=ae===254,We=ce.tray_info_idx?te?.[ce.tray_info_idx]:null,rt=Y?.[1020],et={vendor:GC(ce)?"Bambu Lab":"Generic",profile:We?.name||rt?.preset_name||ce.tray_sub_brands||ce.tray_type||"Unknown",colorName:BC(ce.tray_id_name)||$C(ce.tray_color),colorHex:ce.tray_color||null,kFactor:HC(ce.k),fillLevel:null,trayUuid:ce.tray_uuid||null},Ct=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Ue?"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:ce.tray_color?`#${ce.tray_color}`:"#333",borderColor:Ue?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ce.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(UC,{data:et,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&et.trayUuid?yt=>{le({trayUuid:yt,trayInfo:{type:et.profile,color:et.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:255,trayId:0,trayCount:1,trayType:ce.tray_type||void 0,trayColor:ce.tray_color||void 0,traySubBrands:ce.tray_sub_brands||void 0,trayInfoIdx:ce.tray_info_idx||void 0})},children:Ct})]})})()]})]})]})})()]}),Te&&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(zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:Te.name}),Pe&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Pe.state==="ON"?"bg-bambu-green/20 text-bambu-green":Pe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Pe.state||"?",Pe.state==="ON"&&Pe.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Pe.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>U(!0),disabled:lt.isPending||Pe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Pe?.state==="ON"?"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-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>q(!0),disabled:lt.isPending||Pe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Pe?.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(cE,{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 ${Te.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Te.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>se.mutate(!Te.auto_off),disabled:se.isPending||Te.auto_off_executed,title:Te.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 ${Te.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Te.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 ${Te.auto_off||Te.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(Me,{variant:"secondary",size:"sm",onClick:()=>Oe.mutate(!ee?.chamber_light),disabled:!ee?.connected||Oe.isPending,title:ee?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:ee?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(PPe,{on:ee?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const vt=localStorage.getItem("cameraWindowState"),on=vt?JSON.parse(vt):{width:640,height:400},Nn=[`width=${on.width}`,`height=${on.height}`,on.left!==void 0?`left=${on.left}`:"",on.top!==void 0?`top=${on.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Nn)}},disabled:!ee?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(BD,{className:"w-4 h-4"})}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C(!0),title:"Browse printer files",children:[s.jsx(iE,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(epe,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),D&&s.jsx(spe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),R&&Te&&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:()=>{lt.mutate("on"),U(!1)},onCancel:()=>U(!1)}),O&&Te&&s.jsx(Un,{title:"Power Off Printer",message:ee?.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:()=>{lt.mutate("off"),q(!1)},onCancel:()=>q(!1)}),K&&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:()=>{ze.mutate(),G(!1)},onCancel:()=>G(!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:()=>{ve.mutate(),ie(!1)},onCancel:()=>ie(!1)}),re&&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(),z(!1)},onCancel:()=>z(!1)}),V&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Z(!1),onKeyDown:vt=>vt.key==="Escape"&&Z(!1),tabIndex:-1,ref:vt=>vt?.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] max-h-[85vh] flex flex-col overflow-hidden",onClick:vt=>vt.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(oV,{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:()=>Z(!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(Wt,{className:"w-4 h-4"})})]}),Be?Be.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 overflow-hidden",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(sfe,{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:[Be.skipped_count,"/",Be.total," skipped"]})]}),(ee?.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(Qi,{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 ",ee?.layer_num??0,")"]})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",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 overflow-y-auto",children:s.jsxs("div",{className:"relative",children:[ee?.cover_url?s.jsx("img",{src:`${ee.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(Fs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Be.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Be.objects.map((vt,on)=>{let Nn,ce;if(vt.x!=null&&vt.y!=null&&Be.bbox_all){const[Ue,We,rt,et]=Be.bbox_all,Ct=rt-Ue,yt=et-We,Mt=8,Vt=100-Mt*2;Nn=Mt+(vt.x-Ue)/Ct*Vt,ce=Mt+(et-vt.y)/yt*Vt,Nn=Math.max(5,Math.min(95,Nn)),ce=Math.max(5,Math.min(95,ce))}else if(vt.x!=null&&vt.y!=null)Nn=vt.x/256*100,ce=100-vt.y/256*100,Nn=Math.max(5,Math.min(95,Nn)),ce=Math.max(5,Math.min(95,ce));else{const Ue=Math.ceil(Math.sqrt(Be.objects.length)),We=Math.floor(on/Ue),rt=on%Ue,et=Math.ceil(Be.objects.length/Ue);Nn=15+rt*(70/Ue)+35/Ue,ce=15+We*(70/et)+35/et}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${vt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Nn}%`,top:`${ce}%`,transform:"translate(-50%, -50%)"},title:vt.name,children:vt.id},vt.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:[Be.objects.filter(vt=>!vt.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Be.objects.map(vt=>s.jsxs("div",{className:`
  85. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  86. ${vt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[s.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${vt.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"}
  90. `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${vt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:vt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${vt.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 ${vt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:vt.name}),vt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),vt.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:()=>Rt.mutate([vt.id]),disabled:Rt.isPending||(ee?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ee?.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:(ee?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},vt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),j&&s.jsx(upe,{printerName:t.name,errors:ee?.hms_errors||[],onClose:()=>W(!1)}),ne&&s.jsx(SPe,{isOpen:!!ne,onClose:()=>he(null),printerId:t.id,printerName:t.name,amsId:ne.amsId,amsLabel:ne.amsLabel,initialMode:ne.mode,thresholds:a}),fe&&s.jsx(MPe,{isOpen:!!fe,onClose:()=>le(null),trayUuid:fe.trayUuid,trayInfo:fe.trayInfo}),Ee&&s.jsx(jPe,{isOpen:!!Ee,onClose:()=>me(null),printerId:t.id,slotInfo:Ee,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),N&&s.jsx(qPe,{printer:t,onClose:()=>A(!1)}),we&&Qe&&s.jsx(WPe,{printer:t,firmwareInfo:Qe,onClose:()=>De(!1)}),wt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>gr(null)})]})}function GPe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState("192.168.1.0/24"),[v,S]=w.useState({scanned:0,total:0});w.useEffect(()=>{Sl.getInfo().then(C=>{b(C.is_docker)}).catch(()=>{})},[]);const M=l.filter(C=>!n.includes(C.serial)),N=async()=>{d(""),c([]),o(!0),m(!1),S({scanned:0,total:0});try{if(p){await Sl.startSubnetScan(y);const C=setInterval(async()=>{try{const D=await Sl.getScanStatus();S({scanned:D.scanned,total:D.total});const T=await Sl.getDiscoveredPrinters();c(T),D.running||(clearInterval(C),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await Sl.startDiscovery(10);const C=setInterval(async()=>{try{const D=await Sl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(C);try{await Sl.stopDiscovery()}catch{}o(!1),m(!0);try{const D=await Sl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(C){console.error("Failed to start discovery:",C),d(C instanceof Error?C.message:"Failed to start discovery"),o(!1),m(!0)}},A=C=>C?{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"}[C]||C:"",k=C=>{const D=C.serial.startsWith("unknown-")?"":C.serial;i({...r,name:C.name||"",serial_number:D,ip_address:C.ip_address,model:A(C.model)}),c([])};return w.useEffect(()=>()=>{Sl.stopDiscovery().catch(()=>{}),Sl.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(Et,{className:"w-full max-w-md",onClick:C=>C.stopPropagation(),children:s.jsxs(At,{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:[p&&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:y,onChange:C=>x(C.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(Me,{type:"button",variant:"secondary",onClick:N,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(va,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),M.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:M.map(C=>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:()=>k(C),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:C.name||C.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[A(C.model)||"Unknown"," • ",C.ip_address,C.serial.startsWith("unknown-")&&s.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),s.jsx(Zi,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},C.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"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",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&M.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:C=>{C.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:C=>i({...r,name:C.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:C=>i({...r,ip_address:C.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:C=>i({...r,serial_number:C.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:C=>i({...r,access_code:C.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:C=>i({...r,model:C.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:C=>i({...r,auto_archive:C.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(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function WPe({printer:t,firmwareInfo:e,onClose:n}){const r=un(),{showToast:i}=qn(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["firmwarePrepare",t.id],queryFn:()=>Q1.prepareUpload(t.id),staleTime:3e4}),p=ht({mutationFn:()=>Q1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const x=await Q1.getUploadStatus(t.id);o(x),(x.status==="complete"||x.status==="error")&&(clearInterval(y),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(y)},onError:y=>{i(`Failed to start upload: ${y.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const b=()=>{o(null),p.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Et,{className:"w-full max-w-md mx-4",children:s.jsxs(At,{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(Ir,{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})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(dt,{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(Fs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((y,x)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Qi,{className:"w-4 h-4 flex-shrink-0"}),y]},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-status-error":a.status==="complete"?"bg-status-ok":"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(Me,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Me,{onClick:b,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ir,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function qPe({printer:t,onClose:e}){const n=un(),[r,i]=w.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=>pe.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.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(Et,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(At,{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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function KPe(t){const{data:e}=ut({queryKey:["printerStatus",t],queryFn:()=>pe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function XPe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=KPe(t.id),{data:a}=ut({queryKey:["smartPlugStatus",e.id],queryFn:()=>pe.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(_u,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function YPe(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,p]=w.useState(()=>{const V=localStorage.getItem("printerCardSize");return V?parseInt(V,10):2}),b=m===1?"compact":"expanded",y=un(),[x,v]=w.useState(()=>{const V=localStorage.getItem("openEmbeddedCameras");if(V)try{const Z=JSON.parse(V);return new Map(Z.map(ne=>[ne.id,ne]))}catch{return new Map}return new Map});w.useEffect(()=>{const V=Array.from(x.values());V.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(V)):localStorage.removeItem("openEmbeddedCameras")},[x]);const{data:S,isLoading:M}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:N}=ut({queryKey:["settings"],queryFn:pe.getSettings});w.useEffect(()=>{N?.camera_view_mode==="window"&&x.size>0&&v(new Map)},[N?.camera_view_mode,x.size]);const{data:A}=ut({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:k}=ut({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview,staleTime:60*1e3}),{data:C}=ut({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,staleTime:60*1e3}),D=C?.enabled&&C?.connected,{data:T}=ut({queryKey:["unlinked-spools"],queryFn:pe.getUnlinkedSpools,enabled:!!D,staleTime:30*1e3}),R=T&&T.length>0,U=k?.reduce((V,Z)=>(V[Z.printer_id]={due_count:Z.due_count,warning_count:Z.warning_count,total_print_hours:Z.total_print_hours},V),{})||{},O=A?.reduce((V,Z)=>(Z.printer_id&&(V[Z.printer_id]=Z),V),{})||{},q=ht({mutationFn:pe.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=ht({mutationFn:V=>pe.controlSmartPlug(V,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const V=!n;r(V),localStorage.setItem("hideDisconnectedPrinters",String(V))},K=V=>{u(V),localStorage.setItem("printerSortBy",V)},G=()=>{const V=!d;f(V),localStorage.setItem("printerSortAsc",String(V))},J=()=>{switch(m){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"}},ie=["S","M","L","XL"],re=w.useMemo(()=>{if(!S)return[];const V=[...S];switch(c){case"name":V.sort((Z,ne)=>Z.name.localeCompare(ne.name));break;case"model":V.sort((Z,ne)=>(Z.model||"").localeCompare(ne.model||""));break;case"location":V.sort((Z,ne)=>{const he=Z.location||"",fe=ne.location||"";return!he&&fe?1:he&&!fe?-1:he.localeCompare(fe)||Z.name.localeCompare(ne.name)});break;case"status":V.sort((Z,ne)=>{const he=y.getQueryData(["printerStatus",Z.id]),fe=y.getQueryData(["printerStatus",ne.id]),le=Ee=>Ee?.connected?Ee.state==="RUNNING"?0:1:2;return le(he)-le(fe)});break}return d||V.reverse(),V},[S,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const V={};return re.forEach(Z=>{const ne=Z.location||"Ungrouped";V[ne]||(V[ne]=[]),V[ne].push(Z)}),V},[c,re]);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(VPe,{printers:S})]}),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:V=>K(V.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:G,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(hg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(A0,{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:ie.map((V,Z)=>{const ne=Z+1,he=m===ne;return s.jsx("button",{onClick:()=>{p(ne),localStorage.setItem("printerCardSize",String(ne))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Z===0?"rounded-l-lg":""} ${Z===ie.length-1?"rounded-r-lg":""} ${he?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${V==="S"?"Small":V==="M"?"Medium":V==="L"?"Large":"Extra large"} cards`,children:V},V)})}),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:W,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(O).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(_u,{className:"w-4 h-4"}),"Power On",s.jsx(Zi,{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"}),S?.filter(V=>O[V.id]).map(V=>s.jsx(XPe,{printer:V,plug:O[V.id],onPowerOn:Z=>{l(Z),j.mutate(Z)},isPowering:o===O[V.id]?.id},V.id)),S?.filter(V=>O[V.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Printer"]})]})]}),M?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):S?.length===0?s.jsx(Et,{children:s.jsxs(At,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?s.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([V,Z])=>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"}),V,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Z.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:Z.map(ne=>s.jsx(pV,{printer:ne,hideIfDisconnected:n,maintenanceInfo:U[ne.id],viewMode:b,cardSize:m,amsThresholds:N?{humidityGood:Number(N.ams_humidity_good)||40,humidityFair:Number(N.ams_humidity_fair)||60,tempGood:Number(N.ams_temp_good)||28,tempFair:Number(N.ams_temp_fair)||35}:void 0,spoolmanEnabled:D,hasUnlinkedSpools:R,timeFormat:N?.time_format||"system",cameraViewMode:N?.camera_view_mode||"window",onOpenEmbeddedCamera:(he,fe)=>v(le=>new Map(le).set(he,{id:he,name:fe}))},ne.id))})]},V))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:re.map(V=>s.jsx(pV,{printer:V,hideIfDisconnected:n,maintenanceInfo:U[V.id],viewMode:b,cardSize:m,spoolmanEnabled:D,hasUnlinkedSpools:R,amsThresholds:N?{humidityGood:Number(N.ams_humidity_good)||40,humidityFair:Number(N.ams_humidity_fair)||60,tempGood:Number(N.ams_temp_good)||28,tempFair:Number(N.ams_temp_fair)||35}:void 0,timeFormat:N?.time_format||"system",cameraViewMode:N?.camera_view_mode||"window",onOpenEmbeddedCamera:(Z,ne)=>v(he=>new Map(he).set(Z,{id:Z,name:ne}))},V.id))}),t&&s.jsx(GPe,{onClose:()=>e(!1),onAdd:V=>q.mutate(V),existingSerials:S?.map(V=>V.serial_number)||[]}),Array.from(x.values()).map((V,Z)=>s.jsx(ape,{printerId:V.id,printerName:V.name,viewerIndex:Z,onClose:()=>v(ne=>{const he=new Map(ne);return he.delete(V.id),he})},V.id))]})}function ZPe(){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 QPe(){return ZPe()==="windows"?"bambustudio://":"bambustudioopen://"}function qc(t){const e=QPe();window.location.href=`${e}${encodeURIComponent(t)}`}const q4="182",rg={ROTATE:0,DOLLY:1,PAN:2},Kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},JPe=0,gV=1,e3e=2,ow=1,t3e=2,Bb=3,Qd=0,bs=1,Ll=2,iu=0,ig=1,xV=2,bV=3,yV=4,n3e=5,Qh=100,r3e=101,i3e=102,a3e=103,s3e=104,o3e=200,l3e=201,c3e=202,u3e=203,M3=204,E3=205,d3e=206,h3e=207,f3e=208,m3e=209,p3e=210,g3e=211,x3e=212,b3e=213,y3e=214,N3=0,A3=1,T3=2,Ng=3,C3=4,k3=5,j3=6,P3=7,K4=0,v3e=1,_3e=2,Wl=0,WJ=1,qJ=2,KJ=3,XJ=4,YJ=5,ZJ=6,QJ=7,JJ=300,Yf=301,Ag=302,R3=303,D3=304,oN=306,O3=1e3,Qc=1001,L3=1002,_a=1003,w3e=1004,j_=1005,Oa=1006,WC=1007,ff=1008,zs=1009,eee=1010,tee=1011,W0=1012,X4=1013,nc=1014,Bl=1015,bu=1016,Y4=1017,Z4=1018,q0=1020,nee=35902,ree=35899,iee=1021,aee=1022,Jo=1023,yu=1026,mf=1027,see=1028,Q4=1029,Tg=1030,J4=1031,eL=1033,lw=33776,cw=33777,uw=33778,dw=33779,I3=35840,F3=35841,U3=35842,z3=35843,B3=36196,$3=37492,H3=37496,V3=37488,G3=37489,W3=37490,q3=37491,K3=37808,X3=37809,Y3=37810,Z3=37811,Q3=37812,J3=37813,eR=37814,tR=37815,nR=37816,rR=37817,iR=37818,aR=37819,sR=37820,oR=37821,lR=36492,cR=36494,uR=36495,dR=36283,hR=36284,fR=36285,mR=36286,S3e=3200,oee=0,M3e=1,Sd="",bo="srgb",Cg="srgb-linear",FS="linear",ar="srgb",Jm=7680,vV=519,E3e=512,N3e=513,A3e=514,tL=515,T3e=516,C3e=517,nL=518,k3e=519,_V=35044,wV="300 es",$l=2e3,US=2001;function lee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function zS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function j3e(){const t=zS("canvas");return t.style.display="block",t}const SV={};function MV(...t){const e="THREE."+t.shift();console.log(e,...t)}function dn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Vn(...t){const e="THREE."+t.shift();console.error(e,...t)}function K0(...t){const e=t.join(" ");e in SV||(SV[e]=!0,dn(...t))}function P3e(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 um=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 Na=["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"],hw=Math.PI/180,pR=180/Math.PI;function Hy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Na[t&255]+Na[t>>8&255]+Na[t>>16&255]+Na[t>>24&255]+"-"+Na[e&255]+Na[e>>8&255]+"-"+Na[e>>16&15|64]+Na[e>>24&255]+"-"+Na[n&63|128]+Na[n>>8&255]+"-"+Na[n>>16&255]+Na[n>>24&255]+Na[r&255]+Na[r>>8&255]+Na[r>>16&255]+Na[r>>24&255]).toLowerCase()}function jn(t,e,n){return Math.max(e,Math.min(n,t))}function R3e(t,e){return(t%e+e)%e}function qC(t,e,n){return(1-n)*t+n*e}function gb(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 us(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 D3e={DEG2RAD:hw};let Mn=class cee{constructor(e=0,n=0){cee.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=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(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(jn(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}},Zf=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],m=a[o+0],p=a[o+1],b=a[o+2],y=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]=m,e[n+1]=p,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==b){let x=c*m+u*p+d*b+f*y;x<0&&(m=-m,p=-p,b=-b,y=-y,x=-x);let v=1-l;if(x<.9995){const S=Math.acos(x),M=Math.sin(S);v=Math.sin(v*S)/M,l=Math.sin(l*S)/M,c=c*v+m*l,u=u*v+p*l,d=d*v+b*l,f=f*v+y*l}else{c=c*v+m*l,u=u*v+p*l,d=d*v+b*l,f=f*v+y*l;const S=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=S,u*=S,d*=S,f*=S}}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],m=a[o+1],p=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*p-u*m,e[n+1]=c*b+d*m+u*f-l*p,e[n+2]=u*b+d*p+l*m-c*f,e[n+3]=d*b-l*f-c*m-u*p,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),m=c(r/2),p=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"YXZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"ZXY":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"ZYX":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"YZX":this._x=m*d*f+u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f-m*p*b;break;case"XZY":this._x=m*d*f-u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f+m*p*b;break;default:dn("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],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}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(jn(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}},nt=class uee{constructor(e=0,n=0,r=0){uee.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=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this.z=jn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this.z=jn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(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 KC.copy(this).projectOnVector(e),this.sub(KC)}reflect(e){return this.sub(KC.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(jn(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 KC=new nt,EV=new Zf;let An=class dee{constructor(e,n,r,i,a,o,l,c,u){dee.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],m=r[2],p=r[5],b=r[8],y=i[0],x=i[3],v=i[6],S=i[1],M=i[4],N=i[7],A=i[2],k=i[5],C=i[8];return a[0]=o*y+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*v+l*N+c*C,a[1]=u*y+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*v+d*N+f*C,a[2]=m*y+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*v+p*N+b*C,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,m=l*c-d*a,p=u*a-o*c,b=n*f+r*m+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,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(XC.makeScale(e,n)),this}rotate(e){return this.premultiply(XC.makeRotation(-e)),this}translate(e,n){return this.premultiply(XC.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 XC=new An,NV=new An().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AV=new An().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function O3e(){const t={enabled:!0,workingColorSpace:Cg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===ar&&(i.r=au(i.r),i.g=au(i.g),i.b=au(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===ar&&(i.r=ag(i.r),i.g=ag(i.g),i.b=ag(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===Sd?FS: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 K0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return K0("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({[Cg]:{primaries:e,whitePoint:r,transfer:FS,toXYZ:NV,fromXYZ:AV,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:bo},outputColorSpaceConfig:{drawingBufferColorSpace:bo}},[bo]:{primaries:e,whitePoint:r,transfer:ar,toXYZ:NV,fromXYZ:AV,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:bo}}}),t}const Bn=O3e();function au(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function ag(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ep,L3e=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{ep===void 0&&(ep=zS("canvas")),ep.width=e.width,ep.height=e.height;const i=ep.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ep}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=zS("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]=au(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(au(n[r]/255)*255):n[r]=au(n[r]);return{data:n,width:e.width,height:e.height}}else return dn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},I3e=0,rL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:I3e++}),this.uuid=Hy(),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):typeof VideoFrame<"u"&&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(YC(i[o].image)):a.push(YC(i[o]))}else a=YC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function YC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?L3e.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(dn("Texture: Unable to serialize Texture."),{})}let F3e=0;const ZC=new nt;let xl=class fw extends um{constructor(e=fw.DEFAULT_IMAGE,n=fw.DEFAULT_MAPPING,r=Qc,i=Qc,a=Oa,o=ff,l=Jo,c=zs,u=fw.DEFAULT_ANISOTROPY,d=Sd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:F3e++}),this.uuid=Hy(),this.name="",this.source=new rL(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 Mn(0,0),this.repeat=new Mn(1,1),this.center=new Mn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new An,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(ZC).x}get height(){return this.source.getSize(ZC).y}get depth(){return this.source.getSize(ZC).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){dn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){dn(`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!==JJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case O3:e.x=e.x-Math.floor(e.x);break;case Qc:e.x=e.x<0?0:1;break;case L3: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 O3:e.y=e.y-Math.floor(e.y);break;case Qc:e.y=e.y<0?0:1;break;case L3: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++}};xl.DEFAULT_IMAGE=null;xl.DEFAULT_MAPPING=JJ;xl.DEFAULT_ANISOTROPY=1;let xi=class hee{constructor(e=0,n=0,r=0,i=1){hee.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],m=c[1],p=c[5],b=c[9],y=c[2],x=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,N=(p+1)/2,A=(v+1)/2,k=(d+m)/4,C=(f+y)/4,D=(b+x)/4;return M>N&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=C/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=C/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-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=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this.z=jn(this.z,e.z,n.z),this.w=jn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this.z=jn(this.z,e,n),this.w=jn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(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}},U3e=class extends um{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Oa,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 xi(0,0,e,n),this.scissorTest=!1,this.viewport=new xi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new xl(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:Oa,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 rL(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"})}},ql=class extends U3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},fee=class extends xl{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=_a,this.minFilter=_a,this.wrapR=Qc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},z3e=class extends xl{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=_a,this.minFilter=_a,this.wrapR=Qc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Qf=class{constructor(e=new nt(1/0,1/0,1/0),n=new nt(-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(Bo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Bo.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=Bo.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,Bo):Bo.fromBufferAttribute(a,o),Bo.applyMatrix4(e.matrixWorld),this.expandByPoint(Bo);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,Bo),Bo.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(xb),R_.subVectors(this.max,xb),tp.subVectors(e.a,xb),np.subVectors(e.b,xb),rp.subVectors(e.c,xb),Qu.subVectors(np,tp),Ju.subVectors(rp,np),Oh.subVectors(tp,rp);let n=[0,-Qu.z,Qu.y,0,-Ju.z,Ju.y,0,-Oh.z,Oh.y,Qu.z,0,-Qu.x,Ju.z,0,-Ju.x,Oh.z,0,-Oh.x,-Qu.y,Qu.x,0,-Ju.y,Ju.x,0,-Oh.y,Oh.x,0];return!QC(n,tp,np,rp,R_)||(n=[1,0,0,0,1,0,0,0,1],!QC(n,tp,np,rp,R_))?!1:(D_.crossVectors(Qu,Ju),n=[D_.x,D_.y,D_.z],QC(n,tp,np,rp,R_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Bo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Bo).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 nt,new nt,new nt,new nt,new nt,new nt,new nt,new nt],Bo=new nt,P_=new Qf,tp=new nt,np=new nt,rp=new nt,Qu=new nt,Ju=new nt,Oh=new nt,xb=new nt,R_=new nt,D_=new nt,Lh=new nt;function QC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Lh.fromArray(t,a);const l=i.x*Math.abs(Lh.x)+i.y*Math.abs(Lh.y)+i.z*Math.abs(Lh.z),c=e.dot(Lh),u=n.dot(Lh),d=r.dot(Lh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const B3e=new Qf,bb=new nt,JC=new nt;let lN=class{constructor(e=new nt,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):B3e.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;bb.subVectors(e,this.center);const n=bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(bb,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):(JC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(bb.copy(e.center).add(JC)),this.expandByPoint(bb.copy(e.center).sub(JC))),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 kc=new nt,ek=new nt,O_=new nt,ed=new nt,tk=new nt,L_=new nt,nk=new nt;let iL=class{constructor(e=new nt,n=new nt(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,kc)),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=kc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(kc.copy(this.origin).addScaledVector(this.direction,n),kc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){ek.copy(e).add(n).multiplyScalar(.5),O_.copy(n).sub(e).normalize(),ed.copy(this.origin).sub(ek);const a=e.distanceTo(n)*.5,o=-this.direction.dot(O_),l=ed.dot(this.direction),c=-ed.dot(O_),u=ed.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(ek).addScaledVector(O_,m),p}intersectSphere(e,n){kc.subVectors(e.center,this.origin);const r=kc.dot(this.direction),i=kc.dot(kc)-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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.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,kc)!==null}intersectTriangle(e,n,r,i,a){tk.subVectors(n,e),L_.subVectors(r,e),nk.crossVectors(tk,L_);let o=this.direction.dot(nk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;ed.subVectors(this.origin,e);const c=l*this.direction.dot(L_.crossVectors(ed,L_));if(c<0)return null;const u=l*this.direction.dot(tk.cross(ed));if(u<0||c+u>o)return null;const d=-l*ed.dot(nk);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)}},li=class gR{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){gR.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,m,p,b,y,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=b,v[11]=y,v[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 gR().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 this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/ip.setFromMatrixColumn(e,0).length(),a=1/ip.setFromMatrixColumn(e,1).length(),o=1/ip.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 m=o*d,p=o*f,b=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=b+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m+y*l,n[4]=b*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-b,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,b=l*d,y=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=b*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=y*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose($3e,e,H3e)}lookAt(e,n,r){const i=this.elements;return Rs.subVectors(e,n),Rs.lengthSq()===0&&(Rs.z=1),Rs.normalize(),td.crossVectors(r,Rs),td.lengthSq()===0&&(Math.abs(r.z)===1?Rs.x+=1e-4:Rs.z+=1e-4,Rs.normalize(),td.crossVectors(r,Rs)),td.normalize(),I_.crossVectors(Rs,td),i[0]=td.x,i[4]=I_.x,i[8]=Rs.x,i[1]=td.y,i[5]=I_.y,i[9]=Rs.y,i[2]=td.z,i[6]=I_.z,i[10]=Rs.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],m=r[9],p=r[13],b=r[2],y=r[6],x=r[10],v=r[14],S=r[3],M=r[7],N=r[11],A=r[15],k=i[0],C=i[4],D=i[8],T=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],K=i[10],G=i[14],J=i[3],ie=i[7],re=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*J,a[4]=o*C+l*U+c*W+u*ie,a[8]=o*D+l*O+c*K+u*re,a[12]=o*T+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*J,a[5]=d*C+f*U+m*W+p*ie,a[9]=d*D+f*O+m*K+p*re,a[13]=d*T+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*J,a[6]=b*C+y*U+x*W+v*ie,a[10]=b*D+y*O+x*K+v*re,a[14]=b*T+y*q+x*G+v*z,a[3]=S*k+M*R+N*j+A*J,a[7]=S*C+M*U+N*W+A*ie,a[11]=S*D+M*O+N*K+A*re,a[15]=S*T+M*q+N*G+A*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],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],m=e[10],p=e[14],b=e[3],y=e[7],x=e[11],v=e[15],S=c*p-u*m,M=l*p-u*f,N=l*m-c*f,A=o*p-u*d,k=o*m-c*d,C=o*f-l*d;return n*(y*S-x*M+v*N)-r*(b*S-x*A+v*k)+i*(b*M-y*A+v*C)-a*(b*N-y*k+x*C)}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],m=e[10],p=e[11],b=e[12],y=e[13],x=e[14],v=e[15],S=f*x*u-y*m*u+y*c*p-l*x*p-f*c*v+l*m*v,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*v-o*m*v,N=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,A=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*N+a*A;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=S*C,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*C,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=M*C,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*C,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=N*C,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*C,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=A*C,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*C,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,m=a*u,p=a*d,b=a*f,y=o*d,x=o*f,v=l*f,S=c*u,M=c*d,N=c*f,A=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+N)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-N)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*C,i[9]=(x-S)*C,i[10]=(1-(m+y))*C,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;if(e.x=i[12],e.y=i[13],e.z=i[14],this.determinant()===0)return r.set(1,1,1),n.identity(),this;let a=ip.set(i[0],i[1],i[2]).length();const o=ip.set(i[4],i[5],i[6]).length(),l=ip.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),$o.copy(this);const u=1/a,d=1/o,f=1/l;return $o.elements[0]*=u,$o.elements[1]*=u,$o.elements[2]*=u,$o.elements[4]*=d,$o.elements[5]*=d,$o.elements[6]*=d,$o.elements[8]*=f,$o.elements[9]*=f,$o.elements[10]*=f,n.setFromRotationMatrix($o),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=$l,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let b,y;if(c)b=a/(o-a),y=o*a/(o-a);else if(l===$l)b=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===US)b=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=$l,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let b,y;if(c)b=1/(o-a),y=o/(o-a);else if(l===$l)b=-2/(o-a),y=-(o+a)/(o-a);else if(l===US)b=-1/(o-a),y=-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]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=b,u[14]=y,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 ip=new nt,$o=new li,$3e=new nt(0,0,0),H3e=new nt(1,1,1),td=new nt,I_=new nt,Rs=new nt,TV=new li,CV=new Zf;let Jd=class mee{constructor(e=0,n=0,r=0,i=mee.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(jn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-jn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(jn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-jn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(jn(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,p));break;case"XZY":this._z=Math.asin(-jn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:dn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return TV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return CV.setFromEuler(this),this.setFromQuaternion(CV,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}};Jd.DEFAULT_ORDER="XYZ";let pee=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}},V3e=0;const kV=new nt,ap=new Zf,jc=new li,F_=new nt,yb=new nt,G3e=new nt,W3e=new Zf,jV=new nt(1,0,0),PV=new nt(0,1,0),RV=new nt(0,0,1),DV={type:"added"},q3e={type:"removed"},sp={type:"childadded",child:null},rk={type:"childremoved",child:null};let Ys=class mw extends um{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:V3e++}),this.uuid=Hy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=mw.DEFAULT_UP.clone();const e=new nt,n=new Jd,r=new Zf,i=new nt(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 li},normalMatrix:{value:new An}}),this.matrix=new li,this.matrixWorld=new li,this.matrixAutoUpdate=mw.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=mw.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pee,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 ap.setFromAxisAngle(e,n),this.quaternion.multiply(ap),this}rotateOnWorldAxis(e,n){return ap.setFromAxisAngle(e,n),this.quaternion.premultiply(ap),this}rotateX(e){return this.rotateOnAxis(jV,e)}rotateY(e){return this.rotateOnAxis(PV,e)}rotateZ(e){return this.rotateOnAxis(RV,e)}translateOnAxis(e,n){return kV.copy(e).applyQuaternion(this.quaternion),this.position.add(kV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(jV,e)}translateY(e){return this.translateOnAxis(PV,e)}translateZ(e){return this.translateOnAxis(RV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(jc.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),yb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jc.lookAt(yb,F_,this.up):jc.lookAt(F_,yb,this.up),this.quaternion.setFromRotationMatrix(jc),i&&(jc.extractRotation(i.matrixWorld),ap.setFromRotationMatrix(jc),this.quaternion.premultiply(ap.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vn("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(DV),sp.child=e,this.dispatchEvent(sp),sp.child=null):Vn("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(q3e),rk.child=e,this.dispatchEvent(rk),rk.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),jc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jc.multiply(e.parent.matrixWorld)),e.applyMatrix4(jc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(DV),sp.child=e,this.dispatchEvent(sp),sp.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(yb,e,G3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yb,W3e,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),m=o(e.skeletons),p=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),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),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}};Ys.DEFAULT_UP=new nt(0,1,0);Ys.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ys.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ho=new nt,Pc=new nt,ik=new nt,Rc=new nt,op=new nt,lp=new nt,OV=new nt,ak=new nt,sk=new nt,ok=new nt,lk=new xi,ck=new xi,uk=new xi;let vb=class zp{constructor(e=new nt,n=new nt,r=new nt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ho.subVectors(e,n),i.cross(Ho);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){Ho.subVectors(i,n),Pc.subVectors(r,n),ik.subVectors(e,n);const o=Ho.dot(Ho),l=Ho.dot(Pc),c=Ho.dot(ik),u=Pc.dot(Pc),d=Pc.dot(ik),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Rc)===null?!1:Rc.x>=0&&Rc.y>=0&&Rc.x+Rc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Rc)===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,Rc.x),c.addScaledVector(o,Rc.y),c.addScaledVector(l,Rc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return lk.setScalar(0),ck.setScalar(0),uk.setScalar(0),lk.fromBufferAttribute(e,n),ck.fromBufferAttribute(e,r),uk.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(lk,a.x),o.addScaledVector(ck,a.y),o.addScaledVector(uk,a.z),o}static isFrontFacing(e,n,r,i){return Ho.subVectors(r,n),Pc.subVectors(e,n),Ho.cross(Pc).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 Ho.subVectors(this.c,this.b),Pc.subVectors(this.a,this.b),Ho.cross(Pc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return zp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return zp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return zp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zp.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;op.subVectors(i,r),lp.subVectors(a,r),ak.subVectors(e,r);const c=op.dot(ak),u=lp.dot(ak);if(c<=0&&u<=0)return n.copy(r);sk.subVectors(e,i);const d=op.dot(sk),f=lp.dot(sk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(op,o);ok.subVectors(e,a);const p=op.dot(ok),b=lp.dot(ok);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(lp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return OV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(OV,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(op,o).addScaledVector(lp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const gee={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},nd={h:0,s:0,l:0},U_={h:0,s:0,l:0};function dk(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 Pn=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=bo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Bn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Bn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Bn.workingColorSpace){if(e=R3e(e,1),n=jn(n,0,1),r=jn(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=dk(o,a,e+1/3),this.g=dk(o,a,e),this.b=dk(o,a,e-1/3)}return Bn.colorSpaceToWorking(this,i),this}setStyle(e,n=bo){function r(a){a!==void 0&&parseFloat(a)<1&&dn("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:dn("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);dn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=bo){const r=gee[e.toLowerCase()];return r!==void 0?this.setHex(r,n):dn("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=au(e.r),this.g=au(e.g),this.b=au(e.b),this}copyLinearToSRGB(e){return this.r=ag(e.r),this.g=ag(e.g),this.b=ag(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bo){return Bn.workingToColorSpace(Aa.copy(this),e),Math.round(jn(Aa.r*255,0,255))*65536+Math.round(jn(Aa.g*255,0,255))*256+Math.round(jn(Aa.b*255,0,255))}getHexString(e=bo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Bn.workingColorSpace){Bn.workingToColorSpace(Aa.copy(this),n);const r=Aa.r,i=Aa.g,a=Aa.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=Bn.workingColorSpace){return Bn.workingToColorSpace(Aa.copy(this),n),e.r=Aa.r,e.g=Aa.g,e.b=Aa.b,e}getStyle(e=bo){Bn.workingToColorSpace(Aa.copy(this),e);const n=Aa.r,r=Aa.g,i=Aa.b;return e!==bo?`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(nd),this.setHSL(nd.h+e,nd.s+n,nd.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(nd),e.getHSL(U_);const r=qC(nd.h,U_.h,n),i=qC(nd.s,U_.s,n),a=qC(nd.l,U_.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 Aa=new Pn;Pn.NAMES=gee;let K3e=0,lx=class extends um{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K3e++}),this.uuid=Hy(),this.name="",this.type="Material",this.blending=ig,this.side=Qd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=M3,this.blendDst=E3,this.blendEquation=Qh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Pn(0,0,0),this.blendAlpha=0,this.depthFunc=Ng,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=vV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Jm,this.stencilZFail=Jm,this.stencilZPass=Jm,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){dn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){dn(`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!==ig&&(r.blending=this.blending),this.side!==Qd&&(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!==M3&&(r.blendSrc=this.blendSrc),this.blendDst!==E3&&(r.blendDst=this.blendDst),this.blendEquation!==Qh&&(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!==Ng&&(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!==vV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Jm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Jm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Jm&&(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.allowOverride===!1&&(r.allowOverride=!1),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.allowOverride=e.allowOverride,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++}},aL=class extends lx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Pn(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 Jd,this.combine=K4,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 mi=new nt,z_=new Mn;let X3e=0,Ao=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:X3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=_V,this.updateRanges=[],this.gpuType=Bl,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++)z_.fromBufferAttribute(this,n),z_.applyMatrix3(e),this.setXY(n,z_.x,z_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)mi.fromBufferAttribute(this,n),mi.applyMatrix3(e),this.setXYZ(n,mi.x,mi.y,mi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)mi.fromBufferAttribute(this,n),mi.applyMatrix4(e),this.setXYZ(n,mi.x,mi.y,mi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)mi.fromBufferAttribute(this,n),mi.applyNormalMatrix(e),this.setXYZ(n,mi.x,mi.y,mi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)mi.fromBufferAttribute(this,n),mi.transformDirection(e),this.setXYZ(n,mi.x,mi.y,mi.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=gb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=us(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=gb(n,this.array)),n}setX(e,n){return this.normalized&&(n=us(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=gb(n,this.array)),n}setY(e,n){return this.normalized&&(n=us(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=gb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=us(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=gb(n,this.array)),n}setW(e,n){return this.normalized&&(n=us(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=us(n,this.array),r=us(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=us(n,this.array),r=us(r,this.array),i=us(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=us(n,this.array),r=us(r,this.array),i=us(i,this.array),a=us(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!==_V&&(e.usage=this.usage),e}},xee=class extends Ao{constructor(e,n,r){super(new Uint16Array(e),n,r)}},bee=class extends Ao{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Gs=class extends Ao{constructor(e,n,r){super(new Float32Array(e),n,r)}},Y3e=0;const uo=new li,hk=new Ys,cp=new nt,Ds=new Qf,_b=new Qf,Fi=new nt;let bl=class yee extends um{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Y3e++}),this.uuid=Hy(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(lee(e)?bee:xee)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,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 An().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 uo.makeRotationFromQuaternion(e),this.applyMatrix4(uo),this}rotateX(e){return uo.makeRotationX(e),this.applyMatrix4(uo),this}rotateY(e){return uo.makeRotationY(e),this.applyMatrix4(uo),this}rotateZ(e){return uo.makeRotationZ(e),this.applyMatrix4(uo),this}translate(e,n,r){return uo.makeTranslation(e,n,r),this.applyMatrix4(uo),this}scale(e,n,r){return uo.makeScale(e,n,r),this.applyMatrix4(uo),this}lookAt(e){return hk.lookAt(e),hk.updateMatrix(),this.applyMatrix4(hk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cp).negate(),this.translate(cp.x,cp.y,cp.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 Gs(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&&dn("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 Qf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new nt(-1/0,-1/0,-1/0),new nt(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];Ds.setFromBufferAttribute(a),this.morphTargetsRelative?(Fi.addVectors(this.boundingBox.min,Ds.min),this.boundingBox.expandByPoint(Fi),Fi.addVectors(this.boundingBox.max,Ds.max),this.boundingBox.expandByPoint(Fi)):(this.boundingBox.expandByPoint(Ds.min),this.boundingBox.expandByPoint(Ds.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vn('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 lN);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new nt,1/0);return}if(e){const r=this.boundingSphere.center;if(Ds.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];_b.setFromBufferAttribute(l),this.morphTargetsRelative?(Fi.addVectors(Ds.min,_b.min),Ds.expandByPoint(Fi),Fi.addVectors(Ds.max,_b.max),Ds.expandByPoint(Fi)):(Ds.expandByPoint(_b.min),Ds.expandByPoint(_b.max))}Ds.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Fi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Fi));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++)Fi.fromBufferAttribute(l,u),c&&(cp.fromBufferAttribute(e,u),Fi.add(cp)),i=Math.max(i,r.distanceToSquared(Fi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vn('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){Vn("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 Ao(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new nt,c[D]=new nt;const u=new nt,d=new nt,f=new nt,m=new Mn,p=new Mn,b=new Mn,y=new nt,x=new nt;function v(D,T,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,R),m.fromBufferAttribute(a,D),p.fromBufferAttribute(a,T),b.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(m),b.sub(m);const U=1/(p.x*b.y-b.x*p.y);isFinite(U)&&(y.copy(d).multiplyScalar(b.y).addScaledVector(f,-p.y).multiplyScalar(U),x.copy(f).multiplyScalar(p.x).addScaledVector(d,-b.x).multiplyScalar(U),l[D].add(y),l[T].add(y),l[R].add(y),c[D].add(x),c[T].add(x),c[R].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,T=S.length;D<T;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const M=new nt,N=new nt,A=new nt,k=new nt;function C(D){A.fromBufferAttribute(i,D),k.copy(A);const T=l[D];M.copy(T),M.sub(A.multiplyScalar(A.dot(T))).normalize(),N.crossVectors(k,T);const U=N.dot(c[D])<0?-1:1;o.setXYZW(D,M.x,M.y,M.z,U)}for(let D=0,T=S.length;D<T;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)C(e.getX(q+0)),C(e.getX(q+1)),C(e.getX(q+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 Ao(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new nt,a=new nt,o=new nt,l=new nt,c=new nt,u=new nt,d=new nt,f=new nt;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)Fi.fromBufferAttribute(e,n),Fi.normalize(),e.setXYZ(n,Fi.x,Fi.y,Fi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[b++]=u[p++]}return new Ao(m,d,f)}if(this.index===null)return dn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new yee,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 m=u[d],p=e(m,r);c.push(p)}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,m=u.length;f<m;f++){const p=u[f];d.push(p.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 m=0,p=f.length;m<p;m++)d.push(f[m].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 LV=new li,Ih=new iL,B_=new lN,IV=new nt,$_=new nt,H_=new nt,V_=new nt,fk=new nt,G_=new nt,FV=new nt,W_=new nt;let dl=class extends Ys{constructor(e=new bl,n=new aL){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){G_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(fk.fromBufferAttribute(f,e),o?G_.addScaledVector(fk,d):G_.addScaledVector(fk.sub(n),d))}n.add(G_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),B_.copy(r.boundingSphere),B_.applyMatrix4(a),Ih.copy(e.ray).recast(e.near),!(B_.containsPoint(Ih.origin)===!1&&(Ih.intersectSphere(B_,IV)===null||Ih.origin.distanceToSquared(IV)>(e.far-e.near)**2))&&(LV.copy(a).invert(),Ih.copy(e.ray).applyMatrix4(LV),!(r.boundingBox!==null&&Ih.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Ih)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(l.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=l.getX(N),C=l.getX(N+1),D=l.getX(N+2);i=q_(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),M=l.getX(x+1),N=l.getX(x+2);i=q_(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(c.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=N,C=N+1,D=N+2;i=q_(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=x,M=x+1,N=x+2;i=q_(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function Z3e(t,e,n,r,i,a,o,l){let c;if(e.side===bs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Qd,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 q_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,$_),t.getVertexPosition(c,H_),t.getVertexPosition(u,V_);const d=Z3e(t,e,n,r,$_,H_,V_,FV);if(d){const f=new nt;vb.getBarycoord(FV,$_,H_,V_,f),i&&(d.uv=vb.getInterpolatedAttribute(i,l,c,u,f,new Mn)),a&&(d.uv1=vb.getInterpolatedAttribute(a,l,c,u,f,new Mn)),o&&(d.normal=vb.getInterpolatedAttribute(o,l,c,u,f,new nt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new nt,materialIndex:0};vb.getNormal($_,H_,V_,m.normal),d.face=m,d.barycoord=f}return d}let sL=class vee extends bl{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 m=0,p=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 Gs(u,3)),this.setAttribute("normal",new Gs(d,3)),this.setAttribute("uv",new Gs(f,2));function b(y,x,v,S,M,N,A,k,C,D,T){const R=N/C,U=A/D,O=N/2,q=A/2,j=k/2,W=C+1,K=D+1;let G=0,J=0;const ie=new nt;for(let re=0;re<K;re++){const z=re*U-q;for(let V=0;V<W;V++){const Z=V*R-O;ie[y]=Z*S,ie[x]=z*M,ie[v]=j,u.push(ie.x,ie.y,ie.z),ie[y]=0,ie[x]=0,ie[v]=k>0?1:-1,d.push(ie.x,ie.y,ie.z),f.push(V/C),f.push(1-re/D),G+=1}}for(let re=0;re<D;re++)for(let z=0;z<C;z++){const V=m+z+W*re,Z=m+z+W*(re+1),ne=m+(z+1)+W*(re+1),he=m+(z+1)+W*re;c.push(V,Z,he),c.push(Z,ne,he),J+=6}l.addGroup(p,J,T),p+=J,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vee(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function kg(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?(dn("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 Ha(t){const e={};for(let n=0;n<t.length;n++){const r=kg(t[n]);for(const i in r)e[i]=r[i]}return e}function Q3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function _ee(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Bn.workingColorSpace}const J3e={clone:kg,merge:Ha};var eRe=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,tRe=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let rc=class extends lx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=eRe,this.fragmentShader=tRe,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=kg(e.uniforms),this.uniformsGroups=Q3e(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,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}},wee=class extends Ys{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new li,this.projectionMatrix=new li,this.projectionMatrixInverse=new li,this.coordinateSystem=$l,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 rd=new nt,UV=new Mn,zV=new Mn;let _o=class extends wee{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=pR*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(hw*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return pR*2*Math.atan(Math.tan(hw*.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){rd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rd.x,rd.y).multiplyScalar(-e/rd.z),rd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(rd.x,rd.y).multiplyScalar(-e/rd.z)}getViewSize(e,n){return this.getViewBounds(e,UV,zV),n.subVectors(zV,UV)}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(hw*.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 up=-90,dp=1;let nRe=class extends Ys{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new _o(up,dp,e,n);i.layers=this.layers,this.add(i);const a=new _o(up,dp,e,n);a.layers=this.layers,this.add(a);const o=new _o(up,dp,e,n);o.layers=this.layers,this.add(o);const l=new _o(up,dp,e,n);l.layers=this.layers,this.add(l);const c=new _o(up,dp,e,n);c.layers=this.layers,this.add(c);const u=new _o(up,dp,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===$l)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===US)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},See=class extends xl{constructor(e=[],n=Yf,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}},Mee=class extends ql{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 See(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:`
  95. varying vec3 vWorldDirection;
  96. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  97. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  98. }
  99. void main() {
  100. vWorldDirection = transformDirection( position, modelMatrix );
  101. #include <begin_vertex>
  102. #include <project_vertex>
  103. }
  104. `,fragmentShader:`
  105. uniform sampler2D tEquirect;
  106. varying vec3 vWorldDirection;
  107. #include <common>
  108. void main() {
  109. vec3 direction = normalize( vWorldDirection );
  110. vec2 sampleUV = equirectUv( direction );
  111. gl_FragColor = texture2D( tEquirect, sampleUV );
  112. }
  113. `},i=new sL(5,5,5),a=new rc({name:"CubemapFromEquirect",uniforms:kg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:bs,blending:iu});a.uniforms.tEquirect.value=n;const o=new dl(i,a),l=n.minFilter;return n.minFilter===ff&&(n.minFilter=Oa),new nRe(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)}},$b=class extends Ys{constructor(){super(),this.isGroup=!0,this.type="Group"}};const rRe={type:"move"};let mk=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new $b,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 $b,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new nt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new nt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new $b,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new nt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new nt),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 y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-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(rRe)))}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 $b;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},iRe=class extends Ys{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 Jd,this.environmentIntensity=1,this.environmentRotation=new Jd,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}},aRe=class extends xl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=_a,d=_a,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const pk=new nt,sRe=new nt,oRe=new An;let gd=class{constructor(e=new nt(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=pk.subVectors(r,n).cross(sRe.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(pk),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||oRe.getNormalMatrix(e),i=this.coplanarPoint(pk).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 Fh=new lN,lRe=new Mn(.5,.5),K_=new nt;let oL=class{constructor(e=new gd,n=new gd,r=new gd,i=new gd,a=new gd,o=new gd){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=$l,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],m=a[6],p=a[7],b=a[8],y=a[9],x=a[10],v=a[11],S=a[12],M=a[13],N=a[14],A=a[15];if(i[0].setComponents(u-o,p-d,v-b,A-S).normalize(),i[1].setComponents(u+o,p+d,v+b,A+S).normalize(),i[2].setComponents(u+l,p+f,v+y,A+M).normalize(),i[3].setComponents(u-l,p-f,v-y,A-M).normalize(),r)i[4].setComponents(c,m,x,N).normalize(),i[5].setComponents(u-c,p-m,v-x,A-N).normalize();else if(i[4].setComponents(u-c,p-m,v-x,A-N).normalize(),n===$l)i[5].setComponents(u+c,p+m,v+x,A+N).normalize();else if(n===US)i[5].setComponents(c,m,x,N).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(),Fh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Fh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fh)}intersectsSprite(e){Fh.center.set(0,0,0);const n=lRe.distanceTo(e.center);return Fh.radius=.7071067811865476+n,Fh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fh)}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(K_.x=i.normal.x>0?e.max.x:e.min.x,K_.y=i.normal.y>0?e.max.y:e.min.y,K_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(K_)<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)}},Eee=class extends lx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Pn(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 BS=new nt,$S=new nt,BV=new li,wb=new iL,X_=new lN,gk=new nt,$V=new nt;let cRe=class extends Ys{constructor(e=new bl,n=new Eee){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++)BS.fromBufferAttribute(n,i-1),$S.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=BS.distanceTo($S);e.setAttribute("lineDistance",new Gs(r,1))}else dn("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(),X_.copy(r.boundingSphere),X_.applyMatrix4(i),X_.radius+=a,e.ray.intersectsSphere(X_)===!1)return;BV.copy(i).invert(),wb.copy(e.ray).applyMatrix4(BV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),b=Math.min(d.count,o.start+o.count);for(let y=p,x=b-1;y<x;y+=u){const v=d.getX(y),S=d.getX(y+1),M=Y_(this,e,wb,c,v,S,y);M&&n.push(M)}if(this.isLineLoop){const y=d.getX(b-1),x=d.getX(p),v=Y_(this,e,wb,c,y,x,b-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),b=Math.min(m.count,o.start+o.count);for(let y=p,x=b-1;y<x;y+=u){const v=Y_(this,e,wb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=Y_(this,e,wb,c,b-1,p,b-1);y&&n.push(y)}}}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 Y_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(BS.fromBufferAttribute(l,i),$S.fromBufferAttribute(l,a),n.distanceSqToSegment(BS,$S,gk,$V)>r)return;gk.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(gk);if(!(u<e.near||u>e.far))return{distance:u,point:$V.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const HV=new nt,VV=new nt;let uRe=class extends cRe{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)HV.fromBufferAttribute(n,i),VV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+HV.distanceTo(VV);e.setAttribute("lineDistance",new Gs(r,1))}else dn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},X0=class extends xl{constructor(e,n,r=nc,i,a,o,l=_a,c=_a,u,d=yu,f=1){if(d!==yu&&d!==mf)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,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 rL(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 dRe extends X0{constructor(e,n=nc,r=Yf,i,a,o=_a,l=_a,c,u=yu){const d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,n,r,i,a,o,l,c,u),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Nee extends xl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let lL=class Aee extends bl{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,m=n/c,p=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const N=M*f-a;b.push(N,-S,0),y.push(0,0,1),x.push(M/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,N=S+u*(v+1),A=S+1+u*(v+1),k=S+1+u*v;p.push(M,N,k),p.push(N,A,k)}this.setIndex(p),this.setAttribute("position",new Gs(b,3)),this.setAttribute("normal",new Gs(y,3)),this.setAttribute("uv",new Gs(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Aee(e.width,e.height,e.widthSegments,e.heightSegments)}};class hRe extends rc{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class fRe extends lx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Pn(16777215),this.specular=new Pn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oee,this.normalScale=new Mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jd,this.combine=K4,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 mRe=class extends lx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=S3e,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}},pRe=class extends lx{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}},Tee=class extends Ys{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Pn(e),this.intensity=n}dispose(){this.dispatchEvent({type:"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,n}};const xk=new li,GV=new nt,WV=new nt;let gRe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Mn(512,512),this.mapType=zs,this.map=null,this.mapPass=null,this.matrix=new li,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oL,this._frameExtents=new Mn(1,1),this._viewportCount=1,this._viewports=[new xi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;GV.setFromMatrixPosition(e.matrixWorld),n.position.copy(GV),WV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(WV),n.updateMatrixWorld(),xk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xk,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(xk)}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}},cL=class extends wee{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 xRe extends gRe{constructor(){super(new cL(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class qV extends Tee{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ys.DEFAULT_UP),this.updateMatrix(),this.target=new Ys,this.shadow=new xRe}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const n=super.toJSON(e);return n.object.shadow=this.shadow.toJSON(),n.object.target=this.target.uuid,n}}let bRe=class extends Tee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},yRe=class extends _o{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},KV=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=jn(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(jn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class vRe extends uRe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Pn(r),i=new Pn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,b=-l;m<=n;m++,b+=o){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,0,l);const y=m===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new bl;d.setAttribute("position",new Gs(c,3)),d.setAttribute("color",new Gs(u,3));const f=new Eee({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class _Re extends um{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){dn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function XV(t,e,n,r){const i=wRe(r);switch(n){case iee:return t*e;case see:return t*e/i.components*i.byteLength;case Q4:return t*e/i.components*i.byteLength;case Tg:return t*e*2/i.components*i.byteLength;case J4:return t*e*2/i.components*i.byteLength;case aee:return t*e*3/i.components*i.byteLength;case Jo:return t*e*4/i.components*i.byteLength;case eL:return t*e*4/i.components*i.byteLength;case lw:case cw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case uw:case dw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case F3:case z3:return Math.max(t,16)*Math.max(e,8)/4;case I3:case U3:return Math.max(t,8)*Math.max(e,8)/2;case B3:case $3:case V3:case G3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case H3:case W3:case q3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case K3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case X3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case Y3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Z3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case Q3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case J3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case eR:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case tR:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case nR:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case rR:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case iR:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case aR:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case sR:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case oR:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case lR:case cR:case uR:return Math.ceil(t/4)*Math.ceil(e/4)*16;case dR:case hR:return Math.ceil(t/4)*Math.ceil(e/4)*8;case fR:case mR:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function wRe(t){switch(t){case zs:case eee:return{byteLength:1,components:1};case W0:case tee:case bu:return{byteLength:2,components:1};case Y4:case Z4:return{byteLength:2,components:4};case nc:case X4:case Bl:return{byteLength:4,components:1};case nee:case ree:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:q4}}));typeof window<"u"&&(window.__THREE__?dn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=q4);function Cee(){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 SRe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:p,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((p,b)=>p.start-b.start);let m=0;for(let p=1;p<f.length;p++){const b=f[m],y=f[p];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++m,f[m]=y)}f.length=m+1;for(let p=0,b=f.length;p<b;p++){const y=f[p];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.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 MRe=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,ERe=`#ifdef USE_ALPHAHASH
  116. const float ALPHA_HASH_SCALE = 0.05;
  117. float hash2D( vec2 value ) {
  118. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  119. }
  120. float hash3D( vec3 value ) {
  121. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  122. }
  123. float getAlphaHashThreshold( vec3 position ) {
  124. float maxDeriv = max(
  125. length( dFdx( position.xyz ) ),
  126. length( dFdy( position.xyz ) )
  127. );
  128. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  129. vec2 pixScales = vec2(
  130. exp2( floor( log2( pixScale ) ) ),
  131. exp2( ceil( log2( pixScale ) ) )
  132. );
  133. vec2 alpha = vec2(
  134. hash3D( floor( pixScales.x * position.xyz ) ),
  135. hash3D( floor( pixScales.y * position.xyz ) )
  136. );
  137. float lerpFactor = fract( log2( pixScale ) );
  138. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  139. float a = min( lerpFactor, 1.0 - lerpFactor );
  140. vec3 cases = vec3(
  141. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  142. ( x - 0.5 * a ) / ( 1.0 - a ),
  143. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  144. );
  145. float threshold = ( x < ( 1.0 - a ) )
  146. ? ( ( x < a ) ? cases.x : cases.y )
  147. : cases.z;
  148. return clamp( threshold , 1.0e-6, 1.0 );
  149. }
  150. #endif`,NRe=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,ARe=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,TRe=`#ifdef USE_ALPHATEST
  155. #ifdef ALPHA_TO_COVERAGE
  156. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  157. if ( diffuseColor.a == 0.0 ) discard;
  158. #else
  159. if ( diffuseColor.a < alphaTest ) discard;
  160. #endif
  161. #endif`,CRe=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,kRe=`#ifdef USE_AOMAP
  164. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  165. reflectedLight.indirectDiffuse *= ambientOcclusion;
  166. #if defined( USE_CLEARCOAT )
  167. clearcoatSpecularIndirect *= ambientOcclusion;
  168. #endif
  169. #if defined( USE_SHEEN )
  170. sheenSpecularIndirect *= ambientOcclusion;
  171. #endif
  172. #if defined( USE_ENVMAP ) && defined( STANDARD )
  173. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  174. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  175. #endif
  176. #endif`,jRe=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,PRe=`#ifdef USE_BATCHING
  180. #if ! defined( GL_ANGLE_multi_draw )
  181. #define gl_DrawID _gl_DrawID
  182. uniform int _gl_DrawID;
  183. #endif
  184. uniform highp sampler2D batchingTexture;
  185. uniform highp usampler2D batchingIdTexture;
  186. mat4 getBatchingMatrix( const in float i ) {
  187. int size = textureSize( batchingTexture, 0 ).x;
  188. int j = int( i ) * 4;
  189. int x = j % size;
  190. int y = j / size;
  191. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  192. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  193. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  194. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  195. return mat4( v1, v2, v3, v4 );
  196. }
  197. float getIndirectIndex( const in int i ) {
  198. int size = textureSize( batchingIdTexture, 0 ).x;
  199. int x = i % size;
  200. int y = i / size;
  201. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  202. }
  203. #endif
  204. #ifdef USE_BATCHING_COLOR
  205. uniform sampler2D batchingColorTexture;
  206. vec3 getBatchingColor( const in float i ) {
  207. int size = textureSize( batchingColorTexture, 0 ).x;
  208. int j = int( i );
  209. int x = j % size;
  210. int y = j / size;
  211. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  212. }
  213. #endif`,RRe=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,DRe=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,ORe=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,LRe=`float G_BlinnPhong_Implicit( ) {
  222. return 0.25;
  223. }
  224. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  225. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  226. }
  227. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  228. vec3 halfDir = normalize( lightDir + viewDir );
  229. float dotNH = saturate( dot( normal, halfDir ) );
  230. float dotVH = saturate( dot( viewDir, halfDir ) );
  231. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  232. float G = G_BlinnPhong_Implicit( );
  233. float D = D_BlinnPhong( shininess, dotNH );
  234. return F * ( G * D );
  235. } // validated`,IRe=`#ifdef USE_IRIDESCENCE
  236. const mat3 XYZ_TO_REC709 = mat3(
  237. 3.2404542, -0.9692660, 0.0556434,
  238. -1.5371385, 1.8760108, -0.2040259,
  239. -0.4985314, 0.0415560, 1.0572252
  240. );
  241. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  242. vec3 sqrtF0 = sqrt( fresnel0 );
  243. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  244. }
  245. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  246. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  247. }
  248. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  249. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  250. }
  251. vec3 evalSensitivity( float OPD, vec3 shift ) {
  252. float phase = 2.0 * PI * OPD * 1.0e-9;
  253. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  254. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  255. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  256. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  257. 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 ) );
  258. xyz /= 1.0685e-7;
  259. vec3 rgb = XYZ_TO_REC709 * xyz;
  260. return rgb;
  261. }
  262. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  263. vec3 I;
  264. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  265. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  266. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  267. if ( cosTheta2Sq < 0.0 ) {
  268. return vec3( 1.0 );
  269. }
  270. float cosTheta2 = sqrt( cosTheta2Sq );
  271. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  272. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  273. float T121 = 1.0 - R12;
  274. float phi12 = 0.0;
  275. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  276. float phi21 = PI - phi12;
  277. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  278. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  279. vec3 phi23 = vec3( 0.0 );
  280. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  281. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  282. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  283. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  284. vec3 phi = vec3( phi21 ) + phi23;
  285. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  286. vec3 r123 = sqrt( R123 );
  287. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  288. vec3 C0 = R12 + Rs;
  289. I = C0;
  290. vec3 Cm = Rs - T121;
  291. for ( int m = 1; m <= 2; ++ m ) {
  292. Cm *= r123;
  293. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  294. I += Cm * Sm;
  295. }
  296. return max( I, vec3( 0.0 ) );
  297. }
  298. #endif`,FRe=`#ifdef USE_BUMPMAP
  299. uniform sampler2D bumpMap;
  300. uniform float bumpScale;
  301. vec2 dHdxy_fwd() {
  302. vec2 dSTdx = dFdx( vBumpMapUv );
  303. vec2 dSTdy = dFdy( vBumpMapUv );
  304. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  305. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  306. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  307. return vec2( dBx, dBy );
  308. }
  309. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  310. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  311. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  312. vec3 vN = surf_norm;
  313. vec3 R1 = cross( vSigmaY, vN );
  314. vec3 R2 = cross( vN, vSigmaX );
  315. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  316. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  317. return normalize( abs( fDet ) * surf_norm - vGrad );
  318. }
  319. #endif`,URe=`#if NUM_CLIPPING_PLANES > 0
  320. vec4 plane;
  321. #ifdef ALPHA_TO_COVERAGE
  322. float distanceToPlane, distanceGradient;
  323. float clipOpacity = 1.0;
  324. #pragma unroll_loop_start
  325. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  326. plane = clippingPlanes[ i ];
  327. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  328. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  329. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  330. if ( clipOpacity == 0.0 ) discard;
  331. }
  332. #pragma unroll_loop_end
  333. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  334. float unionClipOpacity = 1.0;
  335. #pragma unroll_loop_start
  336. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  337. plane = clippingPlanes[ i ];
  338. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  339. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  340. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  341. }
  342. #pragma unroll_loop_end
  343. clipOpacity *= 1.0 - unionClipOpacity;
  344. #endif
  345. diffuseColor.a *= clipOpacity;
  346. if ( diffuseColor.a == 0.0 ) discard;
  347. #else
  348. #pragma unroll_loop_start
  349. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  350. plane = clippingPlanes[ i ];
  351. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  352. }
  353. #pragma unroll_loop_end
  354. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  355. bool clipped = true;
  356. #pragma unroll_loop_start
  357. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  358. plane = clippingPlanes[ i ];
  359. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  360. }
  361. #pragma unroll_loop_end
  362. if ( clipped ) discard;
  363. #endif
  364. #endif
  365. #endif`,zRe=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,BRe=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,$Re=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,HRe=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,VRe=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,GRe=`#if defined( USE_COLOR_ALPHA )
  381. varying vec4 vColor;
  382. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  383. varying vec3 vColor;
  384. #endif`,WRe=`#if defined( USE_COLOR_ALPHA )
  385. vColor = vec4( 1.0 );
  386. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  387. vColor = vec3( 1.0 );
  388. #endif
  389. #ifdef USE_COLOR
  390. vColor *= color;
  391. #endif
  392. #ifdef USE_INSTANCING_COLOR
  393. vColor.xyz *= instanceColor.xyz;
  394. #endif
  395. #ifdef USE_BATCHING_COLOR
  396. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  397. vColor.xyz *= batchingColor.xyz;
  398. #endif`,qRe=`#define PI 3.141592653589793
  399. #define PI2 6.283185307179586
  400. #define PI_HALF 1.5707963267948966
  401. #define RECIPROCAL_PI 0.3183098861837907
  402. #define RECIPROCAL_PI2 0.15915494309189535
  403. #define EPSILON 1e-6
  404. #ifndef saturate
  405. #define saturate( a ) clamp( a, 0.0, 1.0 )
  406. #endif
  407. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  408. float pow2( const in float x ) { return x*x; }
  409. vec3 pow2( const in vec3 x ) { return x*x; }
  410. float pow3( const in float x ) { return x*x*x; }
  411. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  412. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  413. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  414. highp float rand( const in vec2 uv ) {
  415. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  416. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  417. return fract( sin( sn ) * c );
  418. }
  419. #ifdef HIGH_PRECISION
  420. float precisionSafeLength( vec3 v ) { return length( v ); }
  421. #else
  422. float precisionSafeLength( vec3 v ) {
  423. float maxComponent = max3( abs( v ) );
  424. return length( v / maxComponent ) * maxComponent;
  425. }
  426. #endif
  427. struct IncidentLight {
  428. vec3 color;
  429. vec3 direction;
  430. bool visible;
  431. };
  432. struct ReflectedLight {
  433. vec3 directDiffuse;
  434. vec3 directSpecular;
  435. vec3 indirectDiffuse;
  436. vec3 indirectSpecular;
  437. };
  438. #ifdef USE_ALPHAHASH
  439. varying vec3 vPosition;
  440. #endif
  441. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  442. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  443. }
  444. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  445. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  446. }
  447. bool isPerspectiveMatrix( mat4 m ) {
  448. return m[ 2 ][ 3 ] == - 1.0;
  449. }
  450. vec2 equirectUv( in vec3 dir ) {
  451. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  452. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  453. return vec2( u, v );
  454. }
  455. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  456. return RECIPROCAL_PI * diffuseColor;
  457. }
  458. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  459. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  460. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  461. }
  462. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  463. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  464. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  465. } // validated`,KRe=`#ifdef ENVMAP_TYPE_CUBE_UV
  466. #define cubeUV_minMipLevel 4.0
  467. #define cubeUV_minTileSize 16.0
  468. float getFace( vec3 direction ) {
  469. vec3 absDirection = abs( direction );
  470. float face = - 1.0;
  471. if ( absDirection.x > absDirection.z ) {
  472. if ( absDirection.x > absDirection.y )
  473. face = direction.x > 0.0 ? 0.0 : 3.0;
  474. else
  475. face = direction.y > 0.0 ? 1.0 : 4.0;
  476. } else {
  477. if ( absDirection.z > absDirection.y )
  478. face = direction.z > 0.0 ? 2.0 : 5.0;
  479. else
  480. face = direction.y > 0.0 ? 1.0 : 4.0;
  481. }
  482. return face;
  483. }
  484. vec2 getUV( vec3 direction, float face ) {
  485. vec2 uv;
  486. if ( face == 0.0 ) {
  487. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  488. } else if ( face == 1.0 ) {
  489. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  490. } else if ( face == 2.0 ) {
  491. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  492. } else if ( face == 3.0 ) {
  493. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  494. } else if ( face == 4.0 ) {
  495. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  496. } else {
  497. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  498. }
  499. return 0.5 * ( uv + 1.0 );
  500. }
  501. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  502. float face = getFace( direction );
  503. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  504. mipInt = max( mipInt, cubeUV_minMipLevel );
  505. float faceSize = exp2( mipInt );
  506. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  507. if ( face > 2.0 ) {
  508. uv.y += faceSize;
  509. face -= 3.0;
  510. }
  511. uv.x += face * faceSize;
  512. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  513. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  514. uv.x *= CUBEUV_TEXEL_WIDTH;
  515. uv.y *= CUBEUV_TEXEL_HEIGHT;
  516. #ifdef texture2DGradEXT
  517. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  518. #else
  519. return texture2D( envMap, uv ).rgb;
  520. #endif
  521. }
  522. #define cubeUV_r0 1.0
  523. #define cubeUV_m0 - 2.0
  524. #define cubeUV_r1 0.8
  525. #define cubeUV_m1 - 1.0
  526. #define cubeUV_r4 0.4
  527. #define cubeUV_m4 2.0
  528. #define cubeUV_r5 0.305
  529. #define cubeUV_m5 3.0
  530. #define cubeUV_r6 0.21
  531. #define cubeUV_m6 4.0
  532. float roughnessToMip( float roughness ) {
  533. float mip = 0.0;
  534. if ( roughness >= cubeUV_r1 ) {
  535. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  536. } else if ( roughness >= cubeUV_r4 ) {
  537. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  538. } else if ( roughness >= cubeUV_r5 ) {
  539. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  540. } else if ( roughness >= cubeUV_r6 ) {
  541. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  542. } else {
  543. mip = - 2.0 * log2( 1.16 * roughness ); }
  544. return mip;
  545. }
  546. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  547. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  548. float mipF = fract( mip );
  549. float mipInt = floor( mip );
  550. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  551. if ( mipF == 0.0 ) {
  552. return vec4( color0, 1.0 );
  553. } else {
  554. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  555. return vec4( mix( color0, color1, mipF ), 1.0 );
  556. }
  557. }
  558. #endif`,XRe=`vec3 transformedNormal = objectNormal;
  559. #ifdef USE_TANGENT
  560. vec3 transformedTangent = objectTangent;
  561. #endif
  562. #ifdef USE_BATCHING
  563. mat3 bm = mat3( batchingMatrix );
  564. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  565. transformedNormal = bm * transformedNormal;
  566. #ifdef USE_TANGENT
  567. transformedTangent = bm * transformedTangent;
  568. #endif
  569. #endif
  570. #ifdef USE_INSTANCING
  571. mat3 im = mat3( instanceMatrix );
  572. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  573. transformedNormal = im * transformedNormal;
  574. #ifdef USE_TANGENT
  575. transformedTangent = im * transformedTangent;
  576. #endif
  577. #endif
  578. transformedNormal = normalMatrix * transformedNormal;
  579. #ifdef FLIP_SIDED
  580. transformedNormal = - transformedNormal;
  581. #endif
  582. #ifdef USE_TANGENT
  583. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  584. #ifdef FLIP_SIDED
  585. transformedTangent = - transformedTangent;
  586. #endif
  587. #endif`,YRe=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,ZRe=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,QRe=`#ifdef USE_EMISSIVEMAP
  594. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  595. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  596. emissiveColor = sRGBTransferEOTF( emissiveColor );
  597. #endif
  598. totalEmissiveRadiance *= emissiveColor.rgb;
  599. #endif`,JRe=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,eDe="gl_FragColor = linearToOutputTexel( gl_FragColor );",tDe=`vec4 LinearTransferOETF( in vec4 value ) {
  602. return value;
  603. }
  604. vec4 sRGBTransferEOTF( in vec4 value ) {
  605. 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 );
  606. }
  607. vec4 sRGBTransferOETF( in vec4 value ) {
  608. 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 );
  609. }`,nDe=`#ifdef USE_ENVMAP
  610. #ifdef ENV_WORLDPOS
  611. vec3 cameraToFrag;
  612. if ( isOrthographic ) {
  613. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  614. } else {
  615. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  616. }
  617. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  618. #ifdef ENVMAP_MODE_REFLECTION
  619. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  620. #else
  621. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  622. #endif
  623. #else
  624. vec3 reflectVec = vReflect;
  625. #endif
  626. #ifdef ENVMAP_TYPE_CUBE
  627. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  628. #else
  629. vec4 envColor = vec4( 0.0 );
  630. #endif
  631. #ifdef ENVMAP_BLENDING_MULTIPLY
  632. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  633. #elif defined( ENVMAP_BLENDING_MIX )
  634. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  635. #elif defined( ENVMAP_BLENDING_ADD )
  636. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  637. #endif
  638. #endif`,rDe=`#ifdef USE_ENVMAP
  639. uniform float envMapIntensity;
  640. uniform float flipEnvMap;
  641. uniform mat3 envMapRotation;
  642. #ifdef ENVMAP_TYPE_CUBE
  643. uniform samplerCube envMap;
  644. #else
  645. uniform sampler2D envMap;
  646. #endif
  647. #endif`,iDe=`#ifdef USE_ENVMAP
  648. uniform float reflectivity;
  649. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  650. #define ENV_WORLDPOS
  651. #endif
  652. #ifdef ENV_WORLDPOS
  653. varying vec3 vWorldPosition;
  654. uniform float refractionRatio;
  655. #else
  656. varying vec3 vReflect;
  657. #endif
  658. #endif`,aDe=`#ifdef USE_ENVMAP
  659. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  660. #define ENV_WORLDPOS
  661. #endif
  662. #ifdef ENV_WORLDPOS
  663. varying vec3 vWorldPosition;
  664. #else
  665. varying vec3 vReflect;
  666. uniform float refractionRatio;
  667. #endif
  668. #endif`,sDe=`#ifdef USE_ENVMAP
  669. #ifdef ENV_WORLDPOS
  670. vWorldPosition = worldPosition.xyz;
  671. #else
  672. vec3 cameraToVertex;
  673. if ( isOrthographic ) {
  674. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  675. } else {
  676. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  677. }
  678. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  679. #ifdef ENVMAP_MODE_REFLECTION
  680. vReflect = reflect( cameraToVertex, worldNormal );
  681. #else
  682. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  683. #endif
  684. #endif
  685. #endif`,oDe=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,lDe=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,cDe=`#ifdef USE_FOG
  690. #ifdef FOG_EXP2
  691. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  692. #else
  693. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  694. #endif
  695. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  696. #endif`,uDe=`#ifdef USE_FOG
  697. uniform vec3 fogColor;
  698. varying float vFogDepth;
  699. #ifdef FOG_EXP2
  700. uniform float fogDensity;
  701. #else
  702. uniform float fogNear;
  703. uniform float fogFar;
  704. #endif
  705. #endif`,dDe=`#ifdef USE_GRADIENTMAP
  706. uniform sampler2D gradientMap;
  707. #endif
  708. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  709. float dotNL = dot( normal, lightDirection );
  710. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  711. #ifdef USE_GRADIENTMAP
  712. return vec3( texture2D( gradientMap, coord ).r );
  713. #else
  714. vec2 fw = fwidth( coord ) * 0.5;
  715. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  716. #endif
  717. }`,hDe=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,fDe=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,mDe=`varying vec3 vViewPosition;
  723. struct LambertMaterial {
  724. vec3 diffuseColor;
  725. float specularStrength;
  726. };
  727. 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 ) {
  728. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  729. vec3 irradiance = dotNL * directLight.color;
  730. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  731. }
  732. 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 ) {
  733. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  734. }
  735. #define RE_Direct RE_Direct_Lambert
  736. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pDe=`uniform bool receiveShadow;
  737. uniform vec3 ambientLightColor;
  738. #if defined( USE_LIGHT_PROBES )
  739. uniform vec3 lightProbe[ 9 ];
  740. #endif
  741. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  742. float x = normal.x, y = normal.y, z = normal.z;
  743. vec3 result = shCoefficients[ 0 ] * 0.886227;
  744. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  745. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  746. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  747. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  748. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  749. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  750. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  751. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  752. return result;
  753. }
  754. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  755. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  756. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  757. return irradiance;
  758. }
  759. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  760. vec3 irradiance = ambientLightColor;
  761. return irradiance;
  762. }
  763. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  764. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  765. if ( cutoffDistance > 0.0 ) {
  766. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  767. }
  768. return distanceFalloff;
  769. }
  770. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  771. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  772. }
  773. #if NUM_DIR_LIGHTS > 0
  774. struct DirectionalLight {
  775. vec3 direction;
  776. vec3 color;
  777. };
  778. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  779. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  780. light.color = directionalLight.color;
  781. light.direction = directionalLight.direction;
  782. light.visible = true;
  783. }
  784. #endif
  785. #if NUM_POINT_LIGHTS > 0
  786. struct PointLight {
  787. vec3 position;
  788. vec3 color;
  789. float distance;
  790. float decay;
  791. };
  792. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  793. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  794. vec3 lVector = pointLight.position - geometryPosition;
  795. light.direction = normalize( lVector );
  796. float lightDistance = length( lVector );
  797. light.color = pointLight.color;
  798. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  799. light.visible = ( light.color != vec3( 0.0 ) );
  800. }
  801. #endif
  802. #if NUM_SPOT_LIGHTS > 0
  803. struct SpotLight {
  804. vec3 position;
  805. vec3 direction;
  806. vec3 color;
  807. float distance;
  808. float decay;
  809. float coneCos;
  810. float penumbraCos;
  811. };
  812. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  813. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  814. vec3 lVector = spotLight.position - geometryPosition;
  815. light.direction = normalize( lVector );
  816. float angleCos = dot( light.direction, spotLight.direction );
  817. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  818. if ( spotAttenuation > 0.0 ) {
  819. float lightDistance = length( lVector );
  820. light.color = spotLight.color * spotAttenuation;
  821. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  822. light.visible = ( light.color != vec3( 0.0 ) );
  823. } else {
  824. light.color = vec3( 0.0 );
  825. light.visible = false;
  826. }
  827. }
  828. #endif
  829. #if NUM_RECT_AREA_LIGHTS > 0
  830. struct RectAreaLight {
  831. vec3 color;
  832. vec3 position;
  833. vec3 halfWidth;
  834. vec3 halfHeight;
  835. };
  836. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  837. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  838. #endif
  839. #if NUM_HEMI_LIGHTS > 0
  840. struct HemisphereLight {
  841. vec3 direction;
  842. vec3 skyColor;
  843. vec3 groundColor;
  844. };
  845. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  846. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  847. float dotNL = dot( normal, hemiLight.direction );
  848. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  849. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  850. return irradiance;
  851. }
  852. #endif`,gDe=`#ifdef USE_ENVMAP
  853. vec3 getIBLIrradiance( const in vec3 normal ) {
  854. #ifdef ENVMAP_TYPE_CUBE_UV
  855. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  856. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  857. return PI * envMapColor.rgb * envMapIntensity;
  858. #else
  859. return vec3( 0.0 );
  860. #endif
  861. }
  862. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  863. #ifdef ENVMAP_TYPE_CUBE_UV
  864. vec3 reflectVec = reflect( - viewDir, normal );
  865. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  866. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  867. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  868. return envMapColor.rgb * envMapIntensity;
  869. #else
  870. return vec3( 0.0 );
  871. #endif
  872. }
  873. #ifdef USE_ANISOTROPY
  874. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  875. #ifdef ENVMAP_TYPE_CUBE_UV
  876. vec3 bentNormal = cross( bitangent, viewDir );
  877. bentNormal = normalize( cross( bentNormal, bitangent ) );
  878. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  879. return getIBLRadiance( viewDir, bentNormal, roughness );
  880. #else
  881. return vec3( 0.0 );
  882. #endif
  883. }
  884. #endif
  885. #endif`,xDe=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,bDe=`varying vec3 vViewPosition;
  887. struct ToonMaterial {
  888. vec3 diffuseColor;
  889. };
  890. 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 ) {
  891. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  892. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  893. }
  894. 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 ) {
  895. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  896. }
  897. #define RE_Direct RE_Direct_Toon
  898. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,yDe=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,vDe=`varying vec3 vViewPosition;
  903. struct BlinnPhongMaterial {
  904. vec3 diffuseColor;
  905. vec3 specularColor;
  906. float specularShininess;
  907. float specularStrength;
  908. };
  909. 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 ) {
  910. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  911. vec3 irradiance = dotNL * directLight.color;
  912. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  913. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  914. }
  915. 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 ) {
  916. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  917. }
  918. #define RE_Direct RE_Direct_BlinnPhong
  919. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_De=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb;
  921. material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  922. material.metalness = metalnessFactor;
  923. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  924. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  925. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  926. material.roughness = min( material.roughness, 1.0 );
  927. #ifdef IOR
  928. material.ior = ior;
  929. #ifdef USE_SPECULAR
  930. float specularIntensityFactor = specularIntensity;
  931. vec3 specularColorFactor = specularColor;
  932. #ifdef USE_SPECULAR_COLORMAP
  933. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  934. #endif
  935. #ifdef USE_SPECULAR_INTENSITYMAP
  936. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  937. #endif
  938. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  939. #else
  940. float specularIntensityFactor = 1.0;
  941. vec3 specularColorFactor = vec3( 1.0 );
  942. material.specularF90 = 1.0;
  943. #endif
  944. material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
  945. material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
  946. #else
  947. material.specularColor = vec3( 0.04 );
  948. material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
  949. material.specularF90 = 1.0;
  950. #endif
  951. #ifdef USE_CLEARCOAT
  952. material.clearcoat = clearcoat;
  953. material.clearcoatRoughness = clearcoatRoughness;
  954. material.clearcoatF0 = vec3( 0.04 );
  955. material.clearcoatF90 = 1.0;
  956. #ifdef USE_CLEARCOATMAP
  957. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  958. #endif
  959. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  960. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  961. #endif
  962. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  963. material.clearcoatRoughness += geometryRoughness;
  964. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  965. #endif
  966. #ifdef USE_DISPERSION
  967. material.dispersion = dispersion;
  968. #endif
  969. #ifdef USE_IRIDESCENCE
  970. material.iridescence = iridescence;
  971. material.iridescenceIOR = iridescenceIOR;
  972. #ifdef USE_IRIDESCENCEMAP
  973. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  974. #endif
  975. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  976. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  977. #else
  978. material.iridescenceThickness = iridescenceThicknessMaximum;
  979. #endif
  980. #endif
  981. #ifdef USE_SHEEN
  982. material.sheenColor = sheenColor;
  983. #ifdef USE_SHEEN_COLORMAP
  984. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  985. #endif
  986. material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
  987. #ifdef USE_SHEEN_ROUGHNESSMAP
  988. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  989. #endif
  990. #endif
  991. #ifdef USE_ANISOTROPY
  992. #ifdef USE_ANISOTROPYMAP
  993. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  994. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  995. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  996. #else
  997. vec2 anisotropyV = anisotropyVector;
  998. #endif
  999. material.anisotropy = length( anisotropyV );
  1000. if( material.anisotropy == 0.0 ) {
  1001. anisotropyV = vec2( 1.0, 0.0 );
  1002. } else {
  1003. anisotropyV /= material.anisotropy;
  1004. material.anisotropy = saturate( material.anisotropy );
  1005. }
  1006. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1007. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1008. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1009. #endif`,wDe=`uniform sampler2D dfgLUT;
  1010. struct PhysicalMaterial {
  1011. vec3 diffuseColor;
  1012. vec3 diffuseContribution;
  1013. vec3 specularColor;
  1014. vec3 specularColorBlended;
  1015. float roughness;
  1016. float metalness;
  1017. float specularF90;
  1018. float dispersion;
  1019. #ifdef USE_CLEARCOAT
  1020. float clearcoat;
  1021. float clearcoatRoughness;
  1022. vec3 clearcoatF0;
  1023. float clearcoatF90;
  1024. #endif
  1025. #ifdef USE_IRIDESCENCE
  1026. float iridescence;
  1027. float iridescenceIOR;
  1028. float iridescenceThickness;
  1029. vec3 iridescenceFresnel;
  1030. vec3 iridescenceF0;
  1031. vec3 iridescenceFresnelDielectric;
  1032. vec3 iridescenceFresnelMetallic;
  1033. #endif
  1034. #ifdef USE_SHEEN
  1035. vec3 sheenColor;
  1036. float sheenRoughness;
  1037. #endif
  1038. #ifdef IOR
  1039. float ior;
  1040. #endif
  1041. #ifdef USE_TRANSMISSION
  1042. float transmission;
  1043. float transmissionAlpha;
  1044. float thickness;
  1045. float attenuationDistance;
  1046. vec3 attenuationColor;
  1047. #endif
  1048. #ifdef USE_ANISOTROPY
  1049. float anisotropy;
  1050. float alphaT;
  1051. vec3 anisotropyT;
  1052. vec3 anisotropyB;
  1053. #endif
  1054. };
  1055. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1056. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1057. vec3 sheenSpecularDirect = vec3( 0.0 );
  1058. vec3 sheenSpecularIndirect = vec3(0.0 );
  1059. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1060. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1061. float x2 = x * x;
  1062. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1063. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1064. }
  1065. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1066. float a2 = pow2( alpha );
  1067. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1068. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1069. return 0.5 / max( gv + gl, EPSILON );
  1070. }
  1071. float D_GGX( const in float alpha, const in float dotNH ) {
  1072. float a2 = pow2( alpha );
  1073. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1074. return RECIPROCAL_PI * a2 / pow2( denom );
  1075. }
  1076. #ifdef USE_ANISOTROPY
  1077. 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 ) {
  1078. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1079. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1080. float v = 0.5 / ( gv + gl );
  1081. return v;
  1082. }
  1083. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1084. float a2 = alphaT * alphaB;
  1085. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1086. highp float v2 = dot( v, v );
  1087. float w2 = a2 / v2;
  1088. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1089. }
  1090. #endif
  1091. #ifdef USE_CLEARCOAT
  1092. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1093. vec3 f0 = material.clearcoatF0;
  1094. float f90 = material.clearcoatF90;
  1095. float roughness = material.clearcoatRoughness;
  1096. float alpha = pow2( roughness );
  1097. vec3 halfDir = normalize( lightDir + viewDir );
  1098. float dotNL = saturate( dot( normal, lightDir ) );
  1099. float dotNV = saturate( dot( normal, viewDir ) );
  1100. float dotNH = saturate( dot( normal, halfDir ) );
  1101. float dotVH = saturate( dot( viewDir, halfDir ) );
  1102. vec3 F = F_Schlick( f0, f90, dotVH );
  1103. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1104. float D = D_GGX( alpha, dotNH );
  1105. return F * ( V * D );
  1106. }
  1107. #endif
  1108. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1109. vec3 f0 = material.specularColorBlended;
  1110. float f90 = material.specularF90;
  1111. float roughness = material.roughness;
  1112. float alpha = pow2( roughness );
  1113. vec3 halfDir = normalize( lightDir + viewDir );
  1114. float dotNL = saturate( dot( normal, lightDir ) );
  1115. float dotNV = saturate( dot( normal, viewDir ) );
  1116. float dotNH = saturate( dot( normal, halfDir ) );
  1117. float dotVH = saturate( dot( viewDir, halfDir ) );
  1118. vec3 F = F_Schlick( f0, f90, dotVH );
  1119. #ifdef USE_IRIDESCENCE
  1120. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1121. #endif
  1122. #ifdef USE_ANISOTROPY
  1123. float dotTL = dot( material.anisotropyT, lightDir );
  1124. float dotTV = dot( material.anisotropyT, viewDir );
  1125. float dotTH = dot( material.anisotropyT, halfDir );
  1126. float dotBL = dot( material.anisotropyB, lightDir );
  1127. float dotBV = dot( material.anisotropyB, viewDir );
  1128. float dotBH = dot( material.anisotropyB, halfDir );
  1129. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1130. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1131. #else
  1132. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1133. float D = D_GGX( alpha, dotNH );
  1134. #endif
  1135. return F * ( V * D );
  1136. }
  1137. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1138. const float LUT_SIZE = 64.0;
  1139. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1140. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1141. float dotNV = saturate( dot( N, V ) );
  1142. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1143. uv = uv * LUT_SCALE + LUT_BIAS;
  1144. return uv;
  1145. }
  1146. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1147. float l = length( f );
  1148. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1149. }
  1150. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1151. float x = dot( v1, v2 );
  1152. float y = abs( x );
  1153. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1154. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1155. float v = a / b;
  1156. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1157. return cross( v1, v2 ) * theta_sintheta;
  1158. }
  1159. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1160. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1161. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1162. vec3 lightNormal = cross( v1, v2 );
  1163. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1164. vec3 T1, T2;
  1165. T1 = normalize( V - N * dot( V, N ) );
  1166. T2 = - cross( N, T1 );
  1167. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1168. vec3 coords[ 4 ];
  1169. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1170. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1171. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1172. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1173. coords[ 0 ] = normalize( coords[ 0 ] );
  1174. coords[ 1 ] = normalize( coords[ 1 ] );
  1175. coords[ 2 ] = normalize( coords[ 2 ] );
  1176. coords[ 3 ] = normalize( coords[ 3 ] );
  1177. vec3 vectorFormFactor = vec3( 0.0 );
  1178. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1179. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1180. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1181. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1182. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1183. return vec3( result );
  1184. }
  1185. #if defined( USE_SHEEN )
  1186. float D_Charlie( float roughness, float dotNH ) {
  1187. float alpha = pow2( roughness );
  1188. float invAlpha = 1.0 / alpha;
  1189. float cos2h = dotNH * dotNH;
  1190. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1191. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1192. }
  1193. float V_Neubelt( float dotNV, float dotNL ) {
  1194. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1195. }
  1196. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1197. vec3 halfDir = normalize( lightDir + viewDir );
  1198. float dotNL = saturate( dot( normal, lightDir ) );
  1199. float dotNV = saturate( dot( normal, viewDir ) );
  1200. float dotNH = saturate( dot( normal, halfDir ) );
  1201. float D = D_Charlie( sheenRoughness, dotNH );
  1202. float V = V_Neubelt( dotNV, dotNL );
  1203. return sheenColor * ( D * V );
  1204. }
  1205. #endif
  1206. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1207. float dotNV = saturate( dot( normal, viewDir ) );
  1208. float r2 = roughness * roughness;
  1209. float rInv = 1.0 / ( roughness + 0.1 );
  1210. float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
  1211. float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
  1212. float DG = exp( a * dotNV + b );
  1213. return saturate( DG );
  1214. }
  1215. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1216. float dotNV = saturate( dot( normal, viewDir ) );
  1217. vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
  1218. return specularColor * fab.x + specularF90 * fab.y;
  1219. }
  1220. #ifdef USE_IRIDESCENCE
  1221. 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 ) {
  1222. #else
  1223. 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 ) {
  1224. #endif
  1225. float dotNV = saturate( dot( normal, viewDir ) );
  1226. vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
  1227. #ifdef USE_IRIDESCENCE
  1228. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1229. #else
  1230. vec3 Fr = specularColor;
  1231. #endif
  1232. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1233. float Ess = fab.x + fab.y;
  1234. float Ems = 1.0 - Ess;
  1235. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1236. singleScatter += FssEss;
  1237. multiScatter += Fms * Ems;
  1238. }
  1239. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1240. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1241. float dotNL = saturate( dot( normal, lightDir ) );
  1242. float dotNV = saturate( dot( normal, viewDir ) );
  1243. vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
  1244. vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
  1245. vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
  1246. vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
  1247. float Ess_V = dfgV.x + dfgV.y;
  1248. float Ess_L = dfgL.x + dfgL.y;
  1249. float Ems_V = 1.0 - Ess_V;
  1250. float Ems_L = 1.0 - Ess_L;
  1251. vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
  1252. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
  1253. float compensationFactor = Ems_V * Ems_L;
  1254. vec3 multiScatter = Fms * compensationFactor;
  1255. return singleScatter + multiScatter;
  1256. }
  1257. #if NUM_RECT_AREA_LIGHTS > 0
  1258. 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 ) {
  1259. vec3 normal = geometryNormal;
  1260. vec3 viewDir = geometryViewDir;
  1261. vec3 position = geometryPosition;
  1262. vec3 lightPos = rectAreaLight.position;
  1263. vec3 halfWidth = rectAreaLight.halfWidth;
  1264. vec3 halfHeight = rectAreaLight.halfHeight;
  1265. vec3 lightColor = rectAreaLight.color;
  1266. float roughness = material.roughness;
  1267. vec3 rectCoords[ 4 ];
  1268. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1269. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1270. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1271. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1272. vec4 t1 = texture2D( ltc_1, uv );
  1273. vec4 t2 = texture2D( ltc_2, uv );
  1274. mat3 mInv = mat3(
  1275. vec3( t1.x, 0, t1.y ),
  1276. vec3( 0, 1, 0 ),
  1277. vec3( t1.z, 0, t1.w )
  1278. );
  1279. vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
  1280. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1281. reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1282. }
  1283. #endif
  1284. 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 ) {
  1285. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1286. vec3 irradiance = dotNL * directLight.color;
  1287. #ifdef USE_CLEARCOAT
  1288. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1289. vec3 ccIrradiance = dotNLcc * directLight.color;
  1290. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1291. #endif
  1292. #ifdef USE_SHEEN
  1293. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1294. float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1295. float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
  1296. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
  1297. irradiance *= sheenEnergyComp;
  1298. #endif
  1299. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1300. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
  1301. }
  1302. 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 ) {
  1303. vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
  1304. #ifdef USE_SHEEN
  1305. float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1306. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
  1307. diffuse *= sheenEnergyComp;
  1308. #endif
  1309. reflectedLight.indirectDiffuse += diffuse;
  1310. }
  1311. 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) {
  1312. #ifdef USE_CLEARCOAT
  1313. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1314. #endif
  1315. #ifdef USE_SHEEN
  1316. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
  1317. #endif
  1318. vec3 singleScatteringDielectric = vec3( 0.0 );
  1319. vec3 multiScatteringDielectric = vec3( 0.0 );
  1320. vec3 singleScatteringMetallic = vec3( 0.0 );
  1321. vec3 multiScatteringMetallic = vec3( 0.0 );
  1322. #ifdef USE_IRIDESCENCE
  1323. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
  1324. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
  1325. #else
  1326. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
  1327. computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
  1328. #endif
  1329. vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
  1330. vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
  1331. vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
  1332. vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
  1333. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1334. vec3 indirectSpecular = radiance * singleScattering;
  1335. indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1336. vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
  1337. #ifdef USE_SHEEN
  1338. float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1339. float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
  1340. indirectSpecular *= sheenEnergyComp;
  1341. indirectDiffuse *= sheenEnergyComp;
  1342. #endif
  1343. reflectedLight.indirectSpecular += indirectSpecular;
  1344. reflectedLight.indirectDiffuse += indirectDiffuse;
  1345. }
  1346. #define RE_Direct RE_Direct_Physical
  1347. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1348. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1349. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1350. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1351. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1352. }`,SDe=`
  1353. vec3 geometryPosition = - vViewPosition;
  1354. vec3 geometryNormal = normal;
  1355. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1356. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1357. #ifdef USE_CLEARCOAT
  1358. geometryClearcoatNormal = clearcoatNormal;
  1359. #endif
  1360. #ifdef USE_IRIDESCENCE
  1361. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1362. if ( material.iridescenceThickness == 0.0 ) {
  1363. material.iridescence = 0.0;
  1364. } else {
  1365. material.iridescence = saturate( material.iridescence );
  1366. }
  1367. if ( material.iridescence > 0.0 ) {
  1368. material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1369. material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
  1370. material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
  1371. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1372. }
  1373. #endif
  1374. IncidentLight directLight;
  1375. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1376. PointLight pointLight;
  1377. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1378. PointLightShadow pointLightShadow;
  1379. #endif
  1380. #pragma unroll_loop_start
  1381. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1382. pointLight = pointLights[ i ];
  1383. getPointLightInfo( pointLight, geometryPosition, directLight );
  1384. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
  1385. pointLightShadow = pointLightShadows[ i ];
  1386. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1387. #endif
  1388. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1389. }
  1390. #pragma unroll_loop_end
  1391. #endif
  1392. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1393. SpotLight spotLight;
  1394. vec4 spotColor;
  1395. vec3 spotLightCoord;
  1396. bool inSpotLightMap;
  1397. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1398. SpotLightShadow spotLightShadow;
  1399. #endif
  1400. #pragma unroll_loop_start
  1401. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1402. spotLight = spotLights[ i ];
  1403. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1404. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1405. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1406. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1407. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1408. #else
  1409. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1410. #endif
  1411. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1412. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1413. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1414. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1415. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1416. #endif
  1417. #undef SPOT_LIGHT_MAP_INDEX
  1418. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1419. spotLightShadow = spotLightShadows[ i ];
  1420. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1421. #endif
  1422. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1423. }
  1424. #pragma unroll_loop_end
  1425. #endif
  1426. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1427. DirectionalLight directionalLight;
  1428. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1429. DirectionalLightShadow directionalLightShadow;
  1430. #endif
  1431. #pragma unroll_loop_start
  1432. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1433. directionalLight = directionalLights[ i ];
  1434. getDirectionalLightInfo( directionalLight, directLight );
  1435. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1436. directionalLightShadow = directionalLightShadows[ i ];
  1437. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1438. #endif
  1439. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1440. }
  1441. #pragma unroll_loop_end
  1442. #endif
  1443. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1444. RectAreaLight rectAreaLight;
  1445. #pragma unroll_loop_start
  1446. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1447. rectAreaLight = rectAreaLights[ i ];
  1448. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1449. }
  1450. #pragma unroll_loop_end
  1451. #endif
  1452. #if defined( RE_IndirectDiffuse )
  1453. vec3 iblIrradiance = vec3( 0.0 );
  1454. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1455. #if defined( USE_LIGHT_PROBES )
  1456. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1457. #endif
  1458. #if ( NUM_HEMI_LIGHTS > 0 )
  1459. #pragma unroll_loop_start
  1460. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1461. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1462. }
  1463. #pragma unroll_loop_end
  1464. #endif
  1465. #endif
  1466. #if defined( RE_IndirectSpecular )
  1467. vec3 radiance = vec3( 0.0 );
  1468. vec3 clearcoatRadiance = vec3( 0.0 );
  1469. #endif`,MDe=`#if defined( RE_IndirectDiffuse )
  1470. #ifdef USE_LIGHTMAP
  1471. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1472. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1473. irradiance += lightMapIrradiance;
  1474. #endif
  1475. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1476. iblIrradiance += getIBLIrradiance( geometryNormal );
  1477. #endif
  1478. #endif
  1479. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1480. #ifdef USE_ANISOTROPY
  1481. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1482. #else
  1483. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1484. #endif
  1485. #ifdef USE_CLEARCOAT
  1486. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1487. #endif
  1488. #endif`,EDe=`#if defined( RE_IndirectDiffuse )
  1489. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1490. #endif
  1491. #if defined( RE_IndirectSpecular )
  1492. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1493. #endif`,NDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1494. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1495. #endif`,ADe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1496. uniform float logDepthBufFC;
  1497. varying float vFragDepth;
  1498. varying float vIsPerspective;
  1499. #endif`,TDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1500. varying float vFragDepth;
  1501. varying float vIsPerspective;
  1502. #endif`,CDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1503. vFragDepth = 1.0 + gl_Position.w;
  1504. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1505. #endif`,kDe=`#ifdef USE_MAP
  1506. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1507. #ifdef DECODE_VIDEO_TEXTURE
  1508. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1509. #endif
  1510. diffuseColor *= sampledDiffuseColor;
  1511. #endif`,jDe=`#ifdef USE_MAP
  1512. uniform sampler2D map;
  1513. #endif`,PDe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1514. #if defined( USE_POINTS_UV )
  1515. vec2 uv = vUv;
  1516. #else
  1517. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1518. #endif
  1519. #endif
  1520. #ifdef USE_MAP
  1521. diffuseColor *= texture2D( map, uv );
  1522. #endif
  1523. #ifdef USE_ALPHAMAP
  1524. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1525. #endif`,RDe=`#if defined( USE_POINTS_UV )
  1526. varying vec2 vUv;
  1527. #else
  1528. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1529. uniform mat3 uvTransform;
  1530. #endif
  1531. #endif
  1532. #ifdef USE_MAP
  1533. uniform sampler2D map;
  1534. #endif
  1535. #ifdef USE_ALPHAMAP
  1536. uniform sampler2D alphaMap;
  1537. #endif`,DDe=`float metalnessFactor = metalness;
  1538. #ifdef USE_METALNESSMAP
  1539. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1540. metalnessFactor *= texelMetalness.b;
  1541. #endif`,ODe=`#ifdef USE_METALNESSMAP
  1542. uniform sampler2D metalnessMap;
  1543. #endif`,LDe=`#ifdef USE_INSTANCING_MORPH
  1544. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1545. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1548. }
  1549. #endif`,IDe=`#if defined( USE_MORPHCOLORS )
  1550. vColor *= morphTargetBaseInfluence;
  1551. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1552. #if defined( USE_COLOR_ALPHA )
  1553. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1554. #elif defined( USE_COLOR )
  1555. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1556. #endif
  1557. }
  1558. #endif`,FDe=`#ifdef USE_MORPHNORMALS
  1559. objectNormal *= morphTargetBaseInfluence;
  1560. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1561. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1562. }
  1563. #endif`,UDe=`#ifdef USE_MORPHTARGETS
  1564. #ifndef USE_INSTANCING_MORPH
  1565. uniform float morphTargetBaseInfluence;
  1566. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1567. #endif
  1568. uniform sampler2DArray morphTargetsTexture;
  1569. uniform ivec2 morphTargetsTextureSize;
  1570. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1571. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1572. int y = texelIndex / morphTargetsTextureSize.x;
  1573. int x = texelIndex - y * morphTargetsTextureSize.x;
  1574. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1575. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1576. }
  1577. #endif`,zDe=`#ifdef USE_MORPHTARGETS
  1578. transformed *= morphTargetBaseInfluence;
  1579. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1580. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1581. }
  1582. #endif`,BDe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1583. #ifdef FLAT_SHADED
  1584. vec3 fdx = dFdx( vViewPosition );
  1585. vec3 fdy = dFdy( vViewPosition );
  1586. vec3 normal = normalize( cross( fdx, fdy ) );
  1587. #else
  1588. vec3 normal = normalize( vNormal );
  1589. #ifdef DOUBLE_SIDED
  1590. normal *= faceDirection;
  1591. #endif
  1592. #endif
  1593. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1594. #ifdef USE_TANGENT
  1595. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1596. #else
  1597. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1598. #if defined( USE_NORMALMAP )
  1599. vNormalMapUv
  1600. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1601. vClearcoatNormalMapUv
  1602. #else
  1603. vUv
  1604. #endif
  1605. );
  1606. #endif
  1607. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1608. tbn[0] *= faceDirection;
  1609. tbn[1] *= faceDirection;
  1610. #endif
  1611. #endif
  1612. #ifdef USE_CLEARCOAT_NORMALMAP
  1613. #ifdef USE_TANGENT
  1614. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1615. #else
  1616. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1617. #endif
  1618. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1619. tbn2[0] *= faceDirection;
  1620. tbn2[1] *= faceDirection;
  1621. #endif
  1622. #endif
  1623. vec3 nonPerturbedNormal = normal;`,$De=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1624. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1625. #ifdef FLIP_SIDED
  1626. normal = - normal;
  1627. #endif
  1628. #ifdef DOUBLE_SIDED
  1629. normal = normal * faceDirection;
  1630. #endif
  1631. normal = normalize( normalMatrix * normal );
  1632. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1633. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1634. mapN.xy *= normalScale;
  1635. normal = normalize( tbn * mapN );
  1636. #elif defined( USE_BUMPMAP )
  1637. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1638. #endif`,HDe=`#ifndef FLAT_SHADED
  1639. varying vec3 vNormal;
  1640. #ifdef USE_TANGENT
  1641. varying vec3 vTangent;
  1642. varying vec3 vBitangent;
  1643. #endif
  1644. #endif`,VDe=`#ifndef FLAT_SHADED
  1645. varying vec3 vNormal;
  1646. #ifdef USE_TANGENT
  1647. varying vec3 vTangent;
  1648. varying vec3 vBitangent;
  1649. #endif
  1650. #endif`,GDe=`#ifndef FLAT_SHADED
  1651. vNormal = normalize( transformedNormal );
  1652. #ifdef USE_TANGENT
  1653. vTangent = normalize( transformedTangent );
  1654. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1655. #endif
  1656. #endif`,WDe=`#ifdef USE_NORMALMAP
  1657. uniform sampler2D normalMap;
  1658. uniform vec2 normalScale;
  1659. #endif
  1660. #ifdef USE_NORMALMAP_OBJECTSPACE
  1661. uniform mat3 normalMatrix;
  1662. #endif
  1663. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1664. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1665. vec3 q0 = dFdx( eye_pos.xyz );
  1666. vec3 q1 = dFdy( eye_pos.xyz );
  1667. vec2 st0 = dFdx( uv.st );
  1668. vec2 st1 = dFdy( uv.st );
  1669. vec3 N = surf_norm;
  1670. vec3 q1perp = cross( q1, N );
  1671. vec3 q0perp = cross( N, q0 );
  1672. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1673. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1674. float det = max( dot( T, T ), dot( B, B ) );
  1675. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1676. return mat3( T * scale, B * scale, N );
  1677. }
  1678. #endif`,qDe=`#ifdef USE_CLEARCOAT
  1679. vec3 clearcoatNormal = nonPerturbedNormal;
  1680. #endif`,KDe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1681. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1682. clearcoatMapN.xy *= clearcoatNormalScale;
  1683. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1684. #endif`,XDe=`#ifdef USE_CLEARCOATMAP
  1685. uniform sampler2D clearcoatMap;
  1686. #endif
  1687. #ifdef USE_CLEARCOAT_NORMALMAP
  1688. uniform sampler2D clearcoatNormalMap;
  1689. uniform vec2 clearcoatNormalScale;
  1690. #endif
  1691. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1692. uniform sampler2D clearcoatRoughnessMap;
  1693. #endif`,YDe=`#ifdef USE_IRIDESCENCEMAP
  1694. uniform sampler2D iridescenceMap;
  1695. #endif
  1696. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1697. uniform sampler2D iridescenceThicknessMap;
  1698. #endif`,ZDe=`#ifdef OPAQUE
  1699. diffuseColor.a = 1.0;
  1700. #endif
  1701. #ifdef USE_TRANSMISSION
  1702. diffuseColor.a *= material.transmissionAlpha;
  1703. #endif
  1704. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,QDe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1705. return normalize( normal ) * 0.5 + 0.5;
  1706. }
  1707. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1708. return 2.0 * rgb.xyz - 1.0;
  1709. }
  1710. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1711. const float Inv255 = 1. / 255.;
  1712. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1713. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1714. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1715. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1716. vec4 packDepthToRGBA( const in float v ) {
  1717. if( v <= 0.0 )
  1718. return vec4( 0., 0., 0., 0. );
  1719. if( v >= 1.0 )
  1720. return vec4( 1., 1., 1., 1. );
  1721. float vuf;
  1722. float af = modf( v * PackFactors.a, vuf );
  1723. float bf = modf( vuf * ShiftRight8, vuf );
  1724. float gf = modf( vuf * ShiftRight8, vuf );
  1725. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1726. }
  1727. vec3 packDepthToRGB( const in float v ) {
  1728. if( v <= 0.0 )
  1729. return vec3( 0., 0., 0. );
  1730. if( v >= 1.0 )
  1731. return vec3( 1., 1., 1. );
  1732. float vuf;
  1733. float bf = modf( v * PackFactors.b, vuf );
  1734. float gf = modf( vuf * ShiftRight8, vuf );
  1735. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1736. }
  1737. vec2 packDepthToRG( const in float v ) {
  1738. if( v <= 0.0 )
  1739. return vec2( 0., 0. );
  1740. if( v >= 1.0 )
  1741. return vec2( 1., 1. );
  1742. float vuf;
  1743. float gf = modf( v * 256., vuf );
  1744. return vec2( vuf * Inv255, gf );
  1745. }
  1746. float unpackRGBAToDepth( const in vec4 v ) {
  1747. return dot( v, UnpackFactors4 );
  1748. }
  1749. float unpackRGBToDepth( const in vec3 v ) {
  1750. return dot( v, UnpackFactors3 );
  1751. }
  1752. float unpackRGToDepth( const in vec2 v ) {
  1753. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1754. }
  1755. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1756. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1757. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1758. }
  1759. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1760. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1761. }
  1762. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1763. return ( viewZ + near ) / ( near - far );
  1764. }
  1765. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1766. return depth * ( near - far ) - near;
  1767. }
  1768. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1769. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1770. }
  1771. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1772. return ( near * far ) / ( ( far - near ) * depth - far );
  1773. }`,JDe=`#ifdef PREMULTIPLIED_ALPHA
  1774. gl_FragColor.rgb *= gl_FragColor.a;
  1775. #endif`,eOe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1776. #ifdef USE_BATCHING
  1777. mvPosition = batchingMatrix * mvPosition;
  1778. #endif
  1779. #ifdef USE_INSTANCING
  1780. mvPosition = instanceMatrix * mvPosition;
  1781. #endif
  1782. mvPosition = modelViewMatrix * mvPosition;
  1783. gl_Position = projectionMatrix * mvPosition;`,tOe=`#ifdef DITHERING
  1784. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1785. #endif`,nOe=`#ifdef DITHERING
  1786. vec3 dithering( vec3 color ) {
  1787. float grid_position = rand( gl_FragCoord.xy );
  1788. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1789. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1790. return color + dither_shift_RGB;
  1791. }
  1792. #endif`,rOe=`float roughnessFactor = roughness;
  1793. #ifdef USE_ROUGHNESSMAP
  1794. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1795. roughnessFactor *= texelRoughness.g;
  1796. #endif`,iOe=`#ifdef USE_ROUGHNESSMAP
  1797. uniform sampler2D roughnessMap;
  1798. #endif`,aOe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1799. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1800. #endif
  1801. #if NUM_SPOT_LIGHT_MAPS > 0
  1802. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1803. #endif
  1804. #ifdef USE_SHADOWMAP
  1805. #if NUM_DIR_LIGHT_SHADOWS > 0
  1806. #if defined( SHADOWMAP_TYPE_PCF )
  1807. uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1808. #else
  1809. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1810. #endif
  1811. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1812. struct DirectionalLightShadow {
  1813. float shadowIntensity;
  1814. float shadowBias;
  1815. float shadowNormalBias;
  1816. float shadowRadius;
  1817. vec2 shadowMapSize;
  1818. };
  1819. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1820. #endif
  1821. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1822. #if defined( SHADOWMAP_TYPE_PCF )
  1823. uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1824. #else
  1825. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1826. #endif
  1827. struct SpotLightShadow {
  1828. float shadowIntensity;
  1829. float shadowBias;
  1830. float shadowNormalBias;
  1831. float shadowRadius;
  1832. vec2 shadowMapSize;
  1833. };
  1834. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1835. #endif
  1836. #if NUM_POINT_LIGHT_SHADOWS > 0
  1837. #if defined( SHADOWMAP_TYPE_PCF )
  1838. uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1839. #elif defined( SHADOWMAP_TYPE_BASIC )
  1840. uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1841. #endif
  1842. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1843. struct PointLightShadow {
  1844. float shadowIntensity;
  1845. float shadowBias;
  1846. float shadowNormalBias;
  1847. float shadowRadius;
  1848. vec2 shadowMapSize;
  1849. float shadowCameraNear;
  1850. float shadowCameraFar;
  1851. };
  1852. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1853. #endif
  1854. #if defined( SHADOWMAP_TYPE_PCF )
  1855. float interleavedGradientNoise( vec2 position ) {
  1856. return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
  1857. }
  1858. vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
  1859. const float goldenAngle = 2.399963229728653;
  1860. float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
  1861. float theta = float( sampleIndex ) * goldenAngle + phi;
  1862. return vec2( cos( theta ), sin( theta ) ) * r;
  1863. }
  1864. #endif
  1865. #if defined( SHADOWMAP_TYPE_PCF )
  1866. float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1867. float shadow = 1.0;
  1868. shadowCoord.xyz /= shadowCoord.w;
  1869. shadowCoord.z += shadowBias;
  1870. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1871. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1872. if ( frustumTest ) {
  1873. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1874. float radius = shadowRadius * texelSize.x;
  1875. float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
  1876. shadow = (
  1877. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
  1878. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
  1879. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
  1880. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
  1881. texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
  1882. ) * 0.2;
  1883. }
  1884. return mix( 1.0, shadow, shadowIntensity );
  1885. }
  1886. #elif defined( SHADOWMAP_TYPE_VSM )
  1887. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1888. float shadow = 1.0;
  1889. shadowCoord.xyz /= shadowCoord.w;
  1890. shadowCoord.z += shadowBias;
  1891. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1892. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1893. if ( frustumTest ) {
  1894. vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
  1895. float mean = distribution.x;
  1896. float variance = distribution.y * distribution.y;
  1897. #ifdef USE_REVERSED_DEPTH_BUFFER
  1898. float hard_shadow = step( mean, shadowCoord.z );
  1899. #else
  1900. float hard_shadow = step( shadowCoord.z, mean );
  1901. #endif
  1902. if ( hard_shadow == 1.0 ) {
  1903. shadow = 1.0;
  1904. } else {
  1905. variance = max( variance, 0.0000001 );
  1906. float d = shadowCoord.z - mean;
  1907. float p_max = variance / ( variance + d * d );
  1908. p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
  1909. shadow = max( hard_shadow, p_max );
  1910. }
  1911. }
  1912. return mix( 1.0, shadow, shadowIntensity );
  1913. }
  1914. #else
  1915. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1916. float shadow = 1.0;
  1917. shadowCoord.xyz /= shadowCoord.w;
  1918. shadowCoord.z += shadowBias;
  1919. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1920. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1921. if ( frustumTest ) {
  1922. float depth = texture2D( shadowMap, shadowCoord.xy ).r;
  1923. #ifdef USE_REVERSED_DEPTH_BUFFER
  1924. shadow = step( depth, shadowCoord.z );
  1925. #else
  1926. shadow = step( shadowCoord.z, depth );
  1927. #endif
  1928. }
  1929. return mix( 1.0, shadow, shadowIntensity );
  1930. }
  1931. #endif
  1932. #if NUM_POINT_LIGHT_SHADOWS > 0
  1933. #if defined( SHADOWMAP_TYPE_PCF )
  1934. float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1935. float shadow = 1.0;
  1936. vec3 lightToPosition = shadowCoord.xyz;
  1937. vec3 bd3D = normalize( lightToPosition );
  1938. vec3 absVec = abs( lightToPosition );
  1939. float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
  1940. if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
  1941. float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
  1942. dp += shadowBias;
  1943. float texelSize = shadowRadius / shadowMapSize.x;
  1944. vec3 absDir = abs( bd3D );
  1945. vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
  1946. tangent = normalize( cross( bd3D, tangent ) );
  1947. vec3 bitangent = cross( bd3D, tangent );
  1948. float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
  1949. shadow = (
  1950. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
  1951. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
  1952. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
  1953. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
  1954. texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
  1955. ) * 0.2;
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #elif defined( SHADOWMAP_TYPE_BASIC )
  1960. float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1961. float shadow = 1.0;
  1962. vec3 lightToPosition = shadowCoord.xyz;
  1963. vec3 bd3D = normalize( lightToPosition );
  1964. vec3 absVec = abs( lightToPosition );
  1965. float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
  1966. if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
  1967. float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
  1968. dp += shadowBias;
  1969. float depth = textureCube( shadowMap, bd3D ).r;
  1970. #ifdef USE_REVERSED_DEPTH_BUFFER
  1971. shadow = step( depth, dp );
  1972. #else
  1973. shadow = step( dp, depth );
  1974. #endif
  1975. }
  1976. return mix( 1.0, shadow, shadowIntensity );
  1977. }
  1978. #endif
  1979. #endif
  1980. #endif`,sOe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1981. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1982. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1983. #endif
  1984. #ifdef USE_SHADOWMAP
  1985. #if NUM_DIR_LIGHT_SHADOWS > 0
  1986. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1987. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1988. struct DirectionalLightShadow {
  1989. float shadowIntensity;
  1990. float shadowBias;
  1991. float shadowNormalBias;
  1992. float shadowRadius;
  1993. vec2 shadowMapSize;
  1994. };
  1995. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1996. #endif
  1997. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1998. struct SpotLightShadow {
  1999. float shadowIntensity;
  2000. float shadowBias;
  2001. float shadowNormalBias;
  2002. float shadowRadius;
  2003. vec2 shadowMapSize;
  2004. };
  2005. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  2006. #endif
  2007. #if NUM_POINT_LIGHT_SHADOWS > 0
  2008. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  2009. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  2010. struct PointLightShadow {
  2011. float shadowIntensity;
  2012. float shadowBias;
  2013. float shadowNormalBias;
  2014. float shadowRadius;
  2015. vec2 shadowMapSize;
  2016. float shadowCameraNear;
  2017. float shadowCameraFar;
  2018. };
  2019. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  2020. #endif
  2021. #endif`,oOe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2022. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2023. vec4 shadowWorldPosition;
  2024. #endif
  2025. #if defined( USE_SHADOWMAP )
  2026. #if NUM_DIR_LIGHT_SHADOWS > 0
  2027. #pragma unroll_loop_start
  2028. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2029. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2030. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2031. }
  2032. #pragma unroll_loop_end
  2033. #endif
  2034. #if NUM_POINT_LIGHT_SHADOWS > 0
  2035. #pragma unroll_loop_start
  2036. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2037. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2038. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2039. }
  2040. #pragma unroll_loop_end
  2041. #endif
  2042. #endif
  2043. #if NUM_SPOT_LIGHT_COORDS > 0
  2044. #pragma unroll_loop_start
  2045. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2046. shadowWorldPosition = worldPosition;
  2047. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2048. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2049. #endif
  2050. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2051. }
  2052. #pragma unroll_loop_end
  2053. #endif`,lOe=`float getShadowMask() {
  2054. float shadow = 1.0;
  2055. #ifdef USE_SHADOWMAP
  2056. #if NUM_DIR_LIGHT_SHADOWS > 0
  2057. DirectionalLightShadow directionalLight;
  2058. #pragma unroll_loop_start
  2059. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2060. directionalLight = directionalLightShadows[ i ];
  2061. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2062. }
  2063. #pragma unroll_loop_end
  2064. #endif
  2065. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2066. SpotLightShadow spotLight;
  2067. #pragma unroll_loop_start
  2068. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2069. spotLight = spotLightShadows[ i ];
  2070. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2071. }
  2072. #pragma unroll_loop_end
  2073. #endif
  2074. #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
  2075. PointLightShadow pointLight;
  2076. #pragma unroll_loop_start
  2077. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2078. pointLight = pointLightShadows[ i ];
  2079. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2080. }
  2081. #pragma unroll_loop_end
  2082. #endif
  2083. #endif
  2084. return shadow;
  2085. }`,cOe=`#ifdef USE_SKINNING
  2086. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2087. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2088. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2089. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2090. #endif`,uOe=`#ifdef USE_SKINNING
  2091. uniform mat4 bindMatrix;
  2092. uniform mat4 bindMatrixInverse;
  2093. uniform highp sampler2D boneTexture;
  2094. mat4 getBoneMatrix( const in float i ) {
  2095. int size = textureSize( boneTexture, 0 ).x;
  2096. int j = int( i ) * 4;
  2097. int x = j % size;
  2098. int y = j / size;
  2099. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2100. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2101. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2102. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2103. return mat4( v1, v2, v3, v4 );
  2104. }
  2105. #endif`,dOe=`#ifdef USE_SKINNING
  2106. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2107. vec4 skinned = vec4( 0.0 );
  2108. skinned += boneMatX * skinVertex * skinWeight.x;
  2109. skinned += boneMatY * skinVertex * skinWeight.y;
  2110. skinned += boneMatZ * skinVertex * skinWeight.z;
  2111. skinned += boneMatW * skinVertex * skinWeight.w;
  2112. transformed = ( bindMatrixInverse * skinned ).xyz;
  2113. #endif`,hOe=`#ifdef USE_SKINNING
  2114. mat4 skinMatrix = mat4( 0.0 );
  2115. skinMatrix += skinWeight.x * boneMatX;
  2116. skinMatrix += skinWeight.y * boneMatY;
  2117. skinMatrix += skinWeight.z * boneMatZ;
  2118. skinMatrix += skinWeight.w * boneMatW;
  2119. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2120. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2121. #ifdef USE_TANGENT
  2122. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2123. #endif
  2124. #endif`,fOe=`float specularStrength;
  2125. #ifdef USE_SPECULARMAP
  2126. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2127. specularStrength = texelSpecular.r;
  2128. #else
  2129. specularStrength = 1.0;
  2130. #endif`,mOe=`#ifdef USE_SPECULARMAP
  2131. uniform sampler2D specularMap;
  2132. #endif`,pOe=`#if defined( TONE_MAPPING )
  2133. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2134. #endif`,gOe=`#ifndef saturate
  2135. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2136. #endif
  2137. uniform float toneMappingExposure;
  2138. vec3 LinearToneMapping( vec3 color ) {
  2139. return saturate( toneMappingExposure * color );
  2140. }
  2141. vec3 ReinhardToneMapping( vec3 color ) {
  2142. color *= toneMappingExposure;
  2143. return saturate( color / ( vec3( 1.0 ) + color ) );
  2144. }
  2145. vec3 CineonToneMapping( vec3 color ) {
  2146. color *= toneMappingExposure;
  2147. color = max( vec3( 0.0 ), color - 0.004 );
  2148. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2149. }
  2150. vec3 RRTAndODTFit( vec3 v ) {
  2151. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2152. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2153. return a / b;
  2154. }
  2155. vec3 ACESFilmicToneMapping( vec3 color ) {
  2156. const mat3 ACESInputMat = mat3(
  2157. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2158. vec3( 0.04823, 0.01566, 0.83777 )
  2159. );
  2160. const mat3 ACESOutputMat = mat3(
  2161. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2162. vec3( -0.07367, -0.00605, 1.07602 )
  2163. );
  2164. color *= toneMappingExposure / 0.6;
  2165. color = ACESInputMat * color;
  2166. color = RRTAndODTFit( color );
  2167. color = ACESOutputMat * color;
  2168. return saturate( color );
  2169. }
  2170. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2171. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2172. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2173. vec3( - 0.0728, - 0.0083, 1.1187 )
  2174. );
  2175. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2176. vec3( 0.6274, 0.0691, 0.0164 ),
  2177. vec3( 0.3293, 0.9195, 0.0880 ),
  2178. vec3( 0.0433, 0.0113, 0.8956 )
  2179. );
  2180. vec3 agxDefaultContrastApprox( vec3 x ) {
  2181. vec3 x2 = x * x;
  2182. vec3 x4 = x2 * x2;
  2183. return + 15.5 * x4 * x2
  2184. - 40.14 * x4 * x
  2185. + 31.96 * x4
  2186. - 6.868 * x2 * x
  2187. + 0.4298 * x2
  2188. + 0.1191 * x
  2189. - 0.00232;
  2190. }
  2191. vec3 AgXToneMapping( vec3 color ) {
  2192. const mat3 AgXInsetMatrix = mat3(
  2193. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2194. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2195. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2196. );
  2197. const mat3 AgXOutsetMatrix = mat3(
  2198. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2199. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2200. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2201. );
  2202. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2203. color *= toneMappingExposure;
  2204. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2205. color = AgXInsetMatrix * color;
  2206. color = max( color, 1e-10 ); color = log2( color );
  2207. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2208. color = clamp( color, 0.0, 1.0 );
  2209. color = agxDefaultContrastApprox( color );
  2210. color = AgXOutsetMatrix * color;
  2211. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2212. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2213. color = clamp( color, 0.0, 1.0 );
  2214. return color;
  2215. }
  2216. vec3 NeutralToneMapping( vec3 color ) {
  2217. const float StartCompression = 0.8 - 0.04;
  2218. const float Desaturation = 0.15;
  2219. color *= toneMappingExposure;
  2220. float x = min( color.r, min( color.g, color.b ) );
  2221. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2222. color -= offset;
  2223. float peak = max( color.r, max( color.g, color.b ) );
  2224. if ( peak < StartCompression ) return color;
  2225. float d = 1. - StartCompression;
  2226. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2227. color *= newPeak / peak;
  2228. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2229. return mix( color, vec3( newPeak ), g );
  2230. }
  2231. vec3 CustomToneMapping( vec3 color ) { return color; }`,xOe=`#ifdef USE_TRANSMISSION
  2232. material.transmission = transmission;
  2233. material.transmissionAlpha = 1.0;
  2234. material.thickness = thickness;
  2235. material.attenuationDistance = attenuationDistance;
  2236. material.attenuationColor = attenuationColor;
  2237. #ifdef USE_TRANSMISSIONMAP
  2238. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2239. #endif
  2240. #ifdef USE_THICKNESSMAP
  2241. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2242. #endif
  2243. vec3 pos = vWorldPosition;
  2244. vec3 v = normalize( cameraPosition - pos );
  2245. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2246. vec4 transmitted = getIBLVolumeRefraction(
  2247. n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
  2248. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2249. material.attenuationColor, material.attenuationDistance );
  2250. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2251. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2252. #endif`,bOe=`#ifdef USE_TRANSMISSION
  2253. uniform float transmission;
  2254. uniform float thickness;
  2255. uniform float attenuationDistance;
  2256. uniform vec3 attenuationColor;
  2257. #ifdef USE_TRANSMISSIONMAP
  2258. uniform sampler2D transmissionMap;
  2259. #endif
  2260. #ifdef USE_THICKNESSMAP
  2261. uniform sampler2D thicknessMap;
  2262. #endif
  2263. uniform vec2 transmissionSamplerSize;
  2264. uniform sampler2D transmissionSamplerMap;
  2265. uniform mat4 modelMatrix;
  2266. uniform mat4 projectionMatrix;
  2267. varying vec3 vWorldPosition;
  2268. float w0( float a ) {
  2269. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2270. }
  2271. float w1( float a ) {
  2272. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2273. }
  2274. float w2( float a ){
  2275. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2276. }
  2277. float w3( float a ) {
  2278. return ( 1.0 / 6.0 ) * ( a * a * a );
  2279. }
  2280. float g0( float a ) {
  2281. return w0( a ) + w1( a );
  2282. }
  2283. float g1( float a ) {
  2284. return w2( a ) + w3( a );
  2285. }
  2286. float h0( float a ) {
  2287. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2288. }
  2289. float h1( float a ) {
  2290. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2291. }
  2292. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2293. uv = uv * texelSize.zw + 0.5;
  2294. vec2 iuv = floor( uv );
  2295. vec2 fuv = fract( uv );
  2296. float g0x = g0( fuv.x );
  2297. float g1x = g1( fuv.x );
  2298. float h0x = h0( fuv.x );
  2299. float h1x = h1( fuv.x );
  2300. float h0y = h0( fuv.y );
  2301. float h1y = h1( fuv.y );
  2302. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2303. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2304. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2305. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2306. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2307. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2308. }
  2309. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2310. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2311. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2312. vec2 fLodSizeInv = 1.0 / fLodSize;
  2313. vec2 cLodSizeInv = 1.0 / cLodSize;
  2314. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2315. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2316. return mix( fSample, cSample, fract( lod ) );
  2317. }
  2318. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2319. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2320. vec3 modelScale;
  2321. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2322. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2323. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2324. return normalize( refractionVector ) * thickness * modelScale;
  2325. }
  2326. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2327. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2328. }
  2329. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2330. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2331. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2332. }
  2333. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2334. if ( isinf( attenuationDistance ) ) {
  2335. return vec3( 1.0 );
  2336. } else {
  2337. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2338. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2339. }
  2340. }
  2341. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2342. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2343. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2344. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2345. vec4 transmittedLight;
  2346. vec3 transmittance;
  2347. #ifdef USE_DISPERSION
  2348. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2349. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2350. for ( int i = 0; i < 3; i ++ ) {
  2351. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2352. vec3 refractedRayExit = position + transmissionRay;
  2353. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2354. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2355. refractionCoords += 1.0;
  2356. refractionCoords /= 2.0;
  2357. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2358. transmittedLight[ i ] = transmissionSample[ i ];
  2359. transmittedLight.a += transmissionSample.a;
  2360. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2361. }
  2362. transmittedLight.a /= 3.0;
  2363. #else
  2364. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2365. vec3 refractedRayExit = position + transmissionRay;
  2366. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2367. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2368. refractionCoords += 1.0;
  2369. refractionCoords /= 2.0;
  2370. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2371. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2372. #endif
  2373. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2374. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2375. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2376. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2377. }
  2378. #endif`,yOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2379. varying vec2 vUv;
  2380. #endif
  2381. #ifdef USE_MAP
  2382. varying vec2 vMapUv;
  2383. #endif
  2384. #ifdef USE_ALPHAMAP
  2385. varying vec2 vAlphaMapUv;
  2386. #endif
  2387. #ifdef USE_LIGHTMAP
  2388. varying vec2 vLightMapUv;
  2389. #endif
  2390. #ifdef USE_AOMAP
  2391. varying vec2 vAoMapUv;
  2392. #endif
  2393. #ifdef USE_BUMPMAP
  2394. varying vec2 vBumpMapUv;
  2395. #endif
  2396. #ifdef USE_NORMALMAP
  2397. varying vec2 vNormalMapUv;
  2398. #endif
  2399. #ifdef USE_EMISSIVEMAP
  2400. varying vec2 vEmissiveMapUv;
  2401. #endif
  2402. #ifdef USE_METALNESSMAP
  2403. varying vec2 vMetalnessMapUv;
  2404. #endif
  2405. #ifdef USE_ROUGHNESSMAP
  2406. varying vec2 vRoughnessMapUv;
  2407. #endif
  2408. #ifdef USE_ANISOTROPYMAP
  2409. varying vec2 vAnisotropyMapUv;
  2410. #endif
  2411. #ifdef USE_CLEARCOATMAP
  2412. varying vec2 vClearcoatMapUv;
  2413. #endif
  2414. #ifdef USE_CLEARCOAT_NORMALMAP
  2415. varying vec2 vClearcoatNormalMapUv;
  2416. #endif
  2417. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2418. varying vec2 vClearcoatRoughnessMapUv;
  2419. #endif
  2420. #ifdef USE_IRIDESCENCEMAP
  2421. varying vec2 vIridescenceMapUv;
  2422. #endif
  2423. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2424. varying vec2 vIridescenceThicknessMapUv;
  2425. #endif
  2426. #ifdef USE_SHEEN_COLORMAP
  2427. varying vec2 vSheenColorMapUv;
  2428. #endif
  2429. #ifdef USE_SHEEN_ROUGHNESSMAP
  2430. varying vec2 vSheenRoughnessMapUv;
  2431. #endif
  2432. #ifdef USE_SPECULARMAP
  2433. varying vec2 vSpecularMapUv;
  2434. #endif
  2435. #ifdef USE_SPECULAR_COLORMAP
  2436. varying vec2 vSpecularColorMapUv;
  2437. #endif
  2438. #ifdef USE_SPECULAR_INTENSITYMAP
  2439. varying vec2 vSpecularIntensityMapUv;
  2440. #endif
  2441. #ifdef USE_TRANSMISSIONMAP
  2442. uniform mat3 transmissionMapTransform;
  2443. varying vec2 vTransmissionMapUv;
  2444. #endif
  2445. #ifdef USE_THICKNESSMAP
  2446. uniform mat3 thicknessMapTransform;
  2447. varying vec2 vThicknessMapUv;
  2448. #endif`,vOe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2449. varying vec2 vUv;
  2450. #endif
  2451. #ifdef USE_MAP
  2452. uniform mat3 mapTransform;
  2453. varying vec2 vMapUv;
  2454. #endif
  2455. #ifdef USE_ALPHAMAP
  2456. uniform mat3 alphaMapTransform;
  2457. varying vec2 vAlphaMapUv;
  2458. #endif
  2459. #ifdef USE_LIGHTMAP
  2460. uniform mat3 lightMapTransform;
  2461. varying vec2 vLightMapUv;
  2462. #endif
  2463. #ifdef USE_AOMAP
  2464. uniform mat3 aoMapTransform;
  2465. varying vec2 vAoMapUv;
  2466. #endif
  2467. #ifdef USE_BUMPMAP
  2468. uniform mat3 bumpMapTransform;
  2469. varying vec2 vBumpMapUv;
  2470. #endif
  2471. #ifdef USE_NORMALMAP
  2472. uniform mat3 normalMapTransform;
  2473. varying vec2 vNormalMapUv;
  2474. #endif
  2475. #ifdef USE_DISPLACEMENTMAP
  2476. uniform mat3 displacementMapTransform;
  2477. varying vec2 vDisplacementMapUv;
  2478. #endif
  2479. #ifdef USE_EMISSIVEMAP
  2480. uniform mat3 emissiveMapTransform;
  2481. varying vec2 vEmissiveMapUv;
  2482. #endif
  2483. #ifdef USE_METALNESSMAP
  2484. uniform mat3 metalnessMapTransform;
  2485. varying vec2 vMetalnessMapUv;
  2486. #endif
  2487. #ifdef USE_ROUGHNESSMAP
  2488. uniform mat3 roughnessMapTransform;
  2489. varying vec2 vRoughnessMapUv;
  2490. #endif
  2491. #ifdef USE_ANISOTROPYMAP
  2492. uniform mat3 anisotropyMapTransform;
  2493. varying vec2 vAnisotropyMapUv;
  2494. #endif
  2495. #ifdef USE_CLEARCOATMAP
  2496. uniform mat3 clearcoatMapTransform;
  2497. varying vec2 vClearcoatMapUv;
  2498. #endif
  2499. #ifdef USE_CLEARCOAT_NORMALMAP
  2500. uniform mat3 clearcoatNormalMapTransform;
  2501. varying vec2 vClearcoatNormalMapUv;
  2502. #endif
  2503. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2504. uniform mat3 clearcoatRoughnessMapTransform;
  2505. varying vec2 vClearcoatRoughnessMapUv;
  2506. #endif
  2507. #ifdef USE_SHEEN_COLORMAP
  2508. uniform mat3 sheenColorMapTransform;
  2509. varying vec2 vSheenColorMapUv;
  2510. #endif
  2511. #ifdef USE_SHEEN_ROUGHNESSMAP
  2512. uniform mat3 sheenRoughnessMapTransform;
  2513. varying vec2 vSheenRoughnessMapUv;
  2514. #endif
  2515. #ifdef USE_IRIDESCENCEMAP
  2516. uniform mat3 iridescenceMapTransform;
  2517. varying vec2 vIridescenceMapUv;
  2518. #endif
  2519. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2520. uniform mat3 iridescenceThicknessMapTransform;
  2521. varying vec2 vIridescenceThicknessMapUv;
  2522. #endif
  2523. #ifdef USE_SPECULARMAP
  2524. uniform mat3 specularMapTransform;
  2525. varying vec2 vSpecularMapUv;
  2526. #endif
  2527. #ifdef USE_SPECULAR_COLORMAP
  2528. uniform mat3 specularColorMapTransform;
  2529. varying vec2 vSpecularColorMapUv;
  2530. #endif
  2531. #ifdef USE_SPECULAR_INTENSITYMAP
  2532. uniform mat3 specularIntensityMapTransform;
  2533. varying vec2 vSpecularIntensityMapUv;
  2534. #endif
  2535. #ifdef USE_TRANSMISSIONMAP
  2536. uniform mat3 transmissionMapTransform;
  2537. varying vec2 vTransmissionMapUv;
  2538. #endif
  2539. #ifdef USE_THICKNESSMAP
  2540. uniform mat3 thicknessMapTransform;
  2541. varying vec2 vThicknessMapUv;
  2542. #endif`,_Oe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2543. vUv = vec3( uv, 1 ).xy;
  2544. #endif
  2545. #ifdef USE_MAP
  2546. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_ALPHAMAP
  2549. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_LIGHTMAP
  2552. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_AOMAP
  2555. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_BUMPMAP
  2558. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_NORMALMAP
  2561. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_DISPLACEMENTMAP
  2564. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_EMISSIVEMAP
  2567. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_METALNESSMAP
  2570. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_ROUGHNESSMAP
  2573. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_ANISOTROPYMAP
  2576. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_CLEARCOATMAP
  2579. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_CLEARCOAT_NORMALMAP
  2582. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2585. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_IRIDESCENCEMAP
  2588. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2591. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif
  2593. #ifdef USE_SHEEN_COLORMAP
  2594. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2595. #endif
  2596. #ifdef USE_SHEEN_ROUGHNESSMAP
  2597. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2598. #endif
  2599. #ifdef USE_SPECULARMAP
  2600. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2601. #endif
  2602. #ifdef USE_SPECULAR_COLORMAP
  2603. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2604. #endif
  2605. #ifdef USE_SPECULAR_INTENSITYMAP
  2606. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2607. #endif
  2608. #ifdef USE_TRANSMISSIONMAP
  2609. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2610. #endif
  2611. #ifdef USE_THICKNESSMAP
  2612. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2613. #endif`,wOe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2614. vec4 worldPosition = vec4( transformed, 1.0 );
  2615. #ifdef USE_BATCHING
  2616. worldPosition = batchingMatrix * worldPosition;
  2617. #endif
  2618. #ifdef USE_INSTANCING
  2619. worldPosition = instanceMatrix * worldPosition;
  2620. #endif
  2621. worldPosition = modelMatrix * worldPosition;
  2622. #endif`;const SOe=`varying vec2 vUv;
  2623. uniform mat3 uvTransform;
  2624. void main() {
  2625. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2626. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2627. }`,MOe=`uniform sampler2D t2D;
  2628. uniform float backgroundIntensity;
  2629. varying vec2 vUv;
  2630. void main() {
  2631. vec4 texColor = texture2D( t2D, vUv );
  2632. #ifdef DECODE_VIDEO_TEXTURE
  2633. 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 );
  2634. #endif
  2635. texColor.rgb *= backgroundIntensity;
  2636. gl_FragColor = texColor;
  2637. #include <tonemapping_fragment>
  2638. #include <colorspace_fragment>
  2639. }`,EOe=`varying vec3 vWorldDirection;
  2640. #include <common>
  2641. void main() {
  2642. vWorldDirection = transformDirection( position, modelMatrix );
  2643. #include <begin_vertex>
  2644. #include <project_vertex>
  2645. gl_Position.z = gl_Position.w;
  2646. }`,NOe=`#ifdef ENVMAP_TYPE_CUBE
  2647. uniform samplerCube envMap;
  2648. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2649. uniform sampler2D envMap;
  2650. #endif
  2651. uniform float flipEnvMap;
  2652. uniform float backgroundBlurriness;
  2653. uniform float backgroundIntensity;
  2654. uniform mat3 backgroundRotation;
  2655. varying vec3 vWorldDirection;
  2656. #include <cube_uv_reflection_fragment>
  2657. void main() {
  2658. #ifdef ENVMAP_TYPE_CUBE
  2659. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2660. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2661. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2662. #else
  2663. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2664. #endif
  2665. texColor.rgb *= backgroundIntensity;
  2666. gl_FragColor = texColor;
  2667. #include <tonemapping_fragment>
  2668. #include <colorspace_fragment>
  2669. }`,AOe=`varying vec3 vWorldDirection;
  2670. #include <common>
  2671. void main() {
  2672. vWorldDirection = transformDirection( position, modelMatrix );
  2673. #include <begin_vertex>
  2674. #include <project_vertex>
  2675. gl_Position.z = gl_Position.w;
  2676. }`,TOe=`uniform samplerCube tCube;
  2677. uniform float tFlip;
  2678. uniform float opacity;
  2679. varying vec3 vWorldDirection;
  2680. void main() {
  2681. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2682. gl_FragColor = texColor;
  2683. gl_FragColor.a *= opacity;
  2684. #include <tonemapping_fragment>
  2685. #include <colorspace_fragment>
  2686. }`,COe=`#include <common>
  2687. #include <batching_pars_vertex>
  2688. #include <uv_pars_vertex>
  2689. #include <displacementmap_pars_vertex>
  2690. #include <morphtarget_pars_vertex>
  2691. #include <skinning_pars_vertex>
  2692. #include <logdepthbuf_pars_vertex>
  2693. #include <clipping_planes_pars_vertex>
  2694. varying vec2 vHighPrecisionZW;
  2695. void main() {
  2696. #include <uv_vertex>
  2697. #include <batching_vertex>
  2698. #include <skinbase_vertex>
  2699. #include <morphinstance_vertex>
  2700. #ifdef USE_DISPLACEMENTMAP
  2701. #include <beginnormal_vertex>
  2702. #include <morphnormal_vertex>
  2703. #include <skinnormal_vertex>
  2704. #endif
  2705. #include <begin_vertex>
  2706. #include <morphtarget_vertex>
  2707. #include <skinning_vertex>
  2708. #include <displacementmap_vertex>
  2709. #include <project_vertex>
  2710. #include <logdepthbuf_vertex>
  2711. #include <clipping_planes_vertex>
  2712. vHighPrecisionZW = gl_Position.zw;
  2713. }`,kOe=`#if DEPTH_PACKING == 3200
  2714. uniform float opacity;
  2715. #endif
  2716. #include <common>
  2717. #include <packing>
  2718. #include <uv_pars_fragment>
  2719. #include <map_pars_fragment>
  2720. #include <alphamap_pars_fragment>
  2721. #include <alphatest_pars_fragment>
  2722. #include <alphahash_pars_fragment>
  2723. #include <logdepthbuf_pars_fragment>
  2724. #include <clipping_planes_pars_fragment>
  2725. varying vec2 vHighPrecisionZW;
  2726. void main() {
  2727. vec4 diffuseColor = vec4( 1.0 );
  2728. #include <clipping_planes_fragment>
  2729. #if DEPTH_PACKING == 3200
  2730. diffuseColor.a = opacity;
  2731. #endif
  2732. #include <map_fragment>
  2733. #include <alphamap_fragment>
  2734. #include <alphatest_fragment>
  2735. #include <alphahash_fragment>
  2736. #include <logdepthbuf_fragment>
  2737. #ifdef USE_REVERSED_DEPTH_BUFFER
  2738. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2739. #else
  2740. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2741. #endif
  2742. #if DEPTH_PACKING == 3200
  2743. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2744. #elif DEPTH_PACKING == 3201
  2745. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2746. #elif DEPTH_PACKING == 3202
  2747. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2748. #elif DEPTH_PACKING == 3203
  2749. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2750. #endif
  2751. }`,jOe=`#define DISTANCE
  2752. varying vec3 vWorldPosition;
  2753. #include <common>
  2754. #include <batching_pars_vertex>
  2755. #include <uv_pars_vertex>
  2756. #include <displacementmap_pars_vertex>
  2757. #include <morphtarget_pars_vertex>
  2758. #include <skinning_pars_vertex>
  2759. #include <clipping_planes_pars_vertex>
  2760. void main() {
  2761. #include <uv_vertex>
  2762. #include <batching_vertex>
  2763. #include <skinbase_vertex>
  2764. #include <morphinstance_vertex>
  2765. #ifdef USE_DISPLACEMENTMAP
  2766. #include <beginnormal_vertex>
  2767. #include <morphnormal_vertex>
  2768. #include <skinnormal_vertex>
  2769. #endif
  2770. #include <begin_vertex>
  2771. #include <morphtarget_vertex>
  2772. #include <skinning_vertex>
  2773. #include <displacementmap_vertex>
  2774. #include <project_vertex>
  2775. #include <worldpos_vertex>
  2776. #include <clipping_planes_vertex>
  2777. vWorldPosition = worldPosition.xyz;
  2778. }`,POe=`#define DISTANCE
  2779. uniform vec3 referencePosition;
  2780. uniform float nearDistance;
  2781. uniform float farDistance;
  2782. varying vec3 vWorldPosition;
  2783. #include <common>
  2784. #include <uv_pars_fragment>
  2785. #include <map_pars_fragment>
  2786. #include <alphamap_pars_fragment>
  2787. #include <alphatest_pars_fragment>
  2788. #include <alphahash_pars_fragment>
  2789. #include <clipping_planes_pars_fragment>
  2790. void main () {
  2791. vec4 diffuseColor = vec4( 1.0 );
  2792. #include <clipping_planes_fragment>
  2793. #include <map_fragment>
  2794. #include <alphamap_fragment>
  2795. #include <alphatest_fragment>
  2796. #include <alphahash_fragment>
  2797. float dist = length( vWorldPosition - referencePosition );
  2798. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2799. dist = saturate( dist );
  2800. gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
  2801. }`,ROe=`varying vec3 vWorldDirection;
  2802. #include <common>
  2803. void main() {
  2804. vWorldDirection = transformDirection( position, modelMatrix );
  2805. #include <begin_vertex>
  2806. #include <project_vertex>
  2807. }`,DOe=`uniform sampler2D tEquirect;
  2808. varying vec3 vWorldDirection;
  2809. #include <common>
  2810. void main() {
  2811. vec3 direction = normalize( vWorldDirection );
  2812. vec2 sampleUV = equirectUv( direction );
  2813. gl_FragColor = texture2D( tEquirect, sampleUV );
  2814. #include <tonemapping_fragment>
  2815. #include <colorspace_fragment>
  2816. }`,OOe=`uniform float scale;
  2817. attribute float lineDistance;
  2818. varying float vLineDistance;
  2819. #include <common>
  2820. #include <uv_pars_vertex>
  2821. #include <color_pars_vertex>
  2822. #include <fog_pars_vertex>
  2823. #include <morphtarget_pars_vertex>
  2824. #include <logdepthbuf_pars_vertex>
  2825. #include <clipping_planes_pars_vertex>
  2826. void main() {
  2827. vLineDistance = scale * lineDistance;
  2828. #include <uv_vertex>
  2829. #include <color_vertex>
  2830. #include <morphinstance_vertex>
  2831. #include <morphcolor_vertex>
  2832. #include <begin_vertex>
  2833. #include <morphtarget_vertex>
  2834. #include <project_vertex>
  2835. #include <logdepthbuf_vertex>
  2836. #include <clipping_planes_vertex>
  2837. #include <fog_vertex>
  2838. }`,LOe=`uniform vec3 diffuse;
  2839. uniform float opacity;
  2840. uniform float dashSize;
  2841. uniform float totalSize;
  2842. varying float vLineDistance;
  2843. #include <common>
  2844. #include <color_pars_fragment>
  2845. #include <uv_pars_fragment>
  2846. #include <map_pars_fragment>
  2847. #include <fog_pars_fragment>
  2848. #include <logdepthbuf_pars_fragment>
  2849. #include <clipping_planes_pars_fragment>
  2850. void main() {
  2851. vec4 diffuseColor = vec4( diffuse, opacity );
  2852. #include <clipping_planes_fragment>
  2853. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2854. discard;
  2855. }
  2856. vec3 outgoingLight = vec3( 0.0 );
  2857. #include <logdepthbuf_fragment>
  2858. #include <map_fragment>
  2859. #include <color_fragment>
  2860. outgoingLight = diffuseColor.rgb;
  2861. #include <opaque_fragment>
  2862. #include <tonemapping_fragment>
  2863. #include <colorspace_fragment>
  2864. #include <fog_fragment>
  2865. #include <premultiplied_alpha_fragment>
  2866. }`,IOe=`#include <common>
  2867. #include <batching_pars_vertex>
  2868. #include <uv_pars_vertex>
  2869. #include <envmap_pars_vertex>
  2870. #include <color_pars_vertex>
  2871. #include <fog_pars_vertex>
  2872. #include <morphtarget_pars_vertex>
  2873. #include <skinning_pars_vertex>
  2874. #include <logdepthbuf_pars_vertex>
  2875. #include <clipping_planes_pars_vertex>
  2876. void main() {
  2877. #include <uv_vertex>
  2878. #include <color_vertex>
  2879. #include <morphinstance_vertex>
  2880. #include <morphcolor_vertex>
  2881. #include <batching_vertex>
  2882. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2883. #include <beginnormal_vertex>
  2884. #include <morphnormal_vertex>
  2885. #include <skinbase_vertex>
  2886. #include <skinnormal_vertex>
  2887. #include <defaultnormal_vertex>
  2888. #endif
  2889. #include <begin_vertex>
  2890. #include <morphtarget_vertex>
  2891. #include <skinning_vertex>
  2892. #include <project_vertex>
  2893. #include <logdepthbuf_vertex>
  2894. #include <clipping_planes_vertex>
  2895. #include <worldpos_vertex>
  2896. #include <envmap_vertex>
  2897. #include <fog_vertex>
  2898. }`,FOe=`uniform vec3 diffuse;
  2899. uniform float opacity;
  2900. #ifndef FLAT_SHADED
  2901. varying vec3 vNormal;
  2902. #endif
  2903. #include <common>
  2904. #include <dithering_pars_fragment>
  2905. #include <color_pars_fragment>
  2906. #include <uv_pars_fragment>
  2907. #include <map_pars_fragment>
  2908. #include <alphamap_pars_fragment>
  2909. #include <alphatest_pars_fragment>
  2910. #include <alphahash_pars_fragment>
  2911. #include <aomap_pars_fragment>
  2912. #include <lightmap_pars_fragment>
  2913. #include <envmap_common_pars_fragment>
  2914. #include <envmap_pars_fragment>
  2915. #include <fog_pars_fragment>
  2916. #include <specularmap_pars_fragment>
  2917. #include <logdepthbuf_pars_fragment>
  2918. #include <clipping_planes_pars_fragment>
  2919. void main() {
  2920. vec4 diffuseColor = vec4( diffuse, opacity );
  2921. #include <clipping_planes_fragment>
  2922. #include <logdepthbuf_fragment>
  2923. #include <map_fragment>
  2924. #include <color_fragment>
  2925. #include <alphamap_fragment>
  2926. #include <alphatest_fragment>
  2927. #include <alphahash_fragment>
  2928. #include <specularmap_fragment>
  2929. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2930. #ifdef USE_LIGHTMAP
  2931. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2932. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2933. #else
  2934. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2935. #endif
  2936. #include <aomap_fragment>
  2937. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2938. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2939. #include <envmap_fragment>
  2940. #include <opaque_fragment>
  2941. #include <tonemapping_fragment>
  2942. #include <colorspace_fragment>
  2943. #include <fog_fragment>
  2944. #include <premultiplied_alpha_fragment>
  2945. #include <dithering_fragment>
  2946. }`,UOe=`#define LAMBERT
  2947. varying vec3 vViewPosition;
  2948. #include <common>
  2949. #include <batching_pars_vertex>
  2950. #include <uv_pars_vertex>
  2951. #include <displacementmap_pars_vertex>
  2952. #include <envmap_pars_vertex>
  2953. #include <color_pars_vertex>
  2954. #include <fog_pars_vertex>
  2955. #include <normal_pars_vertex>
  2956. #include <morphtarget_pars_vertex>
  2957. #include <skinning_pars_vertex>
  2958. #include <shadowmap_pars_vertex>
  2959. #include <logdepthbuf_pars_vertex>
  2960. #include <clipping_planes_pars_vertex>
  2961. void main() {
  2962. #include <uv_vertex>
  2963. #include <color_vertex>
  2964. #include <morphinstance_vertex>
  2965. #include <morphcolor_vertex>
  2966. #include <batching_vertex>
  2967. #include <beginnormal_vertex>
  2968. #include <morphnormal_vertex>
  2969. #include <skinbase_vertex>
  2970. #include <skinnormal_vertex>
  2971. #include <defaultnormal_vertex>
  2972. #include <normal_vertex>
  2973. #include <begin_vertex>
  2974. #include <morphtarget_vertex>
  2975. #include <skinning_vertex>
  2976. #include <displacementmap_vertex>
  2977. #include <project_vertex>
  2978. #include <logdepthbuf_vertex>
  2979. #include <clipping_planes_vertex>
  2980. vViewPosition = - mvPosition.xyz;
  2981. #include <worldpos_vertex>
  2982. #include <envmap_vertex>
  2983. #include <shadowmap_vertex>
  2984. #include <fog_vertex>
  2985. }`,zOe=`#define LAMBERT
  2986. uniform vec3 diffuse;
  2987. uniform vec3 emissive;
  2988. uniform float opacity;
  2989. #include <common>
  2990. #include <dithering_pars_fragment>
  2991. #include <color_pars_fragment>
  2992. #include <uv_pars_fragment>
  2993. #include <map_pars_fragment>
  2994. #include <alphamap_pars_fragment>
  2995. #include <alphatest_pars_fragment>
  2996. #include <alphahash_pars_fragment>
  2997. #include <aomap_pars_fragment>
  2998. #include <lightmap_pars_fragment>
  2999. #include <emissivemap_pars_fragment>
  3000. #include <envmap_common_pars_fragment>
  3001. #include <envmap_pars_fragment>
  3002. #include <fog_pars_fragment>
  3003. #include <bsdfs>
  3004. #include <lights_pars_begin>
  3005. #include <normal_pars_fragment>
  3006. #include <lights_lambert_pars_fragment>
  3007. #include <shadowmap_pars_fragment>
  3008. #include <bumpmap_pars_fragment>
  3009. #include <normalmap_pars_fragment>
  3010. #include <specularmap_pars_fragment>
  3011. #include <logdepthbuf_pars_fragment>
  3012. #include <clipping_planes_pars_fragment>
  3013. void main() {
  3014. vec4 diffuseColor = vec4( diffuse, opacity );
  3015. #include <clipping_planes_fragment>
  3016. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3017. vec3 totalEmissiveRadiance = emissive;
  3018. #include <logdepthbuf_fragment>
  3019. #include <map_fragment>
  3020. #include <color_fragment>
  3021. #include <alphamap_fragment>
  3022. #include <alphatest_fragment>
  3023. #include <alphahash_fragment>
  3024. #include <specularmap_fragment>
  3025. #include <normal_fragment_begin>
  3026. #include <normal_fragment_maps>
  3027. #include <emissivemap_fragment>
  3028. #include <lights_lambert_fragment>
  3029. #include <lights_fragment_begin>
  3030. #include <lights_fragment_maps>
  3031. #include <lights_fragment_end>
  3032. #include <aomap_fragment>
  3033. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3034. #include <envmap_fragment>
  3035. #include <opaque_fragment>
  3036. #include <tonemapping_fragment>
  3037. #include <colorspace_fragment>
  3038. #include <fog_fragment>
  3039. #include <premultiplied_alpha_fragment>
  3040. #include <dithering_fragment>
  3041. }`,BOe=`#define MATCAP
  3042. varying vec3 vViewPosition;
  3043. #include <common>
  3044. #include <batching_pars_vertex>
  3045. #include <uv_pars_vertex>
  3046. #include <color_pars_vertex>
  3047. #include <displacementmap_pars_vertex>
  3048. #include <fog_pars_vertex>
  3049. #include <normal_pars_vertex>
  3050. #include <morphtarget_pars_vertex>
  3051. #include <skinning_pars_vertex>
  3052. #include <logdepthbuf_pars_vertex>
  3053. #include <clipping_planes_pars_vertex>
  3054. void main() {
  3055. #include <uv_vertex>
  3056. #include <color_vertex>
  3057. #include <morphinstance_vertex>
  3058. #include <morphcolor_vertex>
  3059. #include <batching_vertex>
  3060. #include <beginnormal_vertex>
  3061. #include <morphnormal_vertex>
  3062. #include <skinbase_vertex>
  3063. #include <skinnormal_vertex>
  3064. #include <defaultnormal_vertex>
  3065. #include <normal_vertex>
  3066. #include <begin_vertex>
  3067. #include <morphtarget_vertex>
  3068. #include <skinning_vertex>
  3069. #include <displacementmap_vertex>
  3070. #include <project_vertex>
  3071. #include <logdepthbuf_vertex>
  3072. #include <clipping_planes_vertex>
  3073. #include <fog_vertex>
  3074. vViewPosition = - mvPosition.xyz;
  3075. }`,$Oe=`#define MATCAP
  3076. uniform vec3 diffuse;
  3077. uniform float opacity;
  3078. uniform sampler2D matcap;
  3079. varying vec3 vViewPosition;
  3080. #include <common>
  3081. #include <dithering_pars_fragment>
  3082. #include <color_pars_fragment>
  3083. #include <uv_pars_fragment>
  3084. #include <map_pars_fragment>
  3085. #include <alphamap_pars_fragment>
  3086. #include <alphatest_pars_fragment>
  3087. #include <alphahash_pars_fragment>
  3088. #include <fog_pars_fragment>
  3089. #include <normal_pars_fragment>
  3090. #include <bumpmap_pars_fragment>
  3091. #include <normalmap_pars_fragment>
  3092. #include <logdepthbuf_pars_fragment>
  3093. #include <clipping_planes_pars_fragment>
  3094. void main() {
  3095. vec4 diffuseColor = vec4( diffuse, opacity );
  3096. #include <clipping_planes_fragment>
  3097. #include <logdepthbuf_fragment>
  3098. #include <map_fragment>
  3099. #include <color_fragment>
  3100. #include <alphamap_fragment>
  3101. #include <alphatest_fragment>
  3102. #include <alphahash_fragment>
  3103. #include <normal_fragment_begin>
  3104. #include <normal_fragment_maps>
  3105. vec3 viewDir = normalize( vViewPosition );
  3106. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3107. vec3 y = cross( viewDir, x );
  3108. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3109. #ifdef USE_MATCAP
  3110. vec4 matcapColor = texture2D( matcap, uv );
  3111. #else
  3112. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3113. #endif
  3114. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3115. #include <opaque_fragment>
  3116. #include <tonemapping_fragment>
  3117. #include <colorspace_fragment>
  3118. #include <fog_fragment>
  3119. #include <premultiplied_alpha_fragment>
  3120. #include <dithering_fragment>
  3121. }`,HOe=`#define NORMAL
  3122. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3123. varying vec3 vViewPosition;
  3124. #endif
  3125. #include <common>
  3126. #include <batching_pars_vertex>
  3127. #include <uv_pars_vertex>
  3128. #include <displacementmap_pars_vertex>
  3129. #include <normal_pars_vertex>
  3130. #include <morphtarget_pars_vertex>
  3131. #include <skinning_pars_vertex>
  3132. #include <logdepthbuf_pars_vertex>
  3133. #include <clipping_planes_pars_vertex>
  3134. void main() {
  3135. #include <uv_vertex>
  3136. #include <batching_vertex>
  3137. #include <beginnormal_vertex>
  3138. #include <morphinstance_vertex>
  3139. #include <morphnormal_vertex>
  3140. #include <skinbase_vertex>
  3141. #include <skinnormal_vertex>
  3142. #include <defaultnormal_vertex>
  3143. #include <normal_vertex>
  3144. #include <begin_vertex>
  3145. #include <morphtarget_vertex>
  3146. #include <skinning_vertex>
  3147. #include <displacementmap_vertex>
  3148. #include <project_vertex>
  3149. #include <logdepthbuf_vertex>
  3150. #include <clipping_planes_vertex>
  3151. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3152. vViewPosition = - mvPosition.xyz;
  3153. #endif
  3154. }`,VOe=`#define NORMAL
  3155. uniform float opacity;
  3156. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3157. varying vec3 vViewPosition;
  3158. #endif
  3159. #include <uv_pars_fragment>
  3160. #include <normal_pars_fragment>
  3161. #include <bumpmap_pars_fragment>
  3162. #include <normalmap_pars_fragment>
  3163. #include <logdepthbuf_pars_fragment>
  3164. #include <clipping_planes_pars_fragment>
  3165. void main() {
  3166. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3167. #include <clipping_planes_fragment>
  3168. #include <logdepthbuf_fragment>
  3169. #include <normal_fragment_begin>
  3170. #include <normal_fragment_maps>
  3171. gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
  3172. #ifdef OPAQUE
  3173. gl_FragColor.a = 1.0;
  3174. #endif
  3175. }`,GOe=`#define PHONG
  3176. varying vec3 vViewPosition;
  3177. #include <common>
  3178. #include <batching_pars_vertex>
  3179. #include <uv_pars_vertex>
  3180. #include <displacementmap_pars_vertex>
  3181. #include <envmap_pars_vertex>
  3182. #include <color_pars_vertex>
  3183. #include <fog_pars_vertex>
  3184. #include <normal_pars_vertex>
  3185. #include <morphtarget_pars_vertex>
  3186. #include <skinning_pars_vertex>
  3187. #include <shadowmap_pars_vertex>
  3188. #include <logdepthbuf_pars_vertex>
  3189. #include <clipping_planes_pars_vertex>
  3190. void main() {
  3191. #include <uv_vertex>
  3192. #include <color_vertex>
  3193. #include <morphcolor_vertex>
  3194. #include <batching_vertex>
  3195. #include <beginnormal_vertex>
  3196. #include <morphinstance_vertex>
  3197. #include <morphnormal_vertex>
  3198. #include <skinbase_vertex>
  3199. #include <skinnormal_vertex>
  3200. #include <defaultnormal_vertex>
  3201. #include <normal_vertex>
  3202. #include <begin_vertex>
  3203. #include <morphtarget_vertex>
  3204. #include <skinning_vertex>
  3205. #include <displacementmap_vertex>
  3206. #include <project_vertex>
  3207. #include <logdepthbuf_vertex>
  3208. #include <clipping_planes_vertex>
  3209. vViewPosition = - mvPosition.xyz;
  3210. #include <worldpos_vertex>
  3211. #include <envmap_vertex>
  3212. #include <shadowmap_vertex>
  3213. #include <fog_vertex>
  3214. }`,WOe=`#define PHONG
  3215. uniform vec3 diffuse;
  3216. uniform vec3 emissive;
  3217. uniform vec3 specular;
  3218. uniform float shininess;
  3219. uniform float opacity;
  3220. #include <common>
  3221. #include <dithering_pars_fragment>
  3222. #include <color_pars_fragment>
  3223. #include <uv_pars_fragment>
  3224. #include <map_pars_fragment>
  3225. #include <alphamap_pars_fragment>
  3226. #include <alphatest_pars_fragment>
  3227. #include <alphahash_pars_fragment>
  3228. #include <aomap_pars_fragment>
  3229. #include <lightmap_pars_fragment>
  3230. #include <emissivemap_pars_fragment>
  3231. #include <envmap_common_pars_fragment>
  3232. #include <envmap_pars_fragment>
  3233. #include <fog_pars_fragment>
  3234. #include <bsdfs>
  3235. #include <lights_pars_begin>
  3236. #include <normal_pars_fragment>
  3237. #include <lights_phong_pars_fragment>
  3238. #include <shadowmap_pars_fragment>
  3239. #include <bumpmap_pars_fragment>
  3240. #include <normalmap_pars_fragment>
  3241. #include <specularmap_pars_fragment>
  3242. #include <logdepthbuf_pars_fragment>
  3243. #include <clipping_planes_pars_fragment>
  3244. void main() {
  3245. vec4 diffuseColor = vec4( diffuse, opacity );
  3246. #include <clipping_planes_fragment>
  3247. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3248. vec3 totalEmissiveRadiance = emissive;
  3249. #include <logdepthbuf_fragment>
  3250. #include <map_fragment>
  3251. #include <color_fragment>
  3252. #include <alphamap_fragment>
  3253. #include <alphatest_fragment>
  3254. #include <alphahash_fragment>
  3255. #include <specularmap_fragment>
  3256. #include <normal_fragment_begin>
  3257. #include <normal_fragment_maps>
  3258. #include <emissivemap_fragment>
  3259. #include <lights_phong_fragment>
  3260. #include <lights_fragment_begin>
  3261. #include <lights_fragment_maps>
  3262. #include <lights_fragment_end>
  3263. #include <aomap_fragment>
  3264. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3265. #include <envmap_fragment>
  3266. #include <opaque_fragment>
  3267. #include <tonemapping_fragment>
  3268. #include <colorspace_fragment>
  3269. #include <fog_fragment>
  3270. #include <premultiplied_alpha_fragment>
  3271. #include <dithering_fragment>
  3272. }`,qOe=`#define STANDARD
  3273. varying vec3 vViewPosition;
  3274. #ifdef USE_TRANSMISSION
  3275. varying vec3 vWorldPosition;
  3276. #endif
  3277. #include <common>
  3278. #include <batching_pars_vertex>
  3279. #include <uv_pars_vertex>
  3280. #include <displacementmap_pars_vertex>
  3281. #include <color_pars_vertex>
  3282. #include <fog_pars_vertex>
  3283. #include <normal_pars_vertex>
  3284. #include <morphtarget_pars_vertex>
  3285. #include <skinning_pars_vertex>
  3286. #include <shadowmap_pars_vertex>
  3287. #include <logdepthbuf_pars_vertex>
  3288. #include <clipping_planes_pars_vertex>
  3289. void main() {
  3290. #include <uv_vertex>
  3291. #include <color_vertex>
  3292. #include <morphinstance_vertex>
  3293. #include <morphcolor_vertex>
  3294. #include <batching_vertex>
  3295. #include <beginnormal_vertex>
  3296. #include <morphnormal_vertex>
  3297. #include <skinbase_vertex>
  3298. #include <skinnormal_vertex>
  3299. #include <defaultnormal_vertex>
  3300. #include <normal_vertex>
  3301. #include <begin_vertex>
  3302. #include <morphtarget_vertex>
  3303. #include <skinning_vertex>
  3304. #include <displacementmap_vertex>
  3305. #include <project_vertex>
  3306. #include <logdepthbuf_vertex>
  3307. #include <clipping_planes_vertex>
  3308. vViewPosition = - mvPosition.xyz;
  3309. #include <worldpos_vertex>
  3310. #include <shadowmap_vertex>
  3311. #include <fog_vertex>
  3312. #ifdef USE_TRANSMISSION
  3313. vWorldPosition = worldPosition.xyz;
  3314. #endif
  3315. }`,KOe=`#define STANDARD
  3316. #ifdef PHYSICAL
  3317. #define IOR
  3318. #define USE_SPECULAR
  3319. #endif
  3320. uniform vec3 diffuse;
  3321. uniform vec3 emissive;
  3322. uniform float roughness;
  3323. uniform float metalness;
  3324. uniform float opacity;
  3325. #ifdef IOR
  3326. uniform float ior;
  3327. #endif
  3328. #ifdef USE_SPECULAR
  3329. uniform float specularIntensity;
  3330. uniform vec3 specularColor;
  3331. #ifdef USE_SPECULAR_COLORMAP
  3332. uniform sampler2D specularColorMap;
  3333. #endif
  3334. #ifdef USE_SPECULAR_INTENSITYMAP
  3335. uniform sampler2D specularIntensityMap;
  3336. #endif
  3337. #endif
  3338. #ifdef USE_CLEARCOAT
  3339. uniform float clearcoat;
  3340. uniform float clearcoatRoughness;
  3341. #endif
  3342. #ifdef USE_DISPERSION
  3343. uniform float dispersion;
  3344. #endif
  3345. #ifdef USE_IRIDESCENCE
  3346. uniform float iridescence;
  3347. uniform float iridescenceIOR;
  3348. uniform float iridescenceThicknessMinimum;
  3349. uniform float iridescenceThicknessMaximum;
  3350. #endif
  3351. #ifdef USE_SHEEN
  3352. uniform vec3 sheenColor;
  3353. uniform float sheenRoughness;
  3354. #ifdef USE_SHEEN_COLORMAP
  3355. uniform sampler2D sheenColorMap;
  3356. #endif
  3357. #ifdef USE_SHEEN_ROUGHNESSMAP
  3358. uniform sampler2D sheenRoughnessMap;
  3359. #endif
  3360. #endif
  3361. #ifdef USE_ANISOTROPY
  3362. uniform vec2 anisotropyVector;
  3363. #ifdef USE_ANISOTROPYMAP
  3364. uniform sampler2D anisotropyMap;
  3365. #endif
  3366. #endif
  3367. varying vec3 vViewPosition;
  3368. #include <common>
  3369. #include <dithering_pars_fragment>
  3370. #include <color_pars_fragment>
  3371. #include <uv_pars_fragment>
  3372. #include <map_pars_fragment>
  3373. #include <alphamap_pars_fragment>
  3374. #include <alphatest_pars_fragment>
  3375. #include <alphahash_pars_fragment>
  3376. #include <aomap_pars_fragment>
  3377. #include <lightmap_pars_fragment>
  3378. #include <emissivemap_pars_fragment>
  3379. #include <iridescence_fragment>
  3380. #include <cube_uv_reflection_fragment>
  3381. #include <envmap_common_pars_fragment>
  3382. #include <envmap_physical_pars_fragment>
  3383. #include <fog_pars_fragment>
  3384. #include <lights_pars_begin>
  3385. #include <normal_pars_fragment>
  3386. #include <lights_physical_pars_fragment>
  3387. #include <transmission_pars_fragment>
  3388. #include <shadowmap_pars_fragment>
  3389. #include <bumpmap_pars_fragment>
  3390. #include <normalmap_pars_fragment>
  3391. #include <clearcoat_pars_fragment>
  3392. #include <iridescence_pars_fragment>
  3393. #include <roughnessmap_pars_fragment>
  3394. #include <metalnessmap_pars_fragment>
  3395. #include <logdepthbuf_pars_fragment>
  3396. #include <clipping_planes_pars_fragment>
  3397. void main() {
  3398. vec4 diffuseColor = vec4( diffuse, opacity );
  3399. #include <clipping_planes_fragment>
  3400. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3401. vec3 totalEmissiveRadiance = emissive;
  3402. #include <logdepthbuf_fragment>
  3403. #include <map_fragment>
  3404. #include <color_fragment>
  3405. #include <alphamap_fragment>
  3406. #include <alphatest_fragment>
  3407. #include <alphahash_fragment>
  3408. #include <roughnessmap_fragment>
  3409. #include <metalnessmap_fragment>
  3410. #include <normal_fragment_begin>
  3411. #include <normal_fragment_maps>
  3412. #include <clearcoat_normal_fragment_begin>
  3413. #include <clearcoat_normal_fragment_maps>
  3414. #include <emissivemap_fragment>
  3415. #include <lights_physical_fragment>
  3416. #include <lights_fragment_begin>
  3417. #include <lights_fragment_maps>
  3418. #include <lights_fragment_end>
  3419. #include <aomap_fragment>
  3420. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3421. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3422. #include <transmission_fragment>
  3423. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3424. #ifdef USE_SHEEN
  3425. outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
  3426. #endif
  3427. #ifdef USE_CLEARCOAT
  3428. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3429. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3430. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3431. #endif
  3432. #include <opaque_fragment>
  3433. #include <tonemapping_fragment>
  3434. #include <colorspace_fragment>
  3435. #include <fog_fragment>
  3436. #include <premultiplied_alpha_fragment>
  3437. #include <dithering_fragment>
  3438. }`,XOe=`#define TOON
  3439. varying vec3 vViewPosition;
  3440. #include <common>
  3441. #include <batching_pars_vertex>
  3442. #include <uv_pars_vertex>
  3443. #include <displacementmap_pars_vertex>
  3444. #include <color_pars_vertex>
  3445. #include <fog_pars_vertex>
  3446. #include <normal_pars_vertex>
  3447. #include <morphtarget_pars_vertex>
  3448. #include <skinning_pars_vertex>
  3449. #include <shadowmap_pars_vertex>
  3450. #include <logdepthbuf_pars_vertex>
  3451. #include <clipping_planes_pars_vertex>
  3452. void main() {
  3453. #include <uv_vertex>
  3454. #include <color_vertex>
  3455. #include <morphinstance_vertex>
  3456. #include <morphcolor_vertex>
  3457. #include <batching_vertex>
  3458. #include <beginnormal_vertex>
  3459. #include <morphnormal_vertex>
  3460. #include <skinbase_vertex>
  3461. #include <skinnormal_vertex>
  3462. #include <defaultnormal_vertex>
  3463. #include <normal_vertex>
  3464. #include <begin_vertex>
  3465. #include <morphtarget_vertex>
  3466. #include <skinning_vertex>
  3467. #include <displacementmap_vertex>
  3468. #include <project_vertex>
  3469. #include <logdepthbuf_vertex>
  3470. #include <clipping_planes_vertex>
  3471. vViewPosition = - mvPosition.xyz;
  3472. #include <worldpos_vertex>
  3473. #include <shadowmap_vertex>
  3474. #include <fog_vertex>
  3475. }`,YOe=`#define TOON
  3476. uniform vec3 diffuse;
  3477. uniform vec3 emissive;
  3478. uniform float opacity;
  3479. #include <common>
  3480. #include <dithering_pars_fragment>
  3481. #include <color_pars_fragment>
  3482. #include <uv_pars_fragment>
  3483. #include <map_pars_fragment>
  3484. #include <alphamap_pars_fragment>
  3485. #include <alphatest_pars_fragment>
  3486. #include <alphahash_pars_fragment>
  3487. #include <aomap_pars_fragment>
  3488. #include <lightmap_pars_fragment>
  3489. #include <emissivemap_pars_fragment>
  3490. #include <gradientmap_pars_fragment>
  3491. #include <fog_pars_fragment>
  3492. #include <bsdfs>
  3493. #include <lights_pars_begin>
  3494. #include <normal_pars_fragment>
  3495. #include <lights_toon_pars_fragment>
  3496. #include <shadowmap_pars_fragment>
  3497. #include <bumpmap_pars_fragment>
  3498. #include <normalmap_pars_fragment>
  3499. #include <logdepthbuf_pars_fragment>
  3500. #include <clipping_planes_pars_fragment>
  3501. void main() {
  3502. vec4 diffuseColor = vec4( diffuse, opacity );
  3503. #include <clipping_planes_fragment>
  3504. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3505. vec3 totalEmissiveRadiance = emissive;
  3506. #include <logdepthbuf_fragment>
  3507. #include <map_fragment>
  3508. #include <color_fragment>
  3509. #include <alphamap_fragment>
  3510. #include <alphatest_fragment>
  3511. #include <alphahash_fragment>
  3512. #include <normal_fragment_begin>
  3513. #include <normal_fragment_maps>
  3514. #include <emissivemap_fragment>
  3515. #include <lights_toon_fragment>
  3516. #include <lights_fragment_begin>
  3517. #include <lights_fragment_maps>
  3518. #include <lights_fragment_end>
  3519. #include <aomap_fragment>
  3520. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3521. #include <opaque_fragment>
  3522. #include <tonemapping_fragment>
  3523. #include <colorspace_fragment>
  3524. #include <fog_fragment>
  3525. #include <premultiplied_alpha_fragment>
  3526. #include <dithering_fragment>
  3527. }`,ZOe=`uniform float size;
  3528. uniform float scale;
  3529. #include <common>
  3530. #include <color_pars_vertex>
  3531. #include <fog_pars_vertex>
  3532. #include <morphtarget_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. #ifdef USE_POINTS_UV
  3536. varying vec2 vUv;
  3537. uniform mat3 uvTransform;
  3538. #endif
  3539. void main() {
  3540. #ifdef USE_POINTS_UV
  3541. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3542. #endif
  3543. #include <color_vertex>
  3544. #include <morphinstance_vertex>
  3545. #include <morphcolor_vertex>
  3546. #include <begin_vertex>
  3547. #include <morphtarget_vertex>
  3548. #include <project_vertex>
  3549. gl_PointSize = size;
  3550. #ifdef USE_SIZEATTENUATION
  3551. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3552. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3553. #endif
  3554. #include <logdepthbuf_vertex>
  3555. #include <clipping_planes_vertex>
  3556. #include <worldpos_vertex>
  3557. #include <fog_vertex>
  3558. }`,QOe=`uniform vec3 diffuse;
  3559. uniform float opacity;
  3560. #include <common>
  3561. #include <color_pars_fragment>
  3562. #include <map_particle_pars_fragment>
  3563. #include <alphatest_pars_fragment>
  3564. #include <alphahash_pars_fragment>
  3565. #include <fog_pars_fragment>
  3566. #include <logdepthbuf_pars_fragment>
  3567. #include <clipping_planes_pars_fragment>
  3568. void main() {
  3569. vec4 diffuseColor = vec4( diffuse, opacity );
  3570. #include <clipping_planes_fragment>
  3571. vec3 outgoingLight = vec3( 0.0 );
  3572. #include <logdepthbuf_fragment>
  3573. #include <map_particle_fragment>
  3574. #include <color_fragment>
  3575. #include <alphatest_fragment>
  3576. #include <alphahash_fragment>
  3577. outgoingLight = diffuseColor.rgb;
  3578. #include <opaque_fragment>
  3579. #include <tonemapping_fragment>
  3580. #include <colorspace_fragment>
  3581. #include <fog_fragment>
  3582. #include <premultiplied_alpha_fragment>
  3583. }`,JOe=`#include <common>
  3584. #include <batching_pars_vertex>
  3585. #include <fog_pars_vertex>
  3586. #include <morphtarget_pars_vertex>
  3587. #include <skinning_pars_vertex>
  3588. #include <logdepthbuf_pars_vertex>
  3589. #include <shadowmap_pars_vertex>
  3590. void main() {
  3591. #include <batching_vertex>
  3592. #include <beginnormal_vertex>
  3593. #include <morphinstance_vertex>
  3594. #include <morphnormal_vertex>
  3595. #include <skinbase_vertex>
  3596. #include <skinnormal_vertex>
  3597. #include <defaultnormal_vertex>
  3598. #include <begin_vertex>
  3599. #include <morphtarget_vertex>
  3600. #include <skinning_vertex>
  3601. #include <project_vertex>
  3602. #include <logdepthbuf_vertex>
  3603. #include <worldpos_vertex>
  3604. #include <shadowmap_vertex>
  3605. #include <fog_vertex>
  3606. }`,e4e=`uniform vec3 color;
  3607. uniform float opacity;
  3608. #include <common>
  3609. #include <fog_pars_fragment>
  3610. #include <bsdfs>
  3611. #include <lights_pars_begin>
  3612. #include <logdepthbuf_pars_fragment>
  3613. #include <shadowmap_pars_fragment>
  3614. #include <shadowmask_pars_fragment>
  3615. void main() {
  3616. #include <logdepthbuf_fragment>
  3617. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3618. #include <tonemapping_fragment>
  3619. #include <colorspace_fragment>
  3620. #include <fog_fragment>
  3621. }`,t4e=`uniform float rotation;
  3622. uniform vec2 center;
  3623. #include <common>
  3624. #include <uv_pars_vertex>
  3625. #include <fog_pars_vertex>
  3626. #include <logdepthbuf_pars_vertex>
  3627. #include <clipping_planes_pars_vertex>
  3628. void main() {
  3629. #include <uv_vertex>
  3630. vec4 mvPosition = modelViewMatrix[ 3 ];
  3631. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3632. #ifndef USE_SIZEATTENUATION
  3633. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3634. if ( isPerspective ) scale *= - mvPosition.z;
  3635. #endif
  3636. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3637. vec2 rotatedPosition;
  3638. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3639. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3640. mvPosition.xy += rotatedPosition;
  3641. gl_Position = projectionMatrix * mvPosition;
  3642. #include <logdepthbuf_vertex>
  3643. #include <clipping_planes_vertex>
  3644. #include <fog_vertex>
  3645. }`,n4e=`uniform vec3 diffuse;
  3646. uniform float opacity;
  3647. #include <common>
  3648. #include <uv_pars_fragment>
  3649. #include <map_pars_fragment>
  3650. #include <alphamap_pars_fragment>
  3651. #include <alphatest_pars_fragment>
  3652. #include <alphahash_pars_fragment>
  3653. #include <fog_pars_fragment>
  3654. #include <logdepthbuf_pars_fragment>
  3655. #include <clipping_planes_pars_fragment>
  3656. void main() {
  3657. vec4 diffuseColor = vec4( diffuse, opacity );
  3658. #include <clipping_planes_fragment>
  3659. vec3 outgoingLight = vec3( 0.0 );
  3660. #include <logdepthbuf_fragment>
  3661. #include <map_fragment>
  3662. #include <alphamap_fragment>
  3663. #include <alphatest_fragment>
  3664. #include <alphahash_fragment>
  3665. outgoingLight = diffuseColor.rgb;
  3666. #include <opaque_fragment>
  3667. #include <tonemapping_fragment>
  3668. #include <colorspace_fragment>
  3669. #include <fog_fragment>
  3670. }`,wn={alphahash_fragment:MRe,alphahash_pars_fragment:ERe,alphamap_fragment:NRe,alphamap_pars_fragment:ARe,alphatest_fragment:TRe,alphatest_pars_fragment:CRe,aomap_fragment:kRe,aomap_pars_fragment:jRe,batching_pars_vertex:PRe,batching_vertex:RRe,begin_vertex:DRe,beginnormal_vertex:ORe,bsdfs:LRe,iridescence_fragment:IRe,bumpmap_pars_fragment:FRe,clipping_planes_fragment:URe,clipping_planes_pars_fragment:zRe,clipping_planes_pars_vertex:BRe,clipping_planes_vertex:$Re,color_fragment:HRe,color_pars_fragment:VRe,color_pars_vertex:GRe,color_vertex:WRe,common:qRe,cube_uv_reflection_fragment:KRe,defaultnormal_vertex:XRe,displacementmap_pars_vertex:YRe,displacementmap_vertex:ZRe,emissivemap_fragment:QRe,emissivemap_pars_fragment:JRe,colorspace_fragment:eDe,colorspace_pars_fragment:tDe,envmap_fragment:nDe,envmap_common_pars_fragment:rDe,envmap_pars_fragment:iDe,envmap_pars_vertex:aDe,envmap_physical_pars_fragment:gDe,envmap_vertex:sDe,fog_vertex:oDe,fog_pars_vertex:lDe,fog_fragment:cDe,fog_pars_fragment:uDe,gradientmap_pars_fragment:dDe,lightmap_pars_fragment:hDe,lights_lambert_fragment:fDe,lights_lambert_pars_fragment:mDe,lights_pars_begin:pDe,lights_toon_fragment:xDe,lights_toon_pars_fragment:bDe,lights_phong_fragment:yDe,lights_phong_pars_fragment:vDe,lights_physical_fragment:_De,lights_physical_pars_fragment:wDe,lights_fragment_begin:SDe,lights_fragment_maps:MDe,lights_fragment_end:EDe,logdepthbuf_fragment:NDe,logdepthbuf_pars_fragment:ADe,logdepthbuf_pars_vertex:TDe,logdepthbuf_vertex:CDe,map_fragment:kDe,map_pars_fragment:jDe,map_particle_fragment:PDe,map_particle_pars_fragment:RDe,metalnessmap_fragment:DDe,metalnessmap_pars_fragment:ODe,morphinstance_vertex:LDe,morphcolor_vertex:IDe,morphnormal_vertex:FDe,morphtarget_pars_vertex:UDe,morphtarget_vertex:zDe,normal_fragment_begin:BDe,normal_fragment_maps:$De,normal_pars_fragment:HDe,normal_pars_vertex:VDe,normal_vertex:GDe,normalmap_pars_fragment:WDe,clearcoat_normal_fragment_begin:qDe,clearcoat_normal_fragment_maps:KDe,clearcoat_pars_fragment:XDe,iridescence_pars_fragment:YDe,opaque_fragment:ZDe,packing:QDe,premultiplied_alpha_fragment:JDe,project_vertex:eOe,dithering_fragment:tOe,dithering_pars_fragment:nOe,roughnessmap_fragment:rOe,roughnessmap_pars_fragment:iOe,shadowmap_pars_fragment:aOe,shadowmap_pars_vertex:sOe,shadowmap_vertex:oOe,shadowmask_pars_fragment:lOe,skinbase_vertex:cOe,skinning_pars_vertex:uOe,skinning_vertex:dOe,skinnormal_vertex:hOe,specularmap_fragment:fOe,specularmap_pars_fragment:mOe,tonemapping_fragment:pOe,tonemapping_pars_fragment:gOe,transmission_fragment:xOe,transmission_pars_fragment:bOe,uv_pars_fragment:yOe,uv_pars_vertex:vOe,uv_vertex:_Oe,worldpos_vertex:wOe,background_vert:SOe,background_frag:MOe,backgroundCube_vert:EOe,backgroundCube_frag:NOe,cube_vert:AOe,cube_frag:TOe,depth_vert:COe,depth_frag:kOe,distance_vert:jOe,distance_frag:POe,equirect_vert:ROe,equirect_frag:DOe,linedashed_vert:OOe,linedashed_frag:LOe,meshbasic_vert:IOe,meshbasic_frag:FOe,meshlambert_vert:UOe,meshlambert_frag:zOe,meshmatcap_vert:BOe,meshmatcap_frag:$Oe,meshnormal_vert:HOe,meshnormal_frag:VOe,meshphong_vert:GOe,meshphong_frag:WOe,meshphysical_vert:qOe,meshphysical_frag:KOe,meshtoon_vert:XOe,meshtoon_frag:YOe,points_vert:ZOe,points_frag:QOe,shadow_vert:JOe,shadow_frag:e4e,sprite_vert:t4e,sprite_frag:n4e},It={common:{diffuse:{value:new Pn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new An}},envmap:{envMap:{value:null},envMapRotation:{value:new An},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 An}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new An}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new An},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new An},normalScale:{value:new Mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new An},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new An}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new An}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new An}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Pn(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 Pn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0},uvTransform:{value:new An}},sprite:{diffuse:{value:new Pn(16777215)},opacity:{value:1},center:{value:new Mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}}},Ol={basic:{uniforms:Ha([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.fog]),vertexShader:wn.meshbasic_vert,fragmentShader:wn.meshbasic_frag},lambert:{uniforms:Ha([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new Pn(0)}}]),vertexShader:wn.meshlambert_vert,fragmentShader:wn.meshlambert_frag},phong:{uniforms:Ha([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new Pn(0)},specular:{value:new Pn(1118481)},shininess:{value:30}}]),vertexShader:wn.meshphong_vert,fragmentShader:wn.meshphong_frag},standard:{uniforms:Ha([It.common,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.roughnessmap,It.metalnessmap,It.fog,It.lights,{emissive:{value:new Pn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag},toon:{uniforms:Ha([It.common,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.gradientmap,It.fog,It.lights,{emissive:{value:new Pn(0)}}]),vertexShader:wn.meshtoon_vert,fragmentShader:wn.meshtoon_frag},matcap:{uniforms:Ha([It.common,It.bumpmap,It.normalmap,It.displacementmap,It.fog,{matcap:{value:null}}]),vertexShader:wn.meshmatcap_vert,fragmentShader:wn.meshmatcap_frag},points:{uniforms:Ha([It.points,It.fog]),vertexShader:wn.points_vert,fragmentShader:wn.points_frag},dashed:{uniforms:Ha([It.common,It.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wn.linedashed_vert,fragmentShader:wn.linedashed_frag},depth:{uniforms:Ha([It.common,It.displacementmap]),vertexShader:wn.depth_vert,fragmentShader:wn.depth_frag},normal:{uniforms:Ha([It.common,It.bumpmap,It.normalmap,It.displacementmap,{opacity:{value:1}}]),vertexShader:wn.meshnormal_vert,fragmentShader:wn.meshnormal_frag},sprite:{uniforms:Ha([It.sprite,It.fog]),vertexShader:wn.sprite_vert,fragmentShader:wn.sprite_frag},background:{uniforms:{uvTransform:{value:new An},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wn.background_vert,fragmentShader:wn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new An}},vertexShader:wn.backgroundCube_vert,fragmentShader:wn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wn.cube_vert,fragmentShader:wn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wn.equirect_vert,fragmentShader:wn.equirect_frag},distance:{uniforms:Ha([It.common,It.displacementmap,{referencePosition:{value:new nt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wn.distance_vert,fragmentShader:wn.distance_frag},shadow:{uniforms:Ha([It.lights,It.fog,{color:{value:new Pn(0)},opacity:{value:1}}]),vertexShader:wn.shadow_vert,fragmentShader:wn.shadow_frag}};Ol.physical={uniforms:Ha([Ol.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new An},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new An},clearcoatNormalScale:{value:new Mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new An},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new An},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new An},sheen:{value:0},sheenColor:{value:new Pn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new An},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new An},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new An},transmissionSamplerSize:{value:new Mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new An},attenuationDistance:{value:0},attenuationColor:{value:new Pn(0)},specularColor:{value:new Pn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new An},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new An},anisotropyVector:{value:new Mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new An}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag};const Z_={r:0,b:0,g:0},Uh=new Jd,r4e=new li;function i4e(t,e,n,r,i,a,o){const l=new Pn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function b(M){let N=M.isScene===!0?M.background:null;return N&&N.isTexture&&(N=(M.backgroundBlurriness>0?n:e).get(N)),N}function y(M){let N=!1;const A=b(M);A===null?v(l,c):A&&A.isColor&&(v(A,1),N=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||N)&&(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(M,N){const A=b(N);A&&(A.isCubeTexture||A.mapping===oN)?(d===void 0&&(d=new dl(new sL(1,1,1),new rc({name:"BackgroundCubeMaterial",uniforms:kg(Ol.backgroundCube.uniforms),vertexShader:Ol.backgroundCube.vertexShader,fragmentShader:Ol.backgroundCube.fragmentShader,side:bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Uh.copy(N.backgroundRotation),Uh.x*=-1,Uh.y*=-1,Uh.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(Uh.y*=-1,Uh.z*=-1),d.material.uniforms.envMap.value=A,d.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=N.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(r4e.makeRotationFromEuler(Uh)),d.material.toneMapped=Bn.getTransfer(A.colorSpace)!==ar,(f!==A||m!==A.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=A,m=A.version,p=t.toneMapping),d.layers.enableAll(),M.unshift(d,d.geometry,d.material,0,0,null)):A&&A.isTexture&&(u===void 0&&(u=new dl(new lL(2,2),new rc({name:"BackgroundMaterial",uniforms:kg(Ol.background.uniforms),vertexShader:Ol.background.vertexShader,fragmentShader:Ol.background.fragmentShader,side:Qd,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=A,u.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,u.material.toneMapped=Bn.getTransfer(A.colorSpace)!==ar,A.matrixAutoUpdate===!0&&A.updateMatrix(),u.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||m!==A.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=A,m=A.version,p=t.toneMapping),u.layers.enableAll(),M.unshift(u,u.geometry,u.material,0,0,null))}function v(M,N){M.getRGB(Z_,_ee(t)),r.buffers.color.setClear(Z_.r,Z_.g,Z_.b,N,o)}function S(){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(M,N=1){l.set(M),c=N,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,v(l,c)},render:y,addToRenderList:x,dispose:S}}function a4e(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(R,U,O,q,j){let W=!1;const K=f(q,O,U);a!==K&&(a=K,u(a.object)),W=p(R,q,O,j),W&&b(R,q,O,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,N(R,U,O,q),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,U,O){const q=O.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let W=j[U.id];W===void 0&&(W={},j[U.id]=W);let K=W[q];return K===void 0&&(K=m(c()),W[q]=K),K}function m(R){const U=[],O=[],q=[];for(let j=0;j<n;j++)U[j]=0,O[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:O,attributeDivisors:q,object:R,attributes:{},index:null}}function p(R,U,O,q){const j=a.attributes,W=U.attributes;let K=0;const G=O.getAttributes();for(const J in G)if(G[J].location>=0){const re=j[J];let z=W[J];if(z===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),re===void 0||re.attribute!==z||z&&re.data!==z.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(R,U,O,q){const j={},W=U.attributes;let K=0;const G=O.getAttributes();for(const J in G)if(G[J].location>=0){let re=W[J];re===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(re=R.instanceColor));const z={};z.attribute=re,re&&re.data&&(z.data=re.data),j[J]=z,K++}a.attributes=j,a.attributesNum=K,a.index=q}function y(){const R=a.newAttributes;for(let U=0,O=R.length;U<O;U++)R[U]=0}function x(R){v(R,0)}function v(R,U){const O=a.newAttributes,q=a.enabledAttributes,j=a.attributeDivisors;O[R]=1,q[R]===0&&(t.enableVertexAttribArray(R),q[R]=1),j[R]!==U&&(t.vertexAttribDivisor(R,U),j[R]=U)}function S(){const R=a.newAttributes,U=a.enabledAttributes;for(let O=0,q=U.length;O<q;O++)U[O]!==R[O]&&(t.disableVertexAttribArray(O),U[O]=0)}function M(R,U,O,q,j,W,K){K===!0?t.vertexAttribIPointer(R,U,O,j,W):t.vertexAttribPointer(R,U,O,q,j,W)}function N(R,U,O,q){y();const j=q.attributes,W=O.getAttributes(),K=U.defaultAttributeValues;for(const G in W){const J=W[G];if(J.location>=0){let ie=j[G];if(ie===void 0&&(G==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),G==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor)),ie!==void 0){const re=ie.normalized,z=ie.itemSize,V=e.get(ie);if(V===void 0)continue;const Z=V.buffer,ne=V.type,he=V.bytesPerElement,fe=ne===t.INT||ne===t.UNSIGNED_INT||ie.gpuType===X4;if(ie.isInterleavedBufferAttribute){const le=ie.data,Ee=le.stride,me=ie.offset;if(le.isInstancedInterleavedBuffer){for(let we=0;we<J.locationSize;we++)v(J.location+we,le.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let we=0;we<J.locationSize;we++)x(J.location+we);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let we=0;we<J.locationSize;we++)M(J.location+we,z/J.locationSize,ne,re,Ee*he,(me+z/J.locationSize*we)*he,fe)}else{if(ie.isInstancedBufferAttribute){for(let le=0;le<J.locationSize;le++)v(J.location+le,ie.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let le=0;le<J.locationSize;le++)x(J.location+le);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let le=0;le<J.locationSize;le++)M(J.location+le,z/J.locationSize,ne,re,z*he,z/J.locationSize*le*he,fe)}}else if(K!==void 0){const re=K[G];if(re!==void 0)switch(re.length){case 2:t.vertexAttrib2fv(J.location,re);break;case 3:t.vertexAttrib3fv(J.location,re);break;case 4:t.vertexAttrib4fv(J.location,re);break;default:t.vertexAttrib1fv(J.location,re)}}}}S()}function A(){D();for(const R in r){const U=r[R];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const U=r[R.id];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R.id]}function C(R){for(const U in r){const O=r[U];if(O[R.id]===void 0)continue;const q=O[R.id];for(const j in q)d(q[j].object),delete q[j];delete O[R.id]}}function D(){T(),o=!0,a!==i&&(a=i,u(a.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:T,dispose:A,releaseStatesOfGeometry:k,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:x,disableUnusedAttributes:S}}function s4e(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 p=0;for(let b=0;b<f;b++)p+=d[b];n.update(p,r,1)}function c(u,d,f,m){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let b=0;b<u.length;b++)o(u[b],d[b],m[b]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let b=0;for(let y=0;y<f;y++)b+=d[y]*m[y];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function o4e(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==Jo&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const D=C===bu&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==zs&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Bl&&!D)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="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&&(dn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),M=t.getParameter(t.MAX_VARYING_VECTORS),N=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),A=t.getParameter(t.MAX_SAMPLES),k=t.getParameter(t.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:p,maxVertexTextures:b,maxTextureSize:y,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:S,maxVaryings:M,maxFragmentUniforms:N,maxSamples:A,samples:k}}function l4e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new gd,l=new An,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const b=f.clippingPlanes,y=f.clipIntersection,x=f.clipShadows,v=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const S=a?0:r,M=S*4;let N=v.clippingState||null;c.value=N,N=d(b,m,M,p);for(let A=0;A!==M;++A)N[A]=n[A];v.clippingState=N,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,b){const y=f!==null?f.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=p+y*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let M=0,N=p;M!==y;++M,N+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,N),x[N+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function c4e(t){let e=new WeakMap;function n(o,l){return l===R3?o.mapping=Yf:l===D3&&(o.mapping=Ag),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===R3||l===D3)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 Mee(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 Td=4,YV=[.125,.215,.35,.446,.526,.582],Jh=20,u4e=256,Sb=new cL,ZV=new Pn;let bk=null,yk=0,vk=0,_k=!1;const d4e=new nt;let QV=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=d4e}=a;bk=this._renderer.getRenderTarget(),yk=this._renderer.getActiveCubeFace(),vk=this._renderer.getActiveMipmapLevel(),_k=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=tG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=eG(),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(bk,yk,vk),this._renderer.xr.enabled=_k,e.scissorTest=!1,hp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Yf||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),bk=this._renderer.getRenderTarget(),yk=this._renderer.getActiveCubeFace(),vk=this._renderer.getActiveMipmapLevel(),_k=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:Oa,minFilter:Oa,generateMipmaps:!1,type:bu,format:Jo,colorSpace:Cg,depthBuffer:!1},i=JV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=JV(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=h4e(a)),this._blurMaterial=m4e(a,e,n),this._ggxMaterial=f4e(a,e,n)}return i}_compileMaterial(e){const n=new dl(new bl,e);this._renderer.compile(n,Sb)}_sceneToCubeUV(e,n,r,i,a){const c=new _o(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(ZV),f.toneMapping=Wl,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new dl(new sL,new aL({name:"PMREM.Background",side:bs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,x=y.material;let v=!1;const S=e.background;S?S.isColor&&(x.color.copy(S),e.background=null,v=!0):(x.color.copy(ZV),v=!0);for(let M=0;M<6;M++){const N=M%3;N===0?(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[M],a.y,a.z)):N===1?(c.up.set(0,0,u[M]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[M],a.z)):(c.up.set(0,u[M],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[M]));const A=this._cubeSize;hp(i,N*A,M>2?A:0,A,A),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=p,f.autoClear=m,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Yf||e.mapping===Ag;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=tG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=eG());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;hp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Sb)}_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),m=0+u*1.25,p=f*m,{_lodMax:b}=this,y=this._sizeLods[r],x=3*y*(r>b-Td?r-b+Td:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,hp(a,x,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Sb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,hp(e,x,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Sb)}_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"&&Vn("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Jh-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):Jh;x>Jh&&dn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Jh}`);const v=[];let S=0;for(let C=0;C<Jh;++C){const D=C/y,T=Math.exp(-D*D/2);v.push(T),C===0?S+=T:C<x&&(S+=2*T)}for(let C=0;C<v.length;C++)v[C]=v[C]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const N=this._sizeLods[i],A=3*N*(i>M-Td?i-M+Td:0),k=4*(this._cubeSize-N);hp(n,A,k,3*N,2*N),c.setRenderTarget(n),c.render(f,Sb)}};function h4e(t){const e=[],n=[],r=[];let i=t;const a=t-Td+1+YV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Td?c=YV[o-t+Td-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,b=6,y=3,x=2,v=1,S=new Float32Array(y*b*p),M=new Float32Array(x*b*p),N=new Float32Array(v*b*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,D=k>2?0:-1,T=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];S.set(T,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];N.set(R,v*b*k)}const A=new bl;A.setAttribute("position",new Ao(S,y)),A.setAttribute("uv",new Ao(M,x)),A.setAttribute("faceIndex",new Ao(N,v)),r.push(new dl(A,null)),i>Td&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function JV(t,e,n){const r=new ql(t,e,n);return r.texture.mapping=oN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function hp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function f4e(t,e,n){return new rc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:u4e,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:cN(),fragmentShader:`
  3671. precision highp float;
  3672. precision highp int;
  3673. varying vec3 vOutputDirection;
  3674. uniform sampler2D envMap;
  3675. uniform float roughness;
  3676. uniform float mipInt;
  3677. #define ENVMAP_TYPE_CUBE_UV
  3678. #include <cube_uv_reflection_fragment>
  3679. #define PI 3.14159265359
  3680. // Van der Corput radical inverse
  3681. float radicalInverse_VdC(uint bits) {
  3682. bits = (bits << 16u) | (bits >> 16u);
  3683. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3684. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3685. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3686. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3687. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3688. }
  3689. // Hammersley sequence
  3690. vec2 hammersley(uint i, uint N) {
  3691. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3692. }
  3693. // GGX VNDF importance sampling (Eric Heitz 2018)
  3694. // "Sampling the GGX Distribution of Visible Normals"
  3695. // https://jcgt.org/published/0007/04/01/
  3696. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3697. float alpha = roughness * roughness;
  3698. // Section 3.2: Transform view direction to hemisphere configuration
  3699. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3700. // Section 4.1: Orthonormal basis
  3701. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3702. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3703. vec3 T2 = cross(Vh, T1);
  3704. // Section 4.2: Parameterization of projected area
  3705. float r = sqrt(Xi.x);
  3706. float phi = 2.0 * PI * Xi.y;
  3707. float t1 = r * cos(phi);
  3708. float t2 = r * sin(phi);
  3709. float s = 0.5 * (1.0 + Vh.z);
  3710. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3711. // Section 4.3: Reprojection onto hemisphere
  3712. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3713. // Section 3.4: Transform back to ellipsoid configuration
  3714. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3715. }
  3716. void main() {
  3717. vec3 N = normalize(vOutputDirection);
  3718. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3719. vec3 prefilteredColor = vec3(0.0);
  3720. float totalWeight = 0.0;
  3721. // For very low roughness, just sample the environment directly
  3722. if (roughness < 0.001) {
  3723. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3724. return;
  3725. }
  3726. // Tangent space basis for VNDF sampling
  3727. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3728. vec3 tangent = normalize(cross(up, N));
  3729. vec3 bitangent = cross(N, tangent);
  3730. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3731. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3732. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3733. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3734. // Transform H back to world space
  3735. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3736. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3737. float NdotL = max(dot(N, L), 0.0);
  3738. if(NdotL > 0.0) {
  3739. // Sample environment at fixed mip level
  3740. // VNDF importance sampling handles the distribution filtering
  3741. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3742. // Weight by NdotL for the split-sum approximation
  3743. // VNDF PDF naturally accounts for the visible microfacet distribution
  3744. prefilteredColor += sampleColor * NdotL;
  3745. totalWeight += NdotL;
  3746. }
  3747. }
  3748. if (totalWeight > 0.0) {
  3749. prefilteredColor = prefilteredColor / totalWeight;
  3750. }
  3751. gl_FragColor = vec4(prefilteredColor, 1.0);
  3752. }
  3753. `,blending:iu,depthTest:!1,depthWrite:!1})}function m4e(t,e,n){const r=new Float32Array(Jh),i=new nt(0,1,0);return new rc({name:"SphericalGaussianBlur",defines:{n:Jh,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:cN(),fragmentShader:`
  3754. precision mediump float;
  3755. precision mediump int;
  3756. varying vec3 vOutputDirection;
  3757. uniform sampler2D envMap;
  3758. uniform int samples;
  3759. uniform float weights[ n ];
  3760. uniform bool latitudinal;
  3761. uniform float dTheta;
  3762. uniform float mipInt;
  3763. uniform vec3 poleAxis;
  3764. #define ENVMAP_TYPE_CUBE_UV
  3765. #include <cube_uv_reflection_fragment>
  3766. vec3 getSample( float theta, vec3 axis ) {
  3767. float cosTheta = cos( theta );
  3768. // Rodrigues' axis-angle rotation
  3769. vec3 sampleDirection = vOutputDirection * cosTheta
  3770. + cross( axis, vOutputDirection ) * sin( theta )
  3771. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3772. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3773. }
  3774. void main() {
  3775. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3776. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3777. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3778. }
  3779. axis = normalize( axis );
  3780. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3781. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3782. for ( int i = 1; i < n; i++ ) {
  3783. if ( i >= samples ) {
  3784. break;
  3785. }
  3786. float theta = dTheta * float( i );
  3787. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3788. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3789. }
  3790. }
  3791. `,blending:iu,depthTest:!1,depthWrite:!1})}function eG(){return new rc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cN(),fragmentShader:`
  3792. precision mediump float;
  3793. precision mediump int;
  3794. varying vec3 vOutputDirection;
  3795. uniform sampler2D envMap;
  3796. #include <common>
  3797. void main() {
  3798. vec3 outputDirection = normalize( vOutputDirection );
  3799. vec2 uv = equirectUv( outputDirection );
  3800. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3801. }
  3802. `,blending:iu,depthTest:!1,depthWrite:!1})}function tG(){return new rc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cN(),fragmentShader:`
  3803. precision mediump float;
  3804. precision mediump int;
  3805. uniform float flipEnvMap;
  3806. varying vec3 vOutputDirection;
  3807. uniform samplerCube envMap;
  3808. void main() {
  3809. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3810. }
  3811. `,blending:iu,depthTest:!1,depthWrite:!1})}function cN(){return`
  3812. precision mediump float;
  3813. precision mediump int;
  3814. attribute float faceIndex;
  3815. varying vec3 vOutputDirection;
  3816. // RH coordinate system; PMREM face-indexing convention
  3817. vec3 getDirection( vec2 uv, float face ) {
  3818. uv = 2.0 * uv - 1.0;
  3819. vec3 direction = vec3( uv, 1.0 );
  3820. if ( face == 0.0 ) {
  3821. direction = direction.zyx; // ( 1, v, u ) pos x
  3822. } else if ( face == 1.0 ) {
  3823. direction = direction.xzy;
  3824. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3825. } else if ( face == 2.0 ) {
  3826. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3827. } else if ( face == 3.0 ) {
  3828. direction = direction.zyx;
  3829. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3830. } else if ( face == 4.0 ) {
  3831. direction = direction.xzy;
  3832. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3833. } else if ( face == 5.0 ) {
  3834. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3835. }
  3836. return direction;
  3837. }
  3838. void main() {
  3839. vOutputDirection = getDirection( uv, faceIndex );
  3840. gl_Position = vec4( position, 1.0 );
  3841. }
  3842. `}function p4e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===R3||c===D3,d=c===Yf||c===Ag;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new QV(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 p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new QV(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 g4e(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&&K0("WebGLRenderer: "+r+" extension not supported."),i}}}function x4e(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const b in m.attributes)e.remove(m.attributes[b]);m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const p in m)e.update(m[p],t.ARRAY_BUFFER)}function u(f){const m=[],p=f.index,b=f.attributes.position;let y=0;if(p!==null){const S=p.array;y=p.version;for(let M=0,N=S.length;M<N;M+=3){const A=S[M+0],k=S[M+1],C=S[M+2];m.push(A,k,k,C,C,A)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,N=S.length/3-1;M<N;M+=3){const A=M+0,k=M+1,C=M+2;m.push(A,k,k,C,C,A)}}else return;const x=new(lee(m)?bee:xee)(m,1);x.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,x)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function b4e(t,e,n){let r;function i(m){r=m}let a,o;function l(m){a=m.type,o=m.bytesPerElement}function c(m,p){t.drawElements(r,p,a,m*o),n.update(p,r,1)}function u(m,p,b){b!==0&&(t.drawElementsInstanced(r,p,a,m*o,b),n.update(p,r,b))}function d(m,p,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,m,0,b);let x=0;for(let v=0;v<b;v++)x+=p[v];n.update(x,r,1)}function f(m,p,b,y){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<m.length;v++)u(m[v]/o,p[v],y[v]);else{x.multiDrawElementsInstancedWEBGL(r,p,0,a,m,0,y,0,b);let v=0;for(let S=0;S<b;S++)v+=p[S]*y[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function y4e(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:Vn("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 v4e(t,e,n){const r=new WeakMap,i=new xi;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 m=r.get(l);if(m===void 0||m.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;m!==void 0&&m.texture.dispose();const b=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],M=l.morphAttributes.color||[];let N=0;b===!0&&(N=1),y===!0&&(N=2),x===!0&&(N=3);let A=l.attributes.position.count*N,k=1;A>e.maxTextureSize&&(k=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const C=new Float32Array(A*k*4*f),D=new fee(C,A,k,f);D.type=Bl,D.needsUpdate=!0;const T=N*4;for(let U=0;U<f;U++){const O=v[U],q=S[U],j=M[U],W=A*k*4*U;for(let K=0;K<O.count;K++){const G=K*T;b===!0&&(i.fromBufferAttribute(O,K),C[W+G+0]=i.x,C[W+G+1]=i.y,C[W+G+2]=i.z,C[W+G+3]=0),y===!0&&(i.fromBufferAttribute(q,K),C[W+G+4]=i.x,C[W+G+5]=i.y,C[W+G+6]=i.z,C[W+G+7]=0),x===!0&&(i.fromBufferAttribute(j,K),C[W+G+8]=i.x,C[W+G+9]=i.y,C[W+G+10]=i.z,C[W+G+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:D,size:new Mn(A,k)},r.set(l,m),l.addEventListener("dispose",R)}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 y=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function _4e(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 w4e={[WJ]:"LINEAR_TONE_MAPPING",[qJ]:"REINHARD_TONE_MAPPING",[KJ]:"CINEON_TONE_MAPPING",[XJ]:"ACES_FILMIC_TONE_MAPPING",[ZJ]:"AGX_TONE_MAPPING",[QJ]:"NEUTRAL_TONE_MAPPING",[YJ]:"CUSTOM_TONE_MAPPING"};function S4e(t,e,n,r,i){const a=new ql(e,n,{type:t,depthBuffer:r,stencilBuffer:i}),o=new ql(e,n,{type:bu,depthBuffer:!1,stencilBuffer:!1}),l=new bl;l.setAttribute("position",new Gs([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Gs([0,2,0,0,2,0],2));const c=new hRe({uniforms:{tDiffuse:{value:null}},vertexShader:`
  3843. precision highp float;
  3844. uniform mat4 modelViewMatrix;
  3845. uniform mat4 projectionMatrix;
  3846. attribute vec3 position;
  3847. attribute vec2 uv;
  3848. varying vec2 vUv;
  3849. void main() {
  3850. vUv = uv;
  3851. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3852. }`,fragmentShader:`
  3853. precision highp float;
  3854. uniform sampler2D tDiffuse;
  3855. varying vec2 vUv;
  3856. #include <tonemapping_pars_fragment>
  3857. #include <colorspace_pars_fragment>
  3858. void main() {
  3859. gl_FragColor = texture2D( tDiffuse, vUv );
  3860. #ifdef LINEAR_TONE_MAPPING
  3861. gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
  3862. #elif defined( REINHARD_TONE_MAPPING )
  3863. gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
  3864. #elif defined( CINEON_TONE_MAPPING )
  3865. gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
  3866. #elif defined( ACES_FILMIC_TONE_MAPPING )
  3867. gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
  3868. #elif defined( AGX_TONE_MAPPING )
  3869. gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
  3870. #elif defined( NEUTRAL_TONE_MAPPING )
  3871. gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
  3872. #elif defined( CUSTOM_TONE_MAPPING )
  3873. gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
  3874. #endif
  3875. #ifdef SRGB_TRANSFER
  3876. gl_FragColor = sRGBTransferOETF( gl_FragColor );
  3877. #endif
  3878. }`,depthTest:!1,depthWrite:!1}),u=new dl(l,c),d=new cL(-1,1,1,-1,0,1);let f=null,m=null,p=!1,b,y=null,x=[],v=!1;this.setSize=function(S,M){a.setSize(S,M),o.setSize(S,M);for(let N=0;N<x.length;N++){const A=x[N];A.setSize&&A.setSize(S,M)}},this.setEffects=function(S){x=S,v=x.length>0&&x[0].isRenderPass===!0;const M=a.width,N=a.height;for(let A=0;A<x.length;A++){const k=x[A];k.setSize&&k.setSize(M,N)}},this.begin=function(S,M){if(p||S.toneMapping===Wl&&x.length===0)return!1;if(y=M,M!==null){const N=M.width,A=M.height;(a.width!==N||a.height!==A)&&this.setSize(N,A)}return v===!1&&S.setRenderTarget(a),b=S.toneMapping,S.toneMapping=Wl,!0},this.hasRenderPass=function(){return v},this.end=function(S,M){S.toneMapping=b,p=!0;let N=a,A=o;for(let k=0;k<x.length;k++){const C=x[k];if(C.enabled!==!1&&(C.render(S,A,N,M),C.needsSwap!==!1)){const D=N;N=A,A=D}}if(f!==S.outputColorSpace||m!==S.toneMapping){f=S.outputColorSpace,m=S.toneMapping,c.defines={},Bn.getTransfer(f)===ar&&(c.defines.SRGB_TRANSFER="");const k=w4e[m];k&&(c.defines[k]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=N.texture,S.setRenderTarget(y),S.render(u,d),y=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const kee=new xl,xR=new X0(1,1),jee=new fee,Pee=new z3e,Ree=new See,nG=[],rG=[],iG=new Float32Array(16),aG=new Float32Array(9),sG=new Float32Array(4);function cx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=nG[i];if(a===void 0&&(a=new Float32Array(i),nG[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 Ti(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 Ci(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function uN(t,e){let n=rG[e];n===void 0&&(n=new Int32Array(e),rG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function M4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function E4e(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(Ti(n,e))return;t.uniform2fv(this.addr,e),Ci(n,e)}}function N4e(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(Ti(n,e))return;t.uniform3fv(this.addr,e),Ci(n,e)}}function A4e(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(Ti(n,e))return;t.uniform4fv(this.addr,e),Ci(n,e)}}function T4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;sG.set(r),t.uniformMatrix2fv(this.addr,!1,sG),Ci(n,r)}}function C4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;aG.set(r),t.uniformMatrix3fv(this.addr,!1,aG),Ci(n,r)}}function k4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;iG.set(r),t.uniformMatrix4fv(this.addr,!1,iG),Ci(n,r)}}function j4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function P4e(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(Ti(n,e))return;t.uniform2iv(this.addr,e),Ci(n,e)}}function R4e(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(Ti(n,e))return;t.uniform3iv(this.addr,e),Ci(n,e)}}function D4e(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(Ti(n,e))return;t.uniform4iv(this.addr,e),Ci(n,e)}}function O4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function L4e(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(Ti(n,e))return;t.uniform2uiv(this.addr,e),Ci(n,e)}}function I4e(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(Ti(n,e))return;t.uniform3uiv(this.addr,e),Ci(n,e)}}function F4e(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(Ti(n,e))return;t.uniform4uiv(this.addr,e),Ci(n,e)}}function U4e(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?(xR.compareFunction=n.isReversedDepthBuffer()?nL:tL,a=xR):a=kee,n.setTexture2D(e||a,i)}function z4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||Pee,i)}function B4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||Ree,i)}function $4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||jee,i)}function H4e(t){switch(t){case 5126:return M4e;case 35664:return E4e;case 35665:return N4e;case 35666:return A4e;case 35674:return T4e;case 35675:return C4e;case 35676:return k4e;case 5124:case 35670:return j4e;case 35667:case 35671:return P4e;case 35668:case 35672:return R4e;case 35669:case 35673:return D4e;case 5125:return O4e;case 36294:return L4e;case 36295:return I4e;case 36296:return F4e;case 35678:case 36198:case 36298:case 36306:case 35682:return U4e;case 35679:case 36299:case 36307:return z4e;case 35680:case 36300:case 36308:case 36293:return B4e;case 36289:case 36303:case 36311:case 36292:return $4e}}function V4e(t,e){t.uniform1fv(this.addr,e)}function G4e(t,e){const n=cx(e,this.size,2);t.uniform2fv(this.addr,n)}function W4e(t,e){const n=cx(e,this.size,3);t.uniform3fv(this.addr,n)}function q4e(t,e){const n=cx(e,this.size,4);t.uniform4fv(this.addr,n)}function K4e(t,e){const n=cx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function X4e(t,e){const n=cx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Y4e(t,e){const n=cx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Z4e(t,e){t.uniform1iv(this.addr,e)}function Q4e(t,e){t.uniform2iv(this.addr,e)}function J4e(t,e){t.uniform3iv(this.addr,e)}function eLe(t,e){t.uniform4iv(this.addr,e)}function tLe(t,e){t.uniform1uiv(this.addr,e)}function nLe(t,e){t.uniform2uiv(this.addr,e)}function rLe(t,e){t.uniform3uiv(this.addr,e)}function iLe(t,e){t.uniform4uiv(this.addr,e)}function aLe(t,e,n){const r=this.cache,i=e.length,a=uN(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));let o;this.type===t.SAMPLER_2D_SHADOW?o=xR:o=kee;for(let l=0;l!==i;++l)n.setTexture2D(e[l]||o,a[l])}function sLe(t,e,n){const r=this.cache,i=e.length,a=uN(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||Pee,a[o])}function oLe(t,e,n){const r=this.cache,i=e.length,a=uN(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||Ree,a[o])}function lLe(t,e,n){const r=this.cache,i=e.length,a=uN(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||jee,a[o])}function cLe(t){switch(t){case 5126:return V4e;case 35664:return G4e;case 35665:return W4e;case 35666:return q4e;case 35674:return K4e;case 35675:return X4e;case 35676:return Y4e;case 5124:case 35670:return Z4e;case 35667:case 35671:return Q4e;case 35668:case 35672:return J4e;case 35669:case 35673:return eLe;case 5125:return tLe;case 36294:return nLe;case 36295:return rLe;case 36296:return iLe;case 35678:case 36198:case 36298:case 36306:case 35682:return aLe;case 35679:case 36299:case 36307:return sLe;case 35680:case 36300:case 36308:case 36293:return oLe;case 36289:case 36303:case 36311:case 36292:return lLe}}let uLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=H4e(n.type)}},dLe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=cLe(n.type)}},hLe=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 wk=/(\w+)(\])?(\[|\.)?/g;function oG(t,e){t.seq.push(e),t.map[e.id]=e}function fLe(t,e,n){const r=t.name,i=r.length;for(wk.lastIndex=0;;){const a=wk.exec(r),o=wk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){oG(n,u===void 0?new uLe(l,t,e):new dLe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new hLe(l),oG(n,f)),n=f}}}let pw=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let o=0;o<r;++o){const l=e.getActiveUniform(n,o),c=e.getUniformLocation(n,l.name);fLe(l,c,this)}const i=[],a=[];for(const o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(o):a.push(o);i.length>0&&(this.seq=i.concat(a))}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 lG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const mLe=37297;let pLe=0;function gLe(t,e){const n=t.split(`
  3879. `),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(`
  3880. `)}const cG=new An;function xLe(t){Bn._getMatrix(cG,Bn.workingColorSpace,t);const e=`mat3( ${cG.elements.map(n=>n.toFixed(4))} )`;switch(Bn.getTransfer(t)){case FS:return[e,"LinearTransferOETF"];case ar:return[e,"sRGBTransferOETF"];default:return dn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function uG(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()+`
  3881. `+a+`
  3882. `+gLe(t.getShaderSource(e),l)}else return a}function bLe(t,e){const n=xLe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3883. `)}const yLe={[WJ]:"Linear",[qJ]:"Reinhard",[KJ]:"Cineon",[XJ]:"ACESFilmic",[ZJ]:"AgX",[QJ]:"Neutral",[YJ]:"Custom"};function vLe(t,e){const n=yLe[e];return n===void 0?(dn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Q_=new nt;function _Le(){Bn.getLuminanceCoefficients(Q_);const t=Q_.x.toFixed(4),e=Q_.y.toFixed(4),n=Q_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3884. `)}function wLe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hb).join(`
  3885. `)}function SLe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3886. `)}function MLe(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 Hb(t){return t!==""}function dG(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 hG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ELe=/^[ \t]*#include +<([\w\d./]+)>/gm;function bR(t){return t.replace(ELe,ALe)}const NLe=new Map;function ALe(t,e){let n=wn[e];if(n===void 0){const r=NLe.get(e);if(r!==void 0)n=wn[r],dn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return bR(n)}const TLe=/#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 fG(t){return t.replace(TLe,CLe)}function CLe(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 mG(t){let e=`precision ${t.precision} float;
  3887. precision ${t.precision} int;
  3888. precision ${t.precision} sampler2D;
  3889. precision ${t.precision} samplerCube;
  3890. precision ${t.precision} sampler3D;
  3891. precision ${t.precision} sampler2DArray;
  3892. precision ${t.precision} sampler2DShadow;
  3893. precision ${t.precision} samplerCubeShadow;
  3894. precision ${t.precision} sampler2DArrayShadow;
  3895. precision ${t.precision} isampler2D;
  3896. precision ${t.precision} isampler3D;
  3897. precision ${t.precision} isamplerCube;
  3898. precision ${t.precision} isampler2DArray;
  3899. precision ${t.precision} usampler2D;
  3900. precision ${t.precision} usampler3D;
  3901. precision ${t.precision} usamplerCube;
  3902. precision ${t.precision} usampler2DArray;
  3903. `;return t.precision==="highp"?e+=`
  3904. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3905. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3906. #define LOW_PRECISION`),e}const kLe={[ow]:"SHADOWMAP_TYPE_PCF",[Bb]:"SHADOWMAP_TYPE_VSM"};function jLe(t){return kLe[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const PLe={[Yf]:"ENVMAP_TYPE_CUBE",[Ag]:"ENVMAP_TYPE_CUBE",[oN]:"ENVMAP_TYPE_CUBE_UV"};function RLe(t){return t.envMap===!1?"ENVMAP_TYPE_CUBE":PLe[t.envMapMode]||"ENVMAP_TYPE_CUBE"}const DLe={[Ag]:"ENVMAP_MODE_REFRACTION"};function OLe(t){return t.envMap===!1?"ENVMAP_MODE_REFLECTION":DLe[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}const LLe={[K4]:"ENVMAP_BLENDING_MULTIPLY",[v3e]:"ENVMAP_BLENDING_MIX",[_3e]:"ENVMAP_BLENDING_ADD"};function ILe(t){return t.envMap===!1?"ENVMAP_BLENDING_NONE":LLe[t.combine]||"ENVMAP_BLENDING_NONE"}function FLe(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 ULe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=jLe(n),u=RLe(n),d=OLe(n),f=ILe(n),m=FLe(n),p=wLe(n),b=SLe(a),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
  3907. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Hb).join(`
  3908. `),x.length>0&&(x+=`
  3909. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Hb).join(`
  3910. `),v.length>0&&(v+=`
  3911. `)):(x=[mG(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",`
  3912. `].filter(Hb).join(`
  3913. `),v=[mG(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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!==Wl?"#define TONE_MAPPING":"",n.toneMapping!==Wl?wn.tonemapping_pars_fragment:"",n.toneMapping!==Wl?vLe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wn.colorspace_pars_fragment,bLe("linearToOutputTexel",n.outputColorSpace),_Le(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3914. `].filter(Hb).join(`
  3915. `)),o=bR(o),o=dG(o,n),o=hG(o,n),l=bR(l),l=dG(l,n),l=hG(l,n),o=fG(o),l=fG(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3916. `,x=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3917. `)+`
  3918. `+x,v=["#define varying in",n.glslVersion===wV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===wV?"":"#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(`
  3919. `)+`
  3920. `+v);const M=S+x+o,N=S+v+l,A=lG(i,i.VERTEX_SHADER,M),k=lG(i,i.FRAGMENT_SHADER,N);i.attachShader(y,A),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(A)||"",j=i.getShaderInfoLog(k)||"",W=O.trim(),K=q.trim(),G=j.trim();let J=!0,ie=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(J=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,k);else{const re=uG(i,A,"vertex"),z=uG(i,k,"fragment");Vn("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3921. Material Name: `+U.name+`
  3922. Material Type: `+U.type+`
  3923. Program Info Log: `+W+`
  3924. `+re+`
  3925. `+z)}else W!==""?dn("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(ie=!1);ie&&(U.diagnostics={runnable:J,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:G,prefix:v}})}i.deleteShader(A),i.deleteShader(k),D=new pw(i,y),T=MLe(i,y)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,mLe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=pLe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=k,this}let zLe=0,BLe=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 $Le(e),n.set(e,r)),r}},$Le=class{constructor(e){this.id=zLe++,this.code=e,this.usedTimes=0}};function HLe(t,e,n,r,i,a,o){const l=new pee,c=new BLe,u=new Set,d=[],f=new Map,m=i.logarithmicDepthBuffer;let p=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 y(T){return u.add(T),T===0?"uv":`uv${T}`}function x(T,R,U,O,q){const j=O.fog,W=q.geometry,K=T.isMeshStandardMaterial?O.environment:null,G=(T.isMeshStandardMaterial?n:e).get(T.envMap||K),J=G&&G.mapping===oN?G.image.height:null,ie=b[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&dn("WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const re=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=re!==void 0?re.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let Z,ne,he,fe;if(ie){const Tt=Ol[ie];Z=Tt.vertexShader,ne=Tt.fragmentShader}else Z=T.vertexShader,ne=T.fragmentShader,c.update(T),he=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const le=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),me=q.isInstancedMesh===!0,we=q.isBatchedMesh===!0,De=!!T.map,ee=!!T.matcap,Qe=!!G,B=!!T.aoMap,te=!!T.lightMap,Y=!!T.bumpMap,H=!!T.normalMap,F=!!T.displacementMap,de=!!T.emissiveMap,Ae=!!T.metalnessMap,Le=!!T.roughnessMap,Se=T.anisotropy>0,$=T.clearcoat>0,L=T.dispersion>0,X=T.iridescence>0,xe=T.sheen>0,_e=T.transmission>0,ae=Se&&!!T.anisotropyMap,Te=$&&!!T.clearcoatMap,Pe=$&&!!T.clearcoatNormalMap,Xe=$&&!!T.clearcoatRoughnessMap,Je=X&&!!T.iridescenceMap,Ze=X&&!!T.iridescenceThicknessMap,oe=xe&&!!T.sheenColorMap,ye=xe&&!!T.sheenRoughnessMap,Ce=!!T.specularMap,$e=!!T.specularColorMap,lt=!!T.specularIntensityMap,se=_e&&!!T.transmissionMap,ze=_e&&!!T.thicknessMap,ve=!!T.gradientMap,He=!!T.alphaMap,Oe=T.alphaTest>0,Ne=!!T.alphaHash,Be=!!T.extensions;let at=Wl;T.toneMapped&&(le===null||le.isXRRenderTarget===!0)&&(at=t.toneMapping);const Rt={shaderID:ie,shaderType:T.type,shaderName:T.name,vertexShader:Z,fragmentShader:ne,defines:T.defines,customVertexShaderID:he,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:we,batchingColor:we&&q._colorsTexture!==null,instancing:me,instancingColor:me&&q.instanceColor!==null,instancingMorph:me&&q.morphTexture!==null,outputColorSpace:le===null?t.outputColorSpace:le.isXRRenderTarget===!0?le.texture.colorSpace:Cg,alphaToCoverage:!!T.alphaToCoverage,map:De,matcap:ee,envMap:Qe,envMapMode:Qe&&G.mapping,envMapCubeUVHeight:J,aoMap:B,lightMap:te,bumpMap:Y,normalMap:H,displacementMap:F,emissiveMap:de,normalMapObjectSpace:H&&T.normalMapType===M3e,normalMapTangentSpace:H&&T.normalMapType===oee,metalnessMap:Ae,roughnessMap:Le,anisotropy:Se,anisotropyMap:ae,clearcoat:$,clearcoatMap:Te,clearcoatNormalMap:Pe,clearcoatRoughnessMap:Xe,dispersion:L,iridescence:X,iridescenceMap:Je,iridescenceThicknessMap:Ze,sheen:xe,sheenColorMap:oe,sheenRoughnessMap:ye,specularMap:Ce,specularColorMap:$e,specularIntensityMap:lt,transmission:_e,transmissionMap:se,thicknessMap:ze,gradientMap:ve,opaque:T.transparent===!1&&T.blending===ig&&T.alphaToCoverage===!1,alphaMap:He,alphaTest:Oe,alphaHash:Ne,combine:T.combine,mapUv:De&&y(T.map.channel),aoMapUv:B&&y(T.aoMap.channel),lightMapUv:te&&y(T.lightMap.channel),bumpMapUv:Y&&y(T.bumpMap.channel),normalMapUv:H&&y(T.normalMap.channel),displacementMapUv:F&&y(T.displacementMap.channel),emissiveMapUv:de&&y(T.emissiveMap.channel),metalnessMapUv:Ae&&y(T.metalnessMap.channel),roughnessMapUv:Le&&y(T.roughnessMap.channel),anisotropyMapUv:ae&&y(T.anisotropyMap.channel),clearcoatMapUv:Te&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:Pe&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Je&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ze&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:ye&&y(T.sheenRoughnessMap.channel),specularMapUv:Ce&&y(T.specularMap.channel),specularColorMapUv:$e&&y(T.specularColorMap.channel),specularIntensityMapUv:lt&&y(T.specularIntensityMap.channel),transmissionMapUv:se&&y(T.transmissionMap.channel),thicknessMapUv:ze&&y(T.thicknessMap.channel),alphaMapUv:He&&y(T.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(H||Se),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(De||He),fog:!!j,useFog:T.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Ee,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:at,decodeVideoTexture:De&&T.map.isVideoTexture===!0&&Bn.getTransfer(T.map.colorSpace)===ar,decodeVideoTextureEmissive:de&&T.emissiveMap.isVideoTexture===!0&&Bn.getTransfer(T.emissiveMap.colorSpace)===ar,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Ll,flipSided:T.side===bs,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Be&&T.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&T.extensions.multiDraw===!0||we)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Rt.vertexUv1s=u.has(1),Rt.vertexUv2s=u.has(2),Rt.vertexUv3s=u.has(3),u.clear(),Rt}function v(T){const R=[];if(T.shaderID?R.push(T.shaderID):(R.push(T.customVertexShaderID),R.push(T.customFragmentShaderID)),T.defines!==void 0)for(const U in T.defines)R.push(U),R.push(T.defines[U]);return T.isRawShaderMaterial===!1&&(S(R,T),M(R,T),R.push(t.outputColorSpace)),R.push(T.customProgramCacheKey),R.join()}function S(T,R){T.push(R.precision),T.push(R.outputColorSpace),T.push(R.envMapMode),T.push(R.envMapCubeUVHeight),T.push(R.mapUv),T.push(R.alphaMapUv),T.push(R.lightMapUv),T.push(R.aoMapUv),T.push(R.bumpMapUv),T.push(R.normalMapUv),T.push(R.displacementMapUv),T.push(R.emissiveMapUv),T.push(R.metalnessMapUv),T.push(R.roughnessMapUv),T.push(R.anisotropyMapUv),T.push(R.clearcoatMapUv),T.push(R.clearcoatNormalMapUv),T.push(R.clearcoatRoughnessMapUv),T.push(R.iridescenceMapUv),T.push(R.iridescenceThicknessMapUv),T.push(R.sheenColorMapUv),T.push(R.sheenRoughnessMapUv),T.push(R.specularMapUv),T.push(R.specularColorMapUv),T.push(R.specularIntensityMapUv),T.push(R.transmissionMapUv),T.push(R.thicknessMapUv),T.push(R.combine),T.push(R.fogExp2),T.push(R.sizeAttenuation),T.push(R.morphTargetsCount),T.push(R.morphAttributeCount),T.push(R.numDirLights),T.push(R.numPointLights),T.push(R.numSpotLights),T.push(R.numSpotLightMaps),T.push(R.numHemiLights),T.push(R.numRectAreaLights),T.push(R.numDirLightShadows),T.push(R.numPointLightShadows),T.push(R.numSpotLightShadows),T.push(R.numSpotLightShadowsWithMaps),T.push(R.numLightProbes),T.push(R.shadowMapType),T.push(R.toneMapping),T.push(R.numClippingPlanes),T.push(R.numClipIntersection),T.push(R.depthPacking)}function M(T,R){l.disableAll(),R.instancing&&l.enable(0),R.instancingColor&&l.enable(1),R.instancingMorph&&l.enable(2),R.matcap&&l.enable(3),R.envMap&&l.enable(4),R.normalMapObjectSpace&&l.enable(5),R.normalMapTangentSpace&&l.enable(6),R.clearcoat&&l.enable(7),R.iridescence&&l.enable(8),R.alphaTest&&l.enable(9),R.vertexColors&&l.enable(10),R.vertexAlphas&&l.enable(11),R.vertexUv1s&&l.enable(12),R.vertexUv2s&&l.enable(13),R.vertexUv3s&&l.enable(14),R.vertexTangents&&l.enable(15),R.anisotropy&&l.enable(16),R.alphaHash&&l.enable(17),R.batching&&l.enable(18),R.dispersion&&l.enable(19),R.batchingColor&&l.enable(20),R.gradientMap&&l.enable(21),T.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),T.push(l.mask)}function N(T){const R=b[T.type];let U;if(R){const O=Ol[R];U=J3e.clone(O.uniforms)}else U=T.uniforms;return U}function A(T,R){let U=f.get(R);return U!==void 0?++U.usedTimes:(U=new ULe(t,R,T,a),d.push(U),f.set(R,U)),U}function k(T){if(--T.usedTimes===0){const R=d.indexOf(T);d[R]=d[d.length-1],d.pop(),f.delete(T.cacheKey),T.destroy()}}function C(T){c.remove(T)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:N,acquireProgram:A,releaseProgram:k,releaseShaderCache:C,programs:d,dispose:D}}function VLe(){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 GLe(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 pG(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 gG(){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,m,p,b,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||GLe),r.length>1&&r.sort(m||pG),i.length>1&&i.sort(m||pG)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function WLe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new gG,t.set(r,[o])):i>=a.length?(o=new gG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function qLe(){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 nt,color:new Pn};break;case"SpotLight":n={position:new nt,direction:new nt,color:new Pn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new nt,color:new Pn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new nt,skyColor:new Pn,groundColor:new Pn};break;case"RectAreaLight":n={color:new Pn,position:new nt,halfWidth:new nt,halfHeight:new nt};break}return t[e.id]=n,n}}}function KLe(){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 Mn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let XLe=0;function YLe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function ZLe(t){const e=new qLe,n=KLe(),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 nt);const i=new nt,a=new li,o=new li;function l(u){let d=0,f=0,m=0;for(let T=0;T<9;T++)r.probe[T].set(0,0,0);let p=0,b=0,y=0,x=0,v=0,S=0,M=0,N=0,A=0,k=0,C=0;u.sort(YLe);for(let T=0,R=u.length;T<R;T++){const U=u[T],O=U.color,q=U.intensity,j=U.distance;let W=null;if(U.shadow&&U.shadow.map&&(U.shadow.map.texture.format===Tg?W=U.shadow.map.texture:W=U.shadow.map.depthTexture||U.shadow.map.texture),U.isAmbientLight)d+=O.r*q,f+=O.g*q,m+=O.b*q;else if(U.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(U.sh.coefficients[K],q);C++}else if(U.isDirectionalLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const G=U.shadow,J=n.get(U);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,r.directionalShadow[p]=J,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=U.shadow.matrix,S++}r.directional[p]=K,p++}else if(U.isSpotLight){const K=e.get(U);K.position.setFromMatrixPosition(U.matrixWorld),K.color.copy(O).multiplyScalar(q),K.distance=j,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[y]=K;const G=U.shadow;if(U.map&&(r.spotLightMap[A]=U.map,A++,G.updateMatrices(U),U.castShadow&&k++),r.spotLightMatrix[y]=G.matrix,U.castShadow){const J=n.get(U);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,r.spotShadow[y]=J,r.spotShadowMap[y]=W,N++}y++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(O).multiplyScalar(q),K.halfWidth.set(U.width*.5,0,0),K.halfHeight.set(0,U.height*.5,0),r.rectArea[x]=K,x++}else if(U.isPointLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),K.distance=U.distance,K.decay=U.decay,U.castShadow){const G=U.shadow,J=n.get(U);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,J.shadowCameraNear=G.camera.near,J.shadowCameraFar=G.camera.far,r.pointShadow[b]=J,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=U.shadow.matrix,M++}r.point[b]=K,b++}else if(U.isHemisphereLight){const K=e.get(U);K.skyColor.copy(U.color).multiplyScalar(q),K.groundColor.copy(U.groundColor).multiplyScalar(q),r.hemi[v]=K,v++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=It.LTC_FLOAT_1,r.rectAreaLTC2=It.LTC_FLOAT_2):(r.rectAreaLTC1=It.LTC_HALF_1,r.rectAreaLTC2=It.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const D=r.hash;(D.directionalLength!==p||D.pointLength!==b||D.spotLength!==y||D.rectAreaLength!==x||D.hemiLength!==v||D.numDirectionalShadows!==S||D.numPointShadows!==M||D.numSpotShadows!==N||D.numSpotMaps!==A||D.numLightProbes!==C)&&(r.directional.length=p,r.spot.length=y,r.rectArea.length=x,r.point.length=b,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=M,r.pointShadowMap.length=M,r.spotShadow.length=N,r.spotShadowMap.length=N,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=M,r.spotLightMatrix.length=N+A-k,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=C,D.directionalLength=p,D.pointLength=b,D.spotLength=y,D.rectAreaLength=x,D.hemiLength=v,D.numDirectionalShadows=S,D.numPointShadows=M,D.numSpotShadows=N,D.numSpotMaps=A,D.numLightProbes=C,r.version=XLe++)}function c(u,d){let f=0,m=0,p=0,b=0,y=0;const x=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const M=u[v];if(M.isDirectionalLight){const N=r.directional[f];N.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(x),f++}else if(M.isSpotLight){const N=r.spot[p];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),N.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(x),p++}else if(M.isRectAreaLight){const N=r.rectArea[b];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),o.identity(),a.copy(M.matrixWorld),a.premultiply(x),o.extractRotation(a),N.halfWidth.set(M.width*.5,0,0),N.halfHeight.set(0,M.height*.5,0),N.halfWidth.applyMatrix4(o),N.halfHeight.applyMatrix4(o),b++}else if(M.isPointLight){const N=r.point[m];N.position.setFromMatrixPosition(M.matrixWorld),N.position.applyMatrix4(x),m++}else if(M.isHemisphereLight){const N=r.hemi[y];N.direction.setFromMatrixPosition(M.matrixWorld),N.direction.transformDirection(x),y++}}}return{setup:l,setupView:c,state:r}}function xG(t){const e=new ZLe(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 QLe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new xG(t),e.set(i,[l])):a>=o.length?(l=new xG(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const JLe=`void main() {
  3926. gl_Position = vec4( position, 1.0 );
  3927. }`,eIe=`uniform sampler2D shadow_pass;
  3928. uniform vec2 resolution;
  3929. uniform float radius;
  3930. void main() {
  3931. const float samples = float( VSM_SAMPLES );
  3932. float mean = 0.0;
  3933. float squared_mean = 0.0;
  3934. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3935. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3936. for ( float i = 0.0; i < samples; i ++ ) {
  3937. float uvOffset = uvStart + i * uvStride;
  3938. #ifdef HORIZONTAL_PASS
  3939. vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
  3940. mean += distribution.x;
  3941. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3942. #else
  3943. float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
  3944. mean += depth;
  3945. squared_mean += depth * depth;
  3946. #endif
  3947. }
  3948. mean = mean / samples;
  3949. squared_mean = squared_mean / samples;
  3950. float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
  3951. gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
  3952. }`,tIe=[new nt(1,0,0),new nt(-1,0,0),new nt(0,1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1)],nIe=[new nt(0,-1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1),new nt(0,-1,0),new nt(0,-1,0)],bG=new li,Mb=new nt,Sk=new nt;function rIe(t,e,n){let r=new oL;const i=new Mn,a=new Mn,o=new xi,l=new mRe,c=new pRe,u={},d=n.maxTextureSize,f={[Qd]:bs,[bs]:Qd,[Ll]:Ll},m=new rc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mn},radius:{value:4}},vertexShader:JLe,fragmentShader:eIe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new bl;b.setAttribute("position",new Ao(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new dl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ow;let v=this.type;this.render=function(k,C,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||k.length===0)return;k.type===t3e&&(dn("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),k.type=ow);const T=t.getRenderTarget(),R=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),O=t.state;O.setBlending(iu),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=v!==this.type;q&&C.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(W=>W.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,W=k.length;j<W;j++){const K=k[j],G=K.shadow;if(G===void 0){dn("WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const J=G.getFrameExtents();if(i.multiply(J),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,G.mapSize.y=a.y)),G.map===null||q===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Bb){if(K.isPointLight){dn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new ql(i.x,i.y,{format:Tg,type:bu,minFilter:Oa,magFilter:Oa,generateMipmaps:!1}),G.map.texture.name=K.name+".shadowMap",G.map.depthTexture=new X0(i.x,i.y,Bl),G.map.depthTexture.name=K.name+".shadowMapDepth",G.map.depthTexture.format=yu,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=_a,G.map.depthTexture.magFilter=_a}else{K.isPointLight?(G.map=new Mee(i.x),G.map.depthTexture=new dRe(i.x,nc)):(G.map=new ql(i.x,i.y),G.map.depthTexture=new X0(i.x,i.y,nc)),G.map.depthTexture.name=K.name+".shadowMap",G.map.depthTexture.format=yu;const re=t.state.buffers.depth.getReversed();this.type===ow?(G.map.depthTexture.compareFunction=re?nL:tL,G.map.depthTexture.minFilter=Oa,G.map.depthTexture.magFilter=Oa):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=_a,G.map.depthTexture.magFilter=_a)}G.camera.updateProjectionMatrix()}const ie=G.map.isWebGLCubeRenderTarget?6:1;for(let re=0;re<ie;re++){if(G.map.isWebGLCubeRenderTarget)t.setRenderTarget(G.map,re),t.clear();else{re===0&&(t.setRenderTarget(G.map),t.clear());const z=G.getViewport(re);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),O.viewport(o)}if(K.isPointLight){const z=G.camera,V=G.matrix,Z=K.distance||z.far;Z!==z.far&&(z.far=Z,z.updateProjectionMatrix()),Mb.setFromMatrixPosition(K.matrixWorld),z.position.copy(Mb),Sk.copy(z.position),Sk.add(tIe[re]),z.up.copy(nIe[re]),z.lookAt(Sk),z.updateMatrixWorld(),V.makeTranslation(-Mb.x,-Mb.y,-Mb.z),bG.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),G._frustum.setFromProjectionMatrix(bG,z.coordinateSystem,z.reversedDepth)}else G.updateMatrices(K);r=G.getFrustum(),N(C,D,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===Bb&&S(G,D),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(T,R,U)};function S(k,C){const D=e.update(y);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new ql(i.x,i.y,{format:Tg,type:bu})),m.uniforms.shadow_pass.value=k.map.depthTexture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,D,m,y,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,D,p,y,null)}function M(k,C,D,T){let R=null;const U=D.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(U!==void 0)R=U;else if(R=D.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||C.alphaToCoverage===!0){const O=R.uuid,q=C.uuid;let j=u[O];j===void 0&&(j={},u[O]=j);let W=j[q];W===void 0&&(W=R.clone(),j[q]=W,C.addEventListener("dispose",A)),R=W}if(R.visible=C.visible,R.wireframe=C.wireframe,T===Bb?R.side=C.shadowSide!==null?C.shadowSide:C.side:R.side=C.shadowSide!==null?C.shadowSide:f[C.side],R.alphaMap=C.alphaMap,R.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,R.map=C.map,R.clipShadows=C.clipShadows,R.clippingPlanes=C.clippingPlanes,R.clipIntersection=C.clipIntersection,R.displacementMap=C.displacementMap,R.displacementScale=C.displacementScale,R.displacementBias=C.displacementBias,R.wireframeLinewidth=C.wireframeLinewidth,R.linewidth=C.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const O=t.properties.get(R);O.light=D}return R}function N(k,C,D,T,R){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===Bb)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,k.matrixWorld);const q=e.update(k),j=k.material;if(Array.isArray(j)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const J=W[K],ie=j[J.materialIndex];if(ie&&ie.visible){const re=M(k,ie,T,R);k.onBeforeShadow(t,k,C,D,q,re,J),t.renderBufferDirect(D,null,q,re,k,J),k.onAfterShadow(t,k,C,D,q,re,J)}}}else if(j.visible){const W=M(k,j,T,R);k.onBeforeShadow(t,k,C,D,q,W,null),t.renderBufferDirect(D,null,q,W,k,null),k.onAfterShadow(t,k,C,D,q,W,null)}}const O=k.children;for(let q=0,j=O.length;q<j;q++)N(O[q],C,D,T,R)}function A(k){k.target.removeEventListener("dispose",A);for(const D in u){const T=u[D],R=k.target.uuid;R in T&&(T[R].dispose(),delete T[R])}}}const iIe={[N3]:A3,[T3]:j3,[C3]:P3,[Ng]:k3,[A3]:N3,[j3]:T3,[P3]:C3,[k3]:Ng};function aIe(t,e){function n(){let se=!1;const ze=new xi;let ve=null;const He=new xi(0,0,0,0);return{setMask:function(Oe){ve!==Oe&&!se&&(t.colorMask(Oe,Oe,Oe,Oe),ve=Oe)},setLocked:function(Oe){se=Oe},setClear:function(Oe,Ne,Be,at,Rt){Rt===!0&&(Oe*=at,Ne*=at,Be*=at),ze.set(Oe,Ne,Be,at),He.equals(ze)===!1&&(t.clearColor(Oe,Ne,Be,at),He.copy(ze))},reset:function(){se=!1,ve=null,He.set(-1,0,0,0)}}}function r(){let se=!1,ze=!1,ve=null,He=null,Oe=null;return{setReversed:function(Ne){if(ze!==Ne){const Be=e.get("EXT_clip_control");Ne?Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.ZERO_TO_ONE_EXT):Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.NEGATIVE_ONE_TO_ONE_EXT),ze=Ne;const at=Oe;Oe=null,this.setClear(at)}},getReversed:function(){return ze},setTest:function(Ne){Ne?le(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(Ne){ve!==Ne&&!se&&(t.depthMask(Ne),ve=Ne)},setFunc:function(Ne){if(ze&&(Ne=iIe[Ne]),He!==Ne){switch(Ne){case N3:t.depthFunc(t.NEVER);break;case A3:t.depthFunc(t.ALWAYS);break;case T3:t.depthFunc(t.LESS);break;case Ng:t.depthFunc(t.LEQUAL);break;case C3:t.depthFunc(t.EQUAL);break;case k3:t.depthFunc(t.GEQUAL);break;case j3:t.depthFunc(t.GREATER);break;case P3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}He=Ne}},setLocked:function(Ne){se=Ne},setClear:function(Ne){Oe!==Ne&&(ze&&(Ne=1-Ne),t.clearDepth(Ne),Oe=Ne)},reset:function(){se=!1,ve=null,He=null,Oe=null,ze=!1}}}function i(){let se=!1,ze=null,ve=null,He=null,Oe=null,Ne=null,Be=null,at=null,Rt=null;return{setTest:function(Tt){se||(Tt?le(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(Tt){ze!==Tt&&!se&&(t.stencilMask(Tt),ze=Tt)},setFunc:function(Tt,nn,Lt){(ve!==Tt||He!==nn||Oe!==Lt)&&(t.stencilFunc(Tt,nn,Lt),ve=Tt,He=nn,Oe=Lt)},setOp:function(Tt,nn,Lt){(Ne!==Tt||Be!==nn||at!==Lt)&&(t.stencilOp(Tt,nn,Lt),Ne=Tt,Be=nn,at=Lt)},setLocked:function(Tt){se=Tt},setClear:function(Tt){Rt!==Tt&&(t.clearStencil(Tt),Rt=Tt)},reset:function(){se=!1,ze=null,ve=null,He=null,Oe=null,Ne=null,Be=null,at=null,Rt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,p=[],b=null,y=!1,x=null,v=null,S=null,M=null,N=null,A=null,k=null,C=new Pn(0,0,0),D=0,T=!1,R=null,U=null,O=null,q=null,j=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(J)[1]),K=G>=1):J.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),K=G>=2);let ie=null,re={};const z=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),Z=new xi().fromArray(z),ne=new xi().fromArray(V);function he(se,ze,ve,He){const Oe=new Uint8Array(4),Ne=t.createTexture();t.bindTexture(se,Ne),t.texParameteri(se,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(se,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Be=0;Be<ve;Be++)se===t.TEXTURE_3D||se===t.TEXTURE_2D_ARRAY?t.texImage3D(ze,0,t.RGBA,1,1,He,0,t.RGBA,t.UNSIGNED_BYTE,Oe):t.texImage2D(ze+Be,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Oe);return Ne}const fe={};fe[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=he(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),le(t.DEPTH_TEST),o.setFunc(Ng),Y(!1),H(gV),le(t.CULL_FACE),B(iu);function le(se){d[se]!==!0&&(t.enable(se),d[se]=!0)}function Ee(se){d[se]!==!1&&(t.disable(se),d[se]=!1)}function me(se,ze){return f[se]!==ze?(t.bindFramebuffer(se,ze),f[se]=ze,se===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=ze),se===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=ze),!0):!1}function we(se,ze){let ve=p,He=!1;if(se){ve=m.get(ze),ve===void 0&&(ve=[],m.set(ze,ve));const Oe=se.textures;if(ve.length!==Oe.length||ve[0]!==t.COLOR_ATTACHMENT0){for(let Ne=0,Be=Oe.length;Ne<Be;Ne++)ve[Ne]=t.COLOR_ATTACHMENT0+Ne;ve.length=Oe.length,He=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,He=!0);He&&t.drawBuffers(ve)}function De(se){return b!==se?(t.useProgram(se),b=se,!0):!1}const ee={[Qh]:t.FUNC_ADD,[r3e]:t.FUNC_SUBTRACT,[i3e]:t.FUNC_REVERSE_SUBTRACT};ee[a3e]=t.MIN,ee[s3e]=t.MAX;const Qe={[o3e]:t.ZERO,[l3e]:t.ONE,[c3e]:t.SRC_COLOR,[M3]:t.SRC_ALPHA,[p3e]:t.SRC_ALPHA_SATURATE,[f3e]:t.DST_COLOR,[d3e]:t.DST_ALPHA,[u3e]:t.ONE_MINUS_SRC_COLOR,[E3]:t.ONE_MINUS_SRC_ALPHA,[m3e]:t.ONE_MINUS_DST_COLOR,[h3e]:t.ONE_MINUS_DST_ALPHA,[g3e]:t.CONSTANT_COLOR,[x3e]:t.ONE_MINUS_CONSTANT_COLOR,[b3e]:t.CONSTANT_ALPHA,[y3e]:t.ONE_MINUS_CONSTANT_ALPHA};function B(se,ze,ve,He,Oe,Ne,Be,at,Rt,Tt){if(se===iu){y===!0&&(Ee(t.BLEND),y=!1);return}if(y===!1&&(le(t.BLEND),y=!0),se!==n3e){if(se!==x||Tt!==T){if((v!==Qh||N!==Qh)&&(t.blendEquation(t.FUNC_ADD),v=Qh,N=Qh),Tt)switch(se){case ig:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case xV:t.blendFunc(t.ONE,t.ONE);break;case bV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case yV:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Vn("WebGLState: Invalid blending: ",se);break}else switch(se){case ig:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case xV:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case bV:Vn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case yV:Vn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Vn("WebGLState: Invalid blending: ",se);break}S=null,M=null,A=null,k=null,C.set(0,0,0),D=0,x=se,T=Tt}return}Oe=Oe||ze,Ne=Ne||ve,Be=Be||He,(ze!==v||Oe!==N)&&(t.blendEquationSeparate(ee[ze],ee[Oe]),v=ze,N=Oe),(ve!==S||He!==M||Ne!==A||Be!==k)&&(t.blendFuncSeparate(Qe[ve],Qe[He],Qe[Ne],Qe[Be]),S=ve,M=He,A=Ne,k=Be),(at.equals(C)===!1||Rt!==D)&&(t.blendColor(at.r,at.g,at.b,Rt),C.copy(at),D=Rt),x=se,T=!1}function te(se,ze){se.side===Ll?Ee(t.CULL_FACE):le(t.CULL_FACE);let ve=se.side===bs;ze&&(ve=!ve),Y(ve),se.blending===ig&&se.transparent===!1?B(iu):B(se.blending,se.blendEquation,se.blendSrc,se.blendDst,se.blendEquationAlpha,se.blendSrcAlpha,se.blendDstAlpha,se.blendColor,se.blendAlpha,se.premultipliedAlpha),o.setFunc(se.depthFunc),o.setTest(se.depthTest),o.setMask(se.depthWrite),a.setMask(se.colorWrite);const He=se.stencilWrite;l.setTest(He),He&&(l.setMask(se.stencilWriteMask),l.setFunc(se.stencilFunc,se.stencilRef,se.stencilFuncMask),l.setOp(se.stencilFail,se.stencilZFail,se.stencilZPass)),de(se.polygonOffset,se.polygonOffsetFactor,se.polygonOffsetUnits),se.alphaToCoverage===!0?le(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function Y(se){R!==se&&(se?t.frontFace(t.CW):t.frontFace(t.CCW),R=se)}function H(se){se!==JPe?(le(t.CULL_FACE),se!==U&&(se===gV?t.cullFace(t.BACK):se===e3e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),U=se}function F(se){se!==O&&(K&&t.lineWidth(se),O=se)}function de(se,ze,ve){se?(le(t.POLYGON_OFFSET_FILL),(q!==ze||j!==ve)&&(t.polygonOffset(ze,ve),q=ze,j=ve)):Ee(t.POLYGON_OFFSET_FILL)}function Ae(se){se?le(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Le(se){se===void 0&&(se=t.TEXTURE0+W-1),ie!==se&&(t.activeTexture(se),ie=se)}function Se(se,ze,ve){ve===void 0&&(ie===null?ve=t.TEXTURE0+W-1:ve=ie);let He=re[ve];He===void 0&&(He={type:void 0,texture:void 0},re[ve]=He),(He.type!==se||He.texture!==ze)&&(ie!==ve&&(t.activeTexture(ve),ie=ve),t.bindTexture(se,ze||fe[se]),He.type=se,He.texture=ze)}function $(){const se=re[ie];se!==void 0&&se.type!==void 0&&(t.bindTexture(se.type,null),se.type=void 0,se.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(se){Vn("WebGLState:",se)}}function X(){try{t.compressedTexImage3D(...arguments)}catch(se){Vn("WebGLState:",se)}}function xe(){try{t.texSubImage2D(...arguments)}catch(se){Vn("WebGLState:",se)}}function _e(){try{t.texSubImage3D(...arguments)}catch(se){Vn("WebGLState:",se)}}function ae(){try{t.compressedTexSubImage2D(...arguments)}catch(se){Vn("WebGLState:",se)}}function Te(){try{t.compressedTexSubImage3D(...arguments)}catch(se){Vn("WebGLState:",se)}}function Pe(){try{t.texStorage2D(...arguments)}catch(se){Vn("WebGLState:",se)}}function Xe(){try{t.texStorage3D(...arguments)}catch(se){Vn("WebGLState:",se)}}function Je(){try{t.texImage2D(...arguments)}catch(se){Vn("WebGLState:",se)}}function Ze(){try{t.texImage3D(...arguments)}catch(se){Vn("WebGLState:",se)}}function oe(se){Z.equals(se)===!1&&(t.scissor(se.x,se.y,se.z,se.w),Z.copy(se))}function ye(se){ne.equals(se)===!1&&(t.viewport(se.x,se.y,se.z,se.w),ne.copy(se))}function Ce(se,ze){let ve=u.get(ze);ve===void 0&&(ve=new WeakMap,u.set(ze,ve));let He=ve.get(se);He===void 0&&(He=t.getUniformBlockIndex(ze,se.name),ve.set(se,He))}function $e(se,ze){const He=u.get(ze).get(se);c.get(ze)!==He&&(t.uniformBlockBinding(ze,He,se.__bindingPointIndex),c.set(ze,He))}function lt(){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={},ie=null,re={},f={},m=new WeakMap,p=[],b=null,y=!1,x=null,v=null,S=null,M=null,N=null,A=null,k=null,C=new Pn(0,0,0),D=0,T=!1,R=null,U=null,O=null,q=null,j=null,Z.set(0,0,t.canvas.width,t.canvas.height),ne.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:le,disable:Ee,bindFramebuffer:me,drawBuffers:we,useProgram:De,setBlending:B,setMaterial:te,setFlipSided:Y,setCullFace:H,setLineWidth:F,setPolygonOffset:de,setScissorTest:Ae,activeTexture:Le,bindTexture:Se,unbindTexture:$,compressedTexImage2D:L,compressedTexImage3D:X,texImage2D:Je,texImage3D:Ze,updateUBOMapping:Ce,uniformBlockBinding:$e,texStorage2D:Pe,texStorage3D:Xe,texSubImage2D:xe,texSubImage3D:_e,compressedTexSubImage2D:ae,compressedTexSubImage3D:Te,scissor:oe,viewport:ye,reset:lt}}function sIe(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 Mn,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b($,L){return p?new OffscreenCanvas($,L):zS("canvas")}function y($,L,X){let xe=1;const _e=Se($);if((_e.width>X||_e.height>X)&&(xe=X/Math.max(_e.width,_e.height)),xe<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ae=Math.floor(xe*_e.width),Te=Math.floor(xe*_e.height);f===void 0&&(f=b(ae,Te));const Pe=L?b(ae,Te):f;return Pe.width=ae,Pe.height=Te,Pe.getContext("2d").drawImage($,0,0,ae,Te),dn("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+ae+"x"+Te+")."),Pe}else return"data"in $&&dn("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),$;return $}function x($){return $.generateMipmaps}function v($){t.generateMipmap($)}function S($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function M($,L,X,xe,_e=!1){if($!==null){if(t[$]!==void 0)return t[$];dn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ae=L;if(L===t.RED&&(X===t.FLOAT&&(ae=t.R32F),X===t.HALF_FLOAT&&(ae=t.R16F),X===t.UNSIGNED_BYTE&&(ae=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ae=t.R8UI),X===t.UNSIGNED_SHORT&&(ae=t.R16UI),X===t.UNSIGNED_INT&&(ae=t.R32UI),X===t.BYTE&&(ae=t.R8I),X===t.SHORT&&(ae=t.R16I),X===t.INT&&(ae=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ae=t.RG32F),X===t.HALF_FLOAT&&(ae=t.RG16F),X===t.UNSIGNED_BYTE&&(ae=t.RG8)),L===t.RG_INTEGER&&(X===t.UNSIGNED_BYTE&&(ae=t.RG8UI),X===t.UNSIGNED_SHORT&&(ae=t.RG16UI),X===t.UNSIGNED_INT&&(ae=t.RG32UI),X===t.BYTE&&(ae=t.RG8I),X===t.SHORT&&(ae=t.RG16I),X===t.INT&&(ae=t.RG32I)),L===t.RGB_INTEGER&&(X===t.UNSIGNED_BYTE&&(ae=t.RGB8UI),X===t.UNSIGNED_SHORT&&(ae=t.RGB16UI),X===t.UNSIGNED_INT&&(ae=t.RGB32UI),X===t.BYTE&&(ae=t.RGB8I),X===t.SHORT&&(ae=t.RGB16I),X===t.INT&&(ae=t.RGB32I)),L===t.RGBA_INTEGER&&(X===t.UNSIGNED_BYTE&&(ae=t.RGBA8UI),X===t.UNSIGNED_SHORT&&(ae=t.RGBA16UI),X===t.UNSIGNED_INT&&(ae=t.RGBA32UI),X===t.BYTE&&(ae=t.RGBA8I),X===t.SHORT&&(ae=t.RGBA16I),X===t.INT&&(ae=t.RGBA32I)),L===t.RGB&&(X===t.UNSIGNED_INT_5_9_9_9_REV&&(ae=t.RGB9_E5),X===t.UNSIGNED_INT_10F_11F_11F_REV&&(ae=t.R11F_G11F_B10F)),L===t.RGBA){const Te=_e?FS:Bn.getTransfer(xe);X===t.FLOAT&&(ae=t.RGBA32F),X===t.HALF_FLOAT&&(ae=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ae=Te===ar?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function N($,L){let X;return $?L===null||L===nc||L===q0?X=t.DEPTH24_STENCIL8:L===Bl?X=t.DEPTH32F_STENCIL8:L===W0&&(X=t.DEPTH24_STENCIL8,dn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===nc||L===q0?X=t.DEPTH_COMPONENT24:L===Bl?X=t.DEPTH_COMPONENT32F:L===W0&&(X=t.DEPTH_COMPONENT16),X}function A($,L){return x($)===!0||$.isFramebufferTexture&&$.minFilter!==_a&&$.minFilter!==Oa?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function k($){const L=$.target;L.removeEventListener("dispose",k),D(L),L.isVideoTexture&&d.delete(L)}function C($){const L=$.target;L.removeEventListener("dispose",C),R(L)}function D($){const L=r.get($);if(L.__webglInit===void 0)return;const X=$.source,xe=m.get(X);if(xe){const _e=xe[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&T($),Object.keys(xe).length===0&&m.delete(X)}r.remove($)}function T($){const L=r.get($);t.deleteTexture(L.__webglTexture);const X=$.source,xe=m.get(X);delete xe[L.__cacheKey],o.memory.textures--}function R($){const L=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++){if(Array.isArray(L.__webglFramebuffer[xe]))for(let _e=0;_e<L.__webglFramebuffer[xe].length;_e++)t.deleteFramebuffer(L.__webglFramebuffer[xe][_e]);else t.deleteFramebuffer(L.__webglFramebuffer[xe]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[xe])}else{if(Array.isArray(L.__webglFramebuffer))for(let xe=0;xe<L.__webglFramebuffer.length;xe++)t.deleteFramebuffer(L.__webglFramebuffer[xe]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let xe=0;xe<L.__webglColorRenderbuffer.length;xe++)L.__webglColorRenderbuffer[xe]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[xe]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const X=$.textures;for(let xe=0,_e=X.length;xe<_e;xe++){const ae=r.get(X[xe]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(X[xe])}r.remove($)}let U=0;function O(){U=0}function q(){const $=U;return $>=i.maxTextures&&dn("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),U+=1,$}function j($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function W($,L){const X=r.get($);if($.isVideoTexture&&Ae($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&X.__version!==$.version){const xe=$.image;if(xe===null)dn("WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)dn("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(X,$,L);return}}else $.isExternalTexture&&(X.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function K($,L){const X=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&X.__version!==$.version){fe(X,$,L);return}else $.isExternalTexture&&(X.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function G($,L){const X=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&X.__version!==$.version){fe(X,$,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function J($,L){const X=r.get($);if($.isCubeDepthTexture!==!0&&$.version>0&&X.__version!==$.version){le(X,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const ie={[O3]:t.REPEAT,[Qc]:t.CLAMP_TO_EDGE,[L3]:t.MIRRORED_REPEAT},re={[_a]:t.NEAREST,[w3e]:t.NEAREST_MIPMAP_NEAREST,[j_]:t.NEAREST_MIPMAP_LINEAR,[Oa]:t.LINEAR,[WC]:t.LINEAR_MIPMAP_NEAREST,[ff]:t.LINEAR_MIPMAP_LINEAR},z={[E3e]:t.NEVER,[k3e]:t.ALWAYS,[N3e]:t.LESS,[tL]:t.LEQUAL,[A3e]:t.EQUAL,[nL]:t.GEQUAL,[T3e]:t.GREATER,[C3e]:t.NOTEQUAL};function V($,L){if(L.type===Bl&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Oa||L.magFilter===WC||L.magFilter===j_||L.magFilter===ff||L.minFilter===Oa||L.minFilter===WC||L.minFilter===j_||L.minFilter===ff)&&dn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,ie[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ie[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ie[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,re[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,re[L.minFilter]),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,z[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===_a||L.minFilter!==j_&&L.minFilter!==ff||L.type===Bl&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function Z($,L){let X=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",k));const xe=L.source;let _e=m.get(xe);_e===void 0&&(_e={},m.set(xe,_e));const ae=j(L);if(ae!==$.__cacheKey){_e[ae]===void 0&&(_e[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),_e[ae].usedTimes++;const Te=_e[$.__cacheKey];Te!==void 0&&(_e[$.__cacheKey].usedTimes--,Te.usedTimes===0&&T(L)),$.__cacheKey=ae,$.__webglTexture=_e[ae].texture}return X}function ne($,L,X){return Math.floor(Math.floor($/X)/L)}function he($,L,X,xe){const ae=$.updateRanges;if(ae.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,X,xe,L.data);else{ae.sort((Ze,oe)=>Ze.start-oe.start);let Te=0;for(let Ze=1;Ze<ae.length;Ze++){const oe=ae[Te],ye=ae[Ze],Ce=oe.start+oe.count,$e=ne(ye.start,L.width,4),lt=ne(oe.start,L.width,4);ye.start<=Ce+1&&$e===lt&&ne(ye.start+ye.count-1,L.width,4)===$e?oe.count=Math.max(oe.count,ye.start+ye.count-oe.start):(++Te,ae[Te]=ye)}ae.length=Te+1;const Pe=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),Je=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ze=0,oe=ae.length;Ze<oe;Ze++){const ye=ae[Ze],Ce=Math.floor(ye.start/4),$e=Math.ceil(ye.count/4),lt=Ce%L.width,se=Math.floor(Ce/L.width),ze=$e,ve=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,lt),t.pixelStorei(t.UNPACK_SKIP_ROWS,se),n.texSubImage2D(t.TEXTURE_2D,0,lt,se,ze,ve,X,xe,L.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Pe),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Je)}}function fe($,L,X){let xe=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(xe=t.TEXTURE_3D);const _e=Z($,L),ae=L.source;n.bindTexture(xe,$.__webglTexture,t.TEXTURE0+X);const Te=r.get(ae);if(ae.version!==Te.__version||_e===!0){n.activeTexture(t.TEXTURE0+X);const Pe=Bn.getPrimaries(Bn.workingColorSpace),Xe=L.colorSpace===Sd?null:Bn.getPrimaries(L.colorSpace),Je=L.colorSpace===Sd||Pe===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Je);let Ze=y(L.image,!1,i.maxTextureSize);Ze=Le(L,Ze);const oe=a.convert(L.format,L.colorSpace),ye=a.convert(L.type);let Ce=M(L.internalFormat,oe,ye,L.colorSpace,L.isVideoTexture);V(xe,L);let $e;const lt=L.mipmaps,se=L.isVideoTexture!==!0,ze=Te.__version===void 0||_e===!0,ve=ae.dataReady,He=A(L,Ze);if(L.isDepthTexture)Ce=N(L.format===mf,L.type),ze&&(se?n.texStorage2D(t.TEXTURE_2D,1,Ce,Ze.width,Ze.height):n.texImage2D(t.TEXTURE_2D,0,Ce,Ze.width,Ze.height,0,oe,ye,null));else if(L.isDataTexture)if(lt.length>0){se&&ze&&n.texStorage2D(t.TEXTURE_2D,He,Ce,lt[0].width,lt[0].height);for(let Oe=0,Ne=lt.length;Oe<Ne;Oe++)$e=lt[Oe],se?ve&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,$e.width,$e.height,oe,ye,$e.data):n.texImage2D(t.TEXTURE_2D,Oe,Ce,$e.width,$e.height,0,oe,ye,$e.data);L.generateMipmaps=!1}else se?(ze&&n.texStorage2D(t.TEXTURE_2D,He,Ce,Ze.width,Ze.height),ve&&he(L,Ze,oe,ye)):n.texImage2D(t.TEXTURE_2D,0,Ce,Ze.width,Ze.height,0,oe,ye,Ze.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){se&&ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Ce,lt[0].width,lt[0].height,Ze.depth);for(let Oe=0,Ne=lt.length;Oe<Ne;Oe++)if($e=lt[Oe],L.format!==Jo)if(oe!==null)if(se){if(ve)if(L.layerUpdates.size>0){const Be=XV($e.width,$e.height,L.format,L.type);for(const at of L.layerUpdates){const Rt=$e.data.subarray(at*Be/$e.data.BYTES_PER_ELEMENT,(at+1)*Be/$e.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,at,$e.width,$e.height,1,oe,Rt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,$e.width,$e.height,Ze.depth,oe,$e.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Oe,Ce,$e.width,$e.height,Ze.depth,0,$e.data,0,0);else dn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else se?ve&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,$e.width,$e.height,Ze.depth,oe,ye,$e.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Oe,Ce,$e.width,$e.height,Ze.depth,0,oe,ye,$e.data)}else{se&&ze&&n.texStorage2D(t.TEXTURE_2D,He,Ce,lt[0].width,lt[0].height);for(let Oe=0,Ne=lt.length;Oe<Ne;Oe++)$e=lt[Oe],L.format!==Jo?oe!==null?se?ve&&n.compressedTexSubImage2D(t.TEXTURE_2D,Oe,0,0,$e.width,$e.height,oe,$e.data):n.compressedTexImage2D(t.TEXTURE_2D,Oe,Ce,$e.width,$e.height,0,$e.data):dn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):se?ve&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,$e.width,$e.height,oe,ye,$e.data):n.texImage2D(t.TEXTURE_2D,Oe,Ce,$e.width,$e.height,0,oe,ye,$e.data)}else if(L.isDataArrayTexture)if(se){if(ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Ce,Ze.width,Ze.height,Ze.depth),ve)if(L.layerUpdates.size>0){const Oe=XV(Ze.width,Ze.height,L.format,L.type);for(const Ne of L.layerUpdates){const Be=Ze.data.subarray(Ne*Oe/Ze.data.BYTES_PER_ELEMENT,(Ne+1)*Oe/Ze.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ne,Ze.width,Ze.height,1,oe,ye,Be)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ze.width,Ze.height,Ze.depth,oe,ye,Ze.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ce,Ze.width,Ze.height,Ze.depth,0,oe,ye,Ze.data);else if(L.isData3DTexture)se?(ze&&n.texStorage3D(t.TEXTURE_3D,He,Ce,Ze.width,Ze.height,Ze.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ze.width,Ze.height,Ze.depth,oe,ye,Ze.data)):n.texImage3D(t.TEXTURE_3D,0,Ce,Ze.width,Ze.height,Ze.depth,0,oe,ye,Ze.data);else if(L.isFramebufferTexture){if(ze)if(se)n.texStorage2D(t.TEXTURE_2D,He,Ce,Ze.width,Ze.height);else{let Oe=Ze.width,Ne=Ze.height;for(let Be=0;Be<He;Be++)n.texImage2D(t.TEXTURE_2D,Be,Ce,Oe,Ne,0,oe,ye,null),Oe>>=1,Ne>>=1}}else if(lt.length>0){if(se&&ze){const Oe=Se(lt[0]);n.texStorage2D(t.TEXTURE_2D,He,Ce,Oe.width,Oe.height)}for(let Oe=0,Ne=lt.length;Oe<Ne;Oe++)$e=lt[Oe],se?ve&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,oe,ye,$e):n.texImage2D(t.TEXTURE_2D,Oe,Ce,oe,ye,$e);L.generateMipmaps=!1}else if(se){if(ze){const Oe=Se(Ze);n.texStorage2D(t.TEXTURE_2D,He,Ce,Oe.width,Oe.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,ye,Ze)}else n.texImage2D(t.TEXTURE_2D,0,Ce,oe,ye,Ze);x(L)&&v(xe),Te.__version=ae.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function le($,L,X){if(L.image.length!==6)return;const xe=Z($,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+X);const ae=r.get(_e);if(_e.version!==ae.__version||xe===!0){n.activeTexture(t.TEXTURE0+X);const Te=Bn.getPrimaries(Bn.workingColorSpace),Pe=L.colorSpace===Sd?null:Bn.getPrimaries(L.colorSpace),Xe=L.colorSpace===Sd||Te===Pe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const Je=L.isCompressedTexture||L.image[0].isCompressedTexture,Ze=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let Ne=0;Ne<6;Ne++)!Je&&!Ze?oe[Ne]=y(L.image[Ne],!0,i.maxCubemapSize):oe[Ne]=Ze?L.image[Ne].image:L.image[Ne],oe[Ne]=Le(L,oe[Ne]);const ye=oe[0],Ce=a.convert(L.format,L.colorSpace),$e=a.convert(L.type),lt=M(L.internalFormat,Ce,$e,L.colorSpace),se=L.isVideoTexture!==!0,ze=ae.__version===void 0||xe===!0,ve=_e.dataReady;let He=A(L,ye);V(t.TEXTURE_CUBE_MAP,L);let Oe;if(Je){se&&ze&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,lt,ye.width,ye.height);for(let Ne=0;Ne<6;Ne++){Oe=oe[Ne].mipmaps;for(let Be=0;Be<Oe.length;Be++){const at=Oe[Be];L.format!==Jo?Ce!==null?se?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,0,0,at.width,at.height,Ce,at.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,lt,at.width,at.height,0,at.data):dn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):se?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,0,0,at.width,at.height,Ce,$e,at.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,lt,at.width,at.height,0,Ce,$e,at.data)}}}else{if(Oe=L.mipmaps,se&&ze){Oe.length>0&&He++;const Ne=Se(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,He,lt,Ne.width,Ne.height)}for(let Ne=0;Ne<6;Ne++)if(Ze){se?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,oe[Ne].width,oe[Ne].height,Ce,$e,oe[Ne].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,lt,oe[Ne].width,oe[Ne].height,0,Ce,$e,oe[Ne].data);for(let Be=0;Be<Oe.length;Be++){const Rt=Oe[Be].image[Ne].image;se?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,0,0,Rt.width,Rt.height,Ce,$e,Rt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,lt,Rt.width,Rt.height,0,Ce,$e,Rt.data)}}else{se?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,Ce,$e,oe[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,lt,Ce,$e,oe[Ne]);for(let Be=0;Be<Oe.length;Be++){const at=Oe[Be];se?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,0,0,Ce,$e,at.image[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,lt,Ce,$e,at.image[Ne])}}}x(L)&&v(t.TEXTURE_CUBE_MAP),ae.__version=_e.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ee($,L,X,xe,_e,ae){const Te=a.convert(X.format,X.colorSpace),Pe=a.convert(X.type),Xe=M(X.internalFormat,Te,Pe,X.colorSpace),Je=r.get(L),Ze=r.get(X);if(Ze.__renderTarget=L,!Je.__hasExternalTextures){const oe=Math.max(1,L.width>>ae),ye=Math.max(1,L.height>>ae);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ae,Xe,oe,ye,L.depth,0,Te,Pe,null):n.texImage2D(_e,ae,Xe,oe,ye,0,Te,Pe,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),de(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,_e,Ze.__webglTexture,0,F(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,_e,Ze.__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function me($,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer){const xe=L.depthTexture,_e=xe&&xe.isDepthTexture?xe.type:null,ae=N(L.stencilBuffer,_e),Te=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;de(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,F(L),ae,L.width,L.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,F(L),ae,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ae,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Te,t.RENDERBUFFER,$)}else{const xe=L.textures;for(let _e=0;_e<xe.length;_e++){const ae=xe[_e],Te=a.convert(ae.format,ae.colorSpace),Pe=a.convert(ae.type),Xe=M(ae.internalFormat,Te,Pe,ae.colorSpace);de(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,F(L),Xe,L.width,L.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,F(L),Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we($,L,X){const xe=L.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const _e=r.get(L.depthTexture);if(_e.__renderTarget=L,(!_e.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),xe){if(_e.__webglInit===void 0&&(_e.__webglInit=!0,L.depthTexture.addEventListener("dispose",k)),_e.__webglTexture===void 0){_e.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,_e.__webglTexture),V(t.TEXTURE_CUBE_MAP,L.depthTexture);const Je=a.convert(L.depthTexture.format),Ze=a.convert(L.depthTexture.type);let oe;L.depthTexture.format===yu?oe=t.DEPTH_COMPONENT24:L.depthTexture.format===mf&&(oe=t.DEPTH24_STENCIL8);for(let ye=0;ye<6;ye++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,oe,L.width,L.height,0,Je,Ze,null)}}else W(L.depthTexture,0);const ae=_e.__webglTexture,Te=F(L),Pe=xe?t.TEXTURE_CUBE_MAP_POSITIVE_X+X:t.TEXTURE_2D,Xe=L.depthTexture.format===mf?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(L.depthTexture.format===yu)de(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,Pe,ae,0,Te):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,Pe,ae,0);else if(L.depthTexture.format===mf)de(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,Pe,ae,0,Te):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,Pe,ae,0);else throw new Error("Unknown depthTexture format")}function De($){const L=r.get($),X=$.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==$.depthTexture){const xe=$.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),xe){const _e=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,xe.removeEventListener("dispose",_e)};xe.addEventListener("dispose",_e),L.__depthDisposeCallback=_e}L.__boundDepthTexture=xe}if($.depthTexture&&!L.__autoAllocateDepthBuffer)if(X)for(let xe=0;xe<6;xe++)we(L.__webglFramebuffer[xe],$,xe);else{const xe=$.texture.mipmaps;xe&&xe.length>0?we(L.__webglFramebuffer[0],$,0):we(L.__webglFramebuffer,$,0)}else if(X){L.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[xe]),L.__webglDepthbuffer[xe]===void 0)L.__webglDepthbuffer[xe]=t.createRenderbuffer(),me(L.__webglDepthbuffer[xe],$,!1);else{const _e=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=L.__webglDepthbuffer[xe];t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ae)}}else{const xe=$.texture.mipmaps;if(xe&&xe.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),me(L.__webglDepthbuffer,$,!1);else{const _e=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ae)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ee($,L,X){const xe=r.get($);L!==void 0&&Ee(xe.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&De($)}function Qe($){const L=$.texture,X=r.get($),xe=r.get(L);$.addEventListener("dispose",C);const _e=$.textures,ae=$.isWebGLCubeRenderTarget===!0,Te=_e.length>1;if(Te||(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=L.version,o.memory.textures++),ae){X.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Pe]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)X.__webglFramebuffer[Pe][Xe]=t.createFramebuffer()}else X.__webglFramebuffer[Pe]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Pe=0;Pe<L.mipmaps.length;Pe++)X.__webglFramebuffer[Pe]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(Te)for(let Pe=0,Xe=_e.length;Pe<Xe;Pe++){const Je=r.get(_e[Pe]);Je.__webglTexture===void 0&&(Je.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&de($)===!1){X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let Pe=0;Pe<_e.length;Pe++){const Xe=_e[Pe];X.__webglColorRenderbuffer[Pe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[Pe]);const Je=a.convert(Xe.format,Xe.colorSpace),Ze=a.convert(Xe.type),oe=M(Xe.internalFormat,Je,Ze,Xe.colorSpace,$.isXRRenderTarget===!0),ye=F($);t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,oe,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Pe,t.RENDERBUFFER,X.__webglColorRenderbuffer[Pe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),me(X.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ae){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),V(t.TEXTURE_CUBE_MAP,L);for(let Pe=0;Pe<6;Pe++)if(L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ee(X.__webglFramebuffer[Pe][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Xe);else Ee(X.__webglFramebuffer[Pe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0);x(L)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Te){for(let Pe=0,Xe=_e.length;Pe<Xe;Pe++){const Je=_e[Pe],Ze=r.get(Je);let oe=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(oe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Ze.__webglTexture),V(oe,Je),Ee(X.__webglFramebuffer,$,Je,t.COLOR_ATTACHMENT0+Pe,oe,0),x(Je)&&v(oe)}n.unbindTexture()}else{let Pe=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Pe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Pe,xe.__webglTexture),V(Pe,L),L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ee(X.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,Pe,Xe);else Ee(X.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Pe,0);x(L)&&v(Pe),n.unbindTexture()}$.depthBuffer&&De($)}function B($){const L=$.textures;for(let X=0,xe=L.length;X<xe;X++){const _e=L[X];if(x(_e)){const ae=S($),Te=r.get(_e).__webglTexture;n.bindTexture(ae,Te),v(ae),n.unbindTexture()}}}const te=[],Y=[];function H($){if($.samples>0){if(de($)===!1){const L=$.textures,X=$.width,xe=$.height;let _e=t.COLOR_BUFFER_BIT;const ae=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Te=r.get($),Pe=L.length>1;if(Pe)for(let Je=0;Je<L.length;Je++)n.bindFramebuffer(t.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Te.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Te.__webglMultisampledFramebuffer);const Xe=$.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Te.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Te.__webglFramebuffer);for(let Je=0;Je<L.length;Je++){if($.resolveDepthBuffer&&($.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Pe){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Te.__webglColorRenderbuffer[Je]);const Ze=r.get(L[Je]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ze,0)}t.blitFramebuffer(0,0,X,xe,0,0,X,xe,_e,t.NEAREST),c===!0&&(te.length=0,Y.length=0,te.push(t.COLOR_ATTACHMENT0+Je),$.depthBuffer&&$.resolveDepthBuffer===!1&&(te.push(ae),Y.push(ae),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,Y)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,te))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Pe)for(let Je=0;Je<L.length;Je++){n.bindFramebuffer(t.FRAMEBUFFER,Te.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,Te.__webglColorRenderbuffer[Je]);const Ze=r.get(L[Je]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Te.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,Ze,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Te.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const L=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function F($){return Math.min(i.maxSamples,$.samples)}function de($){const L=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae($){const L=o.render.frame;d.get($)!==L&&(d.set($,L),$.update())}function Le($,L){const X=$.colorSpace,xe=$.format,_e=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||X!==Cg&&X!==Sd&&(Bn.getTransfer(X)===ar?(xe!==Jo||_e!==zs)&&dn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Vn("WebGLTextures: Unsupported texture color space:",X)),L}function Se($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=J,this.rebindTextures=ee,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=H,this.setupDepthRenderbuffer=De,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=de,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function oIe(t,e){function n(r,i=Sd){let a;const o=Bn.getTransfer(i);if(r===zs)return t.UNSIGNED_BYTE;if(r===Y4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Z4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===nee)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===ree)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===eee)return t.BYTE;if(r===tee)return t.SHORT;if(r===W0)return t.UNSIGNED_SHORT;if(r===X4)return t.INT;if(r===nc)return t.UNSIGNED_INT;if(r===Bl)return t.FLOAT;if(r===bu)return t.HALF_FLOAT;if(r===iee)return t.ALPHA;if(r===aee)return t.RGB;if(r===Jo)return t.RGBA;if(r===yu)return t.DEPTH_COMPONENT;if(r===mf)return t.DEPTH_STENCIL;if(r===see)return t.RED;if(r===Q4)return t.RED_INTEGER;if(r===Tg)return t.RG;if(r===J4)return t.RG_INTEGER;if(r===eL)return t.RGBA_INTEGER;if(r===lw||r===cw||r===uw||r===dw)if(o===ar)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===lw)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===cw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===dw)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===lw)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===cw)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===uw)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===dw)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===I3||r===F3||r===U3||r===z3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===I3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===F3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===U3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===z3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===B3||r===$3||r===H3||r===V3||r===G3||r===W3||r===q3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===B3||r===$3)return o===ar?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===H3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===V3)return a.COMPRESSED_R11_EAC;if(r===G3)return a.COMPRESSED_SIGNED_R11_EAC;if(r===W3)return a.COMPRESSED_RG11_EAC;if(r===q3)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===K3||r===X3||r===Y3||r===Z3||r===Q3||r===J3||r===eR||r===tR||r===nR||r===rR||r===iR||r===aR||r===sR||r===oR)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===K3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===X3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Y3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Z3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Q3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===J3)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===eR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===tR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===nR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===rR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===iR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===aR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===sR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===oR)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===lR||r===cR||r===uR)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===lR)return o===ar?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===cR)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===uR)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===dR||r===hR||r===fR||r===mR)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===dR)return a.COMPRESSED_RED_RGTC1_EXT;if(r===hR)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===fR)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===mR)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===q0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const lIe=`
  3953. void main() {
  3954. gl_Position = vec4( position, 1.0 );
  3955. }`,cIe=`
  3956. uniform sampler2DArray depthColor;
  3957. uniform float depthWidth;
  3958. uniform float depthHeight;
  3959. void main() {
  3960. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3961. if ( coord.x >= 1.0 ) {
  3962. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3963. } else {
  3964. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3965. }
  3966. }`;class uIe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new Nee(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 rc({vertexShader:lIe,fragmentShader:cIe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new dl(new lL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let dIe=class extends um{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,m=null,p=null,b=null;const y=typeof XRWebGLBinding<"u",x=new uIe,v={},S=n.getContextAttributes();let M=null,N=null;const A=[],k=[],C=new Mn;let D=null;const T=new _o;T.viewport=new xi;const R=new _o;R.viewport=new xi;const U=[T,R],O=new yRe;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let le=A[fe];return le===void 0&&(le=new mk,A[fe]=le),le.getTargetRaySpace()},this.getControllerGrip=function(fe){let le=A[fe];return le===void 0&&(le=new mk,A[fe]=le),le.getGripSpace()},this.getHand=function(fe){let le=A[fe];return le===void 0&&(le=new mk,A[fe]=le),le.getHandSpace()};function W(fe){const le=k.indexOf(fe.inputSource);if(le===-1)return;const Ee=A[le];Ee!==void 0&&(Ee.update(fe.inputSource,fe.frame,u||o),Ee.dispatchEvent({type:fe.type,data:fe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let fe=0;fe<A.length;fe++){const le=k[fe];le!==null&&(k[fe]=null,A[fe].disconnect(le))}q=null,j=null,x.reset();for(const fe in v)delete v[fe];e.setRenderTarget(M),p=null,m=null,f=null,i=null,N=null,he.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){a=fe,r.isPresenting===!0&&dn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){l=fe,r.isPresenting===!0&&dn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(fe){u=fe},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(fe){if(i=fe,i!==null){if(M=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,me=null,we=null;S.depth&&(we=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=S.stencil?mf:yu,me=S.stencil?q0:nc);const De={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(De),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),N=new ql(m.textureWidth,m.textureHeight,{format:Jo,type:zs,depthTexture:new X0(m.textureWidth,m.textureHeight,me,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ee={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),N=new ql(p.framebufferWidth,p.framebufferHeight,{format:Jo,type:zs,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}N.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),he.setContext(i),he.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(fe){for(let le=0;le<fe.removed.length;le++){const Ee=fe.removed[le],me=k.indexOf(Ee);me>=0&&(k[me]=null,A[me].disconnect(Ee))}for(let le=0;le<fe.added.length;le++){const Ee=fe.added[le];let me=k.indexOf(Ee);if(me===-1){for(let De=0;De<A.length;De++)if(De>=k.length){k.push(Ee),me=De;break}else if(k[De]===null){k[De]=Ee,me=De;break}if(me===-1)break}const we=A[me];we&&we.connect(Ee)}}const J=new nt,ie=new nt;function re(fe,le,Ee){J.setFromMatrixPosition(le.matrixWorld),ie.setFromMatrixPosition(Ee.matrixWorld);const me=J.distanceTo(ie),we=le.projectionMatrix.elements,De=Ee.projectionMatrix.elements,ee=we[14]/(we[10]-1),Qe=we[14]/(we[10]+1),B=(we[9]+1)/we[5],te=(we[9]-1)/we[5],Y=(we[8]-1)/we[0],H=(De[8]+1)/De[0],F=ee*Y,de=ee*H,Ae=me/(-Y+H),Le=Ae*-Y;if(le.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Le),fe.translateZ(Ae),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),we[10]===-1)fe.projectionMatrix.copy(le.projectionMatrix),fe.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const Se=ee+Ae,$=Qe+Ae,L=F-Le,X=de+(me-Le),xe=B*Qe/$*Se,_e=te*Qe/$*Se;fe.projectionMatrix.makePerspective(L,X,xe,_e,Se,$),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function z(fe,le){le===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(le.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let le=fe.near,Ee=fe.far;x.texture!==null&&(x.depthNear>0&&(le=x.depthNear),x.depthFar>0&&(Ee=x.depthFar)),O.near=R.near=T.near=le,O.far=R.far=T.far=Ee,(q!==O.near||j!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,j=O.far),O.layers.mask=fe.layers.mask|6,T.layers.mask=O.layers.mask&3,R.layers.mask=O.layers.mask&5;const me=fe.parent,we=O.cameras;z(O,me);for(let De=0;De<we.length;De++)z(we[De],me);we.length===2?re(O,T,R):O.projectionMatrix.copy(T.projectionMatrix),V(fe,O,me)};function V(fe,le,Ee){Ee===null?fe.matrix.copy(le.matrixWorld):(fe.matrix.copy(Ee.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(le.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(le.projectionMatrix),fe.projectionMatrixInverse.copy(le.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=pR*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(fe){c=fe,m!==null&&(m.fixedFoveation=fe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=fe)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(fe){return v[fe]};let Z=null;function ne(fe,le){if(d=le.getViewerPose(u||o),b=le,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(N,p.framebuffer),e.setRenderTarget(N));let me=!1;Ee.length!==O.cameras.length&&(O.cameras.length=0,me=!0);for(let Qe=0;Qe<Ee.length;Qe++){const B=Ee[Qe];let te=null;if(p!==null)te=p.getViewport(B);else{const H=f.getViewSubImage(m,B);te=H.viewport,Qe===0&&(e.setRenderTargetTextures(N,H.colorTexture,H.depthStencilTexture),e.setRenderTarget(N))}let Y=U[Qe];Y===void 0&&(Y=new _o,Y.layers.enable(Qe),Y.viewport=new xi,U[Qe]=Y),Y.matrix.fromArray(B.transform.matrix),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.projectionMatrix.fromArray(B.projectionMatrix),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert(),Y.viewport.set(te.x,te.y,te.width,te.height),Qe===0&&(O.matrix.copy(Y.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),me===!0&&O.cameras.push(Y)}const we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const Qe=f.getDepthInformation(Ee[0]);Qe&&Qe.isValid&&Qe.texture&&x.init(Qe,i.renderState)}if(we&&we.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let Qe=0;Qe<Ee.length;Qe++){const B=Ee[Qe].camera;if(B){let te=v[B];te||(te=new Nee,v[B]=te);const Y=f.getCameraImage(B);te.sourceTexture=Y}}}}for(let Ee=0;Ee<A.length;Ee++){const me=k[Ee],we=A[Ee];me!==null&&we!==void 0&&we.update(me,le,u||o)}Z&&Z(fe,le),le.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:le}),b=null}const he=new Cee;he.setAnimationLoop(ne),this.setAnimationLoop=function(fe){Z=fe},this.dispose=function(){}}};const zh=new Jd,hIe=new li;function fIe(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,_ee(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,M,N){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(x,v):v.isMeshToonMaterial?(a(x,v),f(x,v)):v.isMeshPhongMaterial?(a(x,v),d(x,v)):v.isMeshStandardMaterial?(a(x,v),m(x,v),v.isMeshPhysicalMaterial&&p(x,v,N)):v.isMeshMatcapMaterial?(a(x,v),b(x,v)):v.isMeshDepthMaterial?a(x,v):v.isMeshDistanceMaterial?(a(x,v),y(x,v)):v.isMeshNormalMaterial?a(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,M):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===bs&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===bs&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v),M=S.envMap,N=S.envMapRotation;M&&(x.envMap.value=M,zh.copy(N),zh.x*=-1,zh.y*=-1,zh.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(zh.y*=-1,zh.z*=-1),x.envMapRotation.value.setFromMatrix4(hIe.makeRotationFromEuler(zh)),x.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap&&(x.lightMap.value=v.lightMap,x.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,x.lightMapTransform)),v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),v.envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===bs&&x.clearcoatNormalScale.value.negate())),v.dispersion>0&&(x.dispersion.value=v.dispersion),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function mIe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){const N=M.program;r.uniformBlockBinding(S,N)}function u(S,M){let N=i[S.id];N===void 0&&(b(S),N=d(S),i[S.id]=N,S.addEventListener("dispose",x));const A=M.program;r.updateUBOMapping(S,A);const k=e.render.frame;a[S.id]!==k&&(m(S),a[S.id]=k)}function d(S){const M=f();S.__bindingPointIndex=M;const N=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,N),N}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Vn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const M=i[S.id],N=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,C=N.length;k<C;k++){const D=Array.isArray(N[k])?N[k]:[N[k]];for(let T=0,R=D.length;T<R;T++){const U=D[T];if(p(U,k,T,A)===!0){const O=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let W=0;W<q.length;W++){const K=q[W],G=y(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,O+j,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,j),j+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,N,A){const k=S.value,C=M+"_"+N;if(A[C]===void 0)return typeof k=="number"||typeof k=="boolean"?A[C]=k:A[C]=k.clone(),!0;{const D=A[C];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return A[C]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function b(S){const M=S.uniforms;let N=0;const A=16;for(let C=0,D=M.length;C<D;C++){const T=Array.isArray(M[C])?M[C]:[M[C]];for(let R=0,U=T.length;R<U;R++){const O=T[R],q=Array.isArray(O.value)?O.value:[O.value];for(let j=0,W=q.length;j<W;j++){const K=q[j],G=y(K),J=N%A,ie=J%G.boundary,re=J+ie;N+=ie,re!==0&&A-re<G.storage&&(N+=A-re),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=N,N+=G.storage}}}const k=N%A;return k>0&&(N+=A-k),S.__size=N,S.__cache={},this}function y(S){const M={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?dn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):dn("WebGLRenderer: Unsupported uniform value type.",S),M}function x(S){const M=S.target;M.removeEventListener("dispose",x);const N=o.indexOf(M.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const pIe=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Al=null;function gIe(){return Al===null&&(Al=new aRe(pIe,16,16,Tg,bu),Al.name="DFG_LUT",Al.minFilter=Oa,Al.magFilter=Oa,Al.wrapS=Qc,Al.wrapT=Qc,Al.generateMipmaps=!1,Al.needsUpdate=!0),Al}let xIe=class{constructor(e={}){const{canvas:n=j3e(),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:m=!1,outputBufferType:p=zs}=e;this.isWebGLRenderer=!0;let b;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");b=r.getContextAttributes().alpha}else b=o;const y=p,x=new Set([eL,J4,Q4]),v=new Set([zs,nc,W0,q0,Y4,Z4]),S=new Uint32Array(4),M=new Int32Array(4);let N=null,A=null;const k=[],C=[];let D=null;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=Wl,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let R=!1;this._outputColorSpace=bo;let U=0,O=0,q=null,j=-1,W=null;const K=new xi,G=new xi;let J=null;const ie=new Pn(0);let re=0,z=n.width,V=n.height,Z=1,ne=null,he=null;const fe=new xi(0,0,z,V),le=new xi(0,0,z,V);let Ee=!1;const me=new oL;let we=!1,De=!1;const ee=new li,Qe=new nt,B=new xi,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function H(){return q===null?Z:1}let F=r;function de(ue,je){return n.getContext(ue,je)}try{const ue={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${q4}`),n.addEventListener("webglcontextlost",at,!1),n.addEventListener("webglcontextrestored",Rt,!1),n.addEventListener("webglcontextcreationerror",Tt,!1),F===null){const je="webgl2";if(F=de(je,ue),F===null)throw de(je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw Vn("WebGLRenderer: "+ue.message),ue}let Ae,Le,Se,$,L,X,xe,_e,ae,Te,Pe,Xe,Je,Ze,oe,ye,Ce,$e,lt,se,ze,ve,He,Oe;function Ne(){Ae=new g4e(F),Ae.init(),ve=new oIe(F,Ae),Le=new o4e(F,Ae,e,ve),Se=new aIe(F,Ae),Le.reversedDepthBuffer&&m&&Se.buffers.depth.setReversed(!0),$=new y4e(F),L=new VLe,X=new sIe(F,Ae,Se,L,Le,ve,$),xe=new c4e(T),_e=new p4e(T),ae=new SRe(F),He=new a4e(F,ae),Te=new x4e(F,ae,$,He),Pe=new _4e(F,Te,ae,$),lt=new v4e(F,Le,X),ye=new l4e(L),Xe=new HLe(T,xe,_e,Ae,Le,He,ye),Je=new fIe(T,L),Ze=new WLe,oe=new QLe(Ae),$e=new i4e(T,xe,_e,Se,Pe,b,c),Ce=new rIe(T,Pe,Le),Oe=new mIe(F,$,Le,Se),se=new s4e(F,Ae,$),ze=new b4e(F,Ae,$),$.programs=Xe.programs,T.capabilities=Le,T.extensions=Ae,T.properties=L,T.renderLists=Ze,T.shadowMap=Ce,T.state=Se,T.info=$}Ne(),y!==zs&&(D=new S4e(y,n.width,n.height,i,a));const Be=new dIe(T,F);this.xr=Be,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){const ue=Ae.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=Ae.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(ue){ue!==void 0&&(Z=ue,this.setSize(z,V,!1))},this.getSize=function(ue){return ue.set(z,V)},this.setSize=function(ue,je,Ge=!0){if(Be.isPresenting){dn("WebGLRenderer: Can't change size while VR device is presenting.");return}z=ue,V=je,n.width=Math.floor(ue*Z),n.height=Math.floor(je*Z),Ge===!0&&(n.style.width=ue+"px",n.style.height=je+"px"),D!==null&&D.setSize(n.width,n.height),this.setViewport(0,0,ue,je)},this.getDrawingBufferSize=function(ue){return ue.set(z*Z,V*Z).floor()},this.setDrawingBufferSize=function(ue,je,Ge){z=ue,V=je,Z=Ge,n.width=Math.floor(ue*Ge),n.height=Math.floor(je*Ge),this.setViewport(0,0,ue,je)},this.setEffects=function(ue){if(y===zs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(ue){for(let je=0;je<ue.length;je++)if(ue[je].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(ue||[])},this.getCurrentViewport=function(ue){return ue.copy(K)},this.getViewport=function(ue){return ue.copy(fe)},this.setViewport=function(ue,je,Ge,qe){ue.isVector4?fe.set(ue.x,ue.y,ue.z,ue.w):fe.set(ue,je,Ge,qe),Se.viewport(K.copy(fe).multiplyScalar(Z).round())},this.getScissor=function(ue){return ue.copy(le)},this.setScissor=function(ue,je,Ge,qe){ue.isVector4?le.set(ue.x,ue.y,ue.z,ue.w):le.set(ue,je,Ge,qe),Se.scissor(G.copy(le).multiplyScalar(Z).round())},this.getScissorTest=function(){return Ee},this.setScissorTest=function(ue){Se.setScissorTest(Ee=ue)},this.setOpaqueSort=function(ue){ne=ue},this.setTransparentSort=function(ue){he=ue},this.getClearColor=function(ue){return ue.copy($e.getClearColor())},this.setClearColor=function(){$e.setClearColor(...arguments)},this.getClearAlpha=function(){return $e.getClearAlpha()},this.setClearAlpha=function(){$e.setClearAlpha(...arguments)},this.clear=function(ue=!0,je=!0,Ge=!0){let qe=0;if(ue){let Ve=!1;if(q!==null){const xt=q.texture.format;Ve=x.has(xt)}if(Ve){const xt=q.texture.type,Pt=v.has(xt),_t=$e.getClearColor(),pt=$e.getClearAlpha(),St=_t.r,Ot=_t.g,Ft=_t.b;Pt?(S[0]=St,S[1]=Ot,S[2]=Ft,S[3]=pt,F.clearBufferuiv(F.COLOR,0,S)):(M[0]=St,M[1]=Ot,M[2]=Ft,M[3]=pt,F.clearBufferiv(F.COLOR,0,M))}else qe|=F.COLOR_BUFFER_BIT}je&&(qe|=F.DEPTH_BUFFER_BIT),Ge&&(qe|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),F.clear(qe)},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",at,!1),n.removeEventListener("webglcontextrestored",Rt,!1),n.removeEventListener("webglcontextcreationerror",Tt,!1),$e.dispose(),Ze.dispose(),oe.dispose(),L.dispose(),xe.dispose(),_e.dispose(),Pe.dispose(),He.dispose(),Oe.dispose(),Xe.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",wt),Be.removeEventListener("sessionend",gr),Nr.stop()};function at(ue){ue.preventDefault(),MV("WebGLRenderer: Context Lost."),R=!0}function Rt(){MV("WebGLRenderer: Context Restored."),R=!1;const ue=$.autoReset,je=Ce.enabled,Ge=Ce.autoUpdate,qe=Ce.needsUpdate,Ve=Ce.type;Ne(),$.autoReset=ue,Ce.enabled=je,Ce.autoUpdate=Ge,Ce.needsUpdate=qe,Ce.type=Ve}function Tt(ue){Vn("WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function nn(ue){const je=ue.target;je.removeEventListener("dispose",nn),Lt(je)}function Lt(ue){ln(ue),L.remove(ue)}function ln(ue){const je=L.get(ue).programs;je!==void 0&&(je.forEach(function(Ge){Xe.releaseProgram(Ge)}),ue.isShaderMaterial&&Xe.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,je,Ge,qe,Ve,xt){je===null&&(je=te);const Pt=Ve.isMesh&&Ve.matrixWorld.determinant()<0,_t=rt(ue,je,Ge,qe,Ve);Se.setMaterial(qe,Pt);let pt=Ge.index,St=1;if(qe.wireframe===!0){if(pt=Te.getWireframeAttribute(Ge),pt===void 0)return;St=2}const Ot=Ge.drawRange,Ft=Ge.attributes.position;let be=Ot.start*St,kt=(Ot.start+Ot.count)*St;xt!==null&&(be=Math.max(be,xt.start*St),kt=Math.min(kt,(xt.start+xt.count)*St)),pt!==null?(be=Math.max(be,0),kt=Math.min(kt,pt.count)):Ft!=null&&(be=Math.max(be,0),kt=Math.min(kt,Ft.count));const rn=kt-be;if(rn<0||rn===1/0)return;He.setup(Ve,qe,_t,Ge,pt);let zt,cn=se;if(pt!==null&&(zt=ae.get(pt),cn=ze,cn.setIndex(zt)),Ve.isMesh)qe.wireframe===!0?(Se.setLineWidth(qe.wireframeLinewidth*H()),cn.setMode(F.LINES)):cn.setMode(F.TRIANGLES);else if(Ve.isLine){let $t=qe.linewidth;$t===void 0&&($t=1),Se.setLineWidth($t*H()),Ve.isLineSegments?cn.setMode(F.LINES):Ve.isLineLoop?cn.setMode(F.LINE_LOOP):cn.setMode(F.LINE_STRIP)}else Ve.isPoints?cn.setMode(F.POINTS):Ve.isSprite&&cn.setMode(F.TRIANGLES);if(Ve.isBatchedMesh)if(Ve._multiDrawInstances!==null)K0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),cn.renderMultiDrawInstances(Ve._multiDrawStarts,Ve._multiDrawCounts,Ve._multiDrawCount,Ve._multiDrawInstances);else if(Ae.get("WEBGL_multi_draw"))cn.renderMultiDraw(Ve._multiDrawStarts,Ve._multiDrawCounts,Ve._multiDrawCount);else{const $t=Ve._multiDrawStarts,Gt=Ve._multiDrawCounts,an=Ve._multiDrawCount,wi=pt?ae.get(pt).bytesPerElement:1,Qs=L.get(qe).currentProgram.getUniforms();for(let ta=0;ta<an;ta++)Qs.setValue(F,"_gl_DrawID",ta),cn.render($t[ta]/wi,Gt[ta])}else if(Ve.isInstancedMesh)cn.renderInstances(be,rn,Ve.count);else if(Ge.isInstancedBufferGeometry){const $t=Ge._maxInstanceCount!==void 0?Ge._maxInstanceCount:1/0,Gt=Math.min(Ge.instanceCount,$t);cn.renderInstances(be,rn,Gt)}else cn.render(be,rn)};function ft(ue,je,Ge){ue.transparent===!0&&ue.side===Ll&&ue.forceSinglePass===!1?(ue.side=bs,ue.needsUpdate=!0,ce(ue,je,Ge),ue.side=Qd,ue.needsUpdate=!0,ce(ue,je,Ge),ue.side=Ll):ce(ue,je,Ge)}this.compile=function(ue,je,Ge=null){Ge===null&&(Ge=ue),A=oe.get(Ge),A.init(je),C.push(A),Ge.traverseVisible(function(Ve){Ve.isLight&&Ve.layers.test(je.layers)&&(A.pushLight(Ve),Ve.castShadow&&A.pushShadow(Ve))}),ue!==Ge&&ue.traverseVisible(function(Ve){Ve.isLight&&Ve.layers.test(je.layers)&&(A.pushLight(Ve),Ve.castShadow&&A.pushShadow(Ve))}),A.setupLights();const qe=new Set;return ue.traverse(function(Ve){if(!(Ve.isMesh||Ve.isPoints||Ve.isLine||Ve.isSprite))return;const xt=Ve.material;if(xt)if(Array.isArray(xt))for(let Pt=0;Pt<xt.length;Pt++){const _t=xt[Pt];ft(_t,Ge,Ve),qe.add(_t)}else ft(xt,Ge,Ve),qe.add(xt)}),A=C.pop(),qe},this.compileAsync=function(ue,je,Ge=null){const qe=this.compile(ue,je,Ge);return new Promise(Ve=>{function xt(){if(qe.forEach(function(Pt){L.get(Pt).currentProgram.isReady()&&qe.delete(Pt)}),qe.size===0){Ve(ue);return}setTimeout(xt,10)}Ae.get("KHR_parallel_shader_compile")!==null?xt():setTimeout(xt,10)})};let Xt=null;function tn(ue){Xt&&Xt(ue)}function wt(){Nr.stop()}function gr(){Nr.start()}const Nr=new Cee;Nr.setAnimationLoop(tn),typeof self<"u"&&Nr.setContext(self),this.setAnimationLoop=function(ue){Xt=ue,Be.setAnimationLoop(ue),ue===null?Nr.stop():Nr.start()},Be.addEventListener("sessionstart",wt),Be.addEventListener("sessionend",gr),this.render=function(ue,je){if(je!==void 0&&je.isCamera!==!0){Vn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;const Ge=Be.enabled===!0&&Be.isPresenting===!0,qe=D!==null&&(q===null||Ge)&&D.begin(T,q);if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),je.parent===null&&je.matrixWorldAutoUpdate===!0&&je.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(je),je=Be.getCamera()),ue.isScene===!0&&ue.onBeforeRender(T,ue,je,q),A=oe.get(ue,C.length),A.init(je),C.push(A),ee.multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse),me.setFromProjectionMatrix(ee,$l,je.reversedDepth),De=this.localClippingEnabled,we=ye.init(this.clippingPlanes,De),N=Ze.get(ue,k.length),N.init(),k.push(N),Be.enabled===!0&&Be.isPresenting===!0){const Pt=T.xr.getDepthSensingMesh();Pt!==null&&_r(Pt,je,-1/0,T.sortObjects)}_r(ue,je,0,T.sortObjects),N.finish(),T.sortObjects===!0&&N.sort(ne,he),Y=Be.enabled===!1||Be.isPresenting===!1||Be.hasDepthSensing()===!1,Y&&$e.addToRenderList(N,ue),this.info.render.frame++,we===!0&&ye.beginShadows();const Ve=A.state.shadowsArray;if(Ce.render(Ve,ue,je),we===!0&&ye.endShadows(),this.info.autoReset===!0&&this.info.reset(),(qe&&D.hasRenderPass())===!1){const Pt=N.opaque,_t=N.transmissive;if(A.setupLights(),je.isArrayCamera){const pt=je.cameras;if(_t.length>0)for(let St=0,Ot=pt.length;St<Ot;St++){const Ft=pt[St];vt(Pt,_t,ue,Ft)}Y&&$e.render(ue);for(let St=0,Ot=pt.length;St<Ot;St++){const Ft=pt[St];er(N,ue,Ft,Ft.viewport)}}else _t.length>0&&vt(Pt,_t,ue,je),Y&&$e.render(ue),er(N,ue,je)}q!==null&&O===0&&(X.updateMultisampleRenderTarget(q),X.updateRenderTargetMipmap(q)),qe&&D.end(T),ue.isScene===!0&&ue.onAfterRender(T,ue,je),He.resetDefaultState(),j=-1,W=null,C.pop(),C.length>0?(A=C[C.length-1],we===!0&&ye.setGlobalState(T.clippingPlanes,A.state.camera)):A=null,k.pop(),k.length>0?N=k[k.length-1]:N=null};function _r(ue,je,Ge,qe){if(ue.visible===!1)return;if(ue.layers.test(je.layers)){if(ue.isGroup)Ge=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(je);else if(ue.isLight)A.pushLight(ue),ue.castShadow&&A.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||me.intersectsSprite(ue)){qe&&B.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(ee);const Pt=Pe.update(ue),_t=ue.material;_t.visible&&N.push(ue,Pt,_t,Ge,B.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||me.intersectsObject(ue))){const Pt=Pe.update(ue),_t=ue.material;if(qe&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),B.copy(ue.boundingSphere.center)):(Pt.boundingSphere===null&&Pt.computeBoundingSphere(),B.copy(Pt.boundingSphere.center)),B.applyMatrix4(ue.matrixWorld).applyMatrix4(ee)),Array.isArray(_t)){const pt=Pt.groups;for(let St=0,Ot=pt.length;St<Ot;St++){const Ft=pt[St],be=_t[Ft.materialIndex];be&&be.visible&&N.push(ue,Pt,be,Ge,B.z,Ft)}}else _t.visible&&N.push(ue,Pt,_t,Ge,B.z,null)}}const xt=ue.children;for(let Pt=0,_t=xt.length;Pt<_t;Pt++)_r(xt[Pt],je,Ge,qe)}function er(ue,je,Ge,qe){const{opaque:Ve,transmissive:xt,transparent:Pt}=ue;A.setupLightsView(Ge),we===!0&&ye.setGlobalState(T.clippingPlanes,Ge),qe&&Se.viewport(K.copy(qe)),Ve.length>0&&on(Ve,je,Ge),xt.length>0&&on(xt,je,Ge),Pt.length>0&&on(Pt,je,Ge),Se.buffers.depth.setTest(!0),Se.buffers.depth.setMask(!0),Se.buffers.color.setMask(!0),Se.setPolygonOffset(!1)}function vt(ue,je,Ge,qe){if((Ge.isScene===!0?Ge.overrideMaterial:null)!==null)return;if(A.state.transmissionRenderTarget[qe.id]===void 0){const be=Ae.has("EXT_color_buffer_half_float")||Ae.has("EXT_color_buffer_float");A.state.transmissionRenderTarget[qe.id]=new ql(1,1,{generateMipmaps:!0,type:be?bu:zs,minFilter:ff,samples:Le.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Bn.workingColorSpace})}const xt=A.state.transmissionRenderTarget[qe.id],Pt=qe.viewport||K;xt.setSize(Pt.z*T.transmissionResolutionScale,Pt.w*T.transmissionResolutionScale);const _t=T.getRenderTarget(),pt=T.getActiveCubeFace(),St=T.getActiveMipmapLevel();T.setRenderTarget(xt),T.getClearColor(ie),re=T.getClearAlpha(),re<1&&T.setClearColor(16777215,.5),T.clear(),Y&&$e.render(Ge);const Ot=T.toneMapping;T.toneMapping=Wl;const Ft=qe.viewport;if(qe.viewport!==void 0&&(qe.viewport=void 0),A.setupLightsView(qe),we===!0&&ye.setGlobalState(T.clippingPlanes,qe),on(ue,Ge,qe),X.updateMultisampleRenderTarget(xt),X.updateRenderTargetMipmap(xt),Ae.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let kt=0,rn=je.length;kt<rn;kt++){const zt=je[kt],{object:cn,geometry:$t,material:Gt,group:an}=zt;if(Gt.side===Ll&&cn.layers.test(qe.layers)){const wi=Gt.side;Gt.side=bs,Gt.needsUpdate=!0,Nn(cn,Ge,qe,$t,Gt,an),Gt.side=wi,Gt.needsUpdate=!0,be=!0}}be===!0&&(X.updateMultisampleRenderTarget(xt),X.updateRenderTargetMipmap(xt))}T.setRenderTarget(_t,pt,St),T.setClearColor(ie,re),Ft!==void 0&&(qe.viewport=Ft),T.toneMapping=Ot}function on(ue,je,Ge){const qe=je.isScene===!0?je.overrideMaterial:null;for(let Ve=0,xt=ue.length;Ve<xt;Ve++){const Pt=ue[Ve],{object:_t,geometry:pt,group:St}=Pt;let Ot=Pt.material;Ot.allowOverride===!0&&qe!==null&&(Ot=qe),_t.layers.test(Ge.layers)&&Nn(_t,je,Ge,pt,Ot,St)}}function Nn(ue,je,Ge,qe,Ve,xt){ue.onBeforeRender(T,je,Ge,qe,Ve,xt),ue.modelViewMatrix.multiplyMatrices(Ge.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),Ve.onBeforeRender(T,je,Ge,qe,ue,xt),Ve.transparent===!0&&Ve.side===Ll&&Ve.forceSinglePass===!1?(Ve.side=bs,Ve.needsUpdate=!0,T.renderBufferDirect(Ge,je,qe,Ve,ue,xt),Ve.side=Qd,Ve.needsUpdate=!0,T.renderBufferDirect(Ge,je,qe,Ve,ue,xt),Ve.side=Ll):T.renderBufferDirect(Ge,je,qe,Ve,ue,xt),ue.onAfterRender(T,je,Ge,qe,Ve,xt)}function ce(ue,je,Ge){je.isScene!==!0&&(je=te);const qe=L.get(ue),Ve=A.state.lights,xt=A.state.shadowsArray,Pt=Ve.state.version,_t=Xe.getParameters(ue,Ve.state,xt,je,Ge),pt=Xe.getProgramCacheKey(_t);let St=qe.programs;qe.environment=ue.isMeshStandardMaterial?je.environment:null,qe.fog=je.fog,qe.envMap=(ue.isMeshStandardMaterial?_e:xe).get(ue.envMap||qe.environment),qe.envMapRotation=qe.environment!==null&&ue.envMap===null?je.environmentRotation:ue.envMapRotation,St===void 0&&(ue.addEventListener("dispose",nn),St=new Map,qe.programs=St);let Ot=St.get(pt);if(Ot!==void 0){if(qe.currentProgram===Ot&&qe.lightsStateVersion===Pt)return We(ue,_t),Ot}else _t.uniforms=Xe.getUniforms(ue),ue.onBeforeCompile(_t,T),Ot=Xe.acquireProgram(_t,pt),St.set(pt,Ot),qe.uniforms=_t.uniforms;const Ft=qe.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(Ft.clippingPlanes=ye.uniform),We(ue,_t),qe.needsLights=Ct(ue),qe.lightsStateVersion=Pt,qe.needsLights&&(Ft.ambientLightColor.value=Ve.state.ambient,Ft.lightProbe.value=Ve.state.probe,Ft.directionalLights.value=Ve.state.directional,Ft.directionalLightShadows.value=Ve.state.directionalShadow,Ft.spotLights.value=Ve.state.spot,Ft.spotLightShadows.value=Ve.state.spotShadow,Ft.rectAreaLights.value=Ve.state.rectArea,Ft.ltc_1.value=Ve.state.rectAreaLTC1,Ft.ltc_2.value=Ve.state.rectAreaLTC2,Ft.pointLights.value=Ve.state.point,Ft.pointLightShadows.value=Ve.state.pointShadow,Ft.hemisphereLights.value=Ve.state.hemi,Ft.directionalShadowMap.value=Ve.state.directionalShadowMap,Ft.directionalShadowMatrix.value=Ve.state.directionalShadowMatrix,Ft.spotShadowMap.value=Ve.state.spotShadowMap,Ft.spotLightMatrix.value=Ve.state.spotLightMatrix,Ft.spotLightMap.value=Ve.state.spotLightMap,Ft.pointShadowMap.value=Ve.state.pointShadowMap,Ft.pointShadowMatrix.value=Ve.state.pointShadowMatrix),qe.currentProgram=Ot,qe.uniformsList=null,Ot}function Ue(ue){if(ue.uniformsList===null){const je=ue.currentProgram.getUniforms();ue.uniformsList=pw.seqWithValue(je.seq,ue.uniforms)}return ue.uniformsList}function We(ue,je){const Ge=L.get(ue);Ge.outputColorSpace=je.outputColorSpace,Ge.batching=je.batching,Ge.batchingColor=je.batchingColor,Ge.instancing=je.instancing,Ge.instancingColor=je.instancingColor,Ge.instancingMorph=je.instancingMorph,Ge.skinning=je.skinning,Ge.morphTargets=je.morphTargets,Ge.morphNormals=je.morphNormals,Ge.morphColors=je.morphColors,Ge.morphTargetsCount=je.morphTargetsCount,Ge.numClippingPlanes=je.numClippingPlanes,Ge.numIntersection=je.numClipIntersection,Ge.vertexAlphas=je.vertexAlphas,Ge.vertexTangents=je.vertexTangents,Ge.toneMapping=je.toneMapping}function rt(ue,je,Ge,qe,Ve){je.isScene!==!0&&(je=te),X.resetTextureUnits();const xt=je.fog,Pt=qe.isMeshStandardMaterial?je.environment:null,_t=q===null?T.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Cg,pt=(qe.isMeshStandardMaterial?_e:xe).get(qe.envMap||Pt),St=qe.vertexColors===!0&&!!Ge.attributes.color&&Ge.attributes.color.itemSize===4,Ot=!!Ge.attributes.tangent&&(!!qe.normalMap||qe.anisotropy>0),Ft=!!Ge.morphAttributes.position,be=!!Ge.morphAttributes.normal,kt=!!Ge.morphAttributes.color;let rn=Wl;qe.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(rn=T.toneMapping);const zt=Ge.morphAttributes.position||Ge.morphAttributes.normal||Ge.morphAttributes.color,cn=zt!==void 0?zt.length:0,$t=L.get(qe),Gt=A.state.lights;if(we===!0&&(De===!0||ue!==W)){const ra=ue===W&&qe.id===j;ye.setState(qe,ue,ra)}let an=!1;qe.version===$t.__version?($t.needsLights&&$t.lightsStateVersion!==Gt.state.version||$t.outputColorSpace!==_t||Ve.isBatchedMesh&&$t.batching===!1||!Ve.isBatchedMesh&&$t.batching===!0||Ve.isBatchedMesh&&$t.batchingColor===!0&&Ve.colorTexture===null||Ve.isBatchedMesh&&$t.batchingColor===!1&&Ve.colorTexture!==null||Ve.isInstancedMesh&&$t.instancing===!1||!Ve.isInstancedMesh&&$t.instancing===!0||Ve.isSkinnedMesh&&$t.skinning===!1||!Ve.isSkinnedMesh&&$t.skinning===!0||Ve.isInstancedMesh&&$t.instancingColor===!0&&Ve.instanceColor===null||Ve.isInstancedMesh&&$t.instancingColor===!1&&Ve.instanceColor!==null||Ve.isInstancedMesh&&$t.instancingMorph===!0&&Ve.morphTexture===null||Ve.isInstancedMesh&&$t.instancingMorph===!1&&Ve.morphTexture!==null||$t.envMap!==pt||qe.fog===!0&&$t.fog!==xt||$t.numClippingPlanes!==void 0&&($t.numClippingPlanes!==ye.numPlanes||$t.numIntersection!==ye.numIntersection)||$t.vertexAlphas!==St||$t.vertexTangents!==Ot||$t.morphTargets!==Ft||$t.morphNormals!==be||$t.morphColors!==kt||$t.toneMapping!==rn||$t.morphTargetsCount!==cn)&&(an=!0):(an=!0,$t.__version=qe.version);let wi=$t.currentProgram;an===!0&&(wi=ce(qe,je,Ve));let Qs=!1,ta=!1,Js=!1;const tr=wi.getUniforms(),na=$t.uniforms;if(Se.useProgram(wi.program)&&(Qs=!0,ta=!0,Js=!0),qe.id!==j&&(j=qe.id,ta=!0),Qs||W!==ue){Se.buffers.depth.getReversed()&&ue.reversedDepth!==!0&&(ue._reversedDepth=!0,ue.updateProjectionMatrix()),tr.setValue(F,"projectionMatrix",ue.projectionMatrix),tr.setValue(F,"viewMatrix",ue.matrixWorldInverse);const ia=tr.map.cameraPosition;ia!==void 0&&ia.setValue(F,Qe.setFromMatrixPosition(ue.matrixWorld)),Le.logarithmicDepthBuffer&&tr.setValue(F,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(qe.isMeshPhongMaterial||qe.isMeshToonMaterial||qe.isMeshLambertMaterial||qe.isMeshBasicMaterial||qe.isMeshStandardMaterial||qe.isShaderMaterial)&&tr.setValue(F,"isOrthographic",ue.isOrthographicCamera===!0),W!==ue&&(W=ue,ta=!0,Js=!0)}if($t.needsLights&&(Gt.state.directionalShadowMap.length>0&&tr.setValue(F,"directionalShadowMap",Gt.state.directionalShadowMap,X),Gt.state.spotShadowMap.length>0&&tr.setValue(F,"spotShadowMap",Gt.state.spotShadowMap,X),Gt.state.pointShadowMap.length>0&&tr.setValue(F,"pointShadowMap",Gt.state.pointShadowMap,X)),Ve.isSkinnedMesh){tr.setOptional(F,Ve,"bindMatrix"),tr.setOptional(F,Ve,"bindMatrixInverse");const ra=Ve.skeleton;ra&&(ra.boneTexture===null&&ra.computeBoneTexture(),tr.setValue(F,"boneTexture",ra.boneTexture,X))}Ve.isBatchedMesh&&(tr.setOptional(F,Ve,"batchingTexture"),tr.setValue(F,"batchingTexture",Ve._matricesTexture,X),tr.setOptional(F,Ve,"batchingIdTexture"),tr.setValue(F,"batchingIdTexture",Ve._indirectTexture,X),tr.setOptional(F,Ve,"batchingColorTexture"),Ve._colorsTexture!==null&&tr.setValue(F,"batchingColorTexture",Ve._colorsTexture,X));const Si=Ge.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&lt.update(Ve,Ge,wi),(ta||$t.receiveShadow!==Ve.receiveShadow)&&($t.receiveShadow=Ve.receiveShadow,tr.setValue(F,"receiveShadow",Ve.receiveShadow)),qe.isMeshGouraudMaterial&&qe.envMap!==null&&(na.envMap.value=pt,na.flipEnvMap.value=pt.isCubeTexture&&pt.isRenderTargetTexture===!1?-1:1),qe.isMeshStandardMaterial&&qe.envMap===null&&je.environment!==null&&(na.envMapIntensity.value=je.environmentIntensity),na.dfgLUT!==void 0&&(na.dfgLUT.value=gIe()),ta&&(tr.setValue(F,"toneMappingExposure",T.toneMappingExposure),$t.needsLights&&et(na,Js),xt&&qe.fog===!0&&Je.refreshFogUniforms(na,xt),Je.refreshMaterialUniforms(na,qe,Z,V,A.state.transmissionRenderTarget[ue.id]),pw.upload(F,Ue($t),na,X)),qe.isShaderMaterial&&qe.uniformsNeedUpdate===!0&&(pw.upload(F,Ue($t),na,X),qe.uniformsNeedUpdate=!1),qe.isSpriteMaterial&&tr.setValue(F,"center",Ve.center),tr.setValue(F,"modelViewMatrix",Ve.modelViewMatrix),tr.setValue(F,"normalMatrix",Ve.normalMatrix),tr.setValue(F,"modelMatrix",Ve.matrixWorld),qe.isShaderMaterial||qe.isRawShaderMaterial){const ra=qe.uniformsGroups;for(let ia=0,mm=ra.length;ia<mm;ia++){const Io=ra[ia];Oe.update(Io,wi),Oe.bind(Io,wi)}}return wi}function et(ue,je){ue.ambientLightColor.needsUpdate=je,ue.lightProbe.needsUpdate=je,ue.directionalLights.needsUpdate=je,ue.directionalLightShadows.needsUpdate=je,ue.pointLights.needsUpdate=je,ue.pointLightShadows.needsUpdate=je,ue.spotLights.needsUpdate=je,ue.spotLightShadows.needsUpdate=je,ue.rectAreaLights.needsUpdate=je,ue.hemisphereLights.needsUpdate=je}function Ct(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(ue,je,Ge){const qe=L.get(ue);qe.__autoAllocateDepthBuffer=ue.resolveDepthBuffer===!1,qe.__autoAllocateDepthBuffer===!1&&(qe.__useRenderToTexture=!1),L.get(ue.texture).__webglTexture=je,L.get(ue.depthTexture).__webglTexture=qe.__autoAllocateDepthBuffer?void 0:Ge,qe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ue,je){const Ge=L.get(ue);Ge.__webglFramebuffer=je,Ge.__useDefaultFramebuffer=je===void 0};const yt=F.createFramebuffer();this.setRenderTarget=function(ue,je=0,Ge=0){q=ue,U=je,O=Ge;let qe=null,Ve=!1,xt=!1;if(ue){const _t=L.get(ue);if(_t.__useDefaultFramebuffer!==void 0){Se.bindFramebuffer(F.FRAMEBUFFER,_t.__webglFramebuffer),K.copy(ue.viewport),G.copy(ue.scissor),J=ue.scissorTest,Se.viewport(K),Se.scissor(G),Se.setScissorTest(J),j=-1;return}else if(_t.__webglFramebuffer===void 0)X.setupRenderTarget(ue);else if(_t.__hasExternalTextures)X.rebindTextures(ue,L.get(ue.texture).__webglTexture,L.get(ue.depthTexture).__webglTexture);else if(ue.depthBuffer){const Ot=ue.depthTexture;if(_t.__boundDepthTexture!==Ot){if(Ot!==null&&L.has(Ot)&&(ue.width!==Ot.image.width||ue.height!==Ot.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(ue)}}const pt=ue.texture;(pt.isData3DTexture||pt.isDataArrayTexture||pt.isCompressedArrayTexture)&&(xt=!0);const St=L.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(St[je])?qe=St[je][Ge]:qe=St[je],Ve=!0):ue.samples>0&&X.useMultisampledRTT(ue)===!1?qe=L.get(ue).__webglMultisampledFramebuffer:Array.isArray(St)?qe=St[Ge]:qe=St,K.copy(ue.viewport),G.copy(ue.scissor),J=ue.scissorTest}else K.copy(fe).multiplyScalar(Z).floor(),G.copy(le).multiplyScalar(Z).floor(),J=Ee;if(Ge!==0&&(qe=yt),Se.bindFramebuffer(F.FRAMEBUFFER,qe)&&Se.drawBuffers(ue,qe),Se.viewport(K),Se.scissor(G),Se.setScissorTest(J),Ve){const _t=L.get(ue.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+je,_t.__webglTexture,Ge)}else if(xt){const _t=je;for(let pt=0;pt<ue.textures.length;pt++){const St=L.get(ue.textures[pt]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+pt,St.__webglTexture,Ge,_t)}}else if(ue!==null&&Ge!==0){const _t=L.get(ue.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,_t.__webglTexture,Ge)}j=-1},this.readRenderTargetPixels=function(ue,je,Ge,qe,Ve,xt,Pt,_t=0){if(!(ue&&ue.isWebGLRenderTarget)){Vn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=L.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Pt!==void 0&&(pt=pt[Pt]),pt){Se.bindFramebuffer(F.FRAMEBUFFER,pt);try{const St=ue.textures[_t],Ot=St.format,Ft=St.type;if(!Le.textureFormatReadable(Ot)){Vn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Le.textureTypeReadable(Ft)){Vn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}je>=0&&je<=ue.width-qe&&Ge>=0&&Ge<=ue.height-Ve&&(ue.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+_t),F.readPixels(je,Ge,qe,Ve,ve.convert(Ot),ve.convert(Ft),xt))}finally{const St=q!==null?L.get(q).__webglFramebuffer:null;Se.bindFramebuffer(F.FRAMEBUFFER,St)}}},this.readRenderTargetPixelsAsync=async function(ue,je,Ge,qe,Ve,xt,Pt,_t=0){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let pt=L.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&Pt!==void 0&&(pt=pt[Pt]),pt)if(je>=0&&je<=ue.width-qe&&Ge>=0&&Ge<=ue.height-Ve){Se.bindFramebuffer(F.FRAMEBUFFER,pt);const St=ue.textures[_t],Ot=St.format,Ft=St.type;if(!Le.textureFormatReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Le.textureTypeReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,be),F.bufferData(F.PIXEL_PACK_BUFFER,xt.byteLength,F.STREAM_READ),ue.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+_t),F.readPixels(je,Ge,qe,Ve,ve.convert(Ot),ve.convert(Ft),0);const kt=q!==null?L.get(q).__webglFramebuffer:null;Se.bindFramebuffer(F.FRAMEBUFFER,kt);const rn=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await P3e(F,rn,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,be),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,xt),F.deleteBuffer(be),F.deleteSync(rn),xt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ue,je=null,Ge=0){const qe=Math.pow(2,-Ge),Ve=Math.floor(ue.image.width*qe),xt=Math.floor(ue.image.height*qe),Pt=je!==null?je.x:0,_t=je!==null?je.y:0;X.setTexture2D(ue,0),F.copyTexSubImage2D(F.TEXTURE_2D,Ge,0,0,Pt,_t,Ve,xt),Se.unbindTexture()};const Mt=F.createFramebuffer(),Vt=F.createFramebuffer();this.copyTextureToTexture=function(ue,je,Ge=null,qe=null,Ve=0,xt=null){xt===null&&(Ve!==0?(K0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),xt=Ve,Ve=0):xt=0);let Pt,_t,pt,St,Ot,Ft,be,kt,rn;const zt=ue.isCompressedTexture?ue.mipmaps[xt]:ue.image;if(Ge!==null)Pt=Ge.max.x-Ge.min.x,_t=Ge.max.y-Ge.min.y,pt=Ge.isBox3?Ge.max.z-Ge.min.z:1,St=Ge.min.x,Ot=Ge.min.y,Ft=Ge.isBox3?Ge.min.z:0;else{const Si=Math.pow(2,-Ve);Pt=Math.floor(zt.width*Si),_t=Math.floor(zt.height*Si),ue.isDataArrayTexture?pt=zt.depth:ue.isData3DTexture?pt=Math.floor(zt.depth*Si):pt=1,St=0,Ot=0,Ft=0}qe!==null?(be=qe.x,kt=qe.y,rn=qe.z):(be=0,kt=0,rn=0);const cn=ve.convert(je.format),$t=ve.convert(je.type);let Gt;je.isData3DTexture?(X.setTexture3D(je,0),Gt=F.TEXTURE_3D):je.isDataArrayTexture||je.isCompressedArrayTexture?(X.setTexture2DArray(je,0),Gt=F.TEXTURE_2D_ARRAY):(X.setTexture2D(je,0),Gt=F.TEXTURE_2D),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,je.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,je.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,je.unpackAlignment);const an=F.getParameter(F.UNPACK_ROW_LENGTH),wi=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Qs=F.getParameter(F.UNPACK_SKIP_PIXELS),ta=F.getParameter(F.UNPACK_SKIP_ROWS),Js=F.getParameter(F.UNPACK_SKIP_IMAGES);F.pixelStorei(F.UNPACK_ROW_LENGTH,zt.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,zt.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,St),F.pixelStorei(F.UNPACK_SKIP_ROWS,Ot),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Ft);const tr=ue.isDataArrayTexture||ue.isData3DTexture,na=je.isDataArrayTexture||je.isData3DTexture;if(ue.isDepthTexture){const Si=L.get(ue),ra=L.get(je),ia=L.get(Si.__renderTarget),mm=L.get(ra.__renderTarget);Se.bindFramebuffer(F.READ_FRAMEBUFFER,ia.__webglFramebuffer),Se.bindFramebuffer(F.DRAW_FRAMEBUFFER,mm.__webglFramebuffer);for(let Io=0;Io<pt;Io++)tr&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,L.get(ue).__webglTexture,Ve,Ft+Io),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,L.get(je).__webglTexture,xt,rn+Io)),F.blitFramebuffer(St,Ot,Pt,_t,be,kt,Pt,_t,F.DEPTH_BUFFER_BIT,F.NEAREST);Se.bindFramebuffer(F.READ_FRAMEBUFFER,null),Se.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(Ve!==0||ue.isRenderTargetTexture||L.has(ue)){const Si=L.get(ue),ra=L.get(je);Se.bindFramebuffer(F.READ_FRAMEBUFFER,Mt),Se.bindFramebuffer(F.DRAW_FRAMEBUFFER,Vt);for(let ia=0;ia<pt;ia++)tr?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,Si.__webglTexture,Ve,Ft+ia):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,Si.__webglTexture,Ve),na?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,ra.__webglTexture,xt,rn+ia):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,ra.__webglTexture,xt),Ve!==0?F.blitFramebuffer(St,Ot,Pt,_t,be,kt,Pt,_t,F.COLOR_BUFFER_BIT,F.NEAREST):na?F.copyTexSubImage3D(Gt,xt,be,kt,rn+ia,St,Ot,Pt,_t):F.copyTexSubImage2D(Gt,xt,be,kt,St,Ot,Pt,_t);Se.bindFramebuffer(F.READ_FRAMEBUFFER,null),Se.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else na?ue.isDataTexture||ue.isData3DTexture?F.texSubImage3D(Gt,xt,be,kt,rn,Pt,_t,pt,cn,$t,zt.data):je.isCompressedArrayTexture?F.compressedTexSubImage3D(Gt,xt,be,kt,rn,Pt,_t,pt,cn,zt.data):F.texSubImage3D(Gt,xt,be,kt,rn,Pt,_t,pt,cn,$t,zt):ue.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,xt,be,kt,Pt,_t,cn,$t,zt.data):ue.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,xt,be,kt,zt.width,zt.height,cn,zt.data):F.texSubImage2D(F.TEXTURE_2D,xt,be,kt,Pt,_t,cn,$t,zt);F.pixelStorei(F.UNPACK_ROW_LENGTH,an),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,wi),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Qs),F.pixelStorei(F.UNPACK_SKIP_ROWS,ta),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Js),xt===0&&je.generateMipmaps&&F.generateMipmap(Gt),Se.unbindTexture()},this.initRenderTarget=function(ue){L.get(ue).__webglFramebuffer===void 0&&X.setupRenderTarget(ue)},this.initTexture=function(ue){ue.isCubeTexture?X.setTextureCube(ue,0):ue.isData3DTexture?X.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?X.setTexture2DArray(ue,0):X.setTexture2D(ue,0),Se.unbindTexture()},this.resetState=function(){U=0,O=0,q=null,Se.reset(),He.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $l}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Bn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Bn._getUnpackColorSpace()}};const yG={type:"change"},uL={type:"start"},Dee={type:"end"},J_=new iL,vG=new gd,bIe=Math.cos(70*D3e.DEG2RAD),Ei=new nt,ds=2*Math.PI,fr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Mk=1e-6;class yIe extends _Re{constructor(e,n=null){super(e,n),this.state=fr.NONE,this.target=new nt,this.cursor=new nt,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:rg.ROTATE,MIDDLE:rg.DOLLY,RIGHT:rg.PAN},this.touches={ONE:Kp.ROTATE,TWO:Kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new nt,this._lastQuaternion=new Zf,this._lastTargetPosition=new nt,this._quat=new Zf().setFromUnitVectors(e.up,new nt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new KV,this._sphericalDelta=new KV,this._scale=1,this._panOffset=new nt,this._rotateStart=new Mn,this._rotateEnd=new Mn,this._rotateDelta=new Mn,this._panStart=new Mn,this._panEnd=new Mn,this._panDelta=new Mn,this._dollyStart=new Mn,this._dollyEnd=new Mn,this._dollyDelta=new Mn,this._dollyDirection=new nt,this._mouse=new Mn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=_Ie.bind(this),this._onPointerDown=vIe.bind(this),this._onPointerUp=wIe.bind(this),this._onContextMenu=CIe.bind(this),this._onMouseWheel=EIe.bind(this),this._onKeyDown=NIe.bind(this),this._onTouchStart=AIe.bind(this),this._onTouchMove=TIe.bind(this),this._onMouseDown=SIe.bind(this),this._onMouseMove=MIe.bind(this),this._interceptControlDown=kIe.bind(this),this._interceptControlUp=jIe.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.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.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(yG),this.update(),this.state=fr.NONE}update(e=null){const n=this.object.position;Ei.copy(n).sub(this.target),Ei.applyQuaternion(this._quat),this._spherical.setFromVector3(Ei),this.autoRotate&&this.state===fr.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+=ds:r>Math.PI&&(r-=ds),i<-Math.PI?i+=ds:i>Math.PI&&(i-=ds),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(Ei.setFromSpherical(this._spherical),Ei.applyQuaternion(this._quatInverse),n.copy(this.target).add(Ei),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=Ei.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 nt(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 nt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Ei.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):(J_.origin.copy(this.object.position),J_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(J_.direction))<bIe?this.object.lookAt(this.target):(vG.setFromNormalAndCoplanarPoint(this.object.up,this.target),J_.intersectPlane(vG,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)>Mk||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Mk||this._lastTargetPosition.distanceToSquared(this.target)>Mk?(this.dispatchEvent(yG),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ds/60*this.autoRotateSpeed*e:ds/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){Ei.setFromMatrixColumn(n,0),Ei.multiplyScalar(-e),this._panOffset.add(Ei)}_panUp(e,n){this.screenSpacePanning===!0?Ei.setFromMatrixColumn(n,1):(Ei.setFromMatrixColumn(n,0),Ei.crossVectors(this.object.up,Ei)),Ei.multiplyScalar(e),this._panOffset.add(Ei)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ei.copy(i).sub(this.target);let a=Ei.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(ds*this._rotateDelta.x/n.clientHeight),this._rotateUp(ds*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(ds*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(-ds*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(ds*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(-ds*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(ds*this._rotateDelta.x/n.clientHeight),this._rotateUp(ds*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 Mn,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 vIe(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function _Ie(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function wIe(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Dee),this.state=fr.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 SIe(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 rg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=fr.DOLLY;break;case rg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=fr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=fr.ROTATE}break;case rg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=fr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=fr.PAN}break;default:this.state=fr.NONE}this.state!==fr.NONE&&this.dispatchEvent(uL)}function MIe(t){switch(this.state){case fr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case fr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case fr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function EIe(t){this.enabled===!1||this.enableZoom===!1||this.state!==fr.NONE||(t.preventDefault(),this.dispatchEvent(uL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(Dee))}function NIe(t){this.enabled!==!1&&this._handleKeyDown(t)}function AIe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=fr.TOUCH_ROTATE;break;case Kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=fr.TOUCH_PAN;break;default:this.state=fr.NONE}break;case 2:switch(this.touches.TWO){case Kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=fr.TOUCH_DOLLY_PAN;break;case Kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=fr.TOUCH_DOLLY_ROTATE;break;default:this.state=fr.NONE}break;default:this.state=fr.NONE}this.state!==fr.NONE&&this.dispatchEvent(uL)}function TIe(t){switch(this._trackPointer(t),this.state){case fr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case fr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case fr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case fr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=fr.NONE}}function CIe(t){this.enabled!==!1&&t.preventDefault()}function kIe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function jIe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function PIe(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 bl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=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 p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),m++}if(m!==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 p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=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,p,d),u+=p}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const p=t[m].index;for(let b=0;b<p.count;++b)f.push(p.getX(b)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=_G(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 m=0;m<f;++m){const p=[];for(let y=0;y<o[d].length;++y)p.push(o[d][y][m]);const b=_G(p);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 _G(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 Ao(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 m=0,p=d.count;m<p;m++)for(let b=0;b<n;b++){const y=d.getComponent(m,b);l.setComponent(m+f,b,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function e1(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 Ek={exports:{}};var wG;function RIe(){return wG||(wG=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 e1=="function"&&e1;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(b){var y=r[u][1][b];return o(y||b)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof e1=="function"&&e1,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,m,p,b,y,x=[],v=0,S=c.length,M=S,N=a.getTypeOf(c)!=="string";v<c.length;)M=S-v,f=N?(u=c[v++],d=v<S?c[v++]:0,v<S?c[v++]:0):(u=c.charCodeAt(v++),d=v<S?c.charCodeAt(v++):0,v<S?c.charCodeAt(v++):0),m=u>>2,p=(3&u)<<4|d>>4,b=1<M?(15&d)<<2|f>>6:64,y=2<M?63&f:64,x.push(l.charAt(m)+l.charAt(p)+l.charAt(b)+l.charAt(y));return x.join("")},i.decode=function(c){var u,d,f,m,p,b,y=0,x=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var S,M=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&M--,c.charAt(c.length-2)===l.charAt(64)&&M--,M%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|M):new Array(0|M);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(m=l.indexOf(c.charAt(y++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(y++)))>>2,f=(3&p)<<6|(b=l.indexOf(c.charAt(y++))),S[x++]=u,p!==64&&(S[x++]=d),b!==64&&(S[x++]=f);return S}},{"./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,m,p,b){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=p,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,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).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,m){var p=o,b=m+f;u^=-1;for(var y=m;y<b;y++)u=u>>>8^p[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,b=m+f;u^=-1;for(var y=m;y<b;y++)u=u>>>8^p[255&(u^d.charCodeAt(y))];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,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,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(m){f.push({data:m,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(p,b){var y,x="";for(y=0;y<b;y++)x+=String.fromCharCode(255&p),p>>>=8;return x}function o(p,b,y,x,v,S){var M,N,A=p.file,k=p.compression,C=S!==u.utf8encode,D=l.transformTo("string",S(A.name)),T=l.transformTo("string",u.utf8encode(A.name)),R=A.comment,U=l.transformTo("string",S(R)),O=l.transformTo("string",u.utf8encode(R)),q=T.length!==A.name.length,j=O.length!==R.length,W="",K="",G="",J=A.dir,ie=A.date,re={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(re.crc32=p.crc32,re.compressedSize=p.compressedSize,re.uncompressedSize=p.uncompressedSize);var z=0;b&&(z|=8),C||!q&&!j||(z|=2048);var V=0,Z=0;J&&(V|=16),v==="UNIX"?(Z=798,V|=(function(he,fe){var le=he;return he||(le=fe?16893:33204),(65535&le)<<16})(A.unixPermissions,J)):(Z=20,V|=(function(he){return 63&(he||0)})(A.dosPermissions)),M=ie.getUTCHours(),M<<=6,M|=ie.getUTCMinutes(),M<<=5,M|=ie.getUTCSeconds()/2,N=ie.getUTCFullYear()-1980,N<<=4,N|=ie.getUTCMonth()+1,N<<=5,N|=ie.getUTCDate(),q&&(K=a(1,1)+a(d(D),4)+T,W+="up"+a(K.length,2)+K),j&&(G=a(1,1)+a(d(U),4)+O,W+="uc"+a(G.length,2)+G);var ne="";return ne+=`
  3967. \0`,ne+=a(z,2),ne+=k.magic,ne+=a(M,2),ne+=a(N,2),ne+=a(re.crc32,4),ne+=a(re.compressedSize,4),ne+=a(re.uncompressedSize,4),ne+=a(D.length,2),ne+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ne+D+W,dirRecord:f.CENTRAL_FILE_HEADER+a(Z,2)+ne+a(U.length,2)+"\0\0\0\0"+a(V,4)+a(x,4)+D+W+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,b,y,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=x,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var b=p.meta.percent||0,y=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-x-1))/y:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var b=this.streamFiles&&!p.file.dir;if(b){var y=o(p,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var b=this.streamFiles&&!p.file.dir,y=o(p,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-p,x=(function(v,S,M,N,A){var k=l.transformTo("string",A(N));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(S,4)+a(M,4)+a(k.length,2)+k})(this.dirRecords.length,y,p,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var b=this;return p.on("data",function(y){b.processChunk(y)}),p.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),p.on("error",function(y){b.error(y)}),this},m.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))},m.prototype.error=function(p){var b=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var y=0;y<b.length;y++)try{b[y].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,b=0;b<p.length;b++)p[b].lock()},r.exports=m},{"../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(m,p){f++;var b=(function(S,M){var N=S||M,A=a[N];if(!A)throw new Error(N+" is not a valid compression method !");return A})(p.options.compression,c.compression),y=p.options.compressionOptions||c.compressionOptions||{},x=p.dir,v=p.date;p._compressWorker(b,y).withStreamInfo("file",{name:m,dir:x,date:v,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}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(m){return new o.Promise(function(p,b){var y=m.decompressed.getContentWorker().pipe(new u);y.on("error",function(x){b(x)}).on("end",function(){y.streamInfo.crc32!==m.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var b=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(y){var x=new c(p);return x.load(y),x}).then(function(y){var x=[o.Promise.resolve(y)],v=y.files;if(p.checkCRC32)for(var S=0;S<v.length;S++)x.push(f(v[S]));return o.Promise.all(x)}).then(function(y){for(var x=y.shift(),v=x.files,S=0;S<v.length;S++){var M=v[S],N=M.fileNameStr,A=a.resolve(M.fileNameStr);b.file(A,M.decompressed,{binary:!0,optimizedBinaryString:!0,date:M.date,dir:M.dir,comment:M.fileCommentStr.length?M.fileCommentStr:null,unixPermissions:M.unixPermissions,dosPermissions:M.dosPermissions,createFolders:p.createFolders}),M.dir||(b.file(A).unsafeOriginalName=N)}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,m){d.push(f)||d._helper.pause(),u&&u(m)}).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(A,k,C){var D,T=l.getTypeOf(k),R=l.extend(C||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(A=v(A)),R.createFolders&&(D=x(A))&&S.call(this,D,!0);var U=T==="string"&&R.binary===!1&&R.base64===!1;C&&C.binary!==void 0||(R.binary=!U),(k instanceof f&&k.uncompressedSize===0||R.dir||!k||k.length===0)&&(R.base64=!1,R.binary=!0,k="",R.compression="STORE",T="string");var O=null;O=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new y(A,k):l.prepareContent(A,k,R.binary,R.optimizedBinaryString,R.base64);var q=new m(A,O,R);this.files[A]=q}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),p=n("./generate"),b=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),x=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var k=A.lastIndexOf("/");return 0<k?A.substring(0,k):""},v=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},S=function(A,k){return k=k!==void 0?k:d.createFolders,A=v(A),this.files[A]||a.call(this,A,null,{dir:!0,createFolders:k}),this.files[A]};function M(A){return Object.prototype.toString.call(A)==="[object RegExp]"}var N={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var k,C,D;for(k in this.files)D=this.files[k],(C=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&A(C,D)},filter:function(A){var k=[];return this.forEach(function(C,D){A(C,D)&&k.push(D)}),k},file:function(A,k,C){if(arguments.length!==1)return A=this.root+A,a.call(this,A,k,C),this;if(M(A)){var D=A;return this.filter(function(R,U){return!U.dir&&D.test(R)})}var T=this.files[this.root+A];return T&&!T.dir?T:null},folder:function(A){if(!A)return this;if(M(A))return this.filter(function(T,R){return R.dir&&A.test(T)});var k=this.root+A,C=S.call(this,k),D=this.clone();return D.root=C.name,D},remove:function(A){A=this.root+A;var k=this.files[A];if(k||(A.slice(-1)!=="/"&&(A+="/"),k=this.files[A]),k&&!k.dir)delete this.files[A];else for(var C=this.filter(function(T,R){return R.name.slice(0,A.length)===A}),D=0;D<C.length;D++)delete this.files[C[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(A){var k,C={};try{if((C=l.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var D=C.comment||this.comment||"";k=p.generateWorker(this,C,D)}catch(T){(k=new c("error")).error(T)}return new u(k,C.type||"string",C.mimeType)},generateAsync:function(A,k){return this.generateInternalStream(A).accumulate(k)},generateNodeStream:function(A,k){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(k)}};r.exports=N},{"./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),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-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),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[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 m=a.getTypeOf(f);return a.checkSupport(m),m!=="string"||o.uint8array?m==="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 m(b,y){return new d.Promise(function(x,v){var S=[],M=b._internalType,N=b._outputType,A=b._mimeType;b.on("data",function(k,C){S.push(k),y&&y(C)}).on("error",function(k){S=[],v(k)}).on("end",function(){try{var k=(function(C,D,T){switch(C){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),T);case"base64":return c.encode(D);default:return a.transformTo(C,D)}})(N,(function(C,D){var T,R=0,U=null,O=0;for(T=0;T<D.length;T++)O+=D[T].length;switch(C){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(U=new Uint8Array(O),T=0;T<D.length;T++)U.set(D[T],R),R+=D[T].length;return U;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+C+"'")}})(M,S),A);x(k)}catch(C){v(C)}S=[]}).resume()})}function p(b,y,x){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=x,a.checkSupport(v),this._worker=b.pipe(new o(v)),b.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}p.prototype={accumulate:function(b){return m(this,b)},on:function(b,y){var x=this;return b==="data"?this._worker.on(b,function(v){y.call(x,v.data,v.meta)}):this._worker.on(b,function(){a.delay(y,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=p},{"../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 m(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(b){var y,x,v,S,M,N=b.length,A=0;for(S=0;S<N;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<N&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),A+=x<128?1:x<2048?2:x<65536?3:4;for(y=o.uint8array?new Uint8Array(A):new Array(A),S=M=0;M<A;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<N&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),x<128?y[M++]=x:(x<2048?y[M++]=192|x>>>6:(x<65536?y[M++]=224|x>>>12:(y[M++]=240|x>>>18,y[M++]=128|x>>>12&63),y[M++]=128|x>>>6&63),y[M++]=128|63&x);return y})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(b){var y,x,v,S,M=b.length,N=new Array(2*M);for(y=x=0;y<M;)if((v=b[y++])<128)N[x++]=v;else if(4<(S=u[v]))N[x++]=65533,y+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&y<M;)v=v<<6|63&b[y++],S--;1<S?N[x++]=65533:v<65536?N[x++]=v:(v-=65536,N[x++]=55296|v>>10&1023,N[x++]=56320|1023&v)}return N.length!==x&&(N.subarray?N=N.subarray(0,x):N.length=x),a.applyFromCharCode(N)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var b=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(function(S,M){var N;for((M=M||S.length)>S.length&&(M=S.length),N=M-1;0<=N&&(192&S[N])==128;)N--;return N<0||N===0?M:N+u[S[N]]>M?N:M})(b),v=b;x!==b.length&&(o.uint8array?(v=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(v=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(v),meta:p.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(m,c),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./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(y){return y}function d(y,x){for(var v=0;v<y.length;++v)x[v]=255&y.charCodeAt(v);return x}n("setimmediate"),i.newBlob=function(y,x){i.checkSupport("blob");try{return new Blob([y],{type:x})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,x,v){var S=[],M=0,N=y.length;if(N<=v)return String.fromCharCode.apply(null,y);for(;M<N;)x==="array"||x==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(M,Math.min(M+v,N)))):S.push(String.fromCharCode.apply(null,y.subarray(M,Math.min(M+v,N)))),M+=v;return S.join("")},stringifyByChar:function(y){for(var x="",v=0;v<y.length;v++)x+=String.fromCharCode(y[v]);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 m(y){var x=65536,v=i.getTypeOf(y),S=!0;if(v==="uint8array"?S=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<x;)try{return f.stringifyByChunk(y,v,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(y)}function p(y,x){for(var v=0;v<y.length;v++)x[v]=y[v];return x}i.applyFromCharCode=m;var b={};b.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},b.array={string:m,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},b.arraybuffer={string:function(y){return m(new Uint8Array(y))},array:function(y){return p(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},b.nodebuffer={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return p(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,x){if(x=x||"",!y)return x;i.checkSupport(y);var v=i.getTypeOf(x);return b[v][y](x)},i.resolve=function(y){for(var x=y.split("/"),v=[],S=0;S<x.length;S++){var M=x[S];M==="."||M===""&&S!==0&&S!==x.length-1||(M===".."?v.pop():v.push(M))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var x,v,S="";for(v=0;v<(y||"").length;v++)S+="\\x"+((x=y.charCodeAt(v))<16?"0":"")+x.toString(16).toUpperCase();return S},i.delay=function(y,x,v){setImmediate(function(){y.apply(v||null,x||[])})},i.inherits=function(y,x){function v(){}v.prototype=x.prototype,y.prototype=new v},i.extend=function(){var y,x,v={};for(y=0;y<arguments.length;y++)for(x in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],x)&&v[x]===void 0&&(v[x]=arguments[y][x]);return v},i.prepareContent=function(y,x,v,S,M){return c.Promise.resolve(x).then(function(N){return a.blob&&(N instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(N))!==-1)&&typeof FileReader<"u"?new c.Promise(function(A,k){var C=new FileReader;C.onload=function(D){A(D.target.result)},C.onerror=function(D){k(D.target.error)},C.readAsArrayBuffer(N)}):N}).then(function(N){var A=i.getTypeOf(N);return A?(A==="arraybuffer"?N=i.transformTo("uint8array",N):A==="string"&&(M?N=o.decode(N):v&&S!==!0&&(N=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(N))),N):c.Promise.reject(new Error("Can't read the data of '"+y+"'. 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 m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var p=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===m;return this.reader.setIndex(p),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),m=u.uint8array?"uint8array":"array",p=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,m,p,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.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 m=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 p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var b=m-p;if(0<b)this.isSignature(m,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 m(p,b){this.options=p,this.loadOptions=b}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var b,y;if(p.skip(22),this.fileNameLength=p.readInt(2),y=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(y),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 v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===x)return d[v];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,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var b=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(b),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var b,y,x,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)b=p.readInt(2),y=p.readInt(2),x=p.readData(y),this.extraFields[b]={id:b,length:y,value:x};p.setIndex(v)},handleUTF8:function(){var p=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 y=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(b,y,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=y,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 y=null,x="string";try{if(!b)throw new Error("No output type specified.");var v=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),y=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!S&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(M){(y=new d("error")).error(M)}return new o(y,x,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){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,y)},_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"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=m;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 y=a.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(b,0)};else{var m=new a.MessageChannel;m.port1.onmessage=b,o=function(){m.port2.postMessage(0)}}var p=[];function b(){var y,x;l=!0;for(var v=p.length;v;){for(x=p,p=[],y=-1;++y<v;)x[y]();v=p.length}l=!1}r.exports=function(y){p.push(y)!==1||l||o()}}).call(this,typeof c_<"u"?c_: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(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function m(v,S,M){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof M=="function"&&(this.onRejected=M,this.callRejected=this.otherCallRejected)}function p(v,S,M){a(function(){var N;try{N=S(M)}catch(A){return l.reject(v,A)}N===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,N)})}function b(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function y(v,S){var M=!1;function N(C){M||(M=!0,l.reject(v,C))}function A(C){M||(M=!0,l.resolve(v,C))}var k=x(function(){S(A,N)});k.status==="error"&&N(k.value)}function x(v,S){var M={};try{M.value=v(S),M.status="success"}catch(N){M.status="error",M.value=N}return M}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(M){return S.resolve(v()).then(function(){return M})},function(M){return S.resolve(v()).then(function(){throw M})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var M=new this.constructor(o);return this.state!==d?p(M,this.state===u?v:S,this.outcome):this.queue.push(new m(M,v,S)),M},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,S){var M=x(b,S);if(M.status==="error")return l.reject(v,M.value);var N=M.value;if(N)y(v,N);else{v.state=u,v.outcome=S;for(var A=-1,k=v.queue.length;++A<k;)v.queue[A].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var M=-1,N=v.queue.length;++M<N;)v.queue[M].callRejected(S);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var S=new this(o);return l.reject(S,v)},f.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=v.length,N=!1;if(!M)return this.resolve([]);for(var A=new Array(M),k=0,C=-1,D=new this(o);++C<M;)T(v[C],C);return D;function T(R,U){S.resolve(R).then(function(O){A[U]=O,++k!==M||N||(N=!0,l.resolve(D,A))},function(O){N||(N=!0,l.reject(D,O))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=v.length,N=!1;if(!M)return this.resolve([]);for(var A=-1,k=new this(o);++A<M;)C=v[A],S.resolve(C).then(function(D){N||(N=!0,l.resolve(k,D))},function(D){N||(N=!0,l.reject(k,D))});var C;return k}},{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,m=-1,p=0,b=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:m,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var M=a.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(M!==f)throw new Error(c[M]);if(S.header&&a.deflateSetHeader(this.strm,S.header),S.dictionary){var N;if(N=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(M=a.deflateSetDictionary(this.strm,N))!==f)throw new Error(c[M]);this._dict_set=!0}}function x(v,S){var M=new y(S);if(M.push(v,!0),M.err)throw M.msg||c[M.err];return M.result}y.prototype.push=function(v,S){var M,N,A=this.strm,k=this.options.chunkSize;if(this.ended)return!1;N=S===~~S?S:S===!0?4:0,typeof v=="string"?A.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?A.input=new Uint8Array(v):A.input=v,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(k),A.next_out=0,A.avail_out=k),(M=a.deflate(A,N))!==1&&M!==f)return this.onEnd(M),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||N!==4&&N!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(A.output,A.next_out))):this.onData(o.shrinkBuf(A.output,A.next_out)))}while((0<A.avail_in||A.avail_out===0)&&M!==1);return N===4?(M=a.deflateEnd(this.strm),this.onEnd(M),this.ended=!0,M===f):N!==2||(this.onEnd(f),!(A.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===f&&(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.Deflate=y,i.deflate=x,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,x(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,x(v,S)}},{"./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"),m=Object.prototype.toString;function p(y){if(!(this instanceof p))return new p(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});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)||y&&y.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 v=a.inflateInit2(this.strm,x.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(y,x){var v=new p(x);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(y,x){var v,S,M,N,A,k,C=this.strm,D=this.options.chunkSize,T=this.options.dictionary,R=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?C.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(D),C.next_out=0,C.avail_out=D),(v=a.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(k=typeof T=="string"?l.string2buf(T):m.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,v=a.inflateSetDictionary(this.strm,k)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&v!==c.Z_STREAM_END&&(C.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(M=l.utf8border(C.output,C.next_out),N=C.next_out-M,A=l.buf2string(C.output,M),C.next_out=N,C.avail_out=D-N,N&&o.arraySet(C.output,C.output,M,N,0),this.onData(A)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(R=!0)}while((0<C.avail_in||C.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},p.prototype.onData=function(y){this.chunks.push(y)},p.prototype.onEnd=function(y){y===c.Z_OK&&(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.Inflate=p,i.inflate=b,i.inflateRaw=function(y,x){return(x=x||{}).raw=!0,b(y,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,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){var u,d,f,m,p,b;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(b=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)p=c[u],b.set(p,m),m+=p.length;return b}},l={arraySet:function(c,u,d,f,m){for(var p=0;p<f;p++)c[m+p]=u[d+p]},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,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,m));for(var p="",b=0;b<m;b++)p+=String.fromCharCode(f[b]);return p}c[254]=c[254]=1,i.string2buf=function(f){var m,p,b,y,x,v=f.length,S=0;for(y=0;y<v;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),y++),S+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(S),y=x=0;x<S;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),y++),p<128?m[x++]=p:(p<2048?m[x++]=192|p>>>6:(p<65536?m[x++]=224|p>>>12:(m[x++]=240|p>>>18,m[x++]=128|p>>>12&63),m[x++]=128|p>>>6&63),m[x++]=128|63&p);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new a.Buf8(f.length),p=0,b=m.length;p<b;p++)m[p]=f.charCodeAt(p);return m},i.buf2string=function(f,m){var p,b,y,x,v=m||f.length,S=new Array(2*v);for(p=b=0;p<v;)if((y=f[p++])<128)S[b++]=y;else if(4<(x=c[y]))S[b++]=65533,p+=x-1;else{for(y&=x===2?31:x===3?15:7;1<x&&p<v;)y=y<<6|63&f[p++],x--;1<x?S[b++]=65533:y<65536?S[b++]=y:(y-=65536,S[b++]=55296|y>>10&1023,S[b++]=56320|1023&y)}return d(S,b)},i.utf8border=function(f,m){var p;for((m=m||f.length)>f.length&&(m=f.length),p=m-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?m:p+c[f[p]]>m?p:m}},{"./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 m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];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,m=4,p=0,b=-2,y=-1,x=4,v=2,S=8,M=9,N=286,A=30,k=19,C=2*N+1,D=15,T=3,R=258,U=R+T+1,O=42,q=113,j=1,W=2,K=3,G=4;function J(B,te){return B.msg=d[te],te}function ie(B){return(B<<1)-(4<B?9:0)}function re(B){for(var te=B.length;0<=--te;)B[te]=0}function z(B){var te=B.state,Y=te.pending;Y>B.avail_out&&(Y=B.avail_out),Y!==0&&(o.arraySet(B.output,te.pending_buf,te.pending_out,Y,B.next_out),B.next_out+=Y,te.pending_out+=Y,B.total_out+=Y,B.avail_out-=Y,te.pending-=Y,te.pending===0&&(te.pending_out=0))}function V(B,te){l._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,te),B.block_start=B.strstart,z(B.strm)}function Z(B,te){B.pending_buf[B.pending++]=te}function ne(B,te){B.pending_buf[B.pending++]=te>>>8&255,B.pending_buf[B.pending++]=255&te}function he(B,te){var Y,H,F=B.max_chain_length,de=B.strstart,Ae=B.prev_length,Le=B.nice_match,Se=B.strstart>B.w_size-U?B.strstart-(B.w_size-U):0,$=B.window,L=B.w_mask,X=B.prev,xe=B.strstart+R,_e=$[de+Ae-1],ae=$[de+Ae];B.prev_length>=B.good_match&&(F>>=2),Le>B.lookahead&&(Le=B.lookahead);do if($[(Y=te)+Ae]===ae&&$[Y+Ae-1]===_e&&$[Y]===$[de]&&$[++Y]===$[de+1]){de+=2,Y++;do;while($[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&$[++de]===$[++Y]&&de<xe);if(H=R-(xe-de),de=xe-R,Ae<H){if(B.match_start=te,Le<=(Ae=H))break;_e=$[de+Ae-1],ae=$[de+Ae]}}while((te=X[te&L])>Se&&--F!=0);return Ae<=B.lookahead?Ae:B.lookahead}function fe(B){var te,Y,H,F,de,Ae,Le,Se,$,L,X=B.w_size;do{if(F=B.window_size-B.lookahead-B.strstart,B.strstart>=X+(X-U)){for(o.arraySet(B.window,B.window,X,X,0),B.match_start-=X,B.strstart-=X,B.block_start-=X,te=Y=B.hash_size;H=B.head[--te],B.head[te]=X<=H?H-X:0,--Y;);for(te=Y=X;H=B.prev[--te],B.prev[te]=X<=H?H-X:0,--Y;);F+=X}if(B.strm.avail_in===0)break;if(Ae=B.strm,Le=B.window,Se=B.strstart+B.lookahead,$=F,L=void 0,L=Ae.avail_in,$<L&&(L=$),Y=L===0?0:(Ae.avail_in-=L,o.arraySet(Le,Ae.input,Ae.next_in,L,Se),Ae.state.wrap===1?Ae.adler=c(Ae.adler,Le,L,Se):Ae.state.wrap===2&&(Ae.adler=u(Ae.adler,Le,L,Se)),Ae.next_in+=L,Ae.total_in+=L,L),B.lookahead+=Y,B.lookahead+B.insert>=T)for(de=B.strstart-B.insert,B.ins_h=B.window[de],B.ins_h=(B.ins_h<<B.hash_shift^B.window[de+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[de+T-1])&B.hash_mask,B.prev[de&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=de,de++,B.insert--,!(B.lookahead+B.insert<T)););}while(B.lookahead<U&&B.strm.avail_in!==0)}function le(B,te){for(var Y,H;;){if(B.lookahead<U){if(fe(B),B.lookahead<U&&te===f)return j;if(B.lookahead===0)break}if(Y=0,B.lookahead>=T&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,Y=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),Y!==0&&B.strstart-Y<=B.w_size-U&&(B.match_length=he(B,Y)),B.match_length>=T)if(H=l._tr_tally(B,B.strstart-B.match_start,B.match_length-T),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=T){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,Y=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else H=l._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(H&&(V(B,!1),B.strm.avail_out===0))return j}return B.insert=B.strstart<T-1?B.strstart:T-1,te===m?(V(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?j:W}function Ee(B,te){for(var Y,H,F;;){if(B.lookahead<U){if(fe(B),B.lookahead<U&&te===f)return j;if(B.lookahead===0)break}if(Y=0,B.lookahead>=T&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,Y=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=T-1,Y!==0&&B.prev_length<B.max_lazy_match&&B.strstart-Y<=B.w_size-U&&(B.match_length=he(B,Y),B.match_length<=5&&(B.strategy===1||B.match_length===T&&4096<B.strstart-B.match_start)&&(B.match_length=T-1)),B.prev_length>=T&&B.match_length<=B.prev_length){for(F=B.strstart+B.lookahead-T,H=l._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-T),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=F&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+T-1])&B.hash_mask,Y=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=T-1,B.strstart++,H&&(V(B,!1),B.strm.avail_out===0))return j}else if(B.match_available){if((H=l._tr_tally(B,0,B.window[B.strstart-1]))&&V(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return j}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(H=l._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<T-1?B.strstart:T-1,te===m?(V(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?j:W}function me(B,te,Y,H,F){this.good_length=B,this.max_lazy=te,this.nice_length=Y,this.max_chain=H,this.func=F}function we(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,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*C),this.dyn_dtree=new o.Buf16(2*(2*A+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),re(this.dyn_ltree),re(this.dyn_dtree),re(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*N+1),re(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*N+1),re(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 De(B){var te;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=v,(te=B.state).pending=0,te.pending_out=0,te.wrap<0&&(te.wrap=-te.wrap),te.status=te.wrap?O:q,B.adler=te.wrap===2?0:1,te.last_flush=f,l._tr_init(te),p):J(B,b)}function ee(B){var te=De(B);return te===p&&(function(Y){Y.window_size=2*Y.w_size,re(Y.head),Y.max_lazy_match=a[Y.level].max_lazy,Y.good_match=a[Y.level].good_length,Y.nice_match=a[Y.level].nice_length,Y.max_chain_length=a[Y.level].max_chain,Y.strstart=0,Y.block_start=0,Y.lookahead=0,Y.insert=0,Y.match_length=Y.prev_length=T-1,Y.match_available=0,Y.ins_h=0})(B.state),te}function Qe(B,te,Y,H,F,de){if(!B)return b;var Ae=1;if(te===y&&(te=6),H<0?(Ae=0,H=-H):15<H&&(Ae=2,H-=16),F<1||M<F||Y!==S||H<8||15<H||te<0||9<te||de<0||x<de)return J(B,b);H===8&&(H=9);var Le=new we;return(B.state=Le).strm=B,Le.wrap=Ae,Le.gzhead=null,Le.w_bits=H,Le.w_size=1<<Le.w_bits,Le.w_mask=Le.w_size-1,Le.hash_bits=F+7,Le.hash_size=1<<Le.hash_bits,Le.hash_mask=Le.hash_size-1,Le.hash_shift=~~((Le.hash_bits+T-1)/T),Le.window=new o.Buf8(2*Le.w_size),Le.head=new o.Buf16(Le.hash_size),Le.prev=new o.Buf16(Le.w_size),Le.lit_bufsize=1<<F+6,Le.pending_buf_size=4*Le.lit_bufsize,Le.pending_buf=new o.Buf8(Le.pending_buf_size),Le.d_buf=1*Le.lit_bufsize,Le.l_buf=3*Le.lit_bufsize,Le.level=te,Le.strategy=de,Le.method=Y,ee(B)}a=[new me(0,0,0,0,function(B,te){var Y=65535;for(Y>B.pending_buf_size-5&&(Y=B.pending_buf_size-5);;){if(B.lookahead<=1){if(fe(B),B.lookahead===0&&te===f)return j;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var H=B.block_start+Y;if((B.strstart===0||B.strstart>=H)&&(B.lookahead=B.strstart-H,B.strstart=H,V(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-U&&(V(B,!1),B.strm.avail_out===0))return j}return B.insert=0,te===m?(V(B,!0),B.strm.avail_out===0?K:G):(B.strstart>B.block_start&&(V(B,!1),B.strm.avail_out),j)}),new me(4,4,8,4,le),new me(4,5,16,8,le),new me(4,6,32,32,le),new me(4,4,16,16,Ee),new me(8,16,32,32,Ee),new me(8,16,128,128,Ee),new me(8,32,128,256,Ee),new me(32,128,258,1024,Ee),new me(32,258,258,4096,Ee)],i.deflateInit=function(B,te){return Qe(B,te,S,15,8,0)},i.deflateInit2=Qe,i.deflateReset=ee,i.deflateResetKeep=De,i.deflateSetHeader=function(B,te){return B&&B.state?B.state.wrap!==2?b:(B.state.gzhead=te,p):b},i.deflate=function(B,te){var Y,H,F,de;if(!B||!B.state||5<te||te<0)return B?J(B,b):b;if(H=B.state,!B.output||!B.input&&B.avail_in!==0||H.status===666&&te!==m)return J(B,B.avail_out===0?-5:b);if(H.strm=B,Y=H.last_flush,H.last_flush=te,H.status===O)if(H.wrap===2)B.adler=0,Z(H,31),Z(H,139),Z(H,8),H.gzhead?(Z(H,(H.gzhead.text?1:0)+(H.gzhead.hcrc?2:0)+(H.gzhead.extra?4:0)+(H.gzhead.name?8:0)+(H.gzhead.comment?16:0)),Z(H,255&H.gzhead.time),Z(H,H.gzhead.time>>8&255),Z(H,H.gzhead.time>>16&255),Z(H,H.gzhead.time>>24&255),Z(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),Z(H,255&H.gzhead.os),H.gzhead.extra&&H.gzhead.extra.length&&(Z(H,255&H.gzhead.extra.length),Z(H,H.gzhead.extra.length>>8&255)),H.gzhead.hcrc&&(B.adler=u(B.adler,H.pending_buf,H.pending,0)),H.gzindex=0,H.status=69):(Z(H,0),Z(H,0),Z(H,0),Z(H,0),Z(H,0),Z(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),Z(H,3),H.status=q);else{var Ae=S+(H.w_bits-8<<4)<<8;Ae|=(2<=H.strategy||H.level<2?0:H.level<6?1:H.level===6?2:3)<<6,H.strstart!==0&&(Ae|=32),Ae+=31-Ae%31,H.status=q,ne(H,Ae),H.strstart!==0&&(ne(H,B.adler>>>16),ne(H,65535&B.adler)),B.adler=1}if(H.status===69)if(H.gzhead.extra){for(F=H.pending;H.gzindex<(65535&H.gzhead.extra.length)&&(H.pending!==H.pending_buf_size||(H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),z(B),F=H.pending,H.pending!==H.pending_buf_size));)Z(H,255&H.gzhead.extra[H.gzindex]),H.gzindex++;H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),H.gzindex===H.gzhead.extra.length&&(H.gzindex=0,H.status=73)}else H.status=73;if(H.status===73)if(H.gzhead.name){F=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),z(B),F=H.pending,H.pending===H.pending_buf_size)){de=1;break}de=H.gzindex<H.gzhead.name.length?255&H.gzhead.name.charCodeAt(H.gzindex++):0,Z(H,de)}while(de!==0);H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),de===0&&(H.gzindex=0,H.status=91)}else H.status=91;if(H.status===91)if(H.gzhead.comment){F=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),z(B),F=H.pending,H.pending===H.pending_buf_size)){de=1;break}de=H.gzindex<H.gzhead.comment.length?255&H.gzhead.comment.charCodeAt(H.gzindex++):0,Z(H,de)}while(de!==0);H.gzhead.hcrc&&H.pending>F&&(B.adler=u(B.adler,H.pending_buf,H.pending-F,F)),de===0&&(H.status=103)}else H.status=103;if(H.status===103&&(H.gzhead.hcrc?(H.pending+2>H.pending_buf_size&&z(B),H.pending+2<=H.pending_buf_size&&(Z(H,255&B.adler),Z(H,B.adler>>8&255),B.adler=0,H.status=q)):H.status=q),H.pending!==0){if(z(B),B.avail_out===0)return H.last_flush=-1,p}else if(B.avail_in===0&&ie(te)<=ie(Y)&&te!==m)return J(B,-5);if(H.status===666&&B.avail_in!==0)return J(B,-5);if(B.avail_in!==0||H.lookahead!==0||te!==f&&H.status!==666){var Le=H.strategy===2?(function(Se,$){for(var L;;){if(Se.lookahead===0&&(fe(Se),Se.lookahead===0)){if($===f)return j;break}if(Se.match_length=0,L=l._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&(V(Se,!1),Se.strm.avail_out===0))return j}return Se.insert=0,$===m?(V(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(V(Se,!1),Se.strm.avail_out===0)?j:W})(H,te):H.strategy===3?(function(Se,$){for(var L,X,xe,_e,ae=Se.window;;){if(Se.lookahead<=R){if(fe(Se),Se.lookahead<=R&&$===f)return j;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=T&&0<Se.strstart&&(X=ae[xe=Se.strstart-1])===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]){_e=Se.strstart+R;do;while(X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&X===ae[++xe]&&xe<_e);Se.match_length=R-(_e-xe),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=T?(L=l._tr_tally(Se,1,Se.match_length-T),Se.lookahead-=Se.match_length,Se.strstart+=Se.match_length,Se.match_length=0):(L=l._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++),L&&(V(Se,!1),Se.strm.avail_out===0))return j}return Se.insert=0,$===m?(V(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(V(Se,!1),Se.strm.avail_out===0)?j:W})(H,te):a[H.level].func(H,te);if(Le!==K&&Le!==G||(H.status=666),Le===j||Le===K)return B.avail_out===0&&(H.last_flush=-1),p;if(Le===W&&(te===1?l._tr_align(H):te!==5&&(l._tr_stored_block(H,0,0,!1),te===3&&(re(H.head),H.lookahead===0&&(H.strstart=0,H.block_start=0,H.insert=0))),z(B),B.avail_out===0))return H.last_flush=-1,p}return te!==m?p:H.wrap<=0?1:(H.wrap===2?(Z(H,255&B.adler),Z(H,B.adler>>8&255),Z(H,B.adler>>16&255),Z(H,B.adler>>24&255),Z(H,255&B.total_in),Z(H,B.total_in>>8&255),Z(H,B.total_in>>16&255),Z(H,B.total_in>>24&255)):(ne(H,B.adler>>>16),ne(H,65535&B.adler)),z(B),0<H.wrap&&(H.wrap=-H.wrap),H.pending!==0?p:1)},i.deflateEnd=function(B){var te;return B&&B.state?(te=B.state.status)!==O&&te!==69&&te!==73&&te!==91&&te!==103&&te!==q&&te!==666?J(B,b):(B.state=null,te===q?J(B,-3):p):b},i.deflateSetDictionary=function(B,te){var Y,H,F,de,Ae,Le,Se,$,L=te.length;if(!B||!B.state||(de=(Y=B.state).wrap)===2||de===1&&Y.status!==O||Y.lookahead)return b;for(de===1&&(B.adler=c(B.adler,te,L,0)),Y.wrap=0,L>=Y.w_size&&(de===0&&(re(Y.head),Y.strstart=0,Y.block_start=0,Y.insert=0),$=new o.Buf8(Y.w_size),o.arraySet($,te,L-Y.w_size,Y.w_size,0),te=$,L=Y.w_size),Ae=B.avail_in,Le=B.next_in,Se=B.input,B.avail_in=L,B.next_in=0,B.input=te,fe(Y);Y.lookahead>=T;){for(H=Y.strstart,F=Y.lookahead-(T-1);Y.ins_h=(Y.ins_h<<Y.hash_shift^Y.window[H+T-1])&Y.hash_mask,Y.prev[H&Y.w_mask]=Y.head[Y.ins_h],Y.head[Y.ins_h]=H,H++,--F;);Y.strstart=H,Y.lookahead=T-1,fe(Y)}return Y.strstart+=Y.lookahead,Y.block_start=Y.strstart,Y.insert=Y.lookahead,Y.lookahead=0,Y.match_length=Y.prev_length=T-1,Y.match_available=0,B.next_in=Le,B.input=Se,B.avail_in=Ae,Y.wrap=de,p},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,m,p,b,y,x,v,S,M,N,A,k,C,D,T,R,U,O,q,j,W;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),p=l.dmax,b=l.wsize,y=l.whave,x=l.wnext,v=l.window,S=l.hold,M=l.bits,N=l.lencode,A=l.distcode,k=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=N[S&k];t:for(;;){if(S>>>=T=D>>>24,M-=T,(T=D>>>16&255)===0)W[d++]=65535&D;else{if(!(16&T)){if((64&T)==0){D=N[(65535&D)+(S&(1<<T)-1)];continue t}if(32&T){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(T&=15)&&(M<T&&(S+=j[c++]<<M,M+=8),R+=S&(1<<T)-1,S>>>=T,M-=T),M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=A[S&C];n:for(;;){if(S>>>=T=D>>>24,M-=T,!(16&(T=D>>>16&255))){if((64&T)==0){D=A[(65535&D)+(S&(1<<T)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&D,M<(T&=15)&&(S+=j[c++]<<M,(M+=8)<T&&(S+=j[c++]<<M,M+=8)),p<(U+=S&(1<<T)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=T,M-=T,(T=d-f)<U){if(y<(T=U-T)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=v,(O=0)===x){if(O+=b-T,T<R){for(R-=T;W[d++]=v[O++],--T;);O=d-U,q=W}}else if(x<T){if(O+=b+x-T,(T-=x)<R){for(R-=T;W[d++]=v[O++],--T;);if(O=0,x<R){for(R-=T=x;W[d++]=v[O++],--T;);O=d-U,q=W}}}else if(O+=x-T,T<R){for(R-=T;W[d++]=v[O++],--T;);O=d-U,q=W}for(;2<R;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],R-=3;R&&(W[d++]=q[O++],1<R&&(W[d++]=q[O++]))}else{for(O=d-U;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(R-=3););R&&(W[d++]=W[O++],1<R&&(W[d++]=W[O++]))}break}}break}}while(c<u&&d<m);c-=R=M>>3,S&=(1<<(M-=R<<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<m?m-d+257:257-(d-m),l.hold=S,l.bits=M}},{}],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,m=0,p=-2,b=1,y=852,x=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function S(){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 M(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(y),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,m):p}function N(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,M(O)):p}function A(O,q){var j,W;return O&&O.state?(W=O.state,q<0?(j=0,q=-q):(j=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=j,W.wbits=q,N(O))):p}function k(O,q){var j,W;return O?(W=new S,(O.state=W).window=null,(j=A(O,q))!==m&&(O.state=null),j):p}var C,D,T=!0;function R(O){if(T){var q;for(C=new a.Buf32(512),D=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,C,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,D,0,O.work,{bits:5}),T=!1}O.lencode=C,O.lenbits=9,O.distcode=D,O.distbits=5}function U(O,q,j,W){var K,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,j-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,j-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,j-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=N,i.inflateReset2=A,i.inflateResetKeep=M,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var j,W,K,G,J,ie,re,z,V,Z,ne,he,fe,le,Ee,me,we,De,ee,Qe,B,te,Y,H,F=0,de=new a.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(j=O.state).mode===12&&(j.mode=13),J=O.next_out,K=O.output,re=O.avail_out,G=O.next_in,W=O.input,ie=O.avail_in,z=j.hold,V=j.bits,Z=ie,ne=re,te=m;e:for(;;)switch(j.mode){case b:if(j.wrap===0){j.mode=13;break}for(;V<16;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(2&j.wrap&&z===35615){de[j.check=0]=255&z,de[1]=z>>>8&255,j.check=l(j.check,de,2,0),V=z=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&z)<<8)+(z>>8))%31){O.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){O.msg="unknown compression method",j.mode=30;break}if(V-=4,B=8+(15&(z>>>=4)),j.wbits===0)j.wbits=B;else if(B>j.wbits){O.msg="invalid window size",j.mode=30;break}j.dmax=1<<B,O.adler=j.check=1,j.mode=512&z?10:12,V=z=0;break;case 2:for(;V<16;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(j.flags=z,(255&j.flags)!=8){O.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){O.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=z>>8&1),512&j.flags&&(de[0]=255&z,de[1]=z>>>8&255,j.check=l(j.check,de,2,0)),V=z=0,j.mode=3;case 3:for(;V<32;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.head&&(j.head.time=z),512&j.flags&&(de[0]=255&z,de[1]=z>>>8&255,de[2]=z>>>16&255,de[3]=z>>>24&255,j.check=l(j.check,de,4,0)),V=z=0,j.mode=4;case 4:for(;V<16;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.head&&(j.head.xflags=255&z,j.head.os=z>>8),512&j.flags&&(de[0]=255&z,de[1]=z>>>8&255,j.check=l(j.check,de,2,0)),V=z=0,j.mode=5;case 5:if(1024&j.flags){for(;V<16;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.length=z,j.head&&(j.head.extra_len=z),512&j.flags&&(de[0]=255&z,de[1]=z>>>8&255,j.check=l(j.check,de,2,0)),V=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(ie<(he=j.length)&&(he=ie),he&&(j.head&&(B=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,W,G,he,B)),512&j.flags&&(j.check=l(j.check,W,he,G)),ie-=he,G+=he,j.length-=he),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(ie===0)break e;for(he=0;B=W[G+he++],j.head&&B&&j.length<65536&&(j.head.name+=String.fromCharCode(B)),B&&he<ie;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),ie-=he,G+=he,B)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(ie===0)break e;for(he=0;B=W[G+he++],j.head&&B&&j.length<65536&&(j.head.comment+=String.fromCharCode(B)),B&&he<ie;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),ie-=he,G+=he,B)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;V<16;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(z!==(65535&j.check)){O.msg="header crc mismatch",j.mode=30;break}V=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),O.adler=j.check=0,j.mode=12;break;case 10:for(;V<32;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}O.adler=j.check=v(z),V=z=0,j.mode=11;case 11:if(j.havedict===0)return O.next_out=J,O.avail_out=re,O.next_in=G,O.avail_in=ie,j.hold=z,j.bits=V,2;O.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){z>>>=7&V,V-=7&V,j.mode=27;break}for(;V<3;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}switch(j.last=1&z,V-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;z>>>=2,V-=2;break e;case 2:j.mode=17;break;case 3:O.msg="invalid block type",j.mode=30}z>>>=2,V-=2;break;case 14:for(z>>>=7&V,V-=7&V;V<32;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if((65535&z)!=(z>>>16^65535)){O.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,V=z=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(he=j.length){if(ie<he&&(he=ie),re<he&&(he=re),he===0)break e;a.arraySet(K,W,G,he,J),ie-=he,G+=he,re-=he,J+=he,j.length-=he;break}j.mode=12;break;case 17:for(;V<14;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(j.nlen=257+(31&z),z>>>=5,V-=5,j.ndist=1+(31&z),z>>>=5,V-=5,j.ncode=4+(15&z),z>>>=4,V-=4,286<j.nlen||30<j.ndist){O.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;V<3;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.lens[Ae[j.have++]]=7&z,z>>>=3,V-=3}for(;j.have<19;)j.lens[Ae[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,Y={bits:j.lenbits},te=u(0,j.lens,0,19,j.lencode,0,j.work,Y),j.lenbits=Y.bits,te){O.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;me=(F=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,we=65535&F,!((Ee=F>>>24)<=V);){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(we<16)z>>>=Ee,V-=Ee,j.lens[j.have++]=we;else{if(we===16){for(H=Ee+2;V<H;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(z>>>=Ee,V-=Ee,j.have===0){O.msg="invalid bit length repeat",j.mode=30;break}B=j.lens[j.have-1],he=3+(3&z),z>>>=2,V-=2}else if(we===17){for(H=Ee+3;V<H;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}V-=Ee,B=0,he=3+(7&(z>>>=Ee)),z>>>=3,V-=3}else{for(H=Ee+7;V<H;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}V-=Ee,B=0,he=11+(127&(z>>>=Ee)),z>>>=7,V-=7}if(j.have+he>j.nlen+j.ndist){O.msg="invalid bit length repeat",j.mode=30;break}for(;he--;)j.lens[j.have++]=B}}if(j.mode===30)break;if(j.lens[256]===0){O.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,Y={bits:j.lenbits},te=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,Y),j.lenbits=Y.bits,te){O.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,Y={bits:j.distbits},te=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,Y),j.distbits=Y.bits,te){O.msg="invalid distances set",j.mode=30;break}if(j.mode=20,q===6)break e;case 20:j.mode=21;case 21:if(6<=ie&&258<=re){O.next_out=J,O.avail_out=re,O.next_in=G,O.avail_in=ie,j.hold=z,j.bits=V,c(O,ne),J=O.next_out,K=O.output,re=O.avail_out,G=O.next_in,W=O.input,ie=O.avail_in,z=j.hold,V=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;me=(F=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,we=65535&F,!((Ee=F>>>24)<=V);){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(me&&(240&me)==0){for(De=Ee,ee=me,Qe=we;me=(F=j.lencode[Qe+((z&(1<<De+ee)-1)>>De)])>>>16&255,we=65535&F,!(De+(Ee=F>>>24)<=V);){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}z>>>=De,V-=De,j.back+=De}if(z>>>=Ee,V-=Ee,j.back+=Ee,j.length=we,me===0){j.mode=26;break}if(32&me){j.back=-1,j.mode=12;break}if(64&me){O.msg="invalid literal/length code",j.mode=30;break}j.extra=15&me,j.mode=22;case 22:if(j.extra){for(H=j.extra;V<H;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,V-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;me=(F=j.distcode[z&(1<<j.distbits)-1])>>>16&255,we=65535&F,!((Ee=F>>>24)<=V);){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if((240&me)==0){for(De=Ee,ee=me,Qe=we;me=(F=j.distcode[Qe+((z&(1<<De+ee)-1)>>De)])>>>16&255,we=65535&F,!(De+(Ee=F>>>24)<=V);){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}z>>>=De,V-=De,j.back+=De}if(z>>>=Ee,V-=Ee,j.back+=Ee,64&me){O.msg="invalid distance code",j.mode=30;break}j.offset=we,j.extra=15&me,j.mode=24;case 24:if(j.extra){for(H=j.extra;V<H;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,V-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){O.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(re===0)break e;if(he=ne-re,j.offset>he){if((he=j.offset-he)>j.whave&&j.sane){O.msg="invalid distance too far back",j.mode=30;break}fe=he>j.wnext?(he-=j.wnext,j.wsize-he):j.wnext-he,he>j.length&&(he=j.length),le=j.window}else le=K,fe=J-j.offset,he=j.length;for(re<he&&(he=re),re-=he,j.length-=he;K[J++]=le[fe++],--he;);j.length===0&&(j.mode=21);break;case 26:if(re===0)break e;K[J++]=j.length,re--,j.mode=21;break;case 27:if(j.wrap){for(;V<32;){if(ie===0)break e;ie--,z|=W[G++]<<V,V+=8}if(ne-=re,O.total_out+=ne,j.total+=ne,ne&&(O.adler=j.check=j.flags?l(j.check,K,ne,J-ne):o(j.check,K,ne,J-ne)),ne=re,(j.flags?z:v(z))!==j.check){O.msg="incorrect data check",j.mode=30;break}V=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;V<32;){if(ie===0)break e;ie--,z+=W[G++]<<V,V+=8}if(z!==(4294967295&j.total)){O.msg="incorrect length check",j.mode=30;break}V=z=0}j.mode=29;case 29:te=1;break e;case 30:te=-3;break e;case 31:return-4;default:return p}return O.next_out=J,O.avail_out=re,O.next_in=G,O.avail_in=ie,j.hold=z,j.bits=V,(j.wsize||ne!==O.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&U(O,O.output,O.next_out,ne-O.avail_out)?(j.mode=31,-4):(Z-=O.avail_in,ne-=O.avail_out,O.total_in+=Z,O.total_out+=ne,j.total+=ne,j.wrap&&ne&&(O.adler=j.check=j.flags?l(j.check,K,ne,O.next_out-ne):o(j.check,K,ne,O.next_out-ne)),O.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(Z==0&&ne===0||q===4)&&te===m&&(te=-5),te)},i.inflateEnd=function(O){if(!O||!O.state)return p;var q=O.state;return q.window&&(q.window=null),O.state=null,m},i.inflateGetHeader=function(O,q){var j;return O&&O.state?(2&(j=O.state).wrap)==0?p:((j.head=q).done=!1,m):p},i.inflateSetDictionary=function(O,q){var j,W=q.length;return O&&O.state?(j=O.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,q,W,0)!==j.check?-3:U(O,q,W,W)?(j.mode=31,-4):(j.havedict=1,m):p},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,m,p,b,y,x,v){var S,M,N,A,k,C,D,T,R,U=v.bits,O=0,q=0,j=0,W=0,K=0,G=0,J=0,ie=0,re=0,z=0,V=null,Z=0,ne=new a.Buf16(16),he=new a.Buf16(16),fe=null,le=0;for(O=0;O<=15;O++)ne[O]=0;for(q=0;q<p;q++)ne[f[m+q]]++;for(K=U,W=15;1<=W&&ne[W]===0;W--);if(W<K&&(K=W),W===0)return b[y++]=20971520,b[y++]=20971520,v.bits=1,0;for(j=1;j<W&&ne[j]===0;j++);for(K<j&&(K=j),O=ie=1;O<=15;O++)if(ie<<=1,(ie-=ne[O])<0)return-1;if(0<ie&&(d===0||W!==1))return-1;for(he[1]=0,O=1;O<15;O++)he[O+1]=he[O]+ne[O];for(q=0;q<p;q++)f[m+q]!==0&&(x[he[f[m+q]]++]=q);if(C=d===0?(V=fe=x,19):d===1?(V=o,Z-=257,fe=l,le-=257,256):(V=c,fe=u,-1),O=j,k=y,J=q=z=0,N=-1,A=(re=1<<(G=K))-1,d===1&&852<re||d===2&&592<re)return 1;for(;;){for(D=O-J,R=x[q]<C?(T=0,x[q]):x[q]>C?(T=fe[le+x[q]],V[Z+x[q]]):(T=96,0),S=1<<O-J,j=M=1<<G;b[k+(z>>J)+(M-=S)]=D<<24|T<<16|R|0,M!==0;);for(S=1<<O-1;z&S;)S>>=1;if(S!==0?(z&=S-1,z+=S):z=0,q++,--ne[O]==0){if(O===W)break;O=f[m+x[q]]}if(K<O&&(z&A)!==N){for(J===0&&(J=K),k+=j,ie=1<<(G=O-J);G+J<W&&!((ie-=ne[G+J])<=0);)G++,ie<<=1;if(re+=1<<G,d===1&&852<re||d===2&&592<re)return 1;b[N=z&A]=K<<24|G<<16|k-y|0}}return z!==0&&(b[k+z]=O-J<<24|64<<16|0),v.bits=K,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(F){for(var de=F.length;0<=--de;)F[de]=0}var u=0,d=29,f=256,m=f+1+d,p=30,b=19,y=2*m+1,x=15,v=16,S=7,M=256,N=16,A=17,k=18,C=[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],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(m+2));c(U);var O=new Array(2*p);c(O);var q=new Array(512);c(q);var j=new Array(256);c(j);var W=new Array(d);c(W);var K,G,J,ie=new Array(p);function re(F,de,Ae,Le,Se){this.static_tree=F,this.extra_bits=de,this.extra_base=Ae,this.elems=Le,this.max_length=Se,this.has_stree=F&&F.length}function z(F,de){this.dyn_tree=F,this.max_code=0,this.stat_desc=de}function V(F){return F<256?q[F]:q[256+(F>>>7)]}function Z(F,de){F.pending_buf[F.pending++]=255&de,F.pending_buf[F.pending++]=de>>>8&255}function ne(F,de,Ae){F.bi_valid>v-Ae?(F.bi_buf|=de<<F.bi_valid&65535,Z(F,F.bi_buf),F.bi_buf=de>>v-F.bi_valid,F.bi_valid+=Ae-v):(F.bi_buf|=de<<F.bi_valid&65535,F.bi_valid+=Ae)}function he(F,de,Ae){ne(F,Ae[2*de],Ae[2*de+1])}function fe(F,de){for(var Ae=0;Ae|=1&F,F>>>=1,Ae<<=1,0<--de;);return Ae>>>1}function le(F,de,Ae){var Le,Se,$=new Array(x+1),L=0;for(Le=1;Le<=x;Le++)$[Le]=L=L+Ae[Le-1]<<1;for(Se=0;Se<=de;Se++){var X=F[2*Se+1];X!==0&&(F[2*Se]=fe($[X]++,X))}}function Ee(F){var de;for(de=0;de<m;de++)F.dyn_ltree[2*de]=0;for(de=0;de<p;de++)F.dyn_dtree[2*de]=0;for(de=0;de<b;de++)F.bl_tree[2*de]=0;F.dyn_ltree[2*M]=1,F.opt_len=F.static_len=0,F.last_lit=F.matches=0}function me(F){8<F.bi_valid?Z(F,F.bi_buf):0<F.bi_valid&&(F.pending_buf[F.pending++]=F.bi_buf),F.bi_buf=0,F.bi_valid=0}function we(F,de,Ae,Le){var Se=2*de,$=2*Ae;return F[Se]<F[$]||F[Se]===F[$]&&Le[de]<=Le[Ae]}function De(F,de,Ae){for(var Le=F.heap[Ae],Se=Ae<<1;Se<=F.heap_len&&(Se<F.heap_len&&we(de,F.heap[Se+1],F.heap[Se],F.depth)&&Se++,!we(de,Le,F.heap[Se],F.depth));)F.heap[Ae]=F.heap[Se],Ae=Se,Se<<=1;F.heap[Ae]=Le}function ee(F,de,Ae){var Le,Se,$,L,X=0;if(F.last_lit!==0)for(;Le=F.pending_buf[F.d_buf+2*X]<<8|F.pending_buf[F.d_buf+2*X+1],Se=F.pending_buf[F.l_buf+X],X++,Le===0?he(F,Se,de):(he(F,($=j[Se])+f+1,de),(L=C[$])!==0&&ne(F,Se-=W[$],L),he(F,$=V(--Le),Ae),(L=D[$])!==0&&ne(F,Le-=ie[$],L)),X<F.last_lit;);he(F,M,de)}function Qe(F,de){var Ae,Le,Se,$=de.dyn_tree,L=de.stat_desc.static_tree,X=de.stat_desc.has_stree,xe=de.stat_desc.elems,_e=-1;for(F.heap_len=0,F.heap_max=y,Ae=0;Ae<xe;Ae++)$[2*Ae]!==0?(F.heap[++F.heap_len]=_e=Ae,F.depth[Ae]=0):$[2*Ae+1]=0;for(;F.heap_len<2;)$[2*(Se=F.heap[++F.heap_len]=_e<2?++_e:0)]=1,F.depth[Se]=0,F.opt_len--,X&&(F.static_len-=L[2*Se+1]);for(de.max_code=_e,Ae=F.heap_len>>1;1<=Ae;Ae--)De(F,$,Ae);for(Se=xe;Ae=F.heap[1],F.heap[1]=F.heap[F.heap_len--],De(F,$,1),Le=F.heap[1],F.heap[--F.heap_max]=Ae,F.heap[--F.heap_max]=Le,$[2*Se]=$[2*Ae]+$[2*Le],F.depth[Se]=(F.depth[Ae]>=F.depth[Le]?F.depth[Ae]:F.depth[Le])+1,$[2*Ae+1]=$[2*Le+1]=Se,F.heap[1]=Se++,De(F,$,1),2<=F.heap_len;);F.heap[--F.heap_max]=F.heap[1],(function(ae,Te){var Pe,Xe,Je,Ze,oe,ye,Ce=Te.dyn_tree,$e=Te.max_code,lt=Te.stat_desc.static_tree,se=Te.stat_desc.has_stree,ze=Te.stat_desc.extra_bits,ve=Te.stat_desc.extra_base,He=Te.stat_desc.max_length,Oe=0;for(Ze=0;Ze<=x;Ze++)ae.bl_count[Ze]=0;for(Ce[2*ae.heap[ae.heap_max]+1]=0,Pe=ae.heap_max+1;Pe<y;Pe++)He<(Ze=Ce[2*Ce[2*(Xe=ae.heap[Pe])+1]+1]+1)&&(Ze=He,Oe++),Ce[2*Xe+1]=Ze,$e<Xe||(ae.bl_count[Ze]++,oe=0,ve<=Xe&&(oe=ze[Xe-ve]),ye=Ce[2*Xe],ae.opt_len+=ye*(Ze+oe),se&&(ae.static_len+=ye*(lt[2*Xe+1]+oe)));if(Oe!==0){do{for(Ze=He-1;ae.bl_count[Ze]===0;)Ze--;ae.bl_count[Ze]--,ae.bl_count[Ze+1]+=2,ae.bl_count[He]--,Oe-=2}while(0<Oe);for(Ze=He;Ze!==0;Ze--)for(Xe=ae.bl_count[Ze];Xe!==0;)$e<(Je=ae.heap[--Pe])||(Ce[2*Je+1]!==Ze&&(ae.opt_len+=(Ze-Ce[2*Je+1])*Ce[2*Je],Ce[2*Je+1]=Ze),Xe--)}})(F,de),le($,_e,F.bl_count)}function B(F,de,Ae){var Le,Se,$=-1,L=de[1],X=0,xe=7,_e=4;for(L===0&&(xe=138,_e=3),de[2*(Ae+1)+1]=65535,Le=0;Le<=Ae;Le++)Se=L,L=de[2*(Le+1)+1],++X<xe&&Se===L||(X<_e?F.bl_tree[2*Se]+=X:Se!==0?(Se!==$&&F.bl_tree[2*Se]++,F.bl_tree[2*N]++):X<=10?F.bl_tree[2*A]++:F.bl_tree[2*k]++,$=Se,_e=(X=0)===L?(xe=138,3):Se===L?(xe=6,3):(xe=7,4))}function te(F,de,Ae){var Le,Se,$=-1,L=de[1],X=0,xe=7,_e=4;for(L===0&&(xe=138,_e=3),Le=0;Le<=Ae;Le++)if(Se=L,L=de[2*(Le+1)+1],!(++X<xe&&Se===L)){if(X<_e)for(;he(F,Se,F.bl_tree),--X!=0;);else Se!==0?(Se!==$&&(he(F,Se,F.bl_tree),X--),he(F,N,F.bl_tree),ne(F,X-3,2)):X<=10?(he(F,A,F.bl_tree),ne(F,X-3,3)):(he(F,k,F.bl_tree),ne(F,X-11,7));$=Se,_e=(X=0)===L?(xe=138,3):Se===L?(xe=6,3):(xe=7,4)}}c(ie);var Y=!1;function H(F,de,Ae,Le){ne(F,(u<<1)+(Le?1:0),3),(function(Se,$,L,X){me(Se),Z(Se,L),Z(Se,~L),a.arraySet(Se.pending_buf,Se.window,$,L,Se.pending),Se.pending+=L})(F,de,Ae)}i._tr_init=function(F){Y||((function(){var de,Ae,Le,Se,$,L=new Array(x+1);for(Se=Le=0;Se<d-1;Se++)for(W[Se]=Le,de=0;de<1<<C[Se];de++)j[Le++]=Se;for(j[Le-1]=Se,Se=$=0;Se<16;Se++)for(ie[Se]=$,de=0;de<1<<D[Se];de++)q[$++]=Se;for($>>=7;Se<p;Se++)for(ie[Se]=$<<7,de=0;de<1<<D[Se]-7;de++)q[256+$++]=Se;for(Ae=0;Ae<=x;Ae++)L[Ae]=0;for(de=0;de<=143;)U[2*de+1]=8,de++,L[8]++;for(;de<=255;)U[2*de+1]=9,de++,L[9]++;for(;de<=279;)U[2*de+1]=7,de++,L[7]++;for(;de<=287;)U[2*de+1]=8,de++,L[8]++;for(le(U,m+1,L),de=0;de<p;de++)O[2*de+1]=5,O[2*de]=fe(de,5);K=new re(U,C,f+1,m,x),G=new re(O,D,0,p,x),J=new re(new Array(0),T,0,b,S)})(),Y=!0),F.l_desc=new z(F.dyn_ltree,K),F.d_desc=new z(F.dyn_dtree,G),F.bl_desc=new z(F.bl_tree,J),F.bi_buf=0,F.bi_valid=0,Ee(F)},i._tr_stored_block=H,i._tr_flush_block=function(F,de,Ae,Le){var Se,$,L=0;0<F.level?(F.strm.data_type===2&&(F.strm.data_type=(function(X){var xe,_e=4093624447;for(xe=0;xe<=31;xe++,_e>>>=1)if(1&_e&&X.dyn_ltree[2*xe]!==0)return o;if(X.dyn_ltree[18]!==0||X.dyn_ltree[20]!==0||X.dyn_ltree[26]!==0)return l;for(xe=32;xe<f;xe++)if(X.dyn_ltree[2*xe]!==0)return l;return o})(F)),Qe(F,F.l_desc),Qe(F,F.d_desc),L=(function(X){var xe;for(B(X,X.dyn_ltree,X.l_desc.max_code),B(X,X.dyn_dtree,X.d_desc.max_code),Qe(X,X.bl_desc),xe=b-1;3<=xe&&X.bl_tree[2*R[xe]+1]===0;xe--);return X.opt_len+=3*(xe+1)+5+5+4,xe})(F),Se=F.opt_len+3+7>>>3,($=F.static_len+3+7>>>3)<=Se&&(Se=$)):Se=$=Ae+5,Ae+4<=Se&&de!==-1?H(F,de,Ae,Le):F.strategy===4||$===Se?(ne(F,2+(Le?1:0),3),ee(F,U,O)):(ne(F,4+(Le?1:0),3),(function(X,xe,_e,ae){var Te;for(ne(X,xe-257,5),ne(X,_e-1,5),ne(X,ae-4,4),Te=0;Te<ae;Te++)ne(X,X.bl_tree[2*R[Te]+1],3);te(X,X.dyn_ltree,xe-1),te(X,X.dyn_dtree,_e-1)})(F,F.l_desc.max_code+1,F.d_desc.max_code+1,L+1),ee(F,F.dyn_ltree,F.dyn_dtree)),Ee(F),Le&&me(F)},i._tr_tally=function(F,de,Ae){return F.pending_buf[F.d_buf+2*F.last_lit]=de>>>8&255,F.pending_buf[F.d_buf+2*F.last_lit+1]=255&de,F.pending_buf[F.l_buf+F.last_lit]=255&Ae,F.last_lit++,de===0?F.dyn_ltree[2*Ae]++:(F.matches++,de--,F.dyn_ltree[2*(j[Ae]+f+1)]++,F.dyn_dtree[2*V(de)]++),F.last_lit===F.lit_bufsize-1},i._tr_align=function(F){ne(F,2,3),he(F,M,U),(function(de){de.bi_valid===16?(Z(de,de.bi_buf),de.bi_buf=0,de.bi_valid=0):8<=de.bi_valid&&(de.pending_buf[de.pending++]=255&de.bi_buf,de.bi_buf>>=8,de.bi_valid-=8)})(F)}},{"../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,m=1,p={},b=!1,y=o.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(o);x=x&&x.setTimeout?x:o,c={}.toString.call(o.process)==="[object process]"?function(N){process.nextTick(function(){S(N)})}:(function(){if(o.postMessage&&!o.importScripts){var N=!0,A=o.onmessage;return o.onmessage=function(){N=!1},o.postMessage("","*"),o.onmessage=A,N}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",M,!1):o.attachEvent("onmessage",M),function(N){o.postMessage(f+N,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(N){S(N.data)},function(N){d.port2.postMessage(N)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(N){var A=y.createElement("script");A.onreadystatechange=function(){S(N),A.onreadystatechange=null,u.removeChild(A),A=null},u.appendChild(A)}):function(N){setTimeout(S,0,N)},x.setImmediate=function(N){typeof N!="function"&&(N=new Function(""+N));for(var A=new Array(arguments.length-1),k=0;k<A.length;k++)A[k]=arguments[k+1];var C={callback:N,args:A};return p[m]=C,c(m),m++},x.clearImmediate=v}function v(N){delete p[N]}function S(N){if(b)setTimeout(S,0,N);else{var A=p[N];if(A){b=!0;try{(function(k){var C=k.callback,D=k.args;switch(D.length){case 0:C();break;case 1:C(D[0]);break;case 2:C(D[0],D[1]);break;case 3:C(D[0],D[1],D[2]);break;default:C.apply(l,D)}})(A)}finally{v(N),b=!1}}}}function M(N){N.source===o&&typeof N.data=="string"&&N.data.indexOf(f)===0&&S(+N.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof c_<"u"?c_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ek)),Ek.exports}var DIe=RIe();const OIe=fl(DIe);function LIe(t){const e=new li;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 SG=LIe;async function MG(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 IIe(t){const e=await OIe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const b=p.startsWith("/")?p.slice(1):p,y=e.files[b];if(!y)return null;const x=await y.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 p=await c.async("string"),y=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let x=0;x<y.length;x++){const v=y[x],S=v.getAttribute("id");if(!S)continue;const M=Array.from(v.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(M.length>0){const A=M[0].getAttribute("value");A&&o.set(S,Math.max(0,parseInt(A,10)-1))}const N=v.getElementsByTagName("part");for(let A=0;A<N.length;A++){const k=N[A],C=k.getAttribute("id");if(!C)continue;const D=Array.from(k.children).filter(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(D.length>0){const T=D[0].getAttribute("value");T&&l.set(`${S}:${C}`,Math.max(0,parseInt(T,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(b=>b.endsWith(".model"));if(p){const b=await a(p);if(b){const y=await MG(b,0);y.length>0&&n.set("1",{id:"1",meshes:y,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 p=0;p<f.length;p++){const b=f[p],y=b.getAttribute("id");if(!y)continue;let x=o.get(y)??-1;if(x<0){const N=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(N,10)-1)}const v=[],S=b.getElementsByTagName("mesh");for(let N=0;N<S.length;N++){const A=S[N],k=[],C=[],D=A.getElementsByTagName("vertex");for(let R=0;R<D.length;R++){const U=D[R];k.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const T=A.getElementsByTagName("triangle");for(let R=0;R<T.length;R++){const U=T[R];C.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}k.length>0&&C.length>0&&v.push({vertices:k,triangles:C,extruder:x})}const M=b.getElementsByTagName("component");for(let N=0;N<M.length;N++){const A=M[N],k=A.getAttribute("p:path")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),C=A.getAttribute("objectid");if(k){const D=await a(k);if(D){const T=C?`${y}:${C}`:null,R=T?l.get(T)??x:x,U=await MG(D,R),O=A.getAttribute("transform"),q=SG(O);for(const j of U)if(O){const W=[];for(let K=0;K<j.vertices.length;K+=3){const G=new nt(j.vertices[K],j.vertices[K+1],j.vertices[K+2]);G.applyMatrix4(q),W.push(G.x,G.y,G.z)}v.push({vertices:W,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:x})}const m=d.getElementsByTagName("build");if(m.length>0){const p=m[0].getElementsByTagName("item");for(let b=0;b<p.length;b++){const y=p[b],x=y.getAttribute("objectid");if(!x)continue;const v=SG(y.getAttribute("transform"));r.push({objectId:x,transform:v})}}return{objects:n,buildItems:r}}function EG(t){const e=new bl,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 Ao(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function FIe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),[u,d]=w.useState(!0),[f,m]=w.useState(null);w.useEffect(()=>{if(!i.current)return;const y=i.current,x=y.clientWidth,v=y.clientHeight,S=new iRe;S.background=new Pn(1710618),o.current=S;const M=new _o(45,x/v,.1,1e4);M.position.set(150,150,150),l.current=M;const N=new xIe({antialias:!0});N.setSize(x,v),N.setPixelRatio(window.devicePixelRatio),y.appendChild(N.domElement),a.current=N;const A=new yIe(M,N.domElement);A.enableDamping=!0,A.dampingFactor=.05,c.current=A;const k=new bRe(16777215,.6);S.add(k);const C=new qV(16777215,.8);C.position.set(100,100,100),S.add(C);const D=new qV(16777215,.4);D.position.set(-100,50,-100),S.add(D);const T=Math.max(e.x,e.y),R=Math.ceil(T/16),U=new vRe(T,R,4473924,3355443);S.add(U);const O=new lL(e.x,e.y),q=new aL({color:44610,transparent:!0,opacity:.15,side:Ll}),j=new dl(O,q);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let W;const K=()=>{W=requestAnimationFrame(K),A.update(),N.render(S,M)};K(),fetch(t).then(J=>{if(!J.ok)throw new Error("Failed to load file");return J.arrayBuffer()}).then(IIe).then(({objects:J,buildItems:ie})=>{if(J.size===0)throw new Error("No meshes found in 3MF file");const re=we=>{const ee=n?.[we]||"#00ae42",Qe=new Pn(ee);return new fRe({color:Qe,shininess:30,flatShading:!1})},z=new $b,V=new Map;if(ie.length>0)for(const we of ie){const De=J.get(we.objectId);if(De)for(const ee of De.meshes){const Qe=we.extruder??ee.extruder,B=[];for(let Y=0;Y<ee.vertices.length;Y+=3){const H=new nt(ee.vertices[Y],ee.vertices[Y+1],ee.vertices[Y+2]);H.applyMatrix4(we.transform),B.push(H.x,H.y,H.z)}const te=EG({vertices:B,triangles:ee.triangles});V.has(Qe)||V.set(Qe,[]),V.get(Qe).push(te)}}else for(const we of J.values())for(const De of we.meshes){const ee=De.extruder,Qe=EG(De);V.has(ee)||V.set(ee,[]),V.get(ee).push(Qe)}for(const[we,De]of V){if(De.length===0)continue;const ee=De.length===1?De[0]:PIe(De,!1);if(ee){const Qe=re(we),B=new dl(ee,Qe);z.add(B)}if(De.length>1)for(const Qe of De)Qe.dispose()}const Z=new Qf().setFromObject(z),ne=Z.getCenter(new nt);z.position.y=-Z.min.y,ie.length===0&&(z.position.x=-ne.x,z.position.z=-ne.z),S.add(z);const he=new Qf().setFromObject(z),fe=he.getCenter(new nt),le=he.getSize(new nt),me=Math.max(le.x,le.y,le.z)*1.8;M.position.set(fe.x+me*.7,fe.y+me*.5,fe.z+me*.7),A.target.copy(fe),A.update(),d(!1)}).catch(J=>{m(J.message),d(!1)});const G=()=>{if(!y)return;const J=y.clientWidth,ie=y.clientHeight;M.aspect=J/ie,M.updateProjectionMatrix(),N.setSize(J,ie)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(W),A.dispose(),N.dispose(),y.removeChild(N.domElement)}},[t,e,n]);const p=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},b=y=>{l.current&&l.current.position.multiplyScalar(y)};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(dt,{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(Me,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:s.jsx($D,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(HD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(om,{className:"w-4 h-4"})})]})]})}const dN="159",fp={ROTATE:0,DOLLY:1,PAN:2},mp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},UIe=0,NG=1,zIe=2,Oee=1,BIe=2,$c=3,eh=0,ys=1,Kc=2,zd=0,sg=1,AG=2,TG=3,CG=4,$Ie=5,ef=100,HIe=101,VIe=102,kG=103,jG=104,GIe=200,WIe=201,qIe=202,KIe=203,yR=204,vR=205,XIe=206,YIe=207,ZIe=208,QIe=209,JIe=210,eFe=211,tFe=212,nFe=213,rFe=214,iFe=0,aFe=1,sFe=2,HS=3,oFe=4,lFe=5,cFe=6,uFe=7,dL=0,dFe=1,hFe=2,Bd=0,fFe=1,mFe=2,pFe=3,gFe=4,xFe=5,Lee=300,jg=301,Pg=302,_R=303,wR=304,hN=306,SR=1e3,Zo=1001,MR=1002,pa=1003,PG=1004,Nk=1005,wo=1006,bFe=1007,Y0=1008,$d=1009,yFe=1010,vFe=1011,hL=1012,Iee=1013,Cd=1014,Jc=1015,Z0=1016,Fee=1017,Uee=1018,Ef=1020,_Fe=1021,So=1023,wFe=1024,SFe=1025,Nf=1026,Rg=1027,MFe=1028,zee=1029,EFe=1030,Bee=1031,$ee=1033,Ak=33776,Tk=33777,Ck=33778,kk=33779,RG=35840,DG=35841,OG=35842,LG=35843,Hee=36196,IG=37492,FG=37496,UG=37808,zG=37809,BG=37810,$G=37811,HG=37812,VG=37813,GG=37814,WG=37815,qG=37816,KG=37817,XG=37818,YG=37819,ZG=37820,QG=37821,jk=36492,JG=36494,e7=36495,NFe=36283,t7=36284,n7=36285,r7=36286,Vee=3e3,Af=3001,AFe=3200,TFe=3201,Gee=0,CFe=1,Mo="",ga="srgb",vu="srgb-linear",fL="display-p3",fN="display-p3-linear",VS="linear",Cr="srgb",GS="rec709",WS="p3",pp=7680,i7=519,kFe=512,jFe=513,PFe=514,Wee=515,RFe=516,DFe=517,OFe=518,LFe=519,ER=35044,a7="300 es",NR=1035,Hl=2e3,Q0=2001;class dm{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 Ta=["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 s7=1234567;const r0=Math.PI/180,J0=180/Math.PI;function su(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ta[t&255]+Ta[t>>8&255]+Ta[t>>16&255]+Ta[t>>24&255]+"-"+Ta[e&255]+Ta[e>>8&255]+"-"+Ta[e>>16&15|64]+Ta[e>>24&255]+"-"+Ta[n&63|128]+Ta[n>>8&255]+"-"+Ta[n>>16&255]+Ta[n>>24&255]+Ta[r&255]+Ta[r>>8&255]+Ta[r>>16&255]+Ta[r>>24&255]).toLowerCase()}function xa(t,e,n){return Math.max(e,Math.min(n,t))}function mL(t,e){return(t%e+e)%e}function IFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function FFe(t,e,n){return t!==e?(n-t)/(e-t):0}function i0(t,e,n){return(1-n)*t+n*e}function UFe(t,e,n,r){return i0(t,e,1-Math.exp(-n*r))}function zFe(t,e=1){return e-Math.abs(mL(t,e*2)-e)}function BFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function $Fe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function HFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function VFe(t,e){return t+Math.random()*(e-t)}function GFe(t){return t*(.5-Math.random())}function WFe(t){t!==void 0&&(s7=t);let e=s7+=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 qFe(t){return t*r0}function KFe(t){return t*J0}function AR(t){return(t&t-1)===0&&t!==0}function XFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function qS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function YFe(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),m=o((e-r)/2),p=a((r-e)/2),b=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*b,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*b,l*u);break;case"ZYZ":t.set(c*b,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Il(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 dr(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 qee={DEG2RAD:r0,RAD2DEG:J0,generateUUID:su,clamp:xa,euclideanModulo:mL,mapLinear:IFe,inverseLerp:FFe,lerp:i0,damp:UFe,pingpong:zFe,smoothstep:BFe,smootherstep:$Fe,randInt:HFe,randFloat:VFe,randFloatSpread:GFe,seededRandom:WFe,degToRad:qFe,radToDeg:KFe,isPowerOfTwo:AR,ceilPowerOfTwo:XFe,floorPowerOfTwo:qS,setQuaternionFromProperEuler:YFe,normalize:dr,denormalize:Il};class pn{constructor(e=0,n=0){pn.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(xa(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 Tn{constructor(e,n,r,i,a,o,l,c,u){Tn.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],m=r[2],p=r[5],b=r[8],y=i[0],x=i[3],v=i[6],S=i[1],M=i[4],N=i[7],A=i[2],k=i[5],C=i[8];return a[0]=o*y+l*S+c*A,a[3]=o*x+l*M+c*k,a[6]=o*v+l*N+c*C,a[1]=u*y+d*S+f*A,a[4]=u*x+d*M+f*k,a[7]=u*v+d*N+f*C,a[2]=m*y+p*S+b*A,a[5]=m*x+p*M+b*k,a[8]=m*v+p*N+b*C,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,m=l*c-d*a,p=u*a-o*c,b=n*f+r*m+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,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(Pk.makeScale(e,n)),this}rotate(e){return this.premultiply(Pk.makeRotation(-e)),this}translate(e,n){return this.premultiply(Pk.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 Pk=new Tn;function Kee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function KS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function ZFe(){const t=KS("canvas");return t.style.display="block",t}const o7={};function a0(t){t in o7||(o7[t]=!0,console.warn(t))}const l7=new Tn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),c7=new Tn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),t1={[vu]:{transfer:VS,primaries:GS,toReference:t=>t,fromReference:t=>t},[ga]:{transfer:Cr,primaries:GS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[fN]:{transfer:VS,primaries:WS,toReference:t=>t.applyMatrix3(c7),fromReference:t=>t.applyMatrix3(l7)},[fL]:{transfer:Cr,primaries:WS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(c7),fromReference:t=>t.applyMatrix3(l7).convertLinearToSRGB()}},QFe=new Set([vu,fN]),hr={enabled:!0,_workingColorSpace:vu,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(!QFe.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=t1[e].toReference,i=t1[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 t1[t].primaries},getTransfer:function(t){return t===Mo?VS:t1[t].transfer}};function og(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Rk(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let gp;class Xee{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gp===void 0&&(gp=KS("canvas")),gp.width=e.width,gp.height=e.height;const r=gp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=gp}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=KS("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]=og(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(og(n[r]/255)*255):n[r]=og(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 JFe=0;class Yee{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:JFe++}),this.uuid=su(),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(Dk(i[o].image)):a.push(Dk(i[o]))}else a=Dk(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function Dk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Xee.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 e5e=0;class vs extends dm{constructor(e=vs.DEFAULT_IMAGE,n=vs.DEFAULT_MAPPING,r=Zo,i=Zo,a=wo,o=Y0,l=So,c=$d,u=vs.DEFAULT_ANISOTROPY,d=Mo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:e5e++}),this.uuid=su(),this.name="",this.source=new Yee(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 pn(0,0),this.repeat=new pn(1,1),this.center=new pn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Af?ga:Mo),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!==Lee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case SR:e.x=e.x-Math.floor(e.x);break;case Zo:e.x=e.x<0?0:1;break;case MR: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 SR:e.y=e.y-Math.floor(e.y);break;case Zo:e.y=e.y<0?0:1;break;case MR: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 a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ga?Af:Vee}set encoding(e){a0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Af?ga:Mo}}vs.DEFAULT_IMAGE=null;vs.DEFAULT_MAPPING=Lee;vs.DEFAULT_ANISOTROPY=1;class mr{constructor(e=0,n=0,r=0,i=1){mr.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],m=c[1],p=c[5],b=c[9],y=c[2],x=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,N=(p+1)/2,A=(v+1)/2,k=(d+m)/4,C=(f+y)/4,D=(b+x)/4;return M>N&&M>A?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=k/r,a=C/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=k/i,a=D/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=C/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-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 t5e extends dm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new mr(0,0,e,n),this.scissorTest=!1,this.viewport=new mr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(a0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Af?ga:Mo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new vs(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 Yee(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 Jf extends t5e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class Zee extends vs{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=pa,this.minFilter=pa,this.wrapR=Zo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class n5e extends vs{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=pa,this.minFilter=pa,this.wrapR=Zo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class em{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 m=a[o+0],p=a[o+1],b=a[o+2],y=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]=m,e[n+1]=p,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==b){let x=1-l;const v=c*m+u*p+d*b+f*y,S=v>=0?1:-1,M=1-v*v;if(M>Number.EPSILON){const A=Math.sqrt(M),k=Math.atan2(A,v*S);x=Math.sin(x*k)/A,l=Math.sin(l*k)/A}const N=l*S;if(c=c*x+m*N,u=u*x+p*N,d=d*x+b*N,f=f*x+y*N,x===1-l){const A=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=A,u*=A,d*=A,f*=A}}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],m=a[o+1],p=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*p-u*m,e[n+1]=c*b+d*m+u*f-l*p,e[n+2]=u*b+d*p+l*m-c*f,e[n+3]=d*b-l*f-c*m-u*p,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),m=c(r/2),p=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"YXZ":this._x=m*d*f+u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"ZXY":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f-m*p*b;break;case"ZYX":this._x=m*d*f-u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f+m*p*b;break;case"YZX":this._x=m*d*f+u*p*b,this._y=u*p*f+m*d*b,this._z=u*d*b-m*p*f,this._w=u*d*f-m*p*b;break;case"XZY":this._x=m*d*f-u*p*b,this._y=u*p*f-m*d*b,this._z=u*d*b+m*p*f,this._w=u*d*f+m*p*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],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}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(xa(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 p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*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,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=a*f+this._z*m,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 Fe{constructor(e=0,n=0,r=0){Fe.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(u7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(u7.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 Ok.copy(this).projectOnVector(e),this.sub(Ok)}reflect(e){return this.sub(Ok.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(xa(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 Ok=new Fe,u7=new em;class To{constructor(e=new Fe(1/0,1/0,1/0),n=new Fe(-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(Vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Vo.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=Vo.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,Vo):Vo.fromBufferAttribute(a,o),Vo.applyMatrix4(e.matrixWorld),this.expandByPoint(Vo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),n1.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),n1.copy(r.boundingBox)),n1.applyMatrix4(e.matrixWorld),this.union(n1)}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,Vo),Vo.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(Eb),r1.subVectors(this.max,Eb),xp.subVectors(e.a,Eb),bp.subVectors(e.b,Eb),yp.subVectors(e.c,Eb),id.subVectors(bp,xp),ad.subVectors(yp,bp),Bh.subVectors(xp,yp);let n=[0,-id.z,id.y,0,-ad.z,ad.y,0,-Bh.z,Bh.y,id.z,0,-id.x,ad.z,0,-ad.x,Bh.z,0,-Bh.x,-id.y,id.x,0,-ad.y,ad.x,0,-Bh.y,Bh.x,0];return!Lk(n,xp,bp,yp,r1)||(n=[1,0,0,0,1,0,0,0,1],!Lk(n,xp,bp,yp,r1))?!1:(i1.crossVectors(id,ad),n=[i1.x,i1.y,i1.z],Lk(n,xp,bp,yp,r1))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Vo).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:(Dc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dc),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 Dc=[new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe],Vo=new Fe,n1=new To,xp=new Fe,bp=new Fe,yp=new Fe,id=new Fe,ad=new Fe,Bh=new Fe,Eb=new Fe,r1=new Fe,i1=new Fe,$h=new Fe;function Lk(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 r5e=new To,Nb=new Fe,Ik=new Fe;class Kl{constructor(e=new Fe,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):r5e.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;Nb.subVectors(e,this.center);const n=Nb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Nb,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):(Ik.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Nb.copy(e.center).add(Ik)),this.expandByPoint(Nb.copy(e.center).sub(Ik))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Oc=new Fe,Fk=new Fe,a1=new Fe,sd=new Fe,Uk=new Fe,s1=new Fe,zk=new Fe;class pL{constructor(e=new Fe,n=new Fe(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,Oc)),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=Oc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Oc.copy(this.origin).addScaledVector(this.direction,n),Oc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Fk.copy(e).add(n).multiplyScalar(.5),a1.copy(n).sub(e).normalize(),sd.copy(this.origin).sub(Fk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(a1),l=sd.dot(this.direction),c=-sd.dot(a1),u=sd.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Fk).addScaledVector(a1,m),p}intersectSphere(e,n){Oc.subVectors(e.center,this.origin);const r=Oc.dot(this.direction),i=Oc.dot(Oc)-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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.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,Oc)!==null}intersectTriangle(e,n,r,i,a){Uk.subVectors(n,e),s1.subVectors(r,e),zk.crossVectors(Uk,s1);let o=this.direction.dot(zk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;sd.subVectors(this.origin,e);const c=l*this.direction.dot(s1.crossVectors(sd,s1));if(c<0)return null;const u=l*this.direction.dot(Uk.cross(sd));if(u<0||c+u>o)return null;const d=-l*sd.dot(zk);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 Er{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){Er.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,m,p,b,y,x)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=p,v[7]=b,v[11]=y,v[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 Er().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/vp.setFromMatrixColumn(e,0).length(),a=1/vp.setFromMatrixColumn(e,1).length(),o=1/vp.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 m=o*d,p=o*f,b=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=b+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m+y*l,n[4]=b*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-b,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,b=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=b+p*l,n[1]=p+b*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,b=l*d,y=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=b*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-b,n[2]=b*f-p,n[6]=l*d,n[10]=y*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(i5e,e,a5e)}lookAt(e,n,r){const i=this.elements;return Os.subVectors(e,n),Os.lengthSq()===0&&(Os.z=1),Os.normalize(),od.crossVectors(r,Os),od.lengthSq()===0&&(Math.abs(r.z)===1?Os.x+=1e-4:Os.z+=1e-4,Os.normalize(),od.crossVectors(r,Os)),od.normalize(),o1.crossVectors(Os,od),i[0]=od.x,i[4]=o1.x,i[8]=Os.x,i[1]=od.y,i[5]=o1.y,i[9]=Os.y,i[2]=od.z,i[6]=o1.z,i[10]=Os.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],m=r[9],p=r[13],b=r[2],y=r[6],x=r[10],v=r[14],S=r[3],M=r[7],N=r[11],A=r[15],k=i[0],C=i[4],D=i[8],T=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],K=i[10],G=i[14],J=i[3],ie=i[7],re=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*J,a[4]=o*C+l*U+c*W+u*ie,a[8]=o*D+l*O+c*K+u*re,a[12]=o*T+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*J,a[5]=d*C+f*U+m*W+p*ie,a[9]=d*D+f*O+m*K+p*re,a[13]=d*T+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*J,a[6]=b*C+y*U+x*W+v*ie,a[10]=b*D+y*O+x*K+v*re,a[14]=b*T+y*q+x*G+v*z,a[3]=S*k+M*R+N*j+A*J,a[7]=S*C+M*U+N*W+A*ie,a[11]=S*D+M*O+N*K+A*re,a[15]=S*T+M*q+N*G+A*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],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],m=e[10],p=e[14],b=e[3],y=e[7],x=e[11],v=e[15];return b*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+y*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+x*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+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],m=e[10],p=e[11],b=e[12],y=e[13],x=e[14],v=e[15],S=f*x*u-y*m*u+y*c*p-l*x*p-f*c*v+l*m*v,M=b*m*u-d*x*u-b*c*p+o*x*p+d*c*v-o*m*v,N=d*y*u-b*f*u+b*l*p-o*y*p-d*l*v+o*f*v,A=b*f*c-d*y*c-b*l*m+o*y*m+d*l*x-o*f*x,k=n*S+r*M+i*N+a*A;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=S*C,e[1]=(y*m*a-f*x*a-y*i*p+r*x*p+f*i*v-r*m*v)*C,e[2]=(l*x*a-y*c*a+y*i*u-r*x*u-l*i*v+r*c*v)*C,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*C,e[4]=M*C,e[5]=(d*x*a-b*m*a+b*i*p-n*x*p-d*i*v+n*m*v)*C,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*v-n*c*v)*C,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*C,e[8]=N*C,e[9]=(b*f*a-d*y*a-b*r*p+n*y*p+d*r*v-n*f*v)*C,e[10]=(o*y*a-b*l*a+b*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*C,e[12]=A*C,e[13]=(d*y*i-b*f*i+b*r*m-n*y*m-d*r*x+n*f*x)*C,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,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,m=a*u,p=a*d,b=a*f,y=o*d,x=o*f,v=l*f,S=c*u,M=c*d,N=c*f,A=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+N)*A,i[2]=(b-M)*A,i[3]=0,i[4]=(p-N)*k,i[5]=(1-(m+v))*k,i[6]=(x+S)*k,i[7]=0,i[8]=(b+M)*C,i[9]=(x-S)*C,i[10]=(1-(m+y))*C,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=vp.set(i[0],i[1],i[2]).length();const o=vp.set(i[4],i[5],i[6]).length(),l=vp.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],Go.copy(this);const u=1/a,d=1/o,f=1/l;return Go.elements[0]*=u,Go.elements[1]*=u,Go.elements[2]*=u,Go.elements[4]*=d,Go.elements[5]*=d,Go.elements[6]*=d,Go.elements[8]*=f,Go.elements[9]*=f,Go.elements[10]*=f,n.setFromRotationMatrix(Go),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Hl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,b;if(l===Hl)p=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===Q0)p=-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]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Hl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,p=(r+i)*d;let b,y;if(l===Hl)b=(o+a)*f,y=-2*f;else if(l===Q0)b=a*f,y=-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]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=y,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 vp=new Fe,Go=new Er,i5e=new Fe(0,0,0),a5e=new Fe(1,1,1),od=new Fe,o1=new Fe,Os=new Fe,d7=new Er,h7=new em;class Vy{constructor(e=0,n=0,r=0,i=Vy.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(xa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-xa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(xa(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-xa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(xa(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,p));break;case"XZY":this._z=Math.asin(-xa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),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 d7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(d7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return h7.setFromEuler(this),this.setFromQuaternion(h7,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}}Vy.DEFAULT_ORDER="XYZ";class Qee{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 s5e=0;const f7=new Fe,_p=new em,Lc=new Er,l1=new Fe,Ab=new Fe,o5e=new Fe,l5e=new em,m7=new Fe(1,0,0),p7=new Fe(0,1,0),g7=new Fe(0,0,1),c5e={type:"added"},u5e={type:"removed"};class Za extends dm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:s5e++}),this.uuid=su(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Za.DEFAULT_UP.clone();const e=new Fe,n=new Vy,r=new em,i=new Fe(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 Er},normalMatrix:{value:new Tn}}),this.matrix=new Er,this.matrixWorld=new Er,this.matrixAutoUpdate=Za.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Za.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Qee,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 _p.setFromAxisAngle(e,n),this.quaternion.multiply(_p),this}rotateOnWorldAxis(e,n){return _p.setFromAxisAngle(e,n),this.quaternion.premultiply(_p),this}rotateX(e){return this.rotateOnAxis(m7,e)}rotateY(e){return this.rotateOnAxis(p7,e)}rotateZ(e){return this.rotateOnAxis(g7,e)}translateOnAxis(e,n){return f7.copy(e).applyQuaternion(this.quaternion),this.position.add(f7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(m7,e)}translateY(e){return this.translateOnAxis(p7,e)}translateZ(e){return this.translateOnAxis(g7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Lc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?l1.copy(e):l1.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ab.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Lc.lookAt(Ab,l1,this.up):Lc.lookAt(l1,Ab,this.up),this.quaternion.setFromRotationMatrix(Lc),i&&(Lc.extractRotation(i.matrixWorld),_p.setFromRotationMatrix(Lc),this.quaternion.premultiply(_p.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(c5e)):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(u5e)),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),Lc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Lc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Lc),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(Ab,e,o5e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ab,l5e,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),m=o(e.skeletons),p=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),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),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}}Za.DEFAULT_UP=new Fe(0,1,0);Za.DEFAULT_MATRIX_AUTO_UPDATE=!0;Za.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Wo=new Fe,Ic=new Fe,Bk=new Fe,Fc=new Fe,wp=new Fe,Sp=new Fe,x7=new Fe,$k=new Fe,Hk=new Fe,Vk=new Fe;let c1=!1;class qo{constructor(e=new Fe,n=new Fe,r=new Fe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Wo.subVectors(e,n),i.cross(Wo);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){Wo.subVectors(i,n),Ic.subVectors(r,n),Bk.subVectors(e,n);const o=Wo.dot(Wo),l=Wo.dot(Ic),c=Wo.dot(Bk),u=Ic.dot(Ic),d=Ic.dot(Bk),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Fc),Fc.x>=0&&Fc.y>=0&&Fc.x+Fc.y<=1}static getUV(e,n,r,i,a,o,l,c){return c1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),c1=!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,Fc),c.setScalar(0),c.addScaledVector(a,Fc.x),c.addScaledVector(o,Fc.y),c.addScaledVector(l,Fc.z),c}static isFrontFacing(e,n,r,i){return Wo.subVectors(r,n),Ic.subVectors(e,n),Wo.cross(Ic).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 Wo.subVectors(this.c,this.b),Ic.subVectors(this.a,this.b),Wo.cross(Ic).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return qo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return c1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),c1=!0),qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return qo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qo.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;wp.subVectors(i,r),Sp.subVectors(a,r),$k.subVectors(e,r);const c=wp.dot($k),u=Sp.dot($k);if(c<=0&&u<=0)return n.copy(r);Hk.subVectors(e,i);const d=wp.dot(Hk),f=Sp.dot(Hk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(wp,o);Vk.subVectors(e,a);const p=wp.dot(Vk),b=Sp.dot(Vk);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Sp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return x7.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(x7,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(wp,o).addScaledVector(Sp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Jee={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},ld={h:0,s:0,l:0},u1={h:0,s:0,l:0};function Gk(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 en=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=ga){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,hr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=hr.workingColorSpace){return this.r=e,this.g=n,this.b=r,hr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=hr.workingColorSpace){if(e=mL(e,1),n=xa(n,0,1),r=xa(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=Gk(o,a,e+1/3),this.g=Gk(o,a,e),this.b=Gk(o,a,e-1/3)}return hr.toWorkingColorSpace(this,i),this}setStyle(e,n=ga){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=ga){const r=Jee[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=og(e.r),this.g=og(e.g),this.b=og(e.b),this}copyLinearToSRGB(e){return this.r=Rk(e.r),this.g=Rk(e.g),this.b=Rk(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ga){return hr.fromWorkingColorSpace(Ca.copy(this),e),Math.round(xa(Ca.r*255,0,255))*65536+Math.round(xa(Ca.g*255,0,255))*256+Math.round(xa(Ca.b*255,0,255))}getHexString(e=ga){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=hr.workingColorSpace){hr.fromWorkingColorSpace(Ca.copy(this),n);const r=Ca.r,i=Ca.g,a=Ca.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=hr.workingColorSpace){return hr.fromWorkingColorSpace(Ca.copy(this),n),e.r=Ca.r,e.g=Ca.g,e.b=Ca.b,e}getStyle(e=ga){hr.fromWorkingColorSpace(Ca.copy(this),e);const n=Ca.r,r=Ca.g,i=Ca.b;return e!==ga?`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(ld),this.setHSL(ld.h+e,ld.s+n,ld.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(ld),e.getHSL(u1);const r=i0(ld.h,u1.h,n),i=i0(ld.s,u1.s,n),a=i0(ld.l,u1.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 Ca=new en;en.NAMES=Jee;let d5e=0;class ux extends dm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:d5e++}),this.uuid=su(),this.name="",this.type="Material",this.blending=sg,this.side=eh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yR,this.blendDst=vR,this.blendEquation=ef,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new en(0,0,0),this.blendAlpha=0,this.depthFunc=HS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=i7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pp,this.stencilZFail=pp,this.stencilZPass=pp,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!==sg&&(r.blending=this.blending),this.side!==eh&&(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!==yR&&(r.blendSrc=this.blendSrc),this.blendDst!==vR&&(r.blendDst=this.blendDst),this.blendEquation!==ef&&(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!==HS&&(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!==i7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==pp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==pp&&(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 ete extends ux{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new en(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=dL,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 pi=new Fe,d1=new pn;class Ws{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=ER,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Jc,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++)d1.fromBufferAttribute(this,n),d1.applyMatrix3(e),this.setXY(n,d1.x,d1.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)pi.fromBufferAttribute(this,n),pi.applyMatrix3(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)pi.fromBufferAttribute(this,n),pi.applyMatrix4(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)pi.fromBufferAttribute(this,n),pi.applyNormalMatrix(e),this.setXYZ(n,pi.x,pi.y,pi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)pi.fromBufferAttribute(this,n),pi.transformDirection(e),this.setXYZ(n,pi.x,pi.y,pi.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=Il(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=dr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Il(n,this.array)),n}setX(e,n){return this.normalized&&(n=dr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Il(n,this.array)),n}setY(e,n){return this.normalized&&(n=dr(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=Il(n,this.array)),n}setZ(e,n){return this.normalized&&(n=dr(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=Il(n,this.array)),n}setW(e,n){return this.normalized&&(n=dr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=dr(n,this.array),r=dr(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=dr(n,this.array),r=dr(r,this.array),i=dr(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=dr(n,this.array),r=dr(r,this.array),i=dr(i,this.array),a=dr(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!==ER&&(e.usage=this.usage),e}}class tte extends Ws{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class nte extends Ws{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class ci extends Ws{constructor(e,n,r){super(new Float32Array(e),n,r)}}let h5e=0;const ho=new Er,Wk=new Za,Mp=new Fe,Ls=new To,Tb=new To,Ui=new Fe;class Ua extends dm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:h5e++}),this.uuid=su(),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(Kee(e)?nte:tte)(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 Tn().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 ho.makeRotationFromQuaternion(e),this.applyMatrix4(ho),this}rotateX(e){return ho.makeRotationX(e),this.applyMatrix4(ho),this}rotateY(e){return ho.makeRotationY(e),this.applyMatrix4(ho),this}rotateZ(e){return ho.makeRotationZ(e),this.applyMatrix4(ho),this}translate(e,n,r){return ho.makeTranslation(e,n,r),this.applyMatrix4(ho),this}scale(e,n,r){return ho.makeScale(e,n,r),this.applyMatrix4(ho),this}lookAt(e){return Wk.lookAt(e),Wk.updateMatrix(),this.applyMatrix4(Wk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mp).negate(),this.translate(Mp.x,Mp.y,Mp.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 ci(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new To);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 Fe(-1/0,-1/0,-1/0),new Fe(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];Ls.setFromBufferAttribute(a),this.morphTargetsRelative?(Ui.addVectors(this.boundingBox.min,Ls.min),this.boundingBox.expandByPoint(Ui),Ui.addVectors(this.boundingBox.max,Ls.max),this.boundingBox.expandByPoint(Ui)):(this.boundingBox.expandByPoint(Ls.min),this.boundingBox.expandByPoint(Ls.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 Kl);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 Fe,1/0);return}if(e){const r=this.boundingSphere.center;if(Ls.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Tb.setFromBufferAttribute(l),this.morphTargetsRelative?(Ui.addVectors(Ls.min,Tb.min),Ls.expandByPoint(Ui),Ui.addVectors(Ls.max,Tb.max),Ls.expandByPoint(Ui)):(Ls.expandByPoint(Tb.min),Ls.expandByPoint(Tb.max))}Ls.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Ui.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ui));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++)Ui.fromBufferAttribute(l,u),c&&(Mp.fromBufferAttribute(e,u),Ui.add(Mp)),i=Math.max(i,r.distanceToSquared(Ui))}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 Ws(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new Fe,d[R]=new Fe;const f=new Fe,m=new Fe,p=new Fe,b=new pn,y=new pn,x=new pn,v=new Fe,S=new Fe;function M(R,U,O){f.fromArray(i,R*3),m.fromArray(i,U*3),p.fromArray(i,O*3),b.fromArray(o,R*2),y.fromArray(o,U*2),x.fromArray(o,O*2),m.sub(f),p.sub(f),y.sub(b),x.sub(b);const q=1/(y.x*x.y-x.x*y.y);isFinite(q)&&(v.copy(m).multiplyScalar(x.y).addScaledVector(p,-y.y).multiplyScalar(q),S.copy(p).multiplyScalar(y.x).addScaledVector(m,-x.x).multiplyScalar(q),u[R].add(v),u[U].add(v),u[O].add(v),d[R].add(S),d[U].add(S),d[O].add(S))}let N=this.groups;N.length===0&&(N=[{start:0,count:r.length}]);for(let R=0,U=N.length;R<U;++R){const O=N[R],q=O.start,j=O.count;for(let W=q,K=q+j;W<K;W+=3)M(r[W+0],r[W+1],r[W+2])}const A=new Fe,k=new Fe,C=new Fe,D=new Fe;function T(R){C.fromArray(a,R*3),D.copy(C);const U=u[R];A.copy(U),A.sub(C.multiplyScalar(C.dot(U))).normalize(),k.crossVectors(D,U);const q=k.dot(d[R])<0?-1:1;c[R*4]=A.x,c[R*4+1]=A.y,c[R*4+2]=A.z,c[R*4+3]=q}for(let R=0,U=N.length;R<U;++R){const O=N[R],q=O.start,j=O.count;for(let W=q,K=q+j;W<K;W+=3)T(r[W+0]),T(r[W+1]),T(r[W+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 Ws(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new Fe,a=new Fe,o=new Fe,l=new Fe,c=new Fe,u=new Fe,d=new Fe,f=new Fe;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)Ui.fromBufferAttribute(e,n),Ui.normalize(),e.setXYZ(n,Ui.x,Ui.y,Ui.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[b++]=u[p++]}return new Ws(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ua,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 m=u[d],p=e(m,r);c.push(p)}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,m=u.length;f<m;f++){const p=u[f];d.push(p.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 m=0,p=f.length;m<p;m++)d.push(f[m].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 b7=new Er,Hh=new pL,h1=new Kl,y7=new Fe,Ep=new Fe,Np=new Fe,Ap=new Fe,qk=new Fe,f1=new Fe,m1=new pn,p1=new pn,g1=new pn,v7=new Fe,_7=new Fe,w7=new Fe,x1=new Fe,b1=new Fe;class el extends Za{constructor(e=new Ua,n=new ete){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){f1.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(qk.fromBufferAttribute(f,e),o?f1.addScaledVector(qk,d):f1.addScaledVector(qk.sub(n),d))}n.add(f1)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),h1.copy(r.boundingSphere),h1.applyMatrix4(a),Hh.copy(e.ray).recast(e.near),!(h1.containsPoint(Hh.origin)===!1&&(Hh.intersectSphere(h1,y7)===null||Hh.origin.distanceToSquared(y7)>(e.far-e.near)**2))&&(b7.copy(a).invert(),Hh.copy(e.ray).applyMatrix4(b7),!(r.boundingBox!==null&&Hh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Hh)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(l.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=l.getX(N),C=l.getX(N+1),D=l.getX(N+2);i=y1(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),M=l.getX(x+1),N=l.getX(x+2);i=y1(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=m.length;b<y;b++){const x=m[b],v=o[x.materialIndex],S=Math.max(x.start,p.start),M=Math.min(c.count,Math.min(x.start+x.count,p.start+p.count));for(let N=S,A=M;N<A;N+=3){const k=N,C=N+1,D=N+2;i=y1(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let x=b,v=y;x<v;x+=3){const S=x,M=x+1,N=x+2;i=y1(this,o,e,r,u,d,f,S,M,N),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function f5e(t,e,n,r,i,a,o,l){let c;if(e.side===ys?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===eh,l),c===null)return null;b1.copy(l),b1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(b1);return u<n.near||u>n.far?null:{distance:u,point:b1.clone(),object:t}}function y1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Ep),t.getVertexPosition(c,Np),t.getVertexPosition(u,Ap);const d=f5e(t,e,n,r,Ep,Np,Ap,x1);if(d){i&&(m1.fromBufferAttribute(i,l),p1.fromBufferAttribute(i,c),g1.fromBufferAttribute(i,u),d.uv=qo.getInterpolation(x1,Ep,Np,Ap,m1,p1,g1,new pn)),a&&(m1.fromBufferAttribute(a,l),p1.fromBufferAttribute(a,c),g1.fromBufferAttribute(a,u),d.uv1=qo.getInterpolation(x1,Ep,Np,Ap,m1,p1,g1,new pn),d.uv2=d.uv1),o&&(v7.fromBufferAttribute(o,l),_7.fromBufferAttribute(o,c),w7.fromBufferAttribute(o,u),d.normal=qo.getInterpolation(x1,Ep,Np,Ap,v7,_7,w7,new Fe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Fe,materialIndex:0};qo.getNormal(Ep,Np,Ap,f.normal),d.face=f}return d}class Gy extends Ua{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 m=0,p=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 ci(u,3)),this.setAttribute("normal",new ci(d,3)),this.setAttribute("uv",new ci(f,2));function b(y,x,v,S,M,N,A,k,C,D,T){const R=N/C,U=A/D,O=N/2,q=A/2,j=k/2,W=C+1,K=D+1;let G=0,J=0;const ie=new Fe;for(let re=0;re<K;re++){const z=re*U-q;for(let V=0;V<W;V++){const Z=V*R-O;ie[y]=Z*S,ie[x]=z*M,ie[v]=j,u.push(ie.x,ie.y,ie.z),ie[y]=0,ie[x]=0,ie[v]=k>0?1:-1,d.push(ie.x,ie.y,ie.z),f.push(V/C),f.push(1-re/D),G+=1}}for(let re=0;re<D;re++)for(let z=0;z<C;z++){const V=m+z+W*re,Z=m+z+W*(re+1),ne=m+(z+1)+W*(re+1),he=m+(z+1)+W*re;c.push(V,Z,he),c.push(Z,ne,he),J+=6}l.addGroup(p,J,T),p+=J,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Dg(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 Va(t){const e={};for(let n=0;n<t.length;n++){const r=Dg(t[n]);for(const i in r)e[i]=r[i]}return e}function m5e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function rte(t){return t.getRenderTarget()===null?t.outputColorSpace:hr.workingColorSpace}const gL={clone:Dg,merge:Va};var p5e=`void main() {
  3968. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3969. }`,g5e=`void main() {
  3970. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3971. }`;class th extends ux{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=p5e,this.fragmentShader=g5e,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=Dg(e.uniforms),this.uniformsGroups=m5e(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 ite extends Za{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Er,this.projectionMatrix=new Er,this.projectionMatrixInverse=new Er,this.coordinateSystem=Hl}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 Is extends ite{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=J0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(r0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return J0*2*Math.atan(Math.tan(r0*.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(r0*.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 Tp=-90,Cp=1;class x5e extends Za{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Is(Tp,Cp,e,n);i.layers=this.layers,this.add(i);const a=new Is(Tp,Cp,e,n);a.layers=this.layers,this.add(a);const o=new Is(Tp,Cp,e,n);o.layers=this.layers,this.add(o);const l=new Is(Tp,Cp,e,n);l.layers=this.layers,this.add(l);const c=new Is(Tp,Cp,e,n);c.layers=this.layers,this.add(c);const u=new Is(Tp,Cp,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===Hl)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===Q0)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class ate extends vs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:jg,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 b5e extends Jf{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&&(a0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Af?ga:Mo),this.texture=new ate(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:wo}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:`
  3972. varying vec3 vWorldDirection;
  3973. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3974. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3975. }
  3976. void main() {
  3977. vWorldDirection = transformDirection( position, modelMatrix );
  3978. #include <begin_vertex>
  3979. #include <project_vertex>
  3980. }
  3981. `,fragmentShader:`
  3982. uniform sampler2D tEquirect;
  3983. varying vec3 vWorldDirection;
  3984. #include <common>
  3985. void main() {
  3986. vec3 direction = normalize( vWorldDirection );
  3987. vec2 sampleUV = equirectUv( direction );
  3988. gl_FragColor = texture2D( tEquirect, sampleUV );
  3989. }
  3990. `},i=new Gy(5,5,5),a=new th({name:"CubemapFromEquirect",uniforms:Dg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ys,blending:zd});a.uniforms.tEquirect.value=n;const o=new el(i,a),l=n.minFilter;return n.minFilter===Y0&&(n.minFilter=wo),new x5e(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 Kk=new Fe,y5e=new Fe,v5e=new Tn;class xd{constructor(e=new Fe(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=Kk.subVectors(r,n).cross(y5e.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(Kk),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||v5e.getNormalMatrix(e),i=this.coplanarPoint(Kk).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 Vh=new Kl,v1=new Fe;class mN{constructor(e=new xd,n=new xd,r=new xd,i=new xd,a=new xd,o=new xd){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=Hl){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],m=i[7],p=i[8],b=i[9],y=i[10],x=i[11],v=i[12],S=i[13],M=i[14],N=i[15];if(r[0].setComponents(c-a,m-u,x-p,N-v).normalize(),r[1].setComponents(c+a,m+u,x+p,N+v).normalize(),r[2].setComponents(c+o,m+d,x+b,N+S).normalize(),r[3].setComponents(c-o,m-d,x-b,N-S).normalize(),r[4].setComponents(c-l,m-f,x-y,N-M).normalize(),n===Hl)r[5].setComponents(c+l,m+f,x+y,N+M).normalize();else if(n===Q0)r[5].setComponents(l,f,y,M).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(),Vh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Vh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vh)}intersectsSprite(e){return Vh.center.set(0,0,0),Vh.radius=.7071067811865476,Vh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vh)}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(v1.x=i.normal.x>0?e.max.x:e.min.x,v1.y=i.normal.y>0?e.max.y:e.min.y,v1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(v1)<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 ste(){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 _5e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,p=f.byteLength,b=t.createBuffer();t.bindBuffer(d,b),t.bufferData(d,f,m),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:b,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const m=d.array,p=d._updateRange,b=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&b.length===0&&t.bufferSubData(f,0,m),b.length!==0){for(let y=0,x=b.length;y<x;y++){const v=b[y];n?t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m,v.start,v.count):t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m,p.offset,p.count):t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m.subarray(p.offset,p.offset+p.count)),p.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 m=r.get(u);(!m||m.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 xL extends Ua{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,m=n/c,p=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const N=M*f-a;b.push(N,-S,0),y.push(0,0,1),x.push(M/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const M=S+u*v,N=S+u*(v+1),A=S+1+u*(v+1),k=S+1+u*v;p.push(M,N,k),p.push(N,A,k)}this.setIndex(p),this.setAttribute("position",new ci(b,3)),this.setAttribute("normal",new ci(y,3)),this.setAttribute("uv",new ci(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xL(e.width,e.height,e.widthSegments,e.heightSegments)}}var w5e=`#ifdef USE_ALPHAHASH
  3991. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3992. #endif`,S5e=`#ifdef USE_ALPHAHASH
  3993. const float ALPHA_HASH_SCALE = 0.05;
  3994. float hash2D( vec2 value ) {
  3995. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3996. }
  3997. float hash3D( vec3 value ) {
  3998. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3999. }
  4000. float getAlphaHashThreshold( vec3 position ) {
  4001. float maxDeriv = max(
  4002. length( dFdx( position.xyz ) ),
  4003. length( dFdy( position.xyz ) )
  4004. );
  4005. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  4006. vec2 pixScales = vec2(
  4007. exp2( floor( log2( pixScale ) ) ),
  4008. exp2( ceil( log2( pixScale ) ) )
  4009. );
  4010. vec2 alpha = vec2(
  4011. hash3D( floor( pixScales.x * position.xyz ) ),
  4012. hash3D( floor( pixScales.y * position.xyz ) )
  4013. );
  4014. float lerpFactor = fract( log2( pixScale ) );
  4015. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  4016. float a = min( lerpFactor, 1.0 - lerpFactor );
  4017. vec3 cases = vec3(
  4018. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  4019. ( x - 0.5 * a ) / ( 1.0 - a ),
  4020. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  4021. );
  4022. float threshold = ( x < ( 1.0 - a ) )
  4023. ? ( ( x < a ) ? cases.x : cases.y )
  4024. : cases.z;
  4025. return clamp( threshold , 1.0e-6, 1.0 );
  4026. }
  4027. #endif`,M5e=`#ifdef USE_ALPHAMAP
  4028. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  4029. #endif`,E5e=`#ifdef USE_ALPHAMAP
  4030. uniform sampler2D alphaMap;
  4031. #endif`,N5e=`#ifdef USE_ALPHATEST
  4032. if ( diffuseColor.a < alphaTest ) discard;
  4033. #endif`,A5e=`#ifdef USE_ALPHATEST
  4034. uniform float alphaTest;
  4035. #endif`,T5e=`#ifdef USE_AOMAP
  4036. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  4037. reflectedLight.indirectDiffuse *= ambientOcclusion;
  4038. #if defined( USE_CLEARCOAT )
  4039. clearcoatSpecularIndirect *= ambientOcclusion;
  4040. #endif
  4041. #if defined( USE_SHEEN )
  4042. sheenSpecularIndirect *= ambientOcclusion;
  4043. #endif
  4044. #if defined( USE_ENVMAP ) && defined( STANDARD )
  4045. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  4046. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  4047. #endif
  4048. #endif`,C5e=`#ifdef USE_AOMAP
  4049. uniform sampler2D aoMap;
  4050. uniform float aoMapIntensity;
  4051. #endif`,k5e=`#ifdef USE_BATCHING
  4052. attribute float batchId;
  4053. uniform highp sampler2D batchingTexture;
  4054. mat4 getBatchingMatrix( const in float i ) {
  4055. int size = textureSize( batchingTexture, 0 ).x;
  4056. int j = int( i ) * 4;
  4057. int x = j % size;
  4058. int y = j / size;
  4059. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4060. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4061. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4062. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4063. return mat4( v1, v2, v3, v4 );
  4064. }
  4065. #endif`,j5e=`#ifdef USE_BATCHING
  4066. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4067. #endif`,P5e=`vec3 transformed = vec3( position );
  4068. #ifdef USE_ALPHAHASH
  4069. vPosition = vec3( position );
  4070. #endif`,R5e=`vec3 objectNormal = vec3( normal );
  4071. #ifdef USE_TANGENT
  4072. vec3 objectTangent = vec3( tangent.xyz );
  4073. #endif`,D5e=`float G_BlinnPhong_Implicit( ) {
  4074. return 0.25;
  4075. }
  4076. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4077. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4078. }
  4079. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4080. vec3 halfDir = normalize( lightDir + viewDir );
  4081. float dotNH = saturate( dot( normal, halfDir ) );
  4082. float dotVH = saturate( dot( viewDir, halfDir ) );
  4083. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4084. float G = G_BlinnPhong_Implicit( );
  4085. float D = D_BlinnPhong( shininess, dotNH );
  4086. return F * ( G * D );
  4087. } // validated`,O5e=`#ifdef USE_IRIDESCENCE
  4088. const mat3 XYZ_TO_REC709 = mat3(
  4089. 3.2404542, -0.9692660, 0.0556434,
  4090. -1.5371385, 1.8760108, -0.2040259,
  4091. -0.4985314, 0.0415560, 1.0572252
  4092. );
  4093. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4094. vec3 sqrtF0 = sqrt( fresnel0 );
  4095. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4096. }
  4097. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4098. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4099. }
  4100. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4101. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4102. }
  4103. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4104. float phase = 2.0 * PI * OPD * 1.0e-9;
  4105. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4106. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4107. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4108. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4109. 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 ) );
  4110. xyz /= 1.0685e-7;
  4111. vec3 rgb = XYZ_TO_REC709 * xyz;
  4112. return rgb;
  4113. }
  4114. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4115. vec3 I;
  4116. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4117. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4118. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4119. if ( cosTheta2Sq < 0.0 ) {
  4120. return vec3( 1.0 );
  4121. }
  4122. float cosTheta2 = sqrt( cosTheta2Sq );
  4123. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4124. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4125. float T121 = 1.0 - R12;
  4126. float phi12 = 0.0;
  4127. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4128. float phi21 = PI - phi12;
  4129. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4130. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4131. vec3 phi23 = vec3( 0.0 );
  4132. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4133. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4134. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4135. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4136. vec3 phi = vec3( phi21 ) + phi23;
  4137. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4138. vec3 r123 = sqrt( R123 );
  4139. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4140. vec3 C0 = R12 + Rs;
  4141. I = C0;
  4142. vec3 Cm = Rs - T121;
  4143. for ( int m = 1; m <= 2; ++ m ) {
  4144. Cm *= r123;
  4145. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4146. I += Cm * Sm;
  4147. }
  4148. return max( I, vec3( 0.0 ) );
  4149. }
  4150. #endif`,L5e=`#ifdef USE_BUMPMAP
  4151. uniform sampler2D bumpMap;
  4152. uniform float bumpScale;
  4153. vec2 dHdxy_fwd() {
  4154. vec2 dSTdx = dFdx( vBumpMapUv );
  4155. vec2 dSTdy = dFdy( vBumpMapUv );
  4156. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4157. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4158. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4159. return vec2( dBx, dBy );
  4160. }
  4161. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4162. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4163. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4164. vec3 vN = surf_norm;
  4165. vec3 R1 = cross( vSigmaY, vN );
  4166. vec3 R2 = cross( vN, vSigmaX );
  4167. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4168. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4169. return normalize( abs( fDet ) * surf_norm - vGrad );
  4170. }
  4171. #endif`,I5e=`#if NUM_CLIPPING_PLANES > 0
  4172. vec4 plane;
  4173. #pragma unroll_loop_start
  4174. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4175. plane = clippingPlanes[ i ];
  4176. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4177. }
  4178. #pragma unroll_loop_end
  4179. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4180. bool clipped = true;
  4181. #pragma unroll_loop_start
  4182. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4183. plane = clippingPlanes[ i ];
  4184. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4185. }
  4186. #pragma unroll_loop_end
  4187. if ( clipped ) discard;
  4188. #endif
  4189. #endif`,F5e=`#if NUM_CLIPPING_PLANES > 0
  4190. varying vec3 vClipPosition;
  4191. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4192. #endif`,U5e=`#if NUM_CLIPPING_PLANES > 0
  4193. varying vec3 vClipPosition;
  4194. #endif`,z5e=`#if NUM_CLIPPING_PLANES > 0
  4195. vClipPosition = - mvPosition.xyz;
  4196. #endif`,B5e=`#if defined( USE_COLOR_ALPHA )
  4197. diffuseColor *= vColor;
  4198. #elif defined( USE_COLOR )
  4199. diffuseColor.rgb *= vColor;
  4200. #endif`,$5e=`#if defined( USE_COLOR_ALPHA )
  4201. varying vec4 vColor;
  4202. #elif defined( USE_COLOR )
  4203. varying vec3 vColor;
  4204. #endif`,H5e=`#if defined( USE_COLOR_ALPHA )
  4205. varying vec4 vColor;
  4206. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4207. varying vec3 vColor;
  4208. #endif`,V5e=`#if defined( USE_COLOR_ALPHA )
  4209. vColor = vec4( 1.0 );
  4210. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4211. vColor = vec3( 1.0 );
  4212. #endif
  4213. #ifdef USE_COLOR
  4214. vColor *= color;
  4215. #endif
  4216. #ifdef USE_INSTANCING_COLOR
  4217. vColor.xyz *= instanceColor.xyz;
  4218. #endif`,G5e=`#define PI 3.141592653589793
  4219. #define PI2 6.283185307179586
  4220. #define PI_HALF 1.5707963267948966
  4221. #define RECIPROCAL_PI 0.3183098861837907
  4222. #define RECIPROCAL_PI2 0.15915494309189535
  4223. #define EPSILON 1e-6
  4224. #ifndef saturate
  4225. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4226. #endif
  4227. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4228. float pow2( const in float x ) { return x*x; }
  4229. vec3 pow2( const in vec3 x ) { return x*x; }
  4230. float pow3( const in float x ) { return x*x*x; }
  4231. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4232. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4233. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4234. highp float rand( const in vec2 uv ) {
  4235. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4236. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4237. return fract( sin( sn ) * c );
  4238. }
  4239. #ifdef HIGH_PRECISION
  4240. float precisionSafeLength( vec3 v ) { return length( v ); }
  4241. #else
  4242. float precisionSafeLength( vec3 v ) {
  4243. float maxComponent = max3( abs( v ) );
  4244. return length( v / maxComponent ) * maxComponent;
  4245. }
  4246. #endif
  4247. struct IncidentLight {
  4248. vec3 color;
  4249. vec3 direction;
  4250. bool visible;
  4251. };
  4252. struct ReflectedLight {
  4253. vec3 directDiffuse;
  4254. vec3 directSpecular;
  4255. vec3 indirectDiffuse;
  4256. vec3 indirectSpecular;
  4257. };
  4258. #ifdef USE_ALPHAHASH
  4259. varying vec3 vPosition;
  4260. #endif
  4261. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4262. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4263. }
  4264. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4265. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4266. }
  4267. mat3 transposeMat3( const in mat3 m ) {
  4268. mat3 tmp;
  4269. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4270. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4271. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4272. return tmp;
  4273. }
  4274. float luminance( const in vec3 rgb ) {
  4275. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4276. return dot( weights, rgb );
  4277. }
  4278. bool isPerspectiveMatrix( mat4 m ) {
  4279. return m[ 2 ][ 3 ] == - 1.0;
  4280. }
  4281. vec2 equirectUv( in vec3 dir ) {
  4282. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4283. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4284. return vec2( u, v );
  4285. }
  4286. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4287. return RECIPROCAL_PI * diffuseColor;
  4288. }
  4289. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4290. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4291. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4292. }
  4293. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4294. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4295. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4296. } // validated`,W5e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4297. #define cubeUV_minMipLevel 4.0
  4298. #define cubeUV_minTileSize 16.0
  4299. float getFace( vec3 direction ) {
  4300. vec3 absDirection = abs( direction );
  4301. float face = - 1.0;
  4302. if ( absDirection.x > absDirection.z ) {
  4303. if ( absDirection.x > absDirection.y )
  4304. face = direction.x > 0.0 ? 0.0 : 3.0;
  4305. else
  4306. face = direction.y > 0.0 ? 1.0 : 4.0;
  4307. } else {
  4308. if ( absDirection.z > absDirection.y )
  4309. face = direction.z > 0.0 ? 2.0 : 5.0;
  4310. else
  4311. face = direction.y > 0.0 ? 1.0 : 4.0;
  4312. }
  4313. return face;
  4314. }
  4315. vec2 getUV( vec3 direction, float face ) {
  4316. vec2 uv;
  4317. if ( face == 0.0 ) {
  4318. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4319. } else if ( face == 1.0 ) {
  4320. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4321. } else if ( face == 2.0 ) {
  4322. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4323. } else if ( face == 3.0 ) {
  4324. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4325. } else if ( face == 4.0 ) {
  4326. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4327. } else {
  4328. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4329. }
  4330. return 0.5 * ( uv + 1.0 );
  4331. }
  4332. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4333. float face = getFace( direction );
  4334. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4335. mipInt = max( mipInt, cubeUV_minMipLevel );
  4336. float faceSize = exp2( mipInt );
  4337. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4338. if ( face > 2.0 ) {
  4339. uv.y += faceSize;
  4340. face -= 3.0;
  4341. }
  4342. uv.x += face * faceSize;
  4343. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4344. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4345. uv.x *= CUBEUV_TEXEL_WIDTH;
  4346. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4347. #ifdef texture2DGradEXT
  4348. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4349. #else
  4350. return texture2D( envMap, uv ).rgb;
  4351. #endif
  4352. }
  4353. #define cubeUV_r0 1.0
  4354. #define cubeUV_v0 0.339
  4355. #define cubeUV_m0 - 2.0
  4356. #define cubeUV_r1 0.8
  4357. #define cubeUV_v1 0.276
  4358. #define cubeUV_m1 - 1.0
  4359. #define cubeUV_r4 0.4
  4360. #define cubeUV_v4 0.046
  4361. #define cubeUV_m4 2.0
  4362. #define cubeUV_r5 0.305
  4363. #define cubeUV_v5 0.016
  4364. #define cubeUV_m5 3.0
  4365. #define cubeUV_r6 0.21
  4366. #define cubeUV_v6 0.0038
  4367. #define cubeUV_m6 4.0
  4368. float roughnessToMip( float roughness ) {
  4369. float mip = 0.0;
  4370. if ( roughness >= cubeUV_r1 ) {
  4371. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4372. } else if ( roughness >= cubeUV_r4 ) {
  4373. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4374. } else if ( roughness >= cubeUV_r5 ) {
  4375. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4376. } else if ( roughness >= cubeUV_r6 ) {
  4377. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4378. } else {
  4379. mip = - 2.0 * log2( 1.16 * roughness ); }
  4380. return mip;
  4381. }
  4382. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4383. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4384. float mipF = fract( mip );
  4385. float mipInt = floor( mip );
  4386. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4387. if ( mipF == 0.0 ) {
  4388. return vec4( color0, 1.0 );
  4389. } else {
  4390. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4391. return vec4( mix( color0, color1, mipF ), 1.0 );
  4392. }
  4393. }
  4394. #endif`,q5e=`vec3 transformedNormal = objectNormal;
  4395. #ifdef USE_TANGENT
  4396. vec3 transformedTangent = objectTangent;
  4397. #endif
  4398. #ifdef USE_BATCHING
  4399. mat3 bm = mat3( batchingMatrix );
  4400. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4401. transformedNormal = bm * transformedNormal;
  4402. #ifdef USE_TANGENT
  4403. transformedTangent = bm * transformedTangent;
  4404. #endif
  4405. #endif
  4406. #ifdef USE_INSTANCING
  4407. mat3 im = mat3( instanceMatrix );
  4408. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4409. transformedNormal = im * transformedNormal;
  4410. #ifdef USE_TANGENT
  4411. transformedTangent = im * transformedTangent;
  4412. #endif
  4413. #endif
  4414. transformedNormal = normalMatrix * transformedNormal;
  4415. #ifdef FLIP_SIDED
  4416. transformedNormal = - transformedNormal;
  4417. #endif
  4418. #ifdef USE_TANGENT
  4419. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4420. #ifdef FLIP_SIDED
  4421. transformedTangent = - transformedTangent;
  4422. #endif
  4423. #endif`,K5e=`#ifdef USE_DISPLACEMENTMAP
  4424. uniform sampler2D displacementMap;
  4425. uniform float displacementScale;
  4426. uniform float displacementBias;
  4427. #endif`,X5e=`#ifdef USE_DISPLACEMENTMAP
  4428. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4429. #endif`,Y5e=`#ifdef USE_EMISSIVEMAP
  4430. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4431. totalEmissiveRadiance *= emissiveColor.rgb;
  4432. #endif`,Z5e=`#ifdef USE_EMISSIVEMAP
  4433. uniform sampler2D emissiveMap;
  4434. #endif`,Q5e="gl_FragColor = linearToOutputTexel( gl_FragColor );",J5e=`
  4435. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4436. vec3( 0.8224621, 0.177538, 0.0 ),
  4437. vec3( 0.0331941, 0.9668058, 0.0 ),
  4438. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4439. );
  4440. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4441. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4442. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4443. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4444. );
  4445. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4446. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4447. }
  4448. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4449. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4450. }
  4451. vec4 LinearTransferOETF( in vec4 value ) {
  4452. return value;
  4453. }
  4454. vec4 sRGBTransferOETF( in vec4 value ) {
  4455. 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 );
  4456. }
  4457. vec4 LinearToLinear( in vec4 value ) {
  4458. return value;
  4459. }
  4460. vec4 LinearTosRGB( in vec4 value ) {
  4461. return sRGBTransferOETF( value );
  4462. }`,eUe=`#ifdef USE_ENVMAP
  4463. #ifdef ENV_WORLDPOS
  4464. vec3 cameraToFrag;
  4465. if ( isOrthographic ) {
  4466. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4467. } else {
  4468. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4469. }
  4470. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4471. #ifdef ENVMAP_MODE_REFLECTION
  4472. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4473. #else
  4474. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4475. #endif
  4476. #else
  4477. vec3 reflectVec = vReflect;
  4478. #endif
  4479. #ifdef ENVMAP_TYPE_CUBE
  4480. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4481. #else
  4482. vec4 envColor = vec4( 0.0 );
  4483. #endif
  4484. #ifdef ENVMAP_BLENDING_MULTIPLY
  4485. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4486. #elif defined( ENVMAP_BLENDING_MIX )
  4487. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4488. #elif defined( ENVMAP_BLENDING_ADD )
  4489. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4490. #endif
  4491. #endif`,tUe=`#ifdef USE_ENVMAP
  4492. uniform float envMapIntensity;
  4493. uniform float flipEnvMap;
  4494. #ifdef ENVMAP_TYPE_CUBE
  4495. uniform samplerCube envMap;
  4496. #else
  4497. uniform sampler2D envMap;
  4498. #endif
  4499. #endif`,nUe=`#ifdef USE_ENVMAP
  4500. uniform float reflectivity;
  4501. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4502. #define ENV_WORLDPOS
  4503. #endif
  4504. #ifdef ENV_WORLDPOS
  4505. varying vec3 vWorldPosition;
  4506. uniform float refractionRatio;
  4507. #else
  4508. varying vec3 vReflect;
  4509. #endif
  4510. #endif`,rUe=`#ifdef USE_ENVMAP
  4511. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4512. #define ENV_WORLDPOS
  4513. #endif
  4514. #ifdef ENV_WORLDPOS
  4515. varying vec3 vWorldPosition;
  4516. #else
  4517. varying vec3 vReflect;
  4518. uniform float refractionRatio;
  4519. #endif
  4520. #endif`,iUe=`#ifdef USE_ENVMAP
  4521. #ifdef ENV_WORLDPOS
  4522. vWorldPosition = worldPosition.xyz;
  4523. #else
  4524. vec3 cameraToVertex;
  4525. if ( isOrthographic ) {
  4526. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4527. } else {
  4528. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4529. }
  4530. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4531. #ifdef ENVMAP_MODE_REFLECTION
  4532. vReflect = reflect( cameraToVertex, worldNormal );
  4533. #else
  4534. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4535. #endif
  4536. #endif
  4537. #endif`,aUe=`#ifdef USE_FOG
  4538. vFogDepth = - mvPosition.z;
  4539. #endif`,sUe=`#ifdef USE_FOG
  4540. varying float vFogDepth;
  4541. #endif`,oUe=`#ifdef USE_FOG
  4542. #ifdef FOG_EXP2
  4543. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4544. #else
  4545. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4546. #endif
  4547. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4548. #endif`,lUe=`#ifdef USE_FOG
  4549. uniform vec3 fogColor;
  4550. varying float vFogDepth;
  4551. #ifdef FOG_EXP2
  4552. uniform float fogDensity;
  4553. #else
  4554. uniform float fogNear;
  4555. uniform float fogFar;
  4556. #endif
  4557. #endif`,cUe=`#ifdef USE_GRADIENTMAP
  4558. uniform sampler2D gradientMap;
  4559. #endif
  4560. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4561. float dotNL = dot( normal, lightDirection );
  4562. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4563. #ifdef USE_GRADIENTMAP
  4564. return vec3( texture2D( gradientMap, coord ).r );
  4565. #else
  4566. vec2 fw = fwidth( coord ) * 0.5;
  4567. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4568. #endif
  4569. }`,uUe=`#ifdef USE_LIGHTMAP
  4570. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4571. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4572. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4573. #endif`,dUe=`#ifdef USE_LIGHTMAP
  4574. uniform sampler2D lightMap;
  4575. uniform float lightMapIntensity;
  4576. #endif`,hUe=`LambertMaterial material;
  4577. material.diffuseColor = diffuseColor.rgb;
  4578. material.specularStrength = specularStrength;`,fUe=`varying vec3 vViewPosition;
  4579. struct LambertMaterial {
  4580. vec3 diffuseColor;
  4581. float specularStrength;
  4582. };
  4583. 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 ) {
  4584. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4585. vec3 irradiance = dotNL * directLight.color;
  4586. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4587. }
  4588. 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 ) {
  4589. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4590. }
  4591. #define RE_Direct RE_Direct_Lambert
  4592. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,mUe=`uniform bool receiveShadow;
  4593. uniform vec3 ambientLightColor;
  4594. #if defined( USE_LIGHT_PROBES )
  4595. uniform vec3 lightProbe[ 9 ];
  4596. #endif
  4597. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4598. float x = normal.x, y = normal.y, z = normal.z;
  4599. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4600. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4601. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4602. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4603. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4604. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4605. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4606. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4607. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4608. return result;
  4609. }
  4610. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4611. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4612. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4613. return irradiance;
  4614. }
  4615. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4616. vec3 irradiance = ambientLightColor;
  4617. return irradiance;
  4618. }
  4619. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4620. #if defined ( LEGACY_LIGHTS )
  4621. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4622. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4623. }
  4624. return 1.0;
  4625. #else
  4626. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4627. if ( cutoffDistance > 0.0 ) {
  4628. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4629. }
  4630. return distanceFalloff;
  4631. #endif
  4632. }
  4633. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4634. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4635. }
  4636. #if NUM_DIR_LIGHTS > 0
  4637. struct DirectionalLight {
  4638. vec3 direction;
  4639. vec3 color;
  4640. };
  4641. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4642. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4643. light.color = directionalLight.color;
  4644. light.direction = directionalLight.direction;
  4645. light.visible = true;
  4646. }
  4647. #endif
  4648. #if NUM_POINT_LIGHTS > 0
  4649. struct PointLight {
  4650. vec3 position;
  4651. vec3 color;
  4652. float distance;
  4653. float decay;
  4654. };
  4655. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4656. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4657. vec3 lVector = pointLight.position - geometryPosition;
  4658. light.direction = normalize( lVector );
  4659. float lightDistance = length( lVector );
  4660. light.color = pointLight.color;
  4661. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4662. light.visible = ( light.color != vec3( 0.0 ) );
  4663. }
  4664. #endif
  4665. #if NUM_SPOT_LIGHTS > 0
  4666. struct SpotLight {
  4667. vec3 position;
  4668. vec3 direction;
  4669. vec3 color;
  4670. float distance;
  4671. float decay;
  4672. float coneCos;
  4673. float penumbraCos;
  4674. };
  4675. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4676. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4677. vec3 lVector = spotLight.position - geometryPosition;
  4678. light.direction = normalize( lVector );
  4679. float angleCos = dot( light.direction, spotLight.direction );
  4680. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4681. if ( spotAttenuation > 0.0 ) {
  4682. float lightDistance = length( lVector );
  4683. light.color = spotLight.color * spotAttenuation;
  4684. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4685. light.visible = ( light.color != vec3( 0.0 ) );
  4686. } else {
  4687. light.color = vec3( 0.0 );
  4688. light.visible = false;
  4689. }
  4690. }
  4691. #endif
  4692. #if NUM_RECT_AREA_LIGHTS > 0
  4693. struct RectAreaLight {
  4694. vec3 color;
  4695. vec3 position;
  4696. vec3 halfWidth;
  4697. vec3 halfHeight;
  4698. };
  4699. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4700. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4701. #endif
  4702. #if NUM_HEMI_LIGHTS > 0
  4703. struct HemisphereLight {
  4704. vec3 direction;
  4705. vec3 skyColor;
  4706. vec3 groundColor;
  4707. };
  4708. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4709. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4710. float dotNL = dot( normal, hemiLight.direction );
  4711. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4712. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4713. return irradiance;
  4714. }
  4715. #endif`,pUe=`#ifdef USE_ENVMAP
  4716. vec3 getIBLIrradiance( const in vec3 normal ) {
  4717. #ifdef ENVMAP_TYPE_CUBE_UV
  4718. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4719. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4720. return PI * envMapColor.rgb * envMapIntensity;
  4721. #else
  4722. return vec3( 0.0 );
  4723. #endif
  4724. }
  4725. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4726. #ifdef ENVMAP_TYPE_CUBE_UV
  4727. vec3 reflectVec = reflect( - viewDir, normal );
  4728. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4729. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4730. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4731. return envMapColor.rgb * envMapIntensity;
  4732. #else
  4733. return vec3( 0.0 );
  4734. #endif
  4735. }
  4736. #ifdef USE_ANISOTROPY
  4737. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4738. #ifdef ENVMAP_TYPE_CUBE_UV
  4739. vec3 bentNormal = cross( bitangent, viewDir );
  4740. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4741. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4742. return getIBLRadiance( viewDir, bentNormal, roughness );
  4743. #else
  4744. return vec3( 0.0 );
  4745. #endif
  4746. }
  4747. #endif
  4748. #endif`,gUe=`ToonMaterial material;
  4749. material.diffuseColor = diffuseColor.rgb;`,xUe=`varying vec3 vViewPosition;
  4750. struct ToonMaterial {
  4751. vec3 diffuseColor;
  4752. };
  4753. 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 ) {
  4754. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4755. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4756. }
  4757. 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 ) {
  4758. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4759. }
  4760. #define RE_Direct RE_Direct_Toon
  4761. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,bUe=`BlinnPhongMaterial material;
  4762. material.diffuseColor = diffuseColor.rgb;
  4763. material.specularColor = specular;
  4764. material.specularShininess = shininess;
  4765. material.specularStrength = specularStrength;`,yUe=`varying vec3 vViewPosition;
  4766. struct BlinnPhongMaterial {
  4767. vec3 diffuseColor;
  4768. vec3 specularColor;
  4769. float specularShininess;
  4770. float specularStrength;
  4771. };
  4772. 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 ) {
  4773. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4774. vec3 irradiance = dotNL * directLight.color;
  4775. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4776. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4777. }
  4778. 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 ) {
  4779. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4780. }
  4781. #define RE_Direct RE_Direct_BlinnPhong
  4782. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,vUe=`PhysicalMaterial material;
  4783. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4784. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4785. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4786. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4787. material.roughness = min( material.roughness, 1.0 );
  4788. #ifdef IOR
  4789. material.ior = ior;
  4790. #ifdef USE_SPECULAR
  4791. float specularIntensityFactor = specularIntensity;
  4792. vec3 specularColorFactor = specularColor;
  4793. #ifdef USE_SPECULAR_COLORMAP
  4794. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4795. #endif
  4796. #ifdef USE_SPECULAR_INTENSITYMAP
  4797. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4798. #endif
  4799. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4800. #else
  4801. float specularIntensityFactor = 1.0;
  4802. vec3 specularColorFactor = vec3( 1.0 );
  4803. material.specularF90 = 1.0;
  4804. #endif
  4805. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4806. #else
  4807. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4808. material.specularF90 = 1.0;
  4809. #endif
  4810. #ifdef USE_CLEARCOAT
  4811. material.clearcoat = clearcoat;
  4812. material.clearcoatRoughness = clearcoatRoughness;
  4813. material.clearcoatF0 = vec3( 0.04 );
  4814. material.clearcoatF90 = 1.0;
  4815. #ifdef USE_CLEARCOATMAP
  4816. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4817. #endif
  4818. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4819. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4820. #endif
  4821. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4822. material.clearcoatRoughness += geometryRoughness;
  4823. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4824. #endif
  4825. #ifdef USE_IRIDESCENCE
  4826. material.iridescence = iridescence;
  4827. material.iridescenceIOR = iridescenceIOR;
  4828. #ifdef USE_IRIDESCENCEMAP
  4829. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4830. #endif
  4831. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4832. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4833. #else
  4834. material.iridescenceThickness = iridescenceThicknessMaximum;
  4835. #endif
  4836. #endif
  4837. #ifdef USE_SHEEN
  4838. material.sheenColor = sheenColor;
  4839. #ifdef USE_SHEEN_COLORMAP
  4840. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4841. #endif
  4842. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4843. #ifdef USE_SHEEN_ROUGHNESSMAP
  4844. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4845. #endif
  4846. #endif
  4847. #ifdef USE_ANISOTROPY
  4848. #ifdef USE_ANISOTROPYMAP
  4849. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4850. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4851. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4852. #else
  4853. vec2 anisotropyV = anisotropyVector;
  4854. #endif
  4855. material.anisotropy = length( anisotropyV );
  4856. if( material.anisotropy == 0.0 ) {
  4857. anisotropyV = vec2( 1.0, 0.0 );
  4858. } else {
  4859. anisotropyV /= material.anisotropy;
  4860. material.anisotropy = saturate( material.anisotropy );
  4861. }
  4862. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4863. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4864. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4865. #endif`,_Ue=`struct PhysicalMaterial {
  4866. vec3 diffuseColor;
  4867. float roughness;
  4868. vec3 specularColor;
  4869. float specularF90;
  4870. #ifdef USE_CLEARCOAT
  4871. float clearcoat;
  4872. float clearcoatRoughness;
  4873. vec3 clearcoatF0;
  4874. float clearcoatF90;
  4875. #endif
  4876. #ifdef USE_IRIDESCENCE
  4877. float iridescence;
  4878. float iridescenceIOR;
  4879. float iridescenceThickness;
  4880. vec3 iridescenceFresnel;
  4881. vec3 iridescenceF0;
  4882. #endif
  4883. #ifdef USE_SHEEN
  4884. vec3 sheenColor;
  4885. float sheenRoughness;
  4886. #endif
  4887. #ifdef IOR
  4888. float ior;
  4889. #endif
  4890. #ifdef USE_TRANSMISSION
  4891. float transmission;
  4892. float transmissionAlpha;
  4893. float thickness;
  4894. float attenuationDistance;
  4895. vec3 attenuationColor;
  4896. #endif
  4897. #ifdef USE_ANISOTROPY
  4898. float anisotropy;
  4899. float alphaT;
  4900. vec3 anisotropyT;
  4901. vec3 anisotropyB;
  4902. #endif
  4903. };
  4904. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4905. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4906. vec3 sheenSpecularDirect = vec3( 0.0 );
  4907. vec3 sheenSpecularIndirect = vec3(0.0 );
  4908. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4909. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4910. float x2 = x * x;
  4911. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4912. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4913. }
  4914. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4915. float a2 = pow2( alpha );
  4916. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4917. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4918. return 0.5 / max( gv + gl, EPSILON );
  4919. }
  4920. float D_GGX( const in float alpha, const in float dotNH ) {
  4921. float a2 = pow2( alpha );
  4922. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4923. return RECIPROCAL_PI * a2 / pow2( denom );
  4924. }
  4925. #ifdef USE_ANISOTROPY
  4926. 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 ) {
  4927. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4928. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4929. float v = 0.5 / ( gv + gl );
  4930. return saturate(v);
  4931. }
  4932. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4933. float a2 = alphaT * alphaB;
  4934. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4935. highp float v2 = dot( v, v );
  4936. float w2 = a2 / v2;
  4937. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4938. }
  4939. #endif
  4940. #ifdef USE_CLEARCOAT
  4941. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4942. vec3 f0 = material.clearcoatF0;
  4943. float f90 = material.clearcoatF90;
  4944. float roughness = material.clearcoatRoughness;
  4945. float alpha = pow2( roughness );
  4946. vec3 halfDir = normalize( lightDir + viewDir );
  4947. float dotNL = saturate( dot( normal, lightDir ) );
  4948. float dotNV = saturate( dot( normal, viewDir ) );
  4949. float dotNH = saturate( dot( normal, halfDir ) );
  4950. float dotVH = saturate( dot( viewDir, halfDir ) );
  4951. vec3 F = F_Schlick( f0, f90, dotVH );
  4952. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4953. float D = D_GGX( alpha, dotNH );
  4954. return F * ( V * D );
  4955. }
  4956. #endif
  4957. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4958. vec3 f0 = material.specularColor;
  4959. float f90 = material.specularF90;
  4960. float roughness = material.roughness;
  4961. float alpha = pow2( roughness );
  4962. vec3 halfDir = normalize( lightDir + viewDir );
  4963. float dotNL = saturate( dot( normal, lightDir ) );
  4964. float dotNV = saturate( dot( normal, viewDir ) );
  4965. float dotNH = saturate( dot( normal, halfDir ) );
  4966. float dotVH = saturate( dot( viewDir, halfDir ) );
  4967. vec3 F = F_Schlick( f0, f90, dotVH );
  4968. #ifdef USE_IRIDESCENCE
  4969. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4970. #endif
  4971. #ifdef USE_ANISOTROPY
  4972. float dotTL = dot( material.anisotropyT, lightDir );
  4973. float dotTV = dot( material.anisotropyT, viewDir );
  4974. float dotTH = dot( material.anisotropyT, halfDir );
  4975. float dotBL = dot( material.anisotropyB, lightDir );
  4976. float dotBV = dot( material.anisotropyB, viewDir );
  4977. float dotBH = dot( material.anisotropyB, halfDir );
  4978. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4979. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4980. #else
  4981. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4982. float D = D_GGX( alpha, dotNH );
  4983. #endif
  4984. return F * ( V * D );
  4985. }
  4986. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4987. const float LUT_SIZE = 64.0;
  4988. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4989. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4990. float dotNV = saturate( dot( N, V ) );
  4991. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4992. uv = uv * LUT_SCALE + LUT_BIAS;
  4993. return uv;
  4994. }
  4995. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4996. float l = length( f );
  4997. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4998. }
  4999. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  5000. float x = dot( v1, v2 );
  5001. float y = abs( x );
  5002. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  5003. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  5004. float v = a / b;
  5005. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  5006. return cross( v1, v2 ) * theta_sintheta;
  5007. }
  5008. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  5009. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  5010. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  5011. vec3 lightNormal = cross( v1, v2 );
  5012. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  5013. vec3 T1, T2;
  5014. T1 = normalize( V - N * dot( V, N ) );
  5015. T2 = - cross( N, T1 );
  5016. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  5017. vec3 coords[ 4 ];
  5018. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  5019. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  5020. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  5021. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  5022. coords[ 0 ] = normalize( coords[ 0 ] );
  5023. coords[ 1 ] = normalize( coords[ 1 ] );
  5024. coords[ 2 ] = normalize( coords[ 2 ] );
  5025. coords[ 3 ] = normalize( coords[ 3 ] );
  5026. vec3 vectorFormFactor = vec3( 0.0 );
  5027. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  5028. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  5029. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  5030. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  5031. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  5032. return vec3( result );
  5033. }
  5034. #if defined( USE_SHEEN )
  5035. float D_Charlie( float roughness, float dotNH ) {
  5036. float alpha = pow2( roughness );
  5037. float invAlpha = 1.0 / alpha;
  5038. float cos2h = dotNH * dotNH;
  5039. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  5040. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  5041. }
  5042. float V_Neubelt( float dotNV, float dotNL ) {
  5043. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  5044. }
  5045. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  5046. vec3 halfDir = normalize( lightDir + viewDir );
  5047. float dotNL = saturate( dot( normal, lightDir ) );
  5048. float dotNV = saturate( dot( normal, viewDir ) );
  5049. float dotNH = saturate( dot( normal, halfDir ) );
  5050. float D = D_Charlie( sheenRoughness, dotNH );
  5051. float V = V_Neubelt( dotNV, dotNL );
  5052. return sheenColor * ( D * V );
  5053. }
  5054. #endif
  5055. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5056. float dotNV = saturate( dot( normal, viewDir ) );
  5057. float r2 = roughness * roughness;
  5058. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5059. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5060. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5061. return saturate( DG * RECIPROCAL_PI );
  5062. }
  5063. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5064. float dotNV = saturate( dot( normal, viewDir ) );
  5065. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5066. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5067. vec4 r = roughness * c0 + c1;
  5068. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5069. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5070. return fab;
  5071. }
  5072. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5073. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5074. return specularColor * fab.x + specularF90 * fab.y;
  5075. }
  5076. #ifdef USE_IRIDESCENCE
  5077. 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 ) {
  5078. #else
  5079. 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 ) {
  5080. #endif
  5081. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5082. #ifdef USE_IRIDESCENCE
  5083. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5084. #else
  5085. vec3 Fr = specularColor;
  5086. #endif
  5087. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5088. float Ess = fab.x + fab.y;
  5089. float Ems = 1.0 - Ess;
  5090. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5091. singleScatter += FssEss;
  5092. multiScatter += Fms * Ems;
  5093. }
  5094. #if NUM_RECT_AREA_LIGHTS > 0
  5095. 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 ) {
  5096. vec3 normal = geometryNormal;
  5097. vec3 viewDir = geometryViewDir;
  5098. vec3 position = geometryPosition;
  5099. vec3 lightPos = rectAreaLight.position;
  5100. vec3 halfWidth = rectAreaLight.halfWidth;
  5101. vec3 halfHeight = rectAreaLight.halfHeight;
  5102. vec3 lightColor = rectAreaLight.color;
  5103. float roughness = material.roughness;
  5104. vec3 rectCoords[ 4 ];
  5105. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5106. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5107. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5108. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5109. vec4 t1 = texture2D( ltc_1, uv );
  5110. vec4 t2 = texture2D( ltc_2, uv );
  5111. mat3 mInv = mat3(
  5112. vec3( t1.x, 0, t1.y ),
  5113. vec3( 0, 1, 0 ),
  5114. vec3( t1.z, 0, t1.w )
  5115. );
  5116. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5117. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5118. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5119. }
  5120. #endif
  5121. 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 ) {
  5122. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5123. vec3 irradiance = dotNL * directLight.color;
  5124. #ifdef USE_CLEARCOAT
  5125. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5126. vec3 ccIrradiance = dotNLcc * directLight.color;
  5127. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5128. #endif
  5129. #ifdef USE_SHEEN
  5130. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5131. #endif
  5132. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5133. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5134. }
  5135. 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 ) {
  5136. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5137. }
  5138. 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) {
  5139. #ifdef USE_CLEARCOAT
  5140. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5141. #endif
  5142. #ifdef USE_SHEEN
  5143. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5144. #endif
  5145. vec3 singleScattering = vec3( 0.0 );
  5146. vec3 multiScattering = vec3( 0.0 );
  5147. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5148. #ifdef USE_IRIDESCENCE
  5149. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5150. #else
  5151. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5152. #endif
  5153. vec3 totalScattering = singleScattering + multiScattering;
  5154. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5155. reflectedLight.indirectSpecular += radiance * singleScattering;
  5156. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5157. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5158. }
  5159. #define RE_Direct RE_Direct_Physical
  5160. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5161. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5162. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5163. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5164. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5165. }`,wUe=`
  5166. vec3 geometryPosition = - vViewPosition;
  5167. vec3 geometryNormal = normal;
  5168. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5169. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5170. #ifdef USE_CLEARCOAT
  5171. geometryClearcoatNormal = clearcoatNormal;
  5172. #endif
  5173. #ifdef USE_IRIDESCENCE
  5174. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5175. if ( material.iridescenceThickness == 0.0 ) {
  5176. material.iridescence = 0.0;
  5177. } else {
  5178. material.iridescence = saturate( material.iridescence );
  5179. }
  5180. if ( material.iridescence > 0.0 ) {
  5181. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5182. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5183. }
  5184. #endif
  5185. IncidentLight directLight;
  5186. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5187. PointLight pointLight;
  5188. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5189. PointLightShadow pointLightShadow;
  5190. #endif
  5191. #pragma unroll_loop_start
  5192. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5193. pointLight = pointLights[ i ];
  5194. getPointLightInfo( pointLight, geometryPosition, directLight );
  5195. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5196. pointLightShadow = pointLightShadows[ i ];
  5197. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5198. #endif
  5199. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5200. }
  5201. #pragma unroll_loop_end
  5202. #endif
  5203. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5204. SpotLight spotLight;
  5205. vec4 spotColor;
  5206. vec3 spotLightCoord;
  5207. bool inSpotLightMap;
  5208. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5209. SpotLightShadow spotLightShadow;
  5210. #endif
  5211. #pragma unroll_loop_start
  5212. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5213. spotLight = spotLights[ i ];
  5214. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5215. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5216. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5217. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5218. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5219. #else
  5220. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5221. #endif
  5222. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5223. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5224. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5225. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5226. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5227. #endif
  5228. #undef SPOT_LIGHT_MAP_INDEX
  5229. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5230. spotLightShadow = spotLightShadows[ i ];
  5231. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5232. #endif
  5233. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5234. }
  5235. #pragma unroll_loop_end
  5236. #endif
  5237. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5238. DirectionalLight directionalLight;
  5239. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5240. DirectionalLightShadow directionalLightShadow;
  5241. #endif
  5242. #pragma unroll_loop_start
  5243. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5244. directionalLight = directionalLights[ i ];
  5245. getDirectionalLightInfo( directionalLight, directLight );
  5246. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5247. directionalLightShadow = directionalLightShadows[ i ];
  5248. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5249. #endif
  5250. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5251. }
  5252. #pragma unroll_loop_end
  5253. #endif
  5254. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5255. RectAreaLight rectAreaLight;
  5256. #pragma unroll_loop_start
  5257. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5258. rectAreaLight = rectAreaLights[ i ];
  5259. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5260. }
  5261. #pragma unroll_loop_end
  5262. #endif
  5263. #if defined( RE_IndirectDiffuse )
  5264. vec3 iblIrradiance = vec3( 0.0 );
  5265. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5266. #if defined( USE_LIGHT_PROBES )
  5267. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5268. #endif
  5269. #if ( NUM_HEMI_LIGHTS > 0 )
  5270. #pragma unroll_loop_start
  5271. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5272. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5273. }
  5274. #pragma unroll_loop_end
  5275. #endif
  5276. #endif
  5277. #if defined( RE_IndirectSpecular )
  5278. vec3 radiance = vec3( 0.0 );
  5279. vec3 clearcoatRadiance = vec3( 0.0 );
  5280. #endif`,SUe=`#if defined( RE_IndirectDiffuse )
  5281. #ifdef USE_LIGHTMAP
  5282. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5283. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5284. irradiance += lightMapIrradiance;
  5285. #endif
  5286. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5287. iblIrradiance += getIBLIrradiance( geometryNormal );
  5288. #endif
  5289. #endif
  5290. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5291. #ifdef USE_ANISOTROPY
  5292. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5293. #else
  5294. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5295. #endif
  5296. #ifdef USE_CLEARCOAT
  5297. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5298. #endif
  5299. #endif`,MUe=`#if defined( RE_IndirectDiffuse )
  5300. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5301. #endif
  5302. #if defined( RE_IndirectSpecular )
  5303. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5304. #endif`,EUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5305. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5306. #endif`,NUe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5307. uniform float logDepthBufFC;
  5308. varying float vFragDepth;
  5309. varying float vIsPerspective;
  5310. #endif`,AUe=`#ifdef USE_LOGDEPTHBUF
  5311. #ifdef USE_LOGDEPTHBUF_EXT
  5312. varying float vFragDepth;
  5313. varying float vIsPerspective;
  5314. #else
  5315. uniform float logDepthBufFC;
  5316. #endif
  5317. #endif`,TUe=`#ifdef USE_LOGDEPTHBUF
  5318. #ifdef USE_LOGDEPTHBUF_EXT
  5319. vFragDepth = 1.0 + gl_Position.w;
  5320. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5321. #else
  5322. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5323. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5324. gl_Position.z *= gl_Position.w;
  5325. }
  5326. #endif
  5327. #endif`,CUe=`#ifdef USE_MAP
  5328. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5329. #ifdef DECODE_VIDEO_TEXTURE
  5330. 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 );
  5331. #endif
  5332. diffuseColor *= sampledDiffuseColor;
  5333. #endif`,kUe=`#ifdef USE_MAP
  5334. uniform sampler2D map;
  5335. #endif`,jUe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5336. #if defined( USE_POINTS_UV )
  5337. vec2 uv = vUv;
  5338. #else
  5339. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5340. #endif
  5341. #endif
  5342. #ifdef USE_MAP
  5343. diffuseColor *= texture2D( map, uv );
  5344. #endif
  5345. #ifdef USE_ALPHAMAP
  5346. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5347. #endif`,PUe=`#if defined( USE_POINTS_UV )
  5348. varying vec2 vUv;
  5349. #else
  5350. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5351. uniform mat3 uvTransform;
  5352. #endif
  5353. #endif
  5354. #ifdef USE_MAP
  5355. uniform sampler2D map;
  5356. #endif
  5357. #ifdef USE_ALPHAMAP
  5358. uniform sampler2D alphaMap;
  5359. #endif`,RUe=`float metalnessFactor = metalness;
  5360. #ifdef USE_METALNESSMAP
  5361. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5362. metalnessFactor *= texelMetalness.b;
  5363. #endif`,DUe=`#ifdef USE_METALNESSMAP
  5364. uniform sampler2D metalnessMap;
  5365. #endif`,OUe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5366. vColor *= morphTargetBaseInfluence;
  5367. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5368. #if defined( USE_COLOR_ALPHA )
  5369. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5370. #elif defined( USE_COLOR )
  5371. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5372. #endif
  5373. }
  5374. #endif`,LUe=`#ifdef USE_MORPHNORMALS
  5375. objectNormal *= morphTargetBaseInfluence;
  5376. #ifdef MORPHTARGETS_TEXTURE
  5377. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5378. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5379. }
  5380. #else
  5381. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5382. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5383. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5384. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5385. #endif
  5386. #endif`,IUe=`#ifdef USE_MORPHTARGETS
  5387. uniform float morphTargetBaseInfluence;
  5388. #ifdef MORPHTARGETS_TEXTURE
  5389. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5390. uniform sampler2DArray morphTargetsTexture;
  5391. uniform ivec2 morphTargetsTextureSize;
  5392. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5393. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5394. int y = texelIndex / morphTargetsTextureSize.x;
  5395. int x = texelIndex - y * morphTargetsTextureSize.x;
  5396. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5397. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5398. }
  5399. #else
  5400. #ifndef USE_MORPHNORMALS
  5401. uniform float morphTargetInfluences[ 8 ];
  5402. #else
  5403. uniform float morphTargetInfluences[ 4 ];
  5404. #endif
  5405. #endif
  5406. #endif`,FUe=`#ifdef USE_MORPHTARGETS
  5407. transformed *= morphTargetBaseInfluence;
  5408. #ifdef MORPHTARGETS_TEXTURE
  5409. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5410. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5411. }
  5412. #else
  5413. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5414. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5415. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5416. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5417. #ifndef USE_MORPHNORMALS
  5418. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5419. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5420. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5421. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5422. #endif
  5423. #endif
  5424. #endif`,UUe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5425. #ifdef FLAT_SHADED
  5426. vec3 fdx = dFdx( vViewPosition );
  5427. vec3 fdy = dFdy( vViewPosition );
  5428. vec3 normal = normalize( cross( fdx, fdy ) );
  5429. #else
  5430. vec3 normal = normalize( vNormal );
  5431. #ifdef DOUBLE_SIDED
  5432. normal *= faceDirection;
  5433. #endif
  5434. #endif
  5435. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5436. #ifdef USE_TANGENT
  5437. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5438. #else
  5439. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5440. #if defined( USE_NORMALMAP )
  5441. vNormalMapUv
  5442. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5443. vClearcoatNormalMapUv
  5444. #else
  5445. vUv
  5446. #endif
  5447. );
  5448. #endif
  5449. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5450. tbn[0] *= faceDirection;
  5451. tbn[1] *= faceDirection;
  5452. #endif
  5453. #endif
  5454. #ifdef USE_CLEARCOAT_NORMALMAP
  5455. #ifdef USE_TANGENT
  5456. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5457. #else
  5458. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5459. #endif
  5460. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5461. tbn2[0] *= faceDirection;
  5462. tbn2[1] *= faceDirection;
  5463. #endif
  5464. #endif
  5465. vec3 nonPerturbedNormal = normal;`,zUe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5466. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5467. #ifdef FLIP_SIDED
  5468. normal = - normal;
  5469. #endif
  5470. #ifdef DOUBLE_SIDED
  5471. normal = normal * faceDirection;
  5472. #endif
  5473. normal = normalize( normalMatrix * normal );
  5474. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5475. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5476. mapN.xy *= normalScale;
  5477. normal = normalize( tbn * mapN );
  5478. #elif defined( USE_BUMPMAP )
  5479. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5480. #endif`,BUe=`#ifndef FLAT_SHADED
  5481. varying vec3 vNormal;
  5482. #ifdef USE_TANGENT
  5483. varying vec3 vTangent;
  5484. varying vec3 vBitangent;
  5485. #endif
  5486. #endif`,$Ue=`#ifndef FLAT_SHADED
  5487. varying vec3 vNormal;
  5488. #ifdef USE_TANGENT
  5489. varying vec3 vTangent;
  5490. varying vec3 vBitangent;
  5491. #endif
  5492. #endif`,HUe=`#ifndef FLAT_SHADED
  5493. vNormal = normalize( transformedNormal );
  5494. #ifdef USE_TANGENT
  5495. vTangent = normalize( transformedTangent );
  5496. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5497. #endif
  5498. #endif`,VUe=`#ifdef USE_NORMALMAP
  5499. uniform sampler2D normalMap;
  5500. uniform vec2 normalScale;
  5501. #endif
  5502. #ifdef USE_NORMALMAP_OBJECTSPACE
  5503. uniform mat3 normalMatrix;
  5504. #endif
  5505. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5506. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5507. vec3 q0 = dFdx( eye_pos.xyz );
  5508. vec3 q1 = dFdy( eye_pos.xyz );
  5509. vec2 st0 = dFdx( uv.st );
  5510. vec2 st1 = dFdy( uv.st );
  5511. vec3 N = surf_norm;
  5512. vec3 q1perp = cross( q1, N );
  5513. vec3 q0perp = cross( N, q0 );
  5514. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5515. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5516. float det = max( dot( T, T ), dot( B, B ) );
  5517. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5518. return mat3( T * scale, B * scale, N );
  5519. }
  5520. #endif`,GUe=`#ifdef USE_CLEARCOAT
  5521. vec3 clearcoatNormal = nonPerturbedNormal;
  5522. #endif`,WUe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5523. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5524. clearcoatMapN.xy *= clearcoatNormalScale;
  5525. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5526. #endif`,qUe=`#ifdef USE_CLEARCOATMAP
  5527. uniform sampler2D clearcoatMap;
  5528. #endif
  5529. #ifdef USE_CLEARCOAT_NORMALMAP
  5530. uniform sampler2D clearcoatNormalMap;
  5531. uniform vec2 clearcoatNormalScale;
  5532. #endif
  5533. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5534. uniform sampler2D clearcoatRoughnessMap;
  5535. #endif`,KUe=`#ifdef USE_IRIDESCENCEMAP
  5536. uniform sampler2D iridescenceMap;
  5537. #endif
  5538. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5539. uniform sampler2D iridescenceThicknessMap;
  5540. #endif`,XUe=`#ifdef OPAQUE
  5541. diffuseColor.a = 1.0;
  5542. #endif
  5543. #ifdef USE_TRANSMISSION
  5544. diffuseColor.a *= material.transmissionAlpha;
  5545. #endif
  5546. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,YUe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5547. return normalize( normal ) * 0.5 + 0.5;
  5548. }
  5549. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5550. return 2.0 * rgb.xyz - 1.0;
  5551. }
  5552. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5553. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5554. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5555. const float ShiftRight8 = 1. / 256.;
  5556. vec4 packDepthToRGBA( const in float v ) {
  5557. vec4 r = vec4( fract( v * PackFactors ), v );
  5558. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5559. }
  5560. float unpackRGBAToDepth( const in vec4 v ) {
  5561. return dot( v, UnpackFactors );
  5562. }
  5563. vec2 packDepthToRG( in highp float v ) {
  5564. return packDepthToRGBA( v ).yx;
  5565. }
  5566. float unpackRGToDepth( const in highp vec2 v ) {
  5567. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5568. }
  5569. vec4 pack2HalfToRGBA( vec2 v ) {
  5570. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5571. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5572. }
  5573. vec2 unpackRGBATo2Half( vec4 v ) {
  5574. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5575. }
  5576. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5577. return ( viewZ + near ) / ( near - far );
  5578. }
  5579. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5580. return depth * ( near - far ) - near;
  5581. }
  5582. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5583. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5584. }
  5585. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5586. return ( near * far ) / ( ( far - near ) * depth - far );
  5587. }`,ZUe=`#ifdef PREMULTIPLIED_ALPHA
  5588. gl_FragColor.rgb *= gl_FragColor.a;
  5589. #endif`,QUe=`vec4 mvPosition = vec4( transformed, 1.0 );
  5590. #ifdef USE_BATCHING
  5591. mvPosition = batchingMatrix * mvPosition;
  5592. #endif
  5593. #ifdef USE_INSTANCING
  5594. mvPosition = instanceMatrix * mvPosition;
  5595. #endif
  5596. mvPosition = modelViewMatrix * mvPosition;
  5597. gl_Position = projectionMatrix * mvPosition;`,JUe=`#ifdef DITHERING
  5598. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5599. #endif`,eze=`#ifdef DITHERING
  5600. vec3 dithering( vec3 color ) {
  5601. float grid_position = rand( gl_FragCoord.xy );
  5602. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5603. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5604. return color + dither_shift_RGB;
  5605. }
  5606. #endif`,tze=`float roughnessFactor = roughness;
  5607. #ifdef USE_ROUGHNESSMAP
  5608. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5609. roughnessFactor *= texelRoughness.g;
  5610. #endif`,nze=`#ifdef USE_ROUGHNESSMAP
  5611. uniform sampler2D roughnessMap;
  5612. #endif`,rze=`#if NUM_SPOT_LIGHT_COORDS > 0
  5613. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5614. #endif
  5615. #if NUM_SPOT_LIGHT_MAPS > 0
  5616. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5617. #endif
  5618. #ifdef USE_SHADOWMAP
  5619. #if NUM_DIR_LIGHT_SHADOWS > 0
  5620. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5621. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5622. struct DirectionalLightShadow {
  5623. float shadowBias;
  5624. float shadowNormalBias;
  5625. float shadowRadius;
  5626. vec2 shadowMapSize;
  5627. };
  5628. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5629. #endif
  5630. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5631. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5632. struct SpotLightShadow {
  5633. float shadowBias;
  5634. float shadowNormalBias;
  5635. float shadowRadius;
  5636. vec2 shadowMapSize;
  5637. };
  5638. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5639. #endif
  5640. #if NUM_POINT_LIGHT_SHADOWS > 0
  5641. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5642. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5643. struct PointLightShadow {
  5644. float shadowBias;
  5645. float shadowNormalBias;
  5646. float shadowRadius;
  5647. vec2 shadowMapSize;
  5648. float shadowCameraNear;
  5649. float shadowCameraFar;
  5650. };
  5651. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5652. #endif
  5653. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5654. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5655. }
  5656. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5657. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5658. }
  5659. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5660. float occlusion = 1.0;
  5661. vec2 distribution = texture2DDistribution( shadow, uv );
  5662. float hard_shadow = step( compare , distribution.x );
  5663. if (hard_shadow != 1.0 ) {
  5664. float distance = compare - distribution.x ;
  5665. float variance = max( 0.00000, distribution.y * distribution.y );
  5666. 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 );
  5667. }
  5668. return occlusion;
  5669. }
  5670. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5671. float shadow = 1.0;
  5672. shadowCoord.xyz /= shadowCoord.w;
  5673. shadowCoord.z += shadowBias;
  5674. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5675. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5676. if ( frustumTest ) {
  5677. #if defined( SHADOWMAP_TYPE_PCF )
  5678. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5679. float dx0 = - texelSize.x * shadowRadius;
  5680. float dy0 = - texelSize.y * shadowRadius;
  5681. float dx1 = + texelSize.x * shadowRadius;
  5682. float dy1 = + texelSize.y * shadowRadius;
  5683. float dx2 = dx0 / 2.0;
  5684. float dy2 = dy0 / 2.0;
  5685. float dx3 = dx1 / 2.0;
  5686. float dy3 = dy1 / 2.0;
  5687. shadow = (
  5688. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5689. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5690. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5691. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5692. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5693. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5694. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5695. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5696. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5697. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5698. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5699. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5700. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5701. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5702. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5703. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5704. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5705. ) * ( 1.0 / 17.0 );
  5706. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5707. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5708. float dx = texelSize.x;
  5709. float dy = texelSize.y;
  5710. vec2 uv = shadowCoord.xy;
  5711. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5712. uv -= f * texelSize;
  5713. shadow = (
  5714. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5715. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5716. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5717. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5718. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5719. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5720. f.x ) +
  5721. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5722. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5723. f.x ) +
  5724. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5725. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5726. f.y ) +
  5727. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5728. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5729. f.y ) +
  5730. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5731. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5732. f.x ),
  5733. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5734. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5735. f.x ),
  5736. f.y )
  5737. ) * ( 1.0 / 9.0 );
  5738. #elif defined( SHADOWMAP_TYPE_VSM )
  5739. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5740. #else
  5741. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5742. #endif
  5743. }
  5744. return shadow;
  5745. }
  5746. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5747. vec3 absV = abs( v );
  5748. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5749. absV *= scaleToCube;
  5750. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5751. vec2 planar = v.xy;
  5752. float almostATexel = 1.5 * texelSizeY;
  5753. float almostOne = 1.0 - almostATexel;
  5754. if ( absV.z >= almostOne ) {
  5755. if ( v.z > 0.0 )
  5756. planar.x = 4.0 - v.x;
  5757. } else if ( absV.x >= almostOne ) {
  5758. float signX = sign( v.x );
  5759. planar.x = v.z * signX + 2.0 * signX;
  5760. } else if ( absV.y >= almostOne ) {
  5761. float signY = sign( v.y );
  5762. planar.x = v.x + 2.0 * signY + 2.0;
  5763. planar.y = v.z * signY - 2.0;
  5764. }
  5765. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5766. }
  5767. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5768. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5769. vec3 lightToPosition = shadowCoord.xyz;
  5770. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5771. vec3 bd3D = normalize( lightToPosition );
  5772. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5773. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5774. return (
  5775. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5776. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5777. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5778. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5779. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5780. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5781. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5782. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5783. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5784. ) * ( 1.0 / 9.0 );
  5785. #else
  5786. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5787. #endif
  5788. }
  5789. #endif`,ize=`#if NUM_SPOT_LIGHT_COORDS > 0
  5790. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5791. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5792. #endif
  5793. #ifdef USE_SHADOWMAP
  5794. #if NUM_DIR_LIGHT_SHADOWS > 0
  5795. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5796. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5797. struct DirectionalLightShadow {
  5798. float shadowBias;
  5799. float shadowNormalBias;
  5800. float shadowRadius;
  5801. vec2 shadowMapSize;
  5802. };
  5803. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5804. #endif
  5805. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5806. struct SpotLightShadow {
  5807. float shadowBias;
  5808. float shadowNormalBias;
  5809. float shadowRadius;
  5810. vec2 shadowMapSize;
  5811. };
  5812. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5813. #endif
  5814. #if NUM_POINT_LIGHT_SHADOWS > 0
  5815. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5816. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5817. struct PointLightShadow {
  5818. float shadowBias;
  5819. float shadowNormalBias;
  5820. float shadowRadius;
  5821. vec2 shadowMapSize;
  5822. float shadowCameraNear;
  5823. float shadowCameraFar;
  5824. };
  5825. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5826. #endif
  5827. #endif`,aze=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5828. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5829. vec4 shadowWorldPosition;
  5830. #endif
  5831. #if defined( USE_SHADOWMAP )
  5832. #if NUM_DIR_LIGHT_SHADOWS > 0
  5833. #pragma unroll_loop_start
  5834. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5835. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5836. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5837. }
  5838. #pragma unroll_loop_end
  5839. #endif
  5840. #if NUM_POINT_LIGHT_SHADOWS > 0
  5841. #pragma unroll_loop_start
  5842. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5843. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5844. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5845. }
  5846. #pragma unroll_loop_end
  5847. #endif
  5848. #endif
  5849. #if NUM_SPOT_LIGHT_COORDS > 0
  5850. #pragma unroll_loop_start
  5851. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5852. shadowWorldPosition = worldPosition;
  5853. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5854. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5855. #endif
  5856. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5857. }
  5858. #pragma unroll_loop_end
  5859. #endif`,sze=`float getShadowMask() {
  5860. float shadow = 1.0;
  5861. #ifdef USE_SHADOWMAP
  5862. #if NUM_DIR_LIGHT_SHADOWS > 0
  5863. DirectionalLightShadow directionalLight;
  5864. #pragma unroll_loop_start
  5865. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5866. directionalLight = directionalLightShadows[ i ];
  5867. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5868. }
  5869. #pragma unroll_loop_end
  5870. #endif
  5871. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5872. SpotLightShadow spotLight;
  5873. #pragma unroll_loop_start
  5874. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5875. spotLight = spotLightShadows[ i ];
  5876. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5877. }
  5878. #pragma unroll_loop_end
  5879. #endif
  5880. #if NUM_POINT_LIGHT_SHADOWS > 0
  5881. PointLightShadow pointLight;
  5882. #pragma unroll_loop_start
  5883. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5884. pointLight = pointLightShadows[ i ];
  5885. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5886. }
  5887. #pragma unroll_loop_end
  5888. #endif
  5889. #endif
  5890. return shadow;
  5891. }`,oze=`#ifdef USE_SKINNING
  5892. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5893. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5894. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5895. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5896. #endif`,lze=`#ifdef USE_SKINNING
  5897. uniform mat4 bindMatrix;
  5898. uniform mat4 bindMatrixInverse;
  5899. uniform highp sampler2D boneTexture;
  5900. mat4 getBoneMatrix( const in float i ) {
  5901. int size = textureSize( boneTexture, 0 ).x;
  5902. int j = int( i ) * 4;
  5903. int x = j % size;
  5904. int y = j / size;
  5905. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5906. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5907. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5908. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5909. return mat4( v1, v2, v3, v4 );
  5910. }
  5911. #endif`,cze=`#ifdef USE_SKINNING
  5912. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5913. vec4 skinned = vec4( 0.0 );
  5914. skinned += boneMatX * skinVertex * skinWeight.x;
  5915. skinned += boneMatY * skinVertex * skinWeight.y;
  5916. skinned += boneMatZ * skinVertex * skinWeight.z;
  5917. skinned += boneMatW * skinVertex * skinWeight.w;
  5918. transformed = ( bindMatrixInverse * skinned ).xyz;
  5919. #endif`,uze=`#ifdef USE_SKINNING
  5920. mat4 skinMatrix = mat4( 0.0 );
  5921. skinMatrix += skinWeight.x * boneMatX;
  5922. skinMatrix += skinWeight.y * boneMatY;
  5923. skinMatrix += skinWeight.z * boneMatZ;
  5924. skinMatrix += skinWeight.w * boneMatW;
  5925. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5926. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5927. #ifdef USE_TANGENT
  5928. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5929. #endif
  5930. #endif`,dze=`float specularStrength;
  5931. #ifdef USE_SPECULARMAP
  5932. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5933. specularStrength = texelSpecular.r;
  5934. #else
  5935. specularStrength = 1.0;
  5936. #endif`,hze=`#ifdef USE_SPECULARMAP
  5937. uniform sampler2D specularMap;
  5938. #endif`,fze=`#if defined( TONE_MAPPING )
  5939. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5940. #endif`,mze=`#ifndef saturate
  5941. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5942. #endif
  5943. uniform float toneMappingExposure;
  5944. vec3 LinearToneMapping( vec3 color ) {
  5945. return saturate( toneMappingExposure * color );
  5946. }
  5947. vec3 ReinhardToneMapping( vec3 color ) {
  5948. color *= toneMappingExposure;
  5949. return saturate( color / ( vec3( 1.0 ) + color ) );
  5950. }
  5951. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5952. color *= toneMappingExposure;
  5953. color = max( vec3( 0.0 ), color - 0.004 );
  5954. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5955. }
  5956. vec3 RRTAndODTFit( vec3 v ) {
  5957. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5958. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5959. return a / b;
  5960. }
  5961. vec3 ACESFilmicToneMapping( vec3 color ) {
  5962. const mat3 ACESInputMat = mat3(
  5963. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5964. vec3( 0.04823, 0.01566, 0.83777 )
  5965. );
  5966. const mat3 ACESOutputMat = mat3(
  5967. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5968. vec3( -0.07367, -0.00605, 1.07602 )
  5969. );
  5970. color *= toneMappingExposure / 0.6;
  5971. color = ACESInputMat * color;
  5972. color = RRTAndODTFit( color );
  5973. color = ACESOutputMat * color;
  5974. return saturate( color );
  5975. }
  5976. vec3 CustomToneMapping( vec3 color ) { return color; }`,pze=`#ifdef USE_TRANSMISSION
  5977. material.transmission = transmission;
  5978. material.transmissionAlpha = 1.0;
  5979. material.thickness = thickness;
  5980. material.attenuationDistance = attenuationDistance;
  5981. material.attenuationColor = attenuationColor;
  5982. #ifdef USE_TRANSMISSIONMAP
  5983. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5984. #endif
  5985. #ifdef USE_THICKNESSMAP
  5986. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5987. #endif
  5988. vec3 pos = vWorldPosition;
  5989. vec3 v = normalize( cameraPosition - pos );
  5990. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5991. vec4 transmitted = getIBLVolumeRefraction(
  5992. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5993. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5994. material.attenuationColor, material.attenuationDistance );
  5995. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5996. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5997. #endif`,gze=`#ifdef USE_TRANSMISSION
  5998. uniform float transmission;
  5999. uniform float thickness;
  6000. uniform float attenuationDistance;
  6001. uniform vec3 attenuationColor;
  6002. #ifdef USE_TRANSMISSIONMAP
  6003. uniform sampler2D transmissionMap;
  6004. #endif
  6005. #ifdef USE_THICKNESSMAP
  6006. uniform sampler2D thicknessMap;
  6007. #endif
  6008. uniform vec2 transmissionSamplerSize;
  6009. uniform sampler2D transmissionSamplerMap;
  6010. uniform mat4 modelMatrix;
  6011. uniform mat4 projectionMatrix;
  6012. varying vec3 vWorldPosition;
  6013. float w0( float a ) {
  6014. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  6015. }
  6016. float w1( float a ) {
  6017. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  6018. }
  6019. float w2( float a ){
  6020. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  6021. }
  6022. float w3( float a ) {
  6023. return ( 1.0 / 6.0 ) * ( a * a * a );
  6024. }
  6025. float g0( float a ) {
  6026. return w0( a ) + w1( a );
  6027. }
  6028. float g1( float a ) {
  6029. return w2( a ) + w3( a );
  6030. }
  6031. float h0( float a ) {
  6032. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  6033. }
  6034. float h1( float a ) {
  6035. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  6036. }
  6037. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  6038. uv = uv * texelSize.zw + 0.5;
  6039. vec2 iuv = floor( uv );
  6040. vec2 fuv = fract( uv );
  6041. float g0x = g0( fuv.x );
  6042. float g1x = g1( fuv.x );
  6043. float h0x = h0( fuv.x );
  6044. float h1x = h1( fuv.x );
  6045. float h0y = h0( fuv.y );
  6046. float h1y = h1( fuv.y );
  6047. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6048. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6049. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6050. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6051. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6052. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6053. }
  6054. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6055. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6056. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6057. vec2 fLodSizeInv = 1.0 / fLodSize;
  6058. vec2 cLodSizeInv = 1.0 / cLodSize;
  6059. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6060. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6061. return mix( fSample, cSample, fract( lod ) );
  6062. }
  6063. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6064. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6065. vec3 modelScale;
  6066. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6067. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6068. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6069. return normalize( refractionVector ) * thickness * modelScale;
  6070. }
  6071. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6072. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6073. }
  6074. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6075. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6076. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6077. }
  6078. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6079. if ( isinf( attenuationDistance ) ) {
  6080. return vec3( 1.0 );
  6081. } else {
  6082. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6083. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6084. }
  6085. }
  6086. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6087. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6088. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6089. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6090. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6091. vec3 refractedRayExit = position + transmissionRay;
  6092. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6093. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6094. refractionCoords += 1.0;
  6095. refractionCoords /= 2.0;
  6096. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6097. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6098. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6099. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6100. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6101. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6102. }
  6103. #endif`,xze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6104. varying vec2 vUv;
  6105. #endif
  6106. #ifdef USE_MAP
  6107. varying vec2 vMapUv;
  6108. #endif
  6109. #ifdef USE_ALPHAMAP
  6110. varying vec2 vAlphaMapUv;
  6111. #endif
  6112. #ifdef USE_LIGHTMAP
  6113. varying vec2 vLightMapUv;
  6114. #endif
  6115. #ifdef USE_AOMAP
  6116. varying vec2 vAoMapUv;
  6117. #endif
  6118. #ifdef USE_BUMPMAP
  6119. varying vec2 vBumpMapUv;
  6120. #endif
  6121. #ifdef USE_NORMALMAP
  6122. varying vec2 vNormalMapUv;
  6123. #endif
  6124. #ifdef USE_EMISSIVEMAP
  6125. varying vec2 vEmissiveMapUv;
  6126. #endif
  6127. #ifdef USE_METALNESSMAP
  6128. varying vec2 vMetalnessMapUv;
  6129. #endif
  6130. #ifdef USE_ROUGHNESSMAP
  6131. varying vec2 vRoughnessMapUv;
  6132. #endif
  6133. #ifdef USE_ANISOTROPYMAP
  6134. varying vec2 vAnisotropyMapUv;
  6135. #endif
  6136. #ifdef USE_CLEARCOATMAP
  6137. varying vec2 vClearcoatMapUv;
  6138. #endif
  6139. #ifdef USE_CLEARCOAT_NORMALMAP
  6140. varying vec2 vClearcoatNormalMapUv;
  6141. #endif
  6142. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6143. varying vec2 vClearcoatRoughnessMapUv;
  6144. #endif
  6145. #ifdef USE_IRIDESCENCEMAP
  6146. varying vec2 vIridescenceMapUv;
  6147. #endif
  6148. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6149. varying vec2 vIridescenceThicknessMapUv;
  6150. #endif
  6151. #ifdef USE_SHEEN_COLORMAP
  6152. varying vec2 vSheenColorMapUv;
  6153. #endif
  6154. #ifdef USE_SHEEN_ROUGHNESSMAP
  6155. varying vec2 vSheenRoughnessMapUv;
  6156. #endif
  6157. #ifdef USE_SPECULARMAP
  6158. varying vec2 vSpecularMapUv;
  6159. #endif
  6160. #ifdef USE_SPECULAR_COLORMAP
  6161. varying vec2 vSpecularColorMapUv;
  6162. #endif
  6163. #ifdef USE_SPECULAR_INTENSITYMAP
  6164. varying vec2 vSpecularIntensityMapUv;
  6165. #endif
  6166. #ifdef USE_TRANSMISSIONMAP
  6167. uniform mat3 transmissionMapTransform;
  6168. varying vec2 vTransmissionMapUv;
  6169. #endif
  6170. #ifdef USE_THICKNESSMAP
  6171. uniform mat3 thicknessMapTransform;
  6172. varying vec2 vThicknessMapUv;
  6173. #endif`,bze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6174. varying vec2 vUv;
  6175. #endif
  6176. #ifdef USE_MAP
  6177. uniform mat3 mapTransform;
  6178. varying vec2 vMapUv;
  6179. #endif
  6180. #ifdef USE_ALPHAMAP
  6181. uniform mat3 alphaMapTransform;
  6182. varying vec2 vAlphaMapUv;
  6183. #endif
  6184. #ifdef USE_LIGHTMAP
  6185. uniform mat3 lightMapTransform;
  6186. varying vec2 vLightMapUv;
  6187. #endif
  6188. #ifdef USE_AOMAP
  6189. uniform mat3 aoMapTransform;
  6190. varying vec2 vAoMapUv;
  6191. #endif
  6192. #ifdef USE_BUMPMAP
  6193. uniform mat3 bumpMapTransform;
  6194. varying vec2 vBumpMapUv;
  6195. #endif
  6196. #ifdef USE_NORMALMAP
  6197. uniform mat3 normalMapTransform;
  6198. varying vec2 vNormalMapUv;
  6199. #endif
  6200. #ifdef USE_DISPLACEMENTMAP
  6201. uniform mat3 displacementMapTransform;
  6202. varying vec2 vDisplacementMapUv;
  6203. #endif
  6204. #ifdef USE_EMISSIVEMAP
  6205. uniform mat3 emissiveMapTransform;
  6206. varying vec2 vEmissiveMapUv;
  6207. #endif
  6208. #ifdef USE_METALNESSMAP
  6209. uniform mat3 metalnessMapTransform;
  6210. varying vec2 vMetalnessMapUv;
  6211. #endif
  6212. #ifdef USE_ROUGHNESSMAP
  6213. uniform mat3 roughnessMapTransform;
  6214. varying vec2 vRoughnessMapUv;
  6215. #endif
  6216. #ifdef USE_ANISOTROPYMAP
  6217. uniform mat3 anisotropyMapTransform;
  6218. varying vec2 vAnisotropyMapUv;
  6219. #endif
  6220. #ifdef USE_CLEARCOATMAP
  6221. uniform mat3 clearcoatMapTransform;
  6222. varying vec2 vClearcoatMapUv;
  6223. #endif
  6224. #ifdef USE_CLEARCOAT_NORMALMAP
  6225. uniform mat3 clearcoatNormalMapTransform;
  6226. varying vec2 vClearcoatNormalMapUv;
  6227. #endif
  6228. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6229. uniform mat3 clearcoatRoughnessMapTransform;
  6230. varying vec2 vClearcoatRoughnessMapUv;
  6231. #endif
  6232. #ifdef USE_SHEEN_COLORMAP
  6233. uniform mat3 sheenColorMapTransform;
  6234. varying vec2 vSheenColorMapUv;
  6235. #endif
  6236. #ifdef USE_SHEEN_ROUGHNESSMAP
  6237. uniform mat3 sheenRoughnessMapTransform;
  6238. varying vec2 vSheenRoughnessMapUv;
  6239. #endif
  6240. #ifdef USE_IRIDESCENCEMAP
  6241. uniform mat3 iridescenceMapTransform;
  6242. varying vec2 vIridescenceMapUv;
  6243. #endif
  6244. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6245. uniform mat3 iridescenceThicknessMapTransform;
  6246. varying vec2 vIridescenceThicknessMapUv;
  6247. #endif
  6248. #ifdef USE_SPECULARMAP
  6249. uniform mat3 specularMapTransform;
  6250. varying vec2 vSpecularMapUv;
  6251. #endif
  6252. #ifdef USE_SPECULAR_COLORMAP
  6253. uniform mat3 specularColorMapTransform;
  6254. varying vec2 vSpecularColorMapUv;
  6255. #endif
  6256. #ifdef USE_SPECULAR_INTENSITYMAP
  6257. uniform mat3 specularIntensityMapTransform;
  6258. varying vec2 vSpecularIntensityMapUv;
  6259. #endif
  6260. #ifdef USE_TRANSMISSIONMAP
  6261. uniform mat3 transmissionMapTransform;
  6262. varying vec2 vTransmissionMapUv;
  6263. #endif
  6264. #ifdef USE_THICKNESSMAP
  6265. uniform mat3 thicknessMapTransform;
  6266. varying vec2 vThicknessMapUv;
  6267. #endif`,yze=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6268. vUv = vec3( uv, 1 ).xy;
  6269. #endif
  6270. #ifdef USE_MAP
  6271. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_ALPHAMAP
  6274. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_LIGHTMAP
  6277. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_AOMAP
  6280. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_BUMPMAP
  6283. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_NORMALMAP
  6286. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_DISPLACEMENTMAP
  6289. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6290. #endif
  6291. #ifdef USE_EMISSIVEMAP
  6292. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6293. #endif
  6294. #ifdef USE_METALNESSMAP
  6295. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6296. #endif
  6297. #ifdef USE_ROUGHNESSMAP
  6298. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6299. #endif
  6300. #ifdef USE_ANISOTROPYMAP
  6301. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6302. #endif
  6303. #ifdef USE_CLEARCOATMAP
  6304. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6305. #endif
  6306. #ifdef USE_CLEARCOAT_NORMALMAP
  6307. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6308. #endif
  6309. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6310. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6311. #endif
  6312. #ifdef USE_IRIDESCENCEMAP
  6313. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6314. #endif
  6315. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6316. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6317. #endif
  6318. #ifdef USE_SHEEN_COLORMAP
  6319. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6320. #endif
  6321. #ifdef USE_SHEEN_ROUGHNESSMAP
  6322. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6323. #endif
  6324. #ifdef USE_SPECULARMAP
  6325. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6326. #endif
  6327. #ifdef USE_SPECULAR_COLORMAP
  6328. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6329. #endif
  6330. #ifdef USE_SPECULAR_INTENSITYMAP
  6331. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6332. #endif
  6333. #ifdef USE_TRANSMISSIONMAP
  6334. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6335. #endif
  6336. #ifdef USE_THICKNESSMAP
  6337. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6338. #endif`,vze=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6339. vec4 worldPosition = vec4( transformed, 1.0 );
  6340. #ifdef USE_BATCHING
  6341. worldPosition = batchingMatrix * worldPosition;
  6342. #endif
  6343. #ifdef USE_INSTANCING
  6344. worldPosition = instanceMatrix * worldPosition;
  6345. #endif
  6346. worldPosition = modelMatrix * worldPosition;
  6347. #endif`;const _ze=`varying vec2 vUv;
  6348. uniform mat3 uvTransform;
  6349. void main() {
  6350. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6351. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6352. }`,wze=`uniform sampler2D t2D;
  6353. uniform float backgroundIntensity;
  6354. varying vec2 vUv;
  6355. void main() {
  6356. vec4 texColor = texture2D( t2D, vUv );
  6357. #ifdef DECODE_VIDEO_TEXTURE
  6358. 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 );
  6359. #endif
  6360. texColor.rgb *= backgroundIntensity;
  6361. gl_FragColor = texColor;
  6362. #include <tonemapping_fragment>
  6363. #include <colorspace_fragment>
  6364. }`,Sze=`varying vec3 vWorldDirection;
  6365. #include <common>
  6366. void main() {
  6367. vWorldDirection = transformDirection( position, modelMatrix );
  6368. #include <begin_vertex>
  6369. #include <project_vertex>
  6370. gl_Position.z = gl_Position.w;
  6371. }`,Mze=`#ifdef ENVMAP_TYPE_CUBE
  6372. uniform samplerCube envMap;
  6373. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6374. uniform sampler2D envMap;
  6375. #endif
  6376. uniform float flipEnvMap;
  6377. uniform float backgroundBlurriness;
  6378. uniform float backgroundIntensity;
  6379. varying vec3 vWorldDirection;
  6380. #include <cube_uv_reflection_fragment>
  6381. void main() {
  6382. #ifdef ENVMAP_TYPE_CUBE
  6383. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6384. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6385. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6386. #else
  6387. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6388. #endif
  6389. texColor.rgb *= backgroundIntensity;
  6390. gl_FragColor = texColor;
  6391. #include <tonemapping_fragment>
  6392. #include <colorspace_fragment>
  6393. }`,Eze=`varying vec3 vWorldDirection;
  6394. #include <common>
  6395. void main() {
  6396. vWorldDirection = transformDirection( position, modelMatrix );
  6397. #include <begin_vertex>
  6398. #include <project_vertex>
  6399. gl_Position.z = gl_Position.w;
  6400. }`,Nze=`uniform samplerCube tCube;
  6401. uniform float tFlip;
  6402. uniform float opacity;
  6403. varying vec3 vWorldDirection;
  6404. void main() {
  6405. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6406. gl_FragColor = texColor;
  6407. gl_FragColor.a *= opacity;
  6408. #include <tonemapping_fragment>
  6409. #include <colorspace_fragment>
  6410. }`,Aze=`#include <common>
  6411. #include <batching_pars_vertex>
  6412. #include <uv_pars_vertex>
  6413. #include <displacementmap_pars_vertex>
  6414. #include <morphtarget_pars_vertex>
  6415. #include <skinning_pars_vertex>
  6416. #include <logdepthbuf_pars_vertex>
  6417. #include <clipping_planes_pars_vertex>
  6418. varying vec2 vHighPrecisionZW;
  6419. void main() {
  6420. #include <uv_vertex>
  6421. #include <batching_vertex>
  6422. #include <skinbase_vertex>
  6423. #ifdef USE_DISPLACEMENTMAP
  6424. #include <beginnormal_vertex>
  6425. #include <morphnormal_vertex>
  6426. #include <skinnormal_vertex>
  6427. #endif
  6428. #include <begin_vertex>
  6429. #include <morphtarget_vertex>
  6430. #include <skinning_vertex>
  6431. #include <displacementmap_vertex>
  6432. #include <project_vertex>
  6433. #include <logdepthbuf_vertex>
  6434. #include <clipping_planes_vertex>
  6435. vHighPrecisionZW = gl_Position.zw;
  6436. }`,Tze=`#if DEPTH_PACKING == 3200
  6437. uniform float opacity;
  6438. #endif
  6439. #include <common>
  6440. #include <packing>
  6441. #include <uv_pars_fragment>
  6442. #include <map_pars_fragment>
  6443. #include <alphamap_pars_fragment>
  6444. #include <alphatest_pars_fragment>
  6445. #include <alphahash_pars_fragment>
  6446. #include <logdepthbuf_pars_fragment>
  6447. #include <clipping_planes_pars_fragment>
  6448. varying vec2 vHighPrecisionZW;
  6449. void main() {
  6450. #include <clipping_planes_fragment>
  6451. vec4 diffuseColor = vec4( 1.0 );
  6452. #if DEPTH_PACKING == 3200
  6453. diffuseColor.a = opacity;
  6454. #endif
  6455. #include <map_fragment>
  6456. #include <alphamap_fragment>
  6457. #include <alphatest_fragment>
  6458. #include <alphahash_fragment>
  6459. #include <logdepthbuf_fragment>
  6460. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6461. #if DEPTH_PACKING == 3200
  6462. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6463. #elif DEPTH_PACKING == 3201
  6464. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6465. #endif
  6466. }`,Cze=`#define DISTANCE
  6467. varying vec3 vWorldPosition;
  6468. #include <common>
  6469. #include <batching_pars_vertex>
  6470. #include <uv_pars_vertex>
  6471. #include <displacementmap_pars_vertex>
  6472. #include <morphtarget_pars_vertex>
  6473. #include <skinning_pars_vertex>
  6474. #include <clipping_planes_pars_vertex>
  6475. void main() {
  6476. #include <uv_vertex>
  6477. #include <batching_vertex>
  6478. #include <skinbase_vertex>
  6479. #ifdef USE_DISPLACEMENTMAP
  6480. #include <beginnormal_vertex>
  6481. #include <morphnormal_vertex>
  6482. #include <skinnormal_vertex>
  6483. #endif
  6484. #include <begin_vertex>
  6485. #include <morphtarget_vertex>
  6486. #include <skinning_vertex>
  6487. #include <displacementmap_vertex>
  6488. #include <project_vertex>
  6489. #include <worldpos_vertex>
  6490. #include <clipping_planes_vertex>
  6491. vWorldPosition = worldPosition.xyz;
  6492. }`,kze=`#define DISTANCE
  6493. uniform vec3 referencePosition;
  6494. uniform float nearDistance;
  6495. uniform float farDistance;
  6496. varying vec3 vWorldPosition;
  6497. #include <common>
  6498. #include <packing>
  6499. #include <uv_pars_fragment>
  6500. #include <map_pars_fragment>
  6501. #include <alphamap_pars_fragment>
  6502. #include <alphatest_pars_fragment>
  6503. #include <alphahash_pars_fragment>
  6504. #include <clipping_planes_pars_fragment>
  6505. void main () {
  6506. #include <clipping_planes_fragment>
  6507. vec4 diffuseColor = vec4( 1.0 );
  6508. #include <map_fragment>
  6509. #include <alphamap_fragment>
  6510. #include <alphatest_fragment>
  6511. #include <alphahash_fragment>
  6512. float dist = length( vWorldPosition - referencePosition );
  6513. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6514. dist = saturate( dist );
  6515. gl_FragColor = packDepthToRGBA( dist );
  6516. }`,jze=`varying vec3 vWorldDirection;
  6517. #include <common>
  6518. void main() {
  6519. vWorldDirection = transformDirection( position, modelMatrix );
  6520. #include <begin_vertex>
  6521. #include <project_vertex>
  6522. }`,Pze=`uniform sampler2D tEquirect;
  6523. varying vec3 vWorldDirection;
  6524. #include <common>
  6525. void main() {
  6526. vec3 direction = normalize( vWorldDirection );
  6527. vec2 sampleUV = equirectUv( direction );
  6528. gl_FragColor = texture2D( tEquirect, sampleUV );
  6529. #include <tonemapping_fragment>
  6530. #include <colorspace_fragment>
  6531. }`,Rze=`uniform float scale;
  6532. attribute float lineDistance;
  6533. varying float vLineDistance;
  6534. #include <common>
  6535. #include <uv_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <logdepthbuf_pars_vertex>
  6540. #include <clipping_planes_pars_vertex>
  6541. void main() {
  6542. vLineDistance = scale * lineDistance;
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <begin_vertex>
  6547. #include <morphtarget_vertex>
  6548. #include <project_vertex>
  6549. #include <logdepthbuf_vertex>
  6550. #include <clipping_planes_vertex>
  6551. #include <fog_vertex>
  6552. }`,Dze=`uniform vec3 diffuse;
  6553. uniform float opacity;
  6554. uniform float dashSize;
  6555. uniform float totalSize;
  6556. varying float vLineDistance;
  6557. #include <common>
  6558. #include <color_pars_fragment>
  6559. #include <uv_pars_fragment>
  6560. #include <map_pars_fragment>
  6561. #include <fog_pars_fragment>
  6562. #include <logdepthbuf_pars_fragment>
  6563. #include <clipping_planes_pars_fragment>
  6564. void main() {
  6565. #include <clipping_planes_fragment>
  6566. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6567. discard;
  6568. }
  6569. vec3 outgoingLight = vec3( 0.0 );
  6570. vec4 diffuseColor = vec4( diffuse, opacity );
  6571. #include <logdepthbuf_fragment>
  6572. #include <map_fragment>
  6573. #include <color_fragment>
  6574. outgoingLight = diffuseColor.rgb;
  6575. #include <opaque_fragment>
  6576. #include <tonemapping_fragment>
  6577. #include <colorspace_fragment>
  6578. #include <fog_fragment>
  6579. #include <premultiplied_alpha_fragment>
  6580. }`,Oze=`#include <common>
  6581. #include <batching_pars_vertex>
  6582. #include <uv_pars_vertex>
  6583. #include <envmap_pars_vertex>
  6584. #include <color_pars_vertex>
  6585. #include <fog_pars_vertex>
  6586. #include <morphtarget_pars_vertex>
  6587. #include <skinning_pars_vertex>
  6588. #include <logdepthbuf_pars_vertex>
  6589. #include <clipping_planes_pars_vertex>
  6590. void main() {
  6591. #include <uv_vertex>
  6592. #include <color_vertex>
  6593. #include <morphcolor_vertex>
  6594. #include <batching_vertex>
  6595. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6596. #include <beginnormal_vertex>
  6597. #include <morphnormal_vertex>
  6598. #include <skinbase_vertex>
  6599. #include <skinnormal_vertex>
  6600. #include <defaultnormal_vertex>
  6601. #endif
  6602. #include <begin_vertex>
  6603. #include <morphtarget_vertex>
  6604. #include <skinning_vertex>
  6605. #include <project_vertex>
  6606. #include <logdepthbuf_vertex>
  6607. #include <clipping_planes_vertex>
  6608. #include <worldpos_vertex>
  6609. #include <envmap_vertex>
  6610. #include <fog_vertex>
  6611. }`,Lze=`uniform vec3 diffuse;
  6612. uniform float opacity;
  6613. #ifndef FLAT_SHADED
  6614. varying vec3 vNormal;
  6615. #endif
  6616. #include <common>
  6617. #include <dithering_pars_fragment>
  6618. #include <color_pars_fragment>
  6619. #include <uv_pars_fragment>
  6620. #include <map_pars_fragment>
  6621. #include <alphamap_pars_fragment>
  6622. #include <alphatest_pars_fragment>
  6623. #include <alphahash_pars_fragment>
  6624. #include <aomap_pars_fragment>
  6625. #include <lightmap_pars_fragment>
  6626. #include <envmap_common_pars_fragment>
  6627. #include <envmap_pars_fragment>
  6628. #include <fog_pars_fragment>
  6629. #include <specularmap_pars_fragment>
  6630. #include <logdepthbuf_pars_fragment>
  6631. #include <clipping_planes_pars_fragment>
  6632. void main() {
  6633. #include <clipping_planes_fragment>
  6634. vec4 diffuseColor = vec4( diffuse, opacity );
  6635. #include <logdepthbuf_fragment>
  6636. #include <map_fragment>
  6637. #include <color_fragment>
  6638. #include <alphamap_fragment>
  6639. #include <alphatest_fragment>
  6640. #include <alphahash_fragment>
  6641. #include <specularmap_fragment>
  6642. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6643. #ifdef USE_LIGHTMAP
  6644. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6645. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6646. #else
  6647. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6648. #endif
  6649. #include <aomap_fragment>
  6650. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6651. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6652. #include <envmap_fragment>
  6653. #include <opaque_fragment>
  6654. #include <tonemapping_fragment>
  6655. #include <colorspace_fragment>
  6656. #include <fog_fragment>
  6657. #include <premultiplied_alpha_fragment>
  6658. #include <dithering_fragment>
  6659. }`,Ize=`#define LAMBERT
  6660. varying vec3 vViewPosition;
  6661. #include <common>
  6662. #include <batching_pars_vertex>
  6663. #include <uv_pars_vertex>
  6664. #include <displacementmap_pars_vertex>
  6665. #include <envmap_pars_vertex>
  6666. #include <color_pars_vertex>
  6667. #include <fog_pars_vertex>
  6668. #include <normal_pars_vertex>
  6669. #include <morphtarget_pars_vertex>
  6670. #include <skinning_pars_vertex>
  6671. #include <shadowmap_pars_vertex>
  6672. #include <logdepthbuf_pars_vertex>
  6673. #include <clipping_planes_pars_vertex>
  6674. void main() {
  6675. #include <uv_vertex>
  6676. #include <color_vertex>
  6677. #include <morphcolor_vertex>
  6678. #include <batching_vertex>
  6679. #include <beginnormal_vertex>
  6680. #include <morphnormal_vertex>
  6681. #include <skinbase_vertex>
  6682. #include <skinnormal_vertex>
  6683. #include <defaultnormal_vertex>
  6684. #include <normal_vertex>
  6685. #include <begin_vertex>
  6686. #include <morphtarget_vertex>
  6687. #include <skinning_vertex>
  6688. #include <displacementmap_vertex>
  6689. #include <project_vertex>
  6690. #include <logdepthbuf_vertex>
  6691. #include <clipping_planes_vertex>
  6692. vViewPosition = - mvPosition.xyz;
  6693. #include <worldpos_vertex>
  6694. #include <envmap_vertex>
  6695. #include <shadowmap_vertex>
  6696. #include <fog_vertex>
  6697. }`,Fze=`#define LAMBERT
  6698. uniform vec3 diffuse;
  6699. uniform vec3 emissive;
  6700. uniform float opacity;
  6701. #include <common>
  6702. #include <packing>
  6703. #include <dithering_pars_fragment>
  6704. #include <color_pars_fragment>
  6705. #include <uv_pars_fragment>
  6706. #include <map_pars_fragment>
  6707. #include <alphamap_pars_fragment>
  6708. #include <alphatest_pars_fragment>
  6709. #include <alphahash_pars_fragment>
  6710. #include <aomap_pars_fragment>
  6711. #include <lightmap_pars_fragment>
  6712. #include <emissivemap_pars_fragment>
  6713. #include <envmap_common_pars_fragment>
  6714. #include <envmap_pars_fragment>
  6715. #include <fog_pars_fragment>
  6716. #include <bsdfs>
  6717. #include <lights_pars_begin>
  6718. #include <normal_pars_fragment>
  6719. #include <lights_lambert_pars_fragment>
  6720. #include <shadowmap_pars_fragment>
  6721. #include <bumpmap_pars_fragment>
  6722. #include <normalmap_pars_fragment>
  6723. #include <specularmap_pars_fragment>
  6724. #include <logdepthbuf_pars_fragment>
  6725. #include <clipping_planes_pars_fragment>
  6726. void main() {
  6727. #include <clipping_planes_fragment>
  6728. vec4 diffuseColor = vec4( diffuse, opacity );
  6729. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6730. vec3 totalEmissiveRadiance = emissive;
  6731. #include <logdepthbuf_fragment>
  6732. #include <map_fragment>
  6733. #include <color_fragment>
  6734. #include <alphamap_fragment>
  6735. #include <alphatest_fragment>
  6736. #include <alphahash_fragment>
  6737. #include <specularmap_fragment>
  6738. #include <normal_fragment_begin>
  6739. #include <normal_fragment_maps>
  6740. #include <emissivemap_fragment>
  6741. #include <lights_lambert_fragment>
  6742. #include <lights_fragment_begin>
  6743. #include <lights_fragment_maps>
  6744. #include <lights_fragment_end>
  6745. #include <aomap_fragment>
  6746. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6747. #include <envmap_fragment>
  6748. #include <opaque_fragment>
  6749. #include <tonemapping_fragment>
  6750. #include <colorspace_fragment>
  6751. #include <fog_fragment>
  6752. #include <premultiplied_alpha_fragment>
  6753. #include <dithering_fragment>
  6754. }`,Uze=`#define MATCAP
  6755. varying vec3 vViewPosition;
  6756. #include <common>
  6757. #include <batching_pars_vertex>
  6758. #include <uv_pars_vertex>
  6759. #include <color_pars_vertex>
  6760. #include <displacementmap_pars_vertex>
  6761. #include <fog_pars_vertex>
  6762. #include <normal_pars_vertex>
  6763. #include <morphtarget_pars_vertex>
  6764. #include <skinning_pars_vertex>
  6765. #include <logdepthbuf_pars_vertex>
  6766. #include <clipping_planes_pars_vertex>
  6767. void main() {
  6768. #include <uv_vertex>
  6769. #include <color_vertex>
  6770. #include <morphcolor_vertex>
  6771. #include <batching_vertex>
  6772. #include <beginnormal_vertex>
  6773. #include <morphnormal_vertex>
  6774. #include <skinbase_vertex>
  6775. #include <skinnormal_vertex>
  6776. #include <defaultnormal_vertex>
  6777. #include <normal_vertex>
  6778. #include <begin_vertex>
  6779. #include <morphtarget_vertex>
  6780. #include <skinning_vertex>
  6781. #include <displacementmap_vertex>
  6782. #include <project_vertex>
  6783. #include <logdepthbuf_vertex>
  6784. #include <clipping_planes_vertex>
  6785. #include <fog_vertex>
  6786. vViewPosition = - mvPosition.xyz;
  6787. }`,zze=`#define MATCAP
  6788. uniform vec3 diffuse;
  6789. uniform float opacity;
  6790. uniform sampler2D matcap;
  6791. varying vec3 vViewPosition;
  6792. #include <common>
  6793. #include <dithering_pars_fragment>
  6794. #include <color_pars_fragment>
  6795. #include <uv_pars_fragment>
  6796. #include <map_pars_fragment>
  6797. #include <alphamap_pars_fragment>
  6798. #include <alphatest_pars_fragment>
  6799. #include <alphahash_pars_fragment>
  6800. #include <fog_pars_fragment>
  6801. #include <normal_pars_fragment>
  6802. #include <bumpmap_pars_fragment>
  6803. #include <normalmap_pars_fragment>
  6804. #include <logdepthbuf_pars_fragment>
  6805. #include <clipping_planes_pars_fragment>
  6806. void main() {
  6807. #include <clipping_planes_fragment>
  6808. vec4 diffuseColor = vec4( diffuse, opacity );
  6809. #include <logdepthbuf_fragment>
  6810. #include <map_fragment>
  6811. #include <color_fragment>
  6812. #include <alphamap_fragment>
  6813. #include <alphatest_fragment>
  6814. #include <alphahash_fragment>
  6815. #include <normal_fragment_begin>
  6816. #include <normal_fragment_maps>
  6817. vec3 viewDir = normalize( vViewPosition );
  6818. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6819. vec3 y = cross( viewDir, x );
  6820. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6821. #ifdef USE_MATCAP
  6822. vec4 matcapColor = texture2D( matcap, uv );
  6823. #else
  6824. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6825. #endif
  6826. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6827. #include <opaque_fragment>
  6828. #include <tonemapping_fragment>
  6829. #include <colorspace_fragment>
  6830. #include <fog_fragment>
  6831. #include <premultiplied_alpha_fragment>
  6832. #include <dithering_fragment>
  6833. }`,Bze=`#define NORMAL
  6834. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6835. varying vec3 vViewPosition;
  6836. #endif
  6837. #include <common>
  6838. #include <batching_pars_vertex>
  6839. #include <uv_pars_vertex>
  6840. #include <displacementmap_pars_vertex>
  6841. #include <normal_pars_vertex>
  6842. #include <morphtarget_pars_vertex>
  6843. #include <skinning_pars_vertex>
  6844. #include <logdepthbuf_pars_vertex>
  6845. #include <clipping_planes_pars_vertex>
  6846. void main() {
  6847. #include <uv_vertex>
  6848. #include <batching_vertex>
  6849. #include <beginnormal_vertex>
  6850. #include <morphnormal_vertex>
  6851. #include <skinbase_vertex>
  6852. #include <skinnormal_vertex>
  6853. #include <defaultnormal_vertex>
  6854. #include <normal_vertex>
  6855. #include <begin_vertex>
  6856. #include <morphtarget_vertex>
  6857. #include <skinning_vertex>
  6858. #include <displacementmap_vertex>
  6859. #include <project_vertex>
  6860. #include <logdepthbuf_vertex>
  6861. #include <clipping_planes_vertex>
  6862. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6863. vViewPosition = - mvPosition.xyz;
  6864. #endif
  6865. }`,$ze=`#define NORMAL
  6866. uniform float opacity;
  6867. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6868. varying vec3 vViewPosition;
  6869. #endif
  6870. #include <packing>
  6871. #include <uv_pars_fragment>
  6872. #include <normal_pars_fragment>
  6873. #include <bumpmap_pars_fragment>
  6874. #include <normalmap_pars_fragment>
  6875. #include <logdepthbuf_pars_fragment>
  6876. #include <clipping_planes_pars_fragment>
  6877. void main() {
  6878. #include <clipping_planes_fragment>
  6879. #include <logdepthbuf_fragment>
  6880. #include <normal_fragment_begin>
  6881. #include <normal_fragment_maps>
  6882. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6883. #ifdef OPAQUE
  6884. gl_FragColor.a = 1.0;
  6885. #endif
  6886. }`,Hze=`#define PHONG
  6887. varying vec3 vViewPosition;
  6888. #include <common>
  6889. #include <batching_pars_vertex>
  6890. #include <uv_pars_vertex>
  6891. #include <displacementmap_pars_vertex>
  6892. #include <envmap_pars_vertex>
  6893. #include <color_pars_vertex>
  6894. #include <fog_pars_vertex>
  6895. #include <normal_pars_vertex>
  6896. #include <morphtarget_pars_vertex>
  6897. #include <skinning_pars_vertex>
  6898. #include <shadowmap_pars_vertex>
  6899. #include <logdepthbuf_pars_vertex>
  6900. #include <clipping_planes_pars_vertex>
  6901. void main() {
  6902. #include <uv_vertex>
  6903. #include <color_vertex>
  6904. #include <morphcolor_vertex>
  6905. #include <batching_vertex>
  6906. #include <beginnormal_vertex>
  6907. #include <morphnormal_vertex>
  6908. #include <skinbase_vertex>
  6909. #include <skinnormal_vertex>
  6910. #include <defaultnormal_vertex>
  6911. #include <normal_vertex>
  6912. #include <begin_vertex>
  6913. #include <morphtarget_vertex>
  6914. #include <skinning_vertex>
  6915. #include <displacementmap_vertex>
  6916. #include <project_vertex>
  6917. #include <logdepthbuf_vertex>
  6918. #include <clipping_planes_vertex>
  6919. vViewPosition = - mvPosition.xyz;
  6920. #include <worldpos_vertex>
  6921. #include <envmap_vertex>
  6922. #include <shadowmap_vertex>
  6923. #include <fog_vertex>
  6924. }`,Vze=`#define PHONG
  6925. uniform vec3 diffuse;
  6926. uniform vec3 emissive;
  6927. uniform vec3 specular;
  6928. uniform float shininess;
  6929. uniform float opacity;
  6930. #include <common>
  6931. #include <packing>
  6932. #include <dithering_pars_fragment>
  6933. #include <color_pars_fragment>
  6934. #include <uv_pars_fragment>
  6935. #include <map_pars_fragment>
  6936. #include <alphamap_pars_fragment>
  6937. #include <alphatest_pars_fragment>
  6938. #include <alphahash_pars_fragment>
  6939. #include <aomap_pars_fragment>
  6940. #include <lightmap_pars_fragment>
  6941. #include <emissivemap_pars_fragment>
  6942. #include <envmap_common_pars_fragment>
  6943. #include <envmap_pars_fragment>
  6944. #include <fog_pars_fragment>
  6945. #include <bsdfs>
  6946. #include <lights_pars_begin>
  6947. #include <normal_pars_fragment>
  6948. #include <lights_phong_pars_fragment>
  6949. #include <shadowmap_pars_fragment>
  6950. #include <bumpmap_pars_fragment>
  6951. #include <normalmap_pars_fragment>
  6952. #include <specularmap_pars_fragment>
  6953. #include <logdepthbuf_pars_fragment>
  6954. #include <clipping_planes_pars_fragment>
  6955. void main() {
  6956. #include <clipping_planes_fragment>
  6957. vec4 diffuseColor = vec4( diffuse, opacity );
  6958. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6959. vec3 totalEmissiveRadiance = emissive;
  6960. #include <logdepthbuf_fragment>
  6961. #include <map_fragment>
  6962. #include <color_fragment>
  6963. #include <alphamap_fragment>
  6964. #include <alphatest_fragment>
  6965. #include <alphahash_fragment>
  6966. #include <specularmap_fragment>
  6967. #include <normal_fragment_begin>
  6968. #include <normal_fragment_maps>
  6969. #include <emissivemap_fragment>
  6970. #include <lights_phong_fragment>
  6971. #include <lights_fragment_begin>
  6972. #include <lights_fragment_maps>
  6973. #include <lights_fragment_end>
  6974. #include <aomap_fragment>
  6975. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6976. #include <envmap_fragment>
  6977. #include <opaque_fragment>
  6978. #include <tonemapping_fragment>
  6979. #include <colorspace_fragment>
  6980. #include <fog_fragment>
  6981. #include <premultiplied_alpha_fragment>
  6982. #include <dithering_fragment>
  6983. }`,Gze=`#define STANDARD
  6984. varying vec3 vViewPosition;
  6985. #ifdef USE_TRANSMISSION
  6986. varying vec3 vWorldPosition;
  6987. #endif
  6988. #include <common>
  6989. #include <batching_pars_vertex>
  6990. #include <uv_pars_vertex>
  6991. #include <displacementmap_pars_vertex>
  6992. #include <color_pars_vertex>
  6993. #include <fog_pars_vertex>
  6994. #include <normal_pars_vertex>
  6995. #include <morphtarget_pars_vertex>
  6996. #include <skinning_pars_vertex>
  6997. #include <shadowmap_pars_vertex>
  6998. #include <logdepthbuf_pars_vertex>
  6999. #include <clipping_planes_pars_vertex>
  7000. void main() {
  7001. #include <uv_vertex>
  7002. #include <color_vertex>
  7003. #include <morphcolor_vertex>
  7004. #include <batching_vertex>
  7005. #include <beginnormal_vertex>
  7006. #include <morphnormal_vertex>
  7007. #include <skinbase_vertex>
  7008. #include <skinnormal_vertex>
  7009. #include <defaultnormal_vertex>
  7010. #include <normal_vertex>
  7011. #include <begin_vertex>
  7012. #include <morphtarget_vertex>
  7013. #include <skinning_vertex>
  7014. #include <displacementmap_vertex>
  7015. #include <project_vertex>
  7016. #include <logdepthbuf_vertex>
  7017. #include <clipping_planes_vertex>
  7018. vViewPosition = - mvPosition.xyz;
  7019. #include <worldpos_vertex>
  7020. #include <shadowmap_vertex>
  7021. #include <fog_vertex>
  7022. #ifdef USE_TRANSMISSION
  7023. vWorldPosition = worldPosition.xyz;
  7024. #endif
  7025. }`,Wze=`#define STANDARD
  7026. #ifdef PHYSICAL
  7027. #define IOR
  7028. #define USE_SPECULAR
  7029. #endif
  7030. uniform vec3 diffuse;
  7031. uniform vec3 emissive;
  7032. uniform float roughness;
  7033. uniform float metalness;
  7034. uniform float opacity;
  7035. #ifdef IOR
  7036. uniform float ior;
  7037. #endif
  7038. #ifdef USE_SPECULAR
  7039. uniform float specularIntensity;
  7040. uniform vec3 specularColor;
  7041. #ifdef USE_SPECULAR_COLORMAP
  7042. uniform sampler2D specularColorMap;
  7043. #endif
  7044. #ifdef USE_SPECULAR_INTENSITYMAP
  7045. uniform sampler2D specularIntensityMap;
  7046. #endif
  7047. #endif
  7048. #ifdef USE_CLEARCOAT
  7049. uniform float clearcoat;
  7050. uniform float clearcoatRoughness;
  7051. #endif
  7052. #ifdef USE_IRIDESCENCE
  7053. uniform float iridescence;
  7054. uniform float iridescenceIOR;
  7055. uniform float iridescenceThicknessMinimum;
  7056. uniform float iridescenceThicknessMaximum;
  7057. #endif
  7058. #ifdef USE_SHEEN
  7059. uniform vec3 sheenColor;
  7060. uniform float sheenRoughness;
  7061. #ifdef USE_SHEEN_COLORMAP
  7062. uniform sampler2D sheenColorMap;
  7063. #endif
  7064. #ifdef USE_SHEEN_ROUGHNESSMAP
  7065. uniform sampler2D sheenRoughnessMap;
  7066. #endif
  7067. #endif
  7068. #ifdef USE_ANISOTROPY
  7069. uniform vec2 anisotropyVector;
  7070. #ifdef USE_ANISOTROPYMAP
  7071. uniform sampler2D anisotropyMap;
  7072. #endif
  7073. #endif
  7074. varying vec3 vViewPosition;
  7075. #include <common>
  7076. #include <packing>
  7077. #include <dithering_pars_fragment>
  7078. #include <color_pars_fragment>
  7079. #include <uv_pars_fragment>
  7080. #include <map_pars_fragment>
  7081. #include <alphamap_pars_fragment>
  7082. #include <alphatest_pars_fragment>
  7083. #include <alphahash_pars_fragment>
  7084. #include <aomap_pars_fragment>
  7085. #include <lightmap_pars_fragment>
  7086. #include <emissivemap_pars_fragment>
  7087. #include <iridescence_fragment>
  7088. #include <cube_uv_reflection_fragment>
  7089. #include <envmap_common_pars_fragment>
  7090. #include <envmap_physical_pars_fragment>
  7091. #include <fog_pars_fragment>
  7092. #include <lights_pars_begin>
  7093. #include <normal_pars_fragment>
  7094. #include <lights_physical_pars_fragment>
  7095. #include <transmission_pars_fragment>
  7096. #include <shadowmap_pars_fragment>
  7097. #include <bumpmap_pars_fragment>
  7098. #include <normalmap_pars_fragment>
  7099. #include <clearcoat_pars_fragment>
  7100. #include <iridescence_pars_fragment>
  7101. #include <roughnessmap_pars_fragment>
  7102. #include <metalnessmap_pars_fragment>
  7103. #include <logdepthbuf_pars_fragment>
  7104. #include <clipping_planes_pars_fragment>
  7105. void main() {
  7106. #include <clipping_planes_fragment>
  7107. vec4 diffuseColor = vec4( diffuse, opacity );
  7108. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7109. vec3 totalEmissiveRadiance = emissive;
  7110. #include <logdepthbuf_fragment>
  7111. #include <map_fragment>
  7112. #include <color_fragment>
  7113. #include <alphamap_fragment>
  7114. #include <alphatest_fragment>
  7115. #include <alphahash_fragment>
  7116. #include <roughnessmap_fragment>
  7117. #include <metalnessmap_fragment>
  7118. #include <normal_fragment_begin>
  7119. #include <normal_fragment_maps>
  7120. #include <clearcoat_normal_fragment_begin>
  7121. #include <clearcoat_normal_fragment_maps>
  7122. #include <emissivemap_fragment>
  7123. #include <lights_physical_fragment>
  7124. #include <lights_fragment_begin>
  7125. #include <lights_fragment_maps>
  7126. #include <lights_fragment_end>
  7127. #include <aomap_fragment>
  7128. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7129. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7130. #include <transmission_fragment>
  7131. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7132. #ifdef USE_SHEEN
  7133. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7134. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7135. #endif
  7136. #ifdef USE_CLEARCOAT
  7137. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7138. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7139. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7140. #endif
  7141. #include <opaque_fragment>
  7142. #include <tonemapping_fragment>
  7143. #include <colorspace_fragment>
  7144. #include <fog_fragment>
  7145. #include <premultiplied_alpha_fragment>
  7146. #include <dithering_fragment>
  7147. }`,qze=`#define TOON
  7148. varying vec3 vViewPosition;
  7149. #include <common>
  7150. #include <batching_pars_vertex>
  7151. #include <uv_pars_vertex>
  7152. #include <displacementmap_pars_vertex>
  7153. #include <color_pars_vertex>
  7154. #include <fog_pars_vertex>
  7155. #include <normal_pars_vertex>
  7156. #include <morphtarget_pars_vertex>
  7157. #include <skinning_pars_vertex>
  7158. #include <shadowmap_pars_vertex>
  7159. #include <logdepthbuf_pars_vertex>
  7160. #include <clipping_planes_pars_vertex>
  7161. void main() {
  7162. #include <uv_vertex>
  7163. #include <color_vertex>
  7164. #include <morphcolor_vertex>
  7165. #include <batching_vertex>
  7166. #include <beginnormal_vertex>
  7167. #include <morphnormal_vertex>
  7168. #include <skinbase_vertex>
  7169. #include <skinnormal_vertex>
  7170. #include <defaultnormal_vertex>
  7171. #include <normal_vertex>
  7172. #include <begin_vertex>
  7173. #include <morphtarget_vertex>
  7174. #include <skinning_vertex>
  7175. #include <displacementmap_vertex>
  7176. #include <project_vertex>
  7177. #include <logdepthbuf_vertex>
  7178. #include <clipping_planes_vertex>
  7179. vViewPosition = - mvPosition.xyz;
  7180. #include <worldpos_vertex>
  7181. #include <shadowmap_vertex>
  7182. #include <fog_vertex>
  7183. }`,Kze=`#define TOON
  7184. uniform vec3 diffuse;
  7185. uniform vec3 emissive;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <dithering_pars_fragment>
  7190. #include <color_pars_fragment>
  7191. #include <uv_pars_fragment>
  7192. #include <map_pars_fragment>
  7193. #include <alphamap_pars_fragment>
  7194. #include <alphatest_pars_fragment>
  7195. #include <alphahash_pars_fragment>
  7196. #include <aomap_pars_fragment>
  7197. #include <lightmap_pars_fragment>
  7198. #include <emissivemap_pars_fragment>
  7199. #include <gradientmap_pars_fragment>
  7200. #include <fog_pars_fragment>
  7201. #include <bsdfs>
  7202. #include <lights_pars_begin>
  7203. #include <normal_pars_fragment>
  7204. #include <lights_toon_pars_fragment>
  7205. #include <shadowmap_pars_fragment>
  7206. #include <bumpmap_pars_fragment>
  7207. #include <normalmap_pars_fragment>
  7208. #include <logdepthbuf_pars_fragment>
  7209. #include <clipping_planes_pars_fragment>
  7210. void main() {
  7211. #include <clipping_planes_fragment>
  7212. vec4 diffuseColor = vec4( diffuse, opacity );
  7213. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7214. vec3 totalEmissiveRadiance = emissive;
  7215. #include <logdepthbuf_fragment>
  7216. #include <map_fragment>
  7217. #include <color_fragment>
  7218. #include <alphamap_fragment>
  7219. #include <alphatest_fragment>
  7220. #include <alphahash_fragment>
  7221. #include <normal_fragment_begin>
  7222. #include <normal_fragment_maps>
  7223. #include <emissivemap_fragment>
  7224. #include <lights_toon_fragment>
  7225. #include <lights_fragment_begin>
  7226. #include <lights_fragment_maps>
  7227. #include <lights_fragment_end>
  7228. #include <aomap_fragment>
  7229. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7230. #include <opaque_fragment>
  7231. #include <tonemapping_fragment>
  7232. #include <colorspace_fragment>
  7233. #include <fog_fragment>
  7234. #include <premultiplied_alpha_fragment>
  7235. #include <dithering_fragment>
  7236. }`,Xze=`uniform float size;
  7237. uniform float scale;
  7238. #include <common>
  7239. #include <color_pars_vertex>
  7240. #include <fog_pars_vertex>
  7241. #include <morphtarget_pars_vertex>
  7242. #include <logdepthbuf_pars_vertex>
  7243. #include <clipping_planes_pars_vertex>
  7244. #ifdef USE_POINTS_UV
  7245. varying vec2 vUv;
  7246. uniform mat3 uvTransform;
  7247. #endif
  7248. void main() {
  7249. #ifdef USE_POINTS_UV
  7250. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7251. #endif
  7252. #include <color_vertex>
  7253. #include <morphcolor_vertex>
  7254. #include <begin_vertex>
  7255. #include <morphtarget_vertex>
  7256. #include <project_vertex>
  7257. gl_PointSize = size;
  7258. #ifdef USE_SIZEATTENUATION
  7259. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7260. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7261. #endif
  7262. #include <logdepthbuf_vertex>
  7263. #include <clipping_planes_vertex>
  7264. #include <worldpos_vertex>
  7265. #include <fog_vertex>
  7266. }`,Yze=`uniform vec3 diffuse;
  7267. uniform float opacity;
  7268. #include <common>
  7269. #include <color_pars_fragment>
  7270. #include <map_particle_pars_fragment>
  7271. #include <alphatest_pars_fragment>
  7272. #include <alphahash_pars_fragment>
  7273. #include <fog_pars_fragment>
  7274. #include <logdepthbuf_pars_fragment>
  7275. #include <clipping_planes_pars_fragment>
  7276. void main() {
  7277. #include <clipping_planes_fragment>
  7278. vec3 outgoingLight = vec3( 0.0 );
  7279. vec4 diffuseColor = vec4( diffuse, opacity );
  7280. #include <logdepthbuf_fragment>
  7281. #include <map_particle_fragment>
  7282. #include <color_fragment>
  7283. #include <alphatest_fragment>
  7284. #include <alphahash_fragment>
  7285. outgoingLight = diffuseColor.rgb;
  7286. #include <opaque_fragment>
  7287. #include <tonemapping_fragment>
  7288. #include <colorspace_fragment>
  7289. #include <fog_fragment>
  7290. #include <premultiplied_alpha_fragment>
  7291. }`,Zze=`#include <common>
  7292. #include <batching_pars_vertex>
  7293. #include <fog_pars_vertex>
  7294. #include <morphtarget_pars_vertex>
  7295. #include <skinning_pars_vertex>
  7296. #include <logdepthbuf_pars_vertex>
  7297. #include <shadowmap_pars_vertex>
  7298. void main() {
  7299. #include <batching_vertex>
  7300. #include <beginnormal_vertex>
  7301. #include <morphnormal_vertex>
  7302. #include <skinbase_vertex>
  7303. #include <skinnormal_vertex>
  7304. #include <defaultnormal_vertex>
  7305. #include <begin_vertex>
  7306. #include <morphtarget_vertex>
  7307. #include <skinning_vertex>
  7308. #include <project_vertex>
  7309. #include <logdepthbuf_vertex>
  7310. #include <worldpos_vertex>
  7311. #include <shadowmap_vertex>
  7312. #include <fog_vertex>
  7313. }`,Qze=`uniform vec3 color;
  7314. uniform float opacity;
  7315. #include <common>
  7316. #include <packing>
  7317. #include <fog_pars_fragment>
  7318. #include <bsdfs>
  7319. #include <lights_pars_begin>
  7320. #include <logdepthbuf_pars_fragment>
  7321. #include <shadowmap_pars_fragment>
  7322. #include <shadowmask_pars_fragment>
  7323. void main() {
  7324. #include <logdepthbuf_fragment>
  7325. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7326. #include <tonemapping_fragment>
  7327. #include <colorspace_fragment>
  7328. #include <fog_fragment>
  7329. }`,Jze=`uniform float rotation;
  7330. uniform vec2 center;
  7331. #include <common>
  7332. #include <uv_pars_vertex>
  7333. #include <fog_pars_vertex>
  7334. #include <logdepthbuf_pars_vertex>
  7335. #include <clipping_planes_pars_vertex>
  7336. void main() {
  7337. #include <uv_vertex>
  7338. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7339. vec2 scale;
  7340. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7341. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7342. #ifndef USE_SIZEATTENUATION
  7343. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7344. if ( isPerspective ) scale *= - mvPosition.z;
  7345. #endif
  7346. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7347. vec2 rotatedPosition;
  7348. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7349. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7350. mvPosition.xy += rotatedPosition;
  7351. gl_Position = projectionMatrix * mvPosition;
  7352. #include <logdepthbuf_vertex>
  7353. #include <clipping_planes_vertex>
  7354. #include <fog_vertex>
  7355. }`,eBe=`uniform vec3 diffuse;
  7356. uniform float opacity;
  7357. #include <common>
  7358. #include <uv_pars_fragment>
  7359. #include <map_pars_fragment>
  7360. #include <alphamap_pars_fragment>
  7361. #include <alphatest_pars_fragment>
  7362. #include <alphahash_pars_fragment>
  7363. #include <fog_pars_fragment>
  7364. #include <logdepthbuf_pars_fragment>
  7365. #include <clipping_planes_pars_fragment>
  7366. void main() {
  7367. #include <clipping_planes_fragment>
  7368. vec3 outgoingLight = vec3( 0.0 );
  7369. vec4 diffuseColor = vec4( diffuse, opacity );
  7370. #include <logdepthbuf_fragment>
  7371. #include <map_fragment>
  7372. #include <alphamap_fragment>
  7373. #include <alphatest_fragment>
  7374. #include <alphahash_fragment>
  7375. outgoingLight = diffuseColor.rgb;
  7376. #include <opaque_fragment>
  7377. #include <tonemapping_fragment>
  7378. #include <colorspace_fragment>
  7379. #include <fog_fragment>
  7380. }`,Sn={alphahash_fragment:w5e,alphahash_pars_fragment:S5e,alphamap_fragment:M5e,alphamap_pars_fragment:E5e,alphatest_fragment:N5e,alphatest_pars_fragment:A5e,aomap_fragment:T5e,aomap_pars_fragment:C5e,batching_pars_vertex:k5e,batching_vertex:j5e,begin_vertex:P5e,beginnormal_vertex:R5e,bsdfs:D5e,iridescence_fragment:O5e,bumpmap_pars_fragment:L5e,clipping_planes_fragment:I5e,clipping_planes_pars_fragment:F5e,clipping_planes_pars_vertex:U5e,clipping_planes_vertex:z5e,color_fragment:B5e,color_pars_fragment:$5e,color_pars_vertex:H5e,color_vertex:V5e,common:G5e,cube_uv_reflection_fragment:W5e,defaultnormal_vertex:q5e,displacementmap_pars_vertex:K5e,displacementmap_vertex:X5e,emissivemap_fragment:Y5e,emissivemap_pars_fragment:Z5e,colorspace_fragment:Q5e,colorspace_pars_fragment:J5e,envmap_fragment:eUe,envmap_common_pars_fragment:tUe,envmap_pars_fragment:nUe,envmap_pars_vertex:rUe,envmap_physical_pars_fragment:pUe,envmap_vertex:iUe,fog_vertex:aUe,fog_pars_vertex:sUe,fog_fragment:oUe,fog_pars_fragment:lUe,gradientmap_pars_fragment:cUe,lightmap_fragment:uUe,lightmap_pars_fragment:dUe,lights_lambert_fragment:hUe,lights_lambert_pars_fragment:fUe,lights_pars_begin:mUe,lights_toon_fragment:gUe,lights_toon_pars_fragment:xUe,lights_phong_fragment:bUe,lights_phong_pars_fragment:yUe,lights_physical_fragment:vUe,lights_physical_pars_fragment:_Ue,lights_fragment_begin:wUe,lights_fragment_maps:SUe,lights_fragment_end:MUe,logdepthbuf_fragment:EUe,logdepthbuf_pars_fragment:NUe,logdepthbuf_pars_vertex:AUe,logdepthbuf_vertex:TUe,map_fragment:CUe,map_pars_fragment:kUe,map_particle_fragment:jUe,map_particle_pars_fragment:PUe,metalnessmap_fragment:RUe,metalnessmap_pars_fragment:DUe,morphcolor_vertex:OUe,morphnormal_vertex:LUe,morphtarget_pars_vertex:IUe,morphtarget_vertex:FUe,normal_fragment_begin:UUe,normal_fragment_maps:zUe,normal_pars_fragment:BUe,normal_pars_vertex:$Ue,normal_vertex:HUe,normalmap_pars_fragment:VUe,clearcoat_normal_fragment_begin:GUe,clearcoat_normal_fragment_maps:WUe,clearcoat_pars_fragment:qUe,iridescence_pars_fragment:KUe,opaque_fragment:XUe,packing:YUe,premultiplied_alpha_fragment:ZUe,project_vertex:QUe,dithering_fragment:JUe,dithering_pars_fragment:eze,roughnessmap_fragment:tze,roughnessmap_pars_fragment:nze,shadowmap_pars_fragment:rze,shadowmap_pars_vertex:ize,shadowmap_vertex:aze,shadowmask_pars_fragment:sze,skinbase_vertex:oze,skinning_pars_vertex:lze,skinning_vertex:cze,skinnormal_vertex:uze,specularmap_fragment:dze,specularmap_pars_fragment:hze,tonemapping_fragment:fze,tonemapping_pars_fragment:mze,transmission_fragment:pze,transmission_pars_fragment:gze,uv_pars_fragment:xze,uv_pars_vertex:bze,uv_vertex:yze,worldpos_vertex:vze,background_vert:_ze,background_frag:wze,backgroundCube_vert:Sze,backgroundCube_frag:Mze,cube_vert:Eze,cube_frag:Nze,depth_vert:Aze,depth_frag:Tze,distanceRGBA_vert:Cze,distanceRGBA_frag:kze,equirect_vert:jze,equirect_frag:Pze,linedashed_vert:Rze,linedashed_frag:Dze,meshbasic_vert:Oze,meshbasic_frag:Lze,meshlambert_vert:Ize,meshlambert_frag:Fze,meshmatcap_vert:Uze,meshmatcap_frag:zze,meshnormal_vert:Bze,meshnormal_frag:$ze,meshphong_vert:Hze,meshphong_frag:Vze,meshphysical_vert:Gze,meshphysical_frag:Wze,meshtoon_vert:qze,meshtoon_frag:Kze,points_vert:Xze,points_frag:Yze,shadow_vert:Zze,shadow_frag:Qze,sprite_vert:Jze,sprite_frag:eBe},Dt={common:{diffuse:{value:new en(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tn}},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 Tn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tn},normalScale:{value:new pn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new en(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 en(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new en(16777215)},opacity:{value:1},center:{value:new pn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}}},fs={basic:{uniforms:Va([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:Sn.meshbasic_vert,fragmentShader:Sn.meshbasic_frag},lambert:{uniforms:Va([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new en(0)}}]),vertexShader:Sn.meshlambert_vert,fragmentShader:Sn.meshlambert_frag},phong:{uniforms:Va([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new en(0)},specular:{value:new en(1118481)},shininess:{value:30}}]),vertexShader:Sn.meshphong_vert,fragmentShader:Sn.meshphong_frag},standard:{uniforms:Va([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new en(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag},toon:{uniforms:Va([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new en(0)}}]),vertexShader:Sn.meshtoon_vert,fragmentShader:Sn.meshtoon_frag},matcap:{uniforms:Va([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:Sn.meshmatcap_vert,fragmentShader:Sn.meshmatcap_frag},points:{uniforms:Va([Dt.points,Dt.fog]),vertexShader:Sn.points_vert,fragmentShader:Sn.points_frag},dashed:{uniforms:Va([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sn.linedashed_vert,fragmentShader:Sn.linedashed_frag},depth:{uniforms:Va([Dt.common,Dt.displacementmap]),vertexShader:Sn.depth_vert,fragmentShader:Sn.depth_frag},normal:{uniforms:Va([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:Sn.meshnormal_vert,fragmentShader:Sn.meshnormal_frag},sprite:{uniforms:Va([Dt.sprite,Dt.fog]),vertexShader:Sn.sprite_vert,fragmentShader:Sn.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Sn.background_vert,fragmentShader:Sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Sn.backgroundCube_vert,fragmentShader:Sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Sn.cube_vert,fragmentShader:Sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Sn.equirect_vert,fragmentShader:Sn.equirect_frag},distanceRGBA:{uniforms:Va([Dt.common,Dt.displacementmap,{referencePosition:{value:new Fe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sn.distanceRGBA_vert,fragmentShader:Sn.distanceRGBA_frag},shadow:{uniforms:Va([Dt.lights,Dt.fog,{color:{value:new en(0)},opacity:{value:1}}]),vertexShader:Sn.shadow_vert,fragmentShader:Sn.shadow_frag}};fs.physical={uniforms:Va([fs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tn},clearcoatNormalScale:{value:new pn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tn},sheen:{value:0},sheenColor:{value:new en(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tn},transmissionSamplerSize:{value:new pn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tn},attenuationDistance:{value:0},attenuationColor:{value:new en(0)},specularColor:{value:new en(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tn},anisotropyVector:{value:new pn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tn}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag};const _1={r:0,b:0,g:0};function tBe(t,e,n,r,i,a,o){const l=new en(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function b(x,v){let S=!1,M=v.isScene===!0?v.background:null;M&&M.isTexture&&(M=(v.backgroundBlurriness>0?n:e).get(M)),M===null?y(l,c):M&&M.isColor&&(y(M,1),S=!0);const N=t.xr.getEnvironmentBlendMode();N==="additive"?r.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),M&&(M.isCubeTexture||M.mapping===hN)?(d===void 0&&(d=new el(new Gy(1,1,1),new th({name:"BackgroundCubeMaterial",uniforms:Dg(fs.backgroundCube.uniforms),vertexShader:fs.backgroundCube.vertexShader,fragmentShader:fs.backgroundCube.fragmentShader,side:ys,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,k,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=hr.getTransfer(M.colorSpace)!==Cr,(f!==M||m!==M.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=M,m=M.version,p=t.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):M&&M.isTexture&&(u===void 0&&(u=new el(new xL(2,2),new th({name:"BackgroundMaterial",uniforms:Dg(fs.background.uniforms),vertexShader:fs.background.vertexShader,fragmentShader:fs.background.fragmentShader,side:eh,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=M,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=hr.getTransfer(M.colorSpace)!==Cr,M.matrixAutoUpdate===!0&&M.updateMatrix(),u.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||m!==M.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=M,m=M.version,p=t.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null))}function y(x,v){x.getRGB(_1,rte(t)),r.buffers.color.setClear(_1.r,_1.g,_1.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(x,v=1){l.set(x),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,y(l,c)},render:b}}function nBe(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(j,W,K,G,J){let ie=!1;if(o){const re=y(G,K,W);u!==re&&(u=re,p(u.object)),ie=v(j,G,K,J),ie&&S(j,G,K,J)}else{const re=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==re)&&(u.geometry=G.id,u.program=K.id,u.wireframe=re,ie=!0)}J!==null&&n.update(J,t.ELEMENT_ARRAY_BUFFER),(ie||d)&&(d=!1,D(j,W,K,G),J!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(J).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function b(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function y(j,W,K){const G=K.wireframe===!0;let J=l[j.id];J===void 0&&(J={},l[j.id]=J);let ie=J[W.id];ie===void 0&&(ie={},J[W.id]=ie);let re=ie[G];return re===void 0&&(re=x(m()),ie[G]=re),re}function x(j){const W=[],K=[],G=[];for(let J=0;J<i;J++)W[J]=0,K[J]=0,G[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:j,attributes:{},index:null}}function v(j,W,K,G){const J=u.attributes,ie=W.attributes;let re=0;const z=K.getAttributes();for(const V in z)if(z[V].location>=0){const ne=J[V];let he=ie[V];if(he===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(he=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(he=j.instanceColor)),ne===void 0||ne.attribute!==he||he&&ne.data!==he.data)return!0;re++}return u.attributesNum!==re||u.index!==G}function S(j,W,K,G){const J={},ie=W.attributes;let re=0;const z=K.getAttributes();for(const V in z)if(z[V].location>=0){let ne=ie[V];ne===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor));const he={};he.attribute=ne,ne&&ne.data&&(he.data=ne.data),J[V]=he,re++}u.attributes=J,u.attributesNum=re,u.index=G}function M(){const j=u.newAttributes;for(let W=0,K=j.length;W<K;W++)j[W]=0}function N(j){A(j,0)}function A(j,W){const K=u.newAttributes,G=u.enabledAttributes,J=u.attributeDivisors;K[j]=1,G[j]===0&&(t.enableVertexAttribArray(j),G[j]=1),J[j]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,W),J[j]=W)}function k(){const j=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==j[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function C(j,W,K,G,J,ie,re){re===!0?t.vertexAttribIPointer(j,W,K,J,ie):t.vertexAttribPointer(j,W,K,G,J,ie)}function D(j,W,K,G){if(r.isWebGL2===!1&&(j.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const J=G.attributes,ie=K.getAttributes(),re=W.defaultAttributeValues;for(const z in ie){const V=ie[z];if(V.location>=0){let Z=J[z];if(Z===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(Z=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(Z=j.instanceColor)),Z!==void 0){const ne=Z.normalized,he=Z.itemSize,fe=n.get(Z);if(fe===void 0)continue;const le=fe.buffer,Ee=fe.type,me=fe.bytesPerElement,we=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||Z.gpuType===Iee);if(Z.isInterleavedBufferAttribute){const De=Z.data,ee=De.stride,Qe=Z.offset;if(De.isInstancedInterleavedBuffer){for(let B=0;B<V.locationSize;B++)A(V.location+B,De.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=De.meshPerAttribute*De.count)}else for(let B=0;B<V.locationSize;B++)N(V.location+B);t.bindBuffer(t.ARRAY_BUFFER,le);for(let B=0;B<V.locationSize;B++)C(V.location+B,he/V.locationSize,Ee,ne,ee*me,(Qe+he/V.locationSize*B)*me,we)}else{if(Z.isInstancedBufferAttribute){for(let De=0;De<V.locationSize;De++)A(V.location+De,Z.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let De=0;De<V.locationSize;De++)N(V.location+De);t.bindBuffer(t.ARRAY_BUFFER,le);for(let De=0;De<V.locationSize;De++)C(V.location+De,he/V.locationSize,Ee,ne,he*me,he/V.locationSize*De*me,we)}}else if(re!==void 0){const ne=re[z];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(V.location,ne);break;case 3:t.vertexAttrib3fv(V.location,ne);break;case 4:t.vertexAttrib4fv(V.location,ne);break;default:t.vertexAttrib1fv(V.location,ne)}}}}k()}function T(){O();for(const j in l){const W=l[j];for(const K in W){const G=W[K];for(const J in G)b(G[J].object),delete G[J];delete W[K]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const W=l[j.id];for(const K in W){const G=W[K];for(const J in G)b(G[J].object),delete G[J];delete W[K]}delete l[j.id]}function U(j){for(const W in l){const K=l[W];if(K[j.id]===void 0)continue;const G=K[j.id];for(const J in G)b(G[J].object),delete G[J];delete K[j.id]}}function O(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:T,releaseStatesOfGeometry:R,releaseStatesOfProgram:U,initAttributes:M,enableAttribute:N,disableUnusedAttributes:k}}function rBe(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,m){if(m===0)return;let p,b;if(i)p=t,b="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[b](a,d,f,m),n.update(f,a,m)}function u(d,f,m){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let b=0;b<m;b++)this.render(d[b],f[b]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,m);let b=0;for(let y=0;y<m;y++)b+=f[y];n.update(b,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function iBe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="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),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,N=o||e.has("OES_texture_float"),A=M&&N,k=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:p,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:x,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:M,floatFragmentTextures:N,floatVertexTextures:A,maxSamples:k}}function aBe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new xd,l=new Tn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const b=f.clippingPlanes,y=f.clipIntersection,x=f.clipShadows,v=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const S=a?0:r,M=S*4;let N=v.clippingState||null;c.value=N,N=d(b,m,M,p);for(let A=0;A!==M;++A)N[A]=n[A];v.clippingState=N,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,b){const y=f!==null?f.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=p+y*4,S=m.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let M=0,N=p;M!==y;++M,N+=4)o.copy(f[M]).applyMatrix4(S,l),o.normal.toArray(x,N),x[N+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function sBe(t){let e=new WeakMap;function n(o,l){return l===_R?o.mapping=jg:l===wR&&(o.mapping=Pg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===_R||l===wR)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 b5e(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 oBe extends ite{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 Xp=4,S7=[.125,.215,.35,.446,.526,.582],tf=20,Xk=new oBe,M7=new en;let Yk=null,Zk=0,Qk=0;const Zh=(1+Math.sqrt(5))/2,kp=1/Zh,E7=[new Fe(1,1,1),new Fe(-1,1,1),new Fe(1,1,-1),new Fe(-1,1,-1),new Fe(0,Zh,kp),new Fe(0,Zh,-kp),new Fe(kp,0,Zh),new Fe(-kp,0,Zh),new Fe(Zh,kp,0),new Fe(-Zh,kp,0)];class N7{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){Yk=this._renderer.getRenderTarget(),Zk=this._renderer.getActiveCubeFace(),Qk=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=C7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=T7(),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(Yk,Zk,Qk),e.scissorTest=!1,w1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===jg||e.mapping===Pg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Yk=this._renderer.getRenderTarget(),Zk=this._renderer.getActiveCubeFace(),Qk=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:wo,minFilter:wo,generateMipmaps:!1,type:Z0,format:So,colorSpace:vu,depthBuffer:!1},i=A7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=A7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=lBe(a)),this._blurMaterial=cBe(a,e,n)}return i}_compileMaterial(e){const n=new el(this._lodPlanes[0],e);this._renderer.compile(n,Xk)}_sceneToCubeUV(e,n,r,i){const l=new Is(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(M7),d.toneMapping=Bd,d.autoClear=!1;const p=new ete({name:"PMREM.Background",side:ys,depthWrite:!1,depthTest:!1}),b=new el(new Gy,p);let y=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(M7),y=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const M=this._cubeSize;w1(i,S*M,v>2?M:0,M,M),d.setRenderTarget(i),y&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===jg||e.mapping===Pg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=C7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=T7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new el(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;w1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Xk)}_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=E7[(i-1)%E7.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 el(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*tf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):tf;x>tf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${tf}`);const v=[];let S=0;for(let C=0;C<tf;++C){const D=C/y,T=Math.exp(-D*D/2);v.push(T),C===0?S+=T:C<x&&(S+=2*T)}for(let C=0;C<v.length;C++)v[C]=v[C]/S;m.envMap.value=e.texture,m.samples.value=x,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:M}=this;m.dTheta.value=b,m.mipInt.value=M-r;const N=this._sizeLods[i],A=3*N*(i>M-Xp?i-M+Xp:0),k=4*(this._cubeSize-N);w1(n,A,k,3*N,2*N),c.setRenderTarget(n),c.render(f,Xk)}}function lBe(t){const e=[],n=[],r=[];let i=t;const a=t-Xp+1+S7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Xp?c=S7[o-t+Xp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,b=6,y=3,x=2,v=1,S=new Float32Array(y*b*p),M=new Float32Array(x*b*p),N=new Float32Array(v*b*p);for(let k=0;k<p;k++){const C=k%3*2/3-1,D=k>2?0:-1,T=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];S.set(T,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];N.set(R,v*b*k)}const A=new Ua;A.setAttribute("position",new Ws(S,y)),A.setAttribute("uv",new Ws(M,x)),A.setAttribute("faceIndex",new Ws(N,v)),e.push(A),i>Xp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function A7(t,e,n){const r=new Jf(t,e,n);return r.texture.mapping=hN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function w1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function cBe(t,e,n){const r=new Float32Array(tf),i=new Fe(0,1,0);return new th({name:"SphericalGaussianBlur",defines:{n:tf,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:bL(),fragmentShader:`
  7381. precision mediump float;
  7382. precision mediump int;
  7383. varying vec3 vOutputDirection;
  7384. uniform sampler2D envMap;
  7385. uniform int samples;
  7386. uniform float weights[ n ];
  7387. uniform bool latitudinal;
  7388. uniform float dTheta;
  7389. uniform float mipInt;
  7390. uniform vec3 poleAxis;
  7391. #define ENVMAP_TYPE_CUBE_UV
  7392. #include <cube_uv_reflection_fragment>
  7393. vec3 getSample( float theta, vec3 axis ) {
  7394. float cosTheta = cos( theta );
  7395. // Rodrigues' axis-angle rotation
  7396. vec3 sampleDirection = vOutputDirection * cosTheta
  7397. + cross( axis, vOutputDirection ) * sin( theta )
  7398. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7399. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7400. }
  7401. void main() {
  7402. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7403. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7404. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7405. }
  7406. axis = normalize( axis );
  7407. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7408. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7409. for ( int i = 1; i < n; i++ ) {
  7410. if ( i >= samples ) {
  7411. break;
  7412. }
  7413. float theta = dTheta * float( i );
  7414. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7415. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7416. }
  7417. }
  7418. `,blending:zd,depthTest:!1,depthWrite:!1})}function T7(){return new th({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:bL(),fragmentShader:`
  7419. precision mediump float;
  7420. precision mediump int;
  7421. varying vec3 vOutputDirection;
  7422. uniform sampler2D envMap;
  7423. #include <common>
  7424. void main() {
  7425. vec3 outputDirection = normalize( vOutputDirection );
  7426. vec2 uv = equirectUv( outputDirection );
  7427. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7428. }
  7429. `,blending:zd,depthTest:!1,depthWrite:!1})}function C7(){return new th({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:bL(),fragmentShader:`
  7430. precision mediump float;
  7431. precision mediump int;
  7432. uniform float flipEnvMap;
  7433. varying vec3 vOutputDirection;
  7434. uniform samplerCube envMap;
  7435. void main() {
  7436. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7437. }
  7438. `,blending:zd,depthTest:!1,depthWrite:!1})}function bL(){return`
  7439. precision mediump float;
  7440. precision mediump int;
  7441. attribute float faceIndex;
  7442. varying vec3 vOutputDirection;
  7443. // RH coordinate system; PMREM face-indexing convention
  7444. vec3 getDirection( vec2 uv, float face ) {
  7445. uv = 2.0 * uv - 1.0;
  7446. vec3 direction = vec3( uv, 1.0 );
  7447. if ( face == 0.0 ) {
  7448. direction = direction.zyx; // ( 1, v, u ) pos x
  7449. } else if ( face == 1.0 ) {
  7450. direction = direction.xzy;
  7451. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7452. } else if ( face == 2.0 ) {
  7453. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7454. } else if ( face == 3.0 ) {
  7455. direction = direction.zyx;
  7456. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7457. } else if ( face == 4.0 ) {
  7458. direction = direction.xzy;
  7459. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7460. } else if ( face == 5.0 ) {
  7461. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7462. }
  7463. return direction;
  7464. }
  7465. void main() {
  7466. vOutputDirection = getDirection( uv, faceIndex );
  7467. gl_Position = vec4( position, 1.0 );
  7468. }
  7469. `}function uBe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===_R||c===wR,d=c===jg||c===Pg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new N7(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 N7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",a),m.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 dBe(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 hBe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const b in m.attributes)e.remove(m.attributes[b]);for(const b in m.morphAttributes){const y=m.morphAttributes[b];for(let x=0,v=y.length;x<v;x++)e.remove(y[x])}m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const b in m)e.update(m[b],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const b in p){const y=p[b];for(let x=0,v=y.length;x<v;x++)e.update(y[x],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,b=f.attributes.position;let y=0;if(p!==null){const S=p.array;y=p.version;for(let M=0,N=S.length;M<N;M+=3){const A=S[M+0],k=S[M+1],C=S[M+2];m.push(A,k,k,C,C,A)}}else if(b!==void 0){const S=b.array;y=b.version;for(let M=0,N=S.length/3-1;M<N;M+=3){const A=M+0,k=M+1,C=M+2;m.push(A,k,k,C,C,A)}}else return;const x=new(Kee(m)?nte:tte)(m,1);x.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,x)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function fBe(t,e,n,r){const i=r.isWebGL2;let a;function o(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,b){t.drawElements(a,b,l,p*c),n.update(b,a,1)}function f(p,b,y){if(y===0)return;let x,v;if(i)x=t,v="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[v](a,b,l,p*c,y),n.update(b,a,y)}function m(p,b,y){if(y===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<y;v++)this.render(p[v]/c,b[v]);else{x.multiDrawElementsWEBGL(a,b,0,l,p,0,y);let v=0;for(let S=0;S<y;S++)v+=b[S];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function mBe(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 pBe(t,e){return t[0]-e[0]}function gBe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function xBe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new mr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=b!==void 0?b.length:0;let x=a.get(d);if(x===void 0||x.count!==y){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;x!==void 0&&x.texture.dispose();const M=d.morphAttributes.position!==void 0,N=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let T=0;M===!0&&(T=1),N===!0&&(T=2),A===!0&&(T=3);let R=d.attributes.position.count*T,U=1;R>e.maxTextureSize&&(U=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const O=new Float32Array(R*U*4*y),q=new Zee(O,R,U,y);q.type=Jc,q.needsUpdate=!0;const j=T*4;for(let K=0;K<y;K++){const G=k[K],J=C[K],ie=D[K],re=R*U*4*K;for(let z=0;z<G.count;z++){const V=z*j;M===!0&&(o.fromBufferAttribute(G,z),O[re+V+0]=o.x,O[re+V+1]=o.y,O[re+V+2]=o.z,O[re+V+3]=0),N===!0&&(o.fromBufferAttribute(J,z),O[re+V+4]=o.x,O[re+V+5]=o.y,O[re+V+6]=o.z,O[re+V+7]=0),A===!0&&(o.fromBufferAttribute(ie,z),O[re+V+8]=o.x,O[re+V+9]=o.y,O[re+V+10]=o.z,O[re+V+11]=ie.itemSize===4?o.w:1)}}x={count:y,texture:q,size:new pn(R,U)},a.set(d,x),d.addEventListener("dispose",W)}let v=0;for(let M=0;M<m.length;M++)v+=m[M];const S=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=m===void 0?0:m.length;let y=r[d.id];if(y===void 0||y.length!==b){y=[];for(let N=0;N<b;N++)y[N]=[N,0];r[d.id]=y}for(let N=0;N<b;N++){const A=y[N];A[0]=N,A[1]=m[N]}y.sort(gBe);for(let N=0;N<8;N++)N<b&&y[N][1]?(l[N][0]=y[N][0],l[N][1]=y[N][1]):(l[N][0]=Number.MAX_SAFE_INTEGER,l[N][1]=0);l.sort(pBe);const x=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let N=0;N<8;N++){const A=l[N],k=A[0],C=A[1];k!==Number.MAX_SAFE_INTEGER&&C?(x&&d.getAttribute("morphTarget"+N)!==x[k]&&d.setAttribute("morphTarget"+N,x[k]),v&&d.getAttribute("morphNormal"+N)!==v[k]&&d.setAttribute("morphNormal"+N,v[k]),i[N]=C,S+=C):(x&&d.hasAttribute("morphTarget"+N)===!0&&d.deleteAttribute("morphTarget"+N),v&&d.hasAttribute("morphNormal"+N)===!0&&d.deleteAttribute("morphNormal"+N),i[N]=0)}const M=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function bBe(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 ote extends vs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Nf,d!==Nf&&d!==Rg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Nf&&(r=Cd),r===void 0&&d===Rg&&(r=Ef),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:pa,this.minFilter=c!==void 0?c:pa,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 lte=new vs,cte=new ote(1,1);cte.compareFunction=Wee;const ute=new Zee,dte=new n5e,hte=new ate,k7=[],j7=[],P7=new Float32Array(16),R7=new Float32Array(9),D7=new Float32Array(4);function dx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=k7[i];if(a===void 0&&(a=new Float32Array(i),k7[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 ki(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 ji(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function pN(t,e){let n=j7[e];n===void 0&&(n=new Int32Array(e),j7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function yBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function vBe(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(ki(n,e))return;t.uniform2fv(this.addr,e),ji(n,e)}}function _Be(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(ki(n,e))return;t.uniform3fv(this.addr,e),ji(n,e)}}function wBe(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(ki(n,e))return;t.uniform4fv(this.addr,e),ji(n,e)}}function SBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ki(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ji(n,e)}else{if(ki(n,r))return;D7.set(r),t.uniformMatrix2fv(this.addr,!1,D7),ji(n,r)}}function MBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ki(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ji(n,e)}else{if(ki(n,r))return;R7.set(r),t.uniformMatrix3fv(this.addr,!1,R7),ji(n,r)}}function EBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ki(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ji(n,e)}else{if(ki(n,r))return;P7.set(r),t.uniformMatrix4fv(this.addr,!1,P7),ji(n,r)}}function NBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function ABe(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(ki(n,e))return;t.uniform2iv(this.addr,e),ji(n,e)}}function TBe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ki(n,e))return;t.uniform3iv(this.addr,e),ji(n,e)}}function CBe(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(ki(n,e))return;t.uniform4iv(this.addr,e),ji(n,e)}}function kBe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function jBe(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(ki(n,e))return;t.uniform2uiv(this.addr,e),ji(n,e)}}function PBe(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(ki(n,e))return;t.uniform3uiv(this.addr,e),ji(n,e)}}function RBe(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(ki(n,e))return;t.uniform4uiv(this.addr,e),ji(n,e)}}function DBe(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?cte:lte;n.setTexture2D(e||a,i)}function OBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||dte,i)}function LBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||hte,i)}function IBe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||ute,i)}function FBe(t){switch(t){case 5126:return yBe;case 35664:return vBe;case 35665:return _Be;case 35666:return wBe;case 35674:return SBe;case 35675:return MBe;case 35676:return EBe;case 5124:case 35670:return NBe;case 35667:case 35671:return ABe;case 35668:case 35672:return TBe;case 35669:case 35673:return CBe;case 5125:return kBe;case 36294:return jBe;case 36295:return PBe;case 36296:return RBe;case 35678:case 36198:case 36298:case 36306:case 35682:return DBe;case 35679:case 36299:case 36307:return OBe;case 35680:case 36300:case 36308:case 36293:return LBe;case 36289:case 36303:case 36311:case 36292:return IBe}}function UBe(t,e){t.uniform1fv(this.addr,e)}function zBe(t,e){const n=dx(e,this.size,2);t.uniform2fv(this.addr,n)}function BBe(t,e){const n=dx(e,this.size,3);t.uniform3fv(this.addr,n)}function $Be(t,e){const n=dx(e,this.size,4);t.uniform4fv(this.addr,n)}function HBe(t,e){const n=dx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function VBe(t,e){const n=dx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function GBe(t,e){const n=dx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function WBe(t,e){t.uniform1iv(this.addr,e)}function qBe(t,e){t.uniform2iv(this.addr,e)}function KBe(t,e){t.uniform3iv(this.addr,e)}function XBe(t,e){t.uniform4iv(this.addr,e)}function YBe(t,e){t.uniform1uiv(this.addr,e)}function ZBe(t,e){t.uniform2uiv(this.addr,e)}function QBe(t,e){t.uniform3uiv(this.addr,e)}function JBe(t,e){t.uniform4uiv(this.addr,e)}function e8e(t,e,n){const r=this.cache,i=e.length,a=pN(n,i);ki(r,a)||(t.uniform1iv(this.addr,a),ji(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||lte,a[o])}function t8e(t,e,n){const r=this.cache,i=e.length,a=pN(n,i);ki(r,a)||(t.uniform1iv(this.addr,a),ji(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||dte,a[o])}function n8e(t,e,n){const r=this.cache,i=e.length,a=pN(n,i);ki(r,a)||(t.uniform1iv(this.addr,a),ji(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||hte,a[o])}function r8e(t,e,n){const r=this.cache,i=e.length,a=pN(n,i);ki(r,a)||(t.uniform1iv(this.addr,a),ji(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||ute,a[o])}function i8e(t){switch(t){case 5126:return UBe;case 35664:return zBe;case 35665:return BBe;case 35666:return $Be;case 35674:return HBe;case 35675:return VBe;case 35676:return GBe;case 5124:case 35670:return WBe;case 35667:case 35671:return qBe;case 35668:case 35672:return KBe;case 35669:case 35673:return XBe;case 5125:return YBe;case 36294:return ZBe;case 36295:return QBe;case 36296:return JBe;case 35678:case 36198:case 36298:case 36306:case 35682:return e8e;case 35679:case 36299:case 36307:return t8e;case 35680:case 36300:case 36308:case 36293:return n8e;case 36289:case 36303:case 36311:case 36292:return r8e}}class a8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=FBe(n.type)}}class s8e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=i8e(n.type)}}class o8e{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 Jk=/(\w+)(\])?(\[|\.)?/g;function O7(t,e){t.seq.push(e),t.map[e.id]=e}function l8e(t,e,n){const r=t.name,i=r.length;for(Jk.lastIndex=0;;){const a=Jk.exec(r),o=Jk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){O7(n,u===void 0?new a8e(l,t,e):new s8e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new o8e(l),O7(n,f)),n=f}}}class gw{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);l8e(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 L7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const c8e=37297;let u8e=0;function d8e(t,e){const n=t.split(`
  7470. `),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(`
  7471. `)}function h8e(t){const e=hr.getPrimaries(hr.workingColorSpace),n=hr.getPrimaries(t);let r;switch(e===n?r="":e===WS&&n===GS?r="LinearDisplayP3ToLinearSRGB":e===GS&&n===WS&&(r="LinearSRGBToLinearDisplayP3"),t){case vu:case fN:return[r,"LinearTransferOETF"];case ga:case fL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function I7(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()+`
  7472. `+i+`
  7473. `+d8e(t.getShaderSource(e),o)}else return i}function f8e(t,e){const n=h8e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function m8e(t,e){let n;switch(e){case fFe:n="Linear";break;case mFe:n="Reinhard";break;case pFe:n="OptimizedCineon";break;case gFe:n="ACESFilmic";break;case xFe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function p8e(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(Vb).join(`
  7474. `)}function g8e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7475. `)}function x8e(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 Vb(t){return t!==""}function F7(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 U7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const b8e=/^[ \t]*#include +<([\w\d./]+)>/gm;function TR(t){return t.replace(b8e,v8e)}const y8e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function v8e(t,e){let n=Sn[e];if(n===void 0){const r=y8e.get(e);if(r!==void 0)n=Sn[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 TR(n)}const _8e=/#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 z7(t){return t.replace(_8e,w8e)}function w8e(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 B7(t){let e="precision "+t.precision+` float;
  7476. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7477. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7478. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7479. #define LOW_PRECISION`),e}function S8e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Oee?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===BIe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===$c&&(e="SHADOWMAP_TYPE_VSM"),e}function M8e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case jg:case Pg:e="ENVMAP_TYPE_CUBE";break;case hN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function E8e(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Pg&&(e="ENVMAP_MODE_REFRACTION"),e}function N8e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case dL:e="ENVMAP_BLENDING_MULTIPLY";break;case dFe:e="ENVMAP_BLENDING_MIX";break;case hFe:e="ENVMAP_BLENDING_ADD";break}return e}function A8e(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 T8e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=S8e(n),u=M8e(n),d=E8e(n),f=N8e(n),m=A8e(n),p=n.isWebGL2?"":p8e(n),b=g8e(a),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
  7480. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
  7481. `),x.length>0&&(x+=`
  7482. `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
  7483. `),v.length>0&&(v+=`
  7484. `)):(x=[B7(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",`
  7485. `].filter(Vb).join(`
  7486. `),v=[p,B7(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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!==Bd?"#define TONE_MAPPING":"",n.toneMapping!==Bd?Sn.tonemapping_pars_fragment:"",n.toneMapping!==Bd?m8e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,f8e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7487. `].filter(Vb).join(`
  7488. `)),o=TR(o),o=F7(o,n),o=U7(o,n),l=TR(l),l=F7(l,n),l=U7(l,n),o=z7(o),l=z7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7489. `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7490. `)+`
  7491. `+x,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===a7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===a7?"":"#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(`
  7492. `)+`
  7493. `+v);const M=S+x+o,N=S+v+l,A=L7(i,i.VERTEX_SHADER,M),k=L7(i,i.FRAGMENT_SHADER,N);i.attachShader(y,A),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(A).trim(),j=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,k);else{const G=I7(i,A,"vertex"),J=I7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7494. Program Info Log: `+O+`
  7495. `+G+`
  7496. `+J)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||j==="")&&(K=!1);K&&(U.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:x},fragmentShader:{log:j,prefix:v}})}i.deleteShader(A),i.deleteShader(k),D=new gw(i,y),T=x8e(i,y)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,c8e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=u8e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=k,this}let C8e=0;class k8e{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 j8e(e),n.set(e,r)),r}}class j8e{constructor(e){this.id=C8e++,this.code=e,this.usedTimes=0}}function P8e(t,e,n,r,i,a,o){const l=new Qee,c=new k8e,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=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 y(T){return T===0?"uv":`uv${T}`}function x(T,R,U,O,q){const j=O.fog,W=q.geometry,K=T.isMeshStandardMaterial?O.environment:null,G=(T.isMeshStandardMaterial?n:e).get(T.envMap||K),J=G&&G.mapping===hN?G.image.height:null,ie=b[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));const re=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=re!==void 0?re.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let Z,ne,he,fe;if(ie){const nn=fs[ie];Z=nn.vertexShader,ne=nn.fragmentShader}else Z=T.vertexShader,ne=T.fragmentShader,c.update(T),he=c.getVertexShaderID(T),fe=c.getFragmentShaderID(T);const le=t.getRenderTarget(),Ee=q.isInstancedMesh===!0,me=q.isBatchedMesh===!0,we=!!T.map,De=!!T.matcap,ee=!!G,Qe=!!T.aoMap,B=!!T.lightMap,te=!!T.bumpMap,Y=!!T.normalMap,H=!!T.displacementMap,F=!!T.emissiveMap,de=!!T.metalnessMap,Ae=!!T.roughnessMap,Le=T.anisotropy>0,Se=T.clearcoat>0,$=T.iridescence>0,L=T.sheen>0,X=T.transmission>0,xe=Le&&!!T.anisotropyMap,_e=Se&&!!T.clearcoatMap,ae=Se&&!!T.clearcoatNormalMap,Te=Se&&!!T.clearcoatRoughnessMap,Pe=$&&!!T.iridescenceMap,Xe=$&&!!T.iridescenceThicknessMap,Je=L&&!!T.sheenColorMap,Ze=L&&!!T.sheenRoughnessMap,oe=!!T.specularMap,ye=!!T.specularColorMap,Ce=!!T.specularIntensityMap,$e=X&&!!T.transmissionMap,lt=X&&!!T.thicknessMap,se=!!T.gradientMap,ze=!!T.alphaMap,ve=T.alphaTest>0,He=!!T.alphaHash,Oe=!!T.extensions,Ne=!!W.attributes.uv1,Be=!!W.attributes.uv2,at=!!W.attributes.uv3;let Rt=Bd;return T.toneMapped&&(le===null||le.isXRRenderTarget===!0)&&(Rt=t.toneMapping),{isWebGL2:d,shaderID:ie,shaderType:T.type,shaderName:T.name,vertexShader:Z,fragmentShader:ne,defines:T.defines,customVertexShaderID:he,customFragmentShaderID:fe,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:me,instancing:Ee,instancingColor:Ee&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:le===null?t.outputColorSpace:le.isXRRenderTarget===!0?le.texture.colorSpace:vu,map:we,matcap:De,envMap:ee,envMapMode:ee&&G.mapping,envMapCubeUVHeight:J,aoMap:Qe,lightMap:B,bumpMap:te,normalMap:Y,displacementMap:m&&H,emissiveMap:F,normalMapObjectSpace:Y&&T.normalMapType===CFe,normalMapTangentSpace:Y&&T.normalMapType===Gee,metalnessMap:de,roughnessMap:Ae,anisotropy:Le,anisotropyMap:xe,clearcoat:Se,clearcoatMap:_e,clearcoatNormalMap:ae,clearcoatRoughnessMap:Te,iridescence:$,iridescenceMap:Pe,iridescenceThicknessMap:Xe,sheen:L,sheenColorMap:Je,sheenRoughnessMap:Ze,specularMap:oe,specularColorMap:ye,specularIntensityMap:Ce,transmission:X,transmissionMap:$e,thicknessMap:lt,gradientMap:se,opaque:T.transparent===!1&&T.blending===sg,alphaMap:ze,alphaTest:ve,alphaHash:He,combine:T.combine,mapUv:we&&y(T.map.channel),aoMapUv:Qe&&y(T.aoMap.channel),lightMapUv:B&&y(T.lightMap.channel),bumpMapUv:te&&y(T.bumpMap.channel),normalMapUv:Y&&y(T.normalMap.channel),displacementMapUv:H&&y(T.displacementMap.channel),emissiveMapUv:F&&y(T.emissiveMap.channel),metalnessMapUv:de&&y(T.metalnessMap.channel),roughnessMapUv:Ae&&y(T.roughnessMap.channel),anisotropyMapUv:xe&&y(T.anisotropyMap.channel),clearcoatMapUv:_e&&y(T.clearcoatMap.channel),clearcoatNormalMapUv:ae&&y(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&y(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Pe&&y(T.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&y(T.iridescenceThicknessMap.channel),sheenColorMapUv:Je&&y(T.sheenColorMap.channel),sheenRoughnessMapUv:Ze&&y(T.sheenRoughnessMap.channel),specularMapUv:oe&&y(T.specularMap.channel),specularColorMapUv:ye&&y(T.specularColorMap.channel),specularIntensityMapUv:Ce&&y(T.specularIntensityMap.channel),transmissionMapUv:$e&&y(T.transmissionMap.channel),thicknessMapUv:lt&&y(T.thicknessMap.channel),alphaMapUv:ze&&y(T.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(Y||Le),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Ne,vertexUv2s:Be,vertexUv3s:at,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(we||ze),fog:!!j,useFog:T.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:T.flatShading===!0,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Rt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&T.map.isVideoTexture===!0&&hr.getTransfer(T.map.colorSpace)===Cr,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Kc,flipSided:T.side===ys,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionDerivatives:Oe&&T.extensions.derivatives===!0,extensionFragDepth:Oe&&T.extensions.fragDepth===!0,extensionDrawBuffers:Oe&&T.extensions.drawBuffers===!0,extensionShaderTextureLOD:Oe&&T.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:T.customProgramCacheKey()}}function v(T){const R=[];if(T.shaderID?R.push(T.shaderID):(R.push(T.customVertexShaderID),R.push(T.customFragmentShaderID)),T.defines!==void 0)for(const U in T.defines)R.push(U),R.push(T.defines[U]);return T.isRawShaderMaterial===!1&&(S(R,T),M(R,T),R.push(t.outputColorSpace)),R.push(T.customProgramCacheKey),R.join()}function S(T,R){T.push(R.precision),T.push(R.outputColorSpace),T.push(R.envMapMode),T.push(R.envMapCubeUVHeight),T.push(R.mapUv),T.push(R.alphaMapUv),T.push(R.lightMapUv),T.push(R.aoMapUv),T.push(R.bumpMapUv),T.push(R.normalMapUv),T.push(R.displacementMapUv),T.push(R.emissiveMapUv),T.push(R.metalnessMapUv),T.push(R.roughnessMapUv),T.push(R.anisotropyMapUv),T.push(R.clearcoatMapUv),T.push(R.clearcoatNormalMapUv),T.push(R.clearcoatRoughnessMapUv),T.push(R.iridescenceMapUv),T.push(R.iridescenceThicknessMapUv),T.push(R.sheenColorMapUv),T.push(R.sheenRoughnessMapUv),T.push(R.specularMapUv),T.push(R.specularColorMapUv),T.push(R.specularIntensityMapUv),T.push(R.transmissionMapUv),T.push(R.thicknessMapUv),T.push(R.combine),T.push(R.fogExp2),T.push(R.sizeAttenuation),T.push(R.morphTargetsCount),T.push(R.morphAttributeCount),T.push(R.numDirLights),T.push(R.numPointLights),T.push(R.numSpotLights),T.push(R.numSpotLightMaps),T.push(R.numHemiLights),T.push(R.numRectAreaLights),T.push(R.numDirLightShadows),T.push(R.numPointLightShadows),T.push(R.numSpotLightShadows),T.push(R.numSpotLightShadowsWithMaps),T.push(R.numLightProbes),T.push(R.shadowMapType),T.push(R.toneMapping),T.push(R.numClippingPlanes),T.push(R.numClipIntersection),T.push(R.depthPacking)}function M(T,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),T.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),T.push(l.mask)}function N(T){const R=b[T.type];let U;if(R){const O=fs[R];U=gL.clone(O.uniforms)}else U=T.uniforms;return U}function A(T,R){let U;for(let O=0,q=u.length;O<q;O++){const j=u[O];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new T8e(t,R,T,a),u.push(U)),U}function k(T){if(--T.usedTimes===0){const R=u.indexOf(T);u[R]=u[u.length-1],u.pop(),T.destroy()}}function C(T){c.remove(T)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:N,acquireProgram:A,releaseProgram:k,releaseShaderCache:C,programs:u,dispose:D}}function R8e(){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 D8e(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 $7(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 H7(){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,m,p,b,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||D8e),r.length>1&&r.sort(m||$7),i.length>1&&i.sort(m||$7)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function O8e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new H7,t.set(r,[o])):i>=a.length?(o=new H7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function L8e(){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 Fe,color:new en};break;case"SpotLight":n={position:new Fe,direction:new Fe,color:new en,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Fe,color:new en,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Fe,skyColor:new en,groundColor:new en};break;case"RectAreaLight":n={color:new en,position:new Fe,halfWidth:new Fe,halfHeight:new Fe};break}return t[e.id]=n,n}}}function I8e(){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 pn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let F8e=0;function U8e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function z8e(t,e){const n=new L8e,r=I8e(),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 Fe);const a=new Fe,o=new Er,l=new Er;function c(d,f){let m=0,p=0,b=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,x=0,v=0,S=0,M=0,N=0,A=0,k=0,C=0,D=0,T=0;d.sort(U8e);const R=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const j=d[O],W=j.color,K=j.intensity,G=j.distance,J=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=W.r*K*R,p+=W.g*K*R,b+=W.b*K*R;else if(j.isLightProbe){for(let ie=0;ie<9;ie++)i.probe[ie].addScaledVector(j.sh.coefficients[ie],K);T++}else if(j.isDirectionalLight){const ie=n.get(j);if(ie.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const re=j.shadow,z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,i.directionalShadow[y]=z,i.directionalShadowMap[y]=J,i.directionalShadowMatrix[y]=j.shadow.matrix,N++}i.directional[y]=ie,y++}else if(j.isSpotLight){const ie=n.get(j);ie.position.setFromMatrixPosition(j.matrixWorld),ie.color.copy(W).multiplyScalar(K*R),ie.distance=G,ie.coneCos=Math.cos(j.angle),ie.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),ie.decay=j.decay,i.spot[v]=ie;const re=j.shadow;if(j.map&&(i.spotLightMap[C]=j.map,C++,re.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=re.matrix,j.castShadow){const z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,i.spotShadow[v]=z,i.spotShadowMap[v]=J,k++}v++}else if(j.isRectAreaLight){const ie=n.get(j);ie.color.copy(W).multiplyScalar(K),ie.halfWidth.set(j.width*.5,0,0),ie.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=ie,S++}else if(j.isPointLight){const ie=n.get(j);if(ie.color.copy(j.color).multiplyScalar(j.intensity*R),ie.distance=j.distance,ie.decay=j.decay,j.castShadow){const re=j.shadow,z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,z.shadowCameraNear=re.camera.near,z.shadowCameraFar=re.camera.far,i.pointShadow[x]=z,i.pointShadowMap[x]=J,i.pointShadowMatrix[x]=j.shadow.matrix,A++}i.point[x]=ie,x++}else if(j.isHemisphereLight){const ie=n.get(j);ie.skyColor.copy(j.color).multiplyScalar(K*R),ie.groundColor.copy(j.groundColor).multiplyScalar(K*R),i.hemi[M]=ie,M++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=p,i.ambient[2]=b;const U=i.hash;(U.directionalLength!==y||U.pointLength!==x||U.spotLength!==v||U.rectAreaLength!==S||U.hemiLength!==M||U.numDirectionalShadows!==N||U.numPointShadows!==A||U.numSpotShadows!==k||U.numSpotMaps!==C||U.numLightProbes!==T)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=S,i.point.length=x,i.hemi.length=M,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=N,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=k+C-D,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=T,U.directionalLength=y,U.pointLength=x,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=M,U.numDirectionalShadows=N,U.numPointShadows=A,U.numSpotShadows=k,U.numSpotMaps=C,U.numLightProbes=T,i.version=F8e++)}function u(d,f){let m=0,p=0,b=0,y=0,x=0;const v=f.matrixWorldInverse;for(let S=0,M=d.length;S<M;S++){const N=d[S];if(N.isDirectionalLight){const A=i.directional[m];A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),m++}else if(N.isSpotLight){const A=i.spot[b];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),b++}else if(N.isRectAreaLight){const A=i.rectArea[y];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),l.identity(),o.copy(N.matrixWorld),o.premultiply(v),l.extractRotation(o),A.halfWidth.set(N.width*.5,0,0),A.halfHeight.set(0,N.height*.5,0),A.halfWidth.applyMatrix4(l),A.halfHeight.applyMatrix4(l),y++}else if(N.isPointLight){const A=i.point[p];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),p++}else if(N.isHemisphereLight){const A=i.hemi[x];A.direction.setFromMatrixPosition(N.matrixWorld),A.direction.transformDirection(v),x++}}}return{setup:c,setupView:u,state:i}}function V7(t,e){const n=new z8e(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 B8e(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new V7(t,e),n.set(a,[c])):o>=l.length?(c=new V7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class $8e extends ux{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=AFe,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 H8e extends ux{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 V8e=`void main() {
  7497. gl_Position = vec4( position, 1.0 );
  7498. }`,G8e=`uniform sampler2D shadow_pass;
  7499. uniform vec2 resolution;
  7500. uniform float radius;
  7501. #include <packing>
  7502. void main() {
  7503. const float samples = float( VSM_SAMPLES );
  7504. float mean = 0.0;
  7505. float squared_mean = 0.0;
  7506. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7507. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7508. for ( float i = 0.0; i < samples; i ++ ) {
  7509. float uvOffset = uvStart + i * uvStride;
  7510. #ifdef HORIZONTAL_PASS
  7511. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7512. mean += distribution.x;
  7513. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7514. #else
  7515. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7516. mean += depth;
  7517. squared_mean += depth * depth;
  7518. #endif
  7519. }
  7520. mean = mean / samples;
  7521. squared_mean = squared_mean / samples;
  7522. float std_dev = sqrt( squared_mean - mean * mean );
  7523. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7524. }`;function W8e(t,e,n){let r=new mN;const i=new pn,a=new pn,o=new mr,l=new $8e({depthPacking:TFe}),c=new H8e,u={},d=n.maxTextureSize,f={[eh]:ys,[ys]:eh,[Kc]:Kc},m=new th({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pn},radius:{value:4}},vertexShader:V8e,fragmentShader:G8e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new Ua;b.setAttribute("position",new Ws(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new el(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oee;let v=this.type;this.render=function(A,k,C){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||A.length===0)return;const D=t.getRenderTarget(),T=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),U=t.state;U.setBlending(zd),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const O=v!==$c&&this.type===$c,q=v===$c&&this.type!==$c;for(let j=0,W=A.length;j<W;j++){const K=A[j],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const J=G.getFrameExtents();if(i.multiply(J),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const re=this.type!==$c?{minFilter:pa,magFilter:pa}:{};G.map!==null&&G.map.dispose(),G.map=new Jf(i.x,i.y,re),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const ie=G.getViewportCount();for(let re=0;re<ie;re++){const z=G.getViewport(re);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),U.viewport(o),G.updateMatrices(K,re),r=G.getFrustum(),N(k,C,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===$c&&S(G,C),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(D,T,R)};function S(A,k){const C=e.update(y);m.defines.VSM_SAMPLES!==A.blurSamples&&(m.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Jf(i.x,i.y)),m.uniforms.shadow_pass.value=A.map.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(k,null,C,m,y,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(k,null,C,p,y,null)}function M(A,k,C,D){let T=null;const R=C.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)T=R;else if(T=C.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const U=T.uuid,O=k.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let j=q[O];j===void 0&&(j=T.clone(),q[O]=j),T=j}if(T.visible=k.visible,T.wireframe=k.wireframe,D===$c?T.side=k.shadowSide!==null?k.shadowSide:k.side:T.side=k.shadowSide!==null?k.shadowSide:f[k.side],T.alphaMap=k.alphaMap,T.alphaTest=k.alphaTest,T.map=k.map,T.clipShadows=k.clipShadows,T.clippingPlanes=k.clippingPlanes,T.clipIntersection=k.clipIntersection,T.displacementMap=k.displacementMap,T.displacementScale=k.displacementScale,T.displacementBias=k.displacementBias,T.wireframeLinewidth=k.wireframeLinewidth,T.linewidth=k.linewidth,C.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const U=t.properties.get(T);U.light=C}return T}function N(A,k,C,D,T){if(A.visible===!1)return;if(A.layers.test(k.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&T===$c)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,A.matrixWorld);const O=e.update(A),q=A.material;if(Array.isArray(q)){const j=O.groups;for(let W=0,K=j.length;W<K;W++){const G=j[W],J=q[G.materialIndex];if(J&&J.visible){const ie=M(A,J,D,T);A.onBeforeShadow(t,A,k,C,O,ie,G),t.renderBufferDirect(C,null,O,ie,A,G),A.onAfterShadow(t,A,k,C,O,ie,G)}}}else if(q.visible){const j=M(A,q,D,T);A.onBeforeShadow(t,A,k,C,O,j,null),t.renderBufferDirect(C,null,O,j,A,null),A.onAfterShadow(t,A,k,C,O,j,null)}}const U=A.children;for(let O=0,q=U.length;O<q;O++)N(U[O],k,C,D,T)}}function q8e(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const He=new mr;let Oe=null;const Ne=new mr(0,0,0,0);return{setMask:function(Be){Oe!==Be&&!ve&&(t.colorMask(Be,Be,Be,Be),Oe=Be)},setLocked:function(Be){ve=Be},setClear:function(Be,at,Rt,Tt,nn){nn===!0&&(Be*=Tt,at*=Tt,Rt*=Tt),He.set(Be,at,Rt,Tt),Ne.equals(He)===!1&&(t.clearColor(Be,at,Rt,Tt),Ne.copy(He))},reset:function(){ve=!1,Oe=null,Ne.set(-1,0,0,0)}}}function a(){let ve=!1,He=null,Oe=null,Ne=null;return{setTest:function(Be){Be?me(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function(Be){He!==Be&&!ve&&(t.depthMask(Be),He=Be)},setFunc:function(Be){if(Oe!==Be){switch(Be){case iFe:t.depthFunc(t.NEVER);break;case aFe:t.depthFunc(t.ALWAYS);break;case sFe:t.depthFunc(t.LESS);break;case HS:t.depthFunc(t.LEQUAL);break;case oFe:t.depthFunc(t.EQUAL);break;case lFe:t.depthFunc(t.GEQUAL);break;case cFe:t.depthFunc(t.GREATER);break;case uFe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=Be}},setLocked:function(Be){ve=Be},setClear:function(Be){Ne!==Be&&(t.clearDepth(Be),Ne=Be)},reset:function(){ve=!1,He=null,Oe=null,Ne=null}}}function o(){let ve=!1,He=null,Oe=null,Ne=null,Be=null,at=null,Rt=null,Tt=null,nn=null;return{setTest:function(Lt){ve||(Lt?me(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(Lt){He!==Lt&&!ve&&(t.stencilMask(Lt),He=Lt)},setFunc:function(Lt,ln,ft){(Oe!==Lt||Ne!==ln||Be!==ft)&&(t.stencilFunc(Lt,ln,ft),Oe=Lt,Ne=ln,Be=ft)},setOp:function(Lt,ln,ft){(at!==Lt||Rt!==ln||Tt!==ft)&&(t.stencilOp(Lt,ln,ft),at=Lt,Rt=ln,Tt=ft)},setLocked:function(Lt){ve=Lt},setClear:function(Lt){nn!==Lt&&(t.clearStencil(Lt),nn=Lt)},reset:function(){ve=!1,He=null,Oe=null,Ne=null,Be=null,at=null,Rt=null,Tt=null,nn=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let m={},p={},b=new WeakMap,y=[],x=null,v=!1,S=null,M=null,N=null,A=null,k=null,C=null,D=null,T=new en(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ie=0;const re=t.getParameter(t.VERSION);re.indexOf("WebGL")!==-1?(ie=parseFloat(/^WebGL (\d)/.exec(re)[1]),J=ie>=1):re.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(re)[1]),J=ie>=2);let z=null,V={};const Z=t.getParameter(t.SCISSOR_BOX),ne=t.getParameter(t.VIEWPORT),he=new mr().fromArray(Z),fe=new mr().fromArray(ne);function le(ve,He,Oe,Ne){const Be=new Uint8Array(4),at=t.createTexture();t.bindTexture(ve,at),t.texParameteri(ve,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ve,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Rt=0;Rt<Oe;Rt++)r&&(ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY)?t.texImage3D(He,0,t.RGBA,1,1,Ne,0,t.RGBA,t.UNSIGNED_BYTE,Be):t.texImage2D(He+Rt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Be);return at}const Ee={};Ee[t.TEXTURE_2D]=le(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=le(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=le(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=le(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),me(t.DEPTH_TEST),c.setFunc(HS),F(!1),de(NG),me(t.CULL_FACE),Y(zd);function me(ve){m[ve]!==!0&&(t.enable(ve),m[ve]=!0)}function we(ve){m[ve]!==!1&&(t.disable(ve),m[ve]=!1)}function De(ve,He){return p[ve]!==He?(t.bindFramebuffer(ve,He),p[ve]=He,r&&(ve===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=He),ve===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=He)),!0):!1}function ee(ve,He){let Oe=y,Ne=!1;if(ve)if(Oe=b.get(He),Oe===void 0&&(Oe=[],b.set(He,Oe)),ve.isWebGLMultipleRenderTargets){const Be=ve.texture;if(Oe.length!==Be.length||Oe[0]!==t.COLOR_ATTACHMENT0){for(let at=0,Rt=Be.length;at<Rt;at++)Oe[at]=t.COLOR_ATTACHMENT0+at;Oe.length=Be.length,Ne=!0}}else Oe[0]!==t.COLOR_ATTACHMENT0&&(Oe[0]=t.COLOR_ATTACHMENT0,Ne=!0);else Oe[0]!==t.BACK&&(Oe[0]=t.BACK,Ne=!0);Ne&&(n.isWebGL2?t.drawBuffers(Oe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Oe))}function Qe(ve){return x!==ve?(t.useProgram(ve),x=ve,!0):!1}const B={[ef]:t.FUNC_ADD,[HIe]:t.FUNC_SUBTRACT,[VIe]:t.FUNC_REVERSE_SUBTRACT};if(r)B[kG]=t.MIN,B[jG]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(B[kG]=ve.MIN_EXT,B[jG]=ve.MAX_EXT)}const te={[GIe]:t.ZERO,[WIe]:t.ONE,[qIe]:t.SRC_COLOR,[yR]:t.SRC_ALPHA,[JIe]:t.SRC_ALPHA_SATURATE,[ZIe]:t.DST_COLOR,[XIe]:t.DST_ALPHA,[KIe]:t.ONE_MINUS_SRC_COLOR,[vR]:t.ONE_MINUS_SRC_ALPHA,[QIe]:t.ONE_MINUS_DST_COLOR,[YIe]:t.ONE_MINUS_DST_ALPHA,[eFe]:t.CONSTANT_COLOR,[tFe]:t.ONE_MINUS_CONSTANT_COLOR,[nFe]:t.CONSTANT_ALPHA,[rFe]:t.ONE_MINUS_CONSTANT_ALPHA};function Y(ve,He,Oe,Ne,Be,at,Rt,Tt,nn,Lt){if(ve===zd){v===!0&&(we(t.BLEND),v=!1);return}if(v===!1&&(me(t.BLEND),v=!0),ve!==$Ie){if(ve!==S||Lt!==U){if((M!==ef||k!==ef)&&(t.blendEquation(t.FUNC_ADD),M=ef,k=ef),Lt)switch(ve){case sg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case AG:t.blendFunc(t.ONE,t.ONE);break;case TG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case CG: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 sg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case AG:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case TG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case CG:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}N=null,A=null,C=null,D=null,T.set(0,0,0),R=0,S=ve,U=Lt}return}Be=Be||He,at=at||Oe,Rt=Rt||Ne,(He!==M||Be!==k)&&(t.blendEquationSeparate(B[He],B[Be]),M=He,k=Be),(Oe!==N||Ne!==A||at!==C||Rt!==D)&&(t.blendFuncSeparate(te[Oe],te[Ne],te[at],te[Rt]),N=Oe,A=Ne,C=at,D=Rt),(Tt.equals(T)===!1||nn!==R)&&(t.blendColor(Tt.r,Tt.g,Tt.b,nn),T.copy(Tt),R=nn),S=ve,U=!1}function H(ve,He){ve.side===Kc?we(t.CULL_FACE):me(t.CULL_FACE);let Oe=ve.side===ys;He&&(Oe=!Oe),F(Oe),ve.blending===sg&&ve.transparent===!1?Y(zd):Y(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)),Le(ve.polygonOffset,ve.polygonOffsetFactor,ve.polygonOffsetUnits),ve.alphaToCoverage===!0?me(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function F(ve){O!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),O=ve)}function de(ve){ve!==UIe?(me(t.CULL_FACE),ve!==q&&(ve===NG?t.cullFace(t.BACK):ve===zIe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),q=ve}function Ae(ve){ve!==j&&(J&&t.lineWidth(ve),j=ve)}function Le(ve,He,Oe){ve?(me(t.POLYGON_OFFSET_FILL),(W!==He||K!==Oe)&&(t.polygonOffset(He,Oe),W=He,K=Oe)):we(t.POLYGON_OFFSET_FILL)}function Se(ve){ve?me(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function $(ve){ve===void 0&&(ve=t.TEXTURE0+G-1),z!==ve&&(t.activeTexture(ve),z=ve)}function L(ve,He,Oe){Oe===void 0&&(z===null?Oe=t.TEXTURE0+G-1:Oe=z);let Ne=V[Oe];Ne===void 0&&(Ne={type:void 0,texture:void 0},V[Oe]=Ne),(Ne.type!==ve||Ne.texture!==He)&&(z!==Oe&&(t.activeTexture(Oe),z=Oe),t.bindTexture(ve,He||Ee[ve]),Ne.type=ve,Ne.texture=He)}function X(){const ve=V[z];ve!==void 0&&ve.type!==void 0&&(t.bindTexture(ve.type,null),ve.type=void 0,ve.texture=void 0)}function xe(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ae(){try{t.texSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Te(){try{t.texSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Pe(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Xe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Je(){try{t.texStorage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ze(){try{t.texStorage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ye(){try{t.texImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ce(ve){he.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),he.copy(ve))}function $e(ve){fe.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),fe.copy(ve))}function lt(ve,He){let Oe=f.get(He);Oe===void 0&&(Oe=new WeakMap,f.set(He,Oe));let Ne=Oe.get(ve);Ne===void 0&&(Ne=t.getUniformBlockIndex(He,ve.name),Oe.set(ve,Ne))}function se(ve,He){const Ne=f.get(He).get(ve);d.get(He)!==Ne&&(t.uniformBlockBinding(He,Ne,ve.__bindingPointIndex),d.set(He,Ne))}function ze(){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),m={},z=null,V={},p={},b=new WeakMap,y=[],x=null,v=!1,S=null,M=null,N=null,A=null,k=null,C=null,D=null,T=new en(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,K=null,he.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:me,disable:we,bindFramebuffer:De,drawBuffers:ee,useProgram:Qe,setBlending:Y,setMaterial:H,setFlipSided:F,setCullFace:de,setLineWidth:Ae,setPolygonOffset:Le,setScissorTest:Se,activeTexture:$,bindTexture:L,unbindTexture:X,compressedTexImage2D:xe,compressedTexImage3D:_e,texImage2D:oe,texImage3D:ye,updateUBOMapping:lt,uniformBlockBinding:se,texStorage2D:Je,texStorage3D:Ze,texSubImage2D:ae,texSubImage3D:Te,compressedTexSubImage2D:Pe,compressedTexSubImage3D:Xe,scissor:Ce,viewport:$e,reset:ze}}function K8e(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),b=new WeakMap;let y;const x=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S($,L){return v?new OffscreenCanvas($,L):KS("canvas")}function M($,L,X,xe){let _e=1;if(($.width>xe||$.height>xe)&&(_e=xe/Math.max($.width,$.height)),_e<1||L===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ae=L?qS:Math.floor,Te=ae(_e*$.width),Pe=ae(_e*$.height);y===void 0&&(y=S(Te,Pe));const Xe=X?S(Te,Pe):y;return Xe.width=Te,Xe.height=Pe,Xe.getContext("2d").drawImage($,0,0,Te,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+Te+"x"+Pe+")."),Xe}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function N($){return AR($.width)&&AR($.height)}function A($){return l?!1:$.wrapS!==Zo||$.wrapT!==Zo||$.minFilter!==pa&&$.minFilter!==wo}function k($,L){return $.generateMipmaps&&L&&$.minFilter!==pa&&$.minFilter!==wo}function C($){t.generateMipmap($)}function D($,L,X,xe,_e=!1){if(l===!1)return L;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ae=L;if(L===t.RED&&(X===t.FLOAT&&(ae=t.R32F),X===t.HALF_FLOAT&&(ae=t.R16F),X===t.UNSIGNED_BYTE&&(ae=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ae=t.R8UI),X===t.UNSIGNED_SHORT&&(ae=t.R16UI),X===t.UNSIGNED_INT&&(ae=t.R32UI),X===t.BYTE&&(ae=t.R8I),X===t.SHORT&&(ae=t.R16I),X===t.INT&&(ae=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ae=t.RG32F),X===t.HALF_FLOAT&&(ae=t.RG16F),X===t.UNSIGNED_BYTE&&(ae=t.RG8)),L===t.RGBA){const Te=_e?VS:hr.getTransfer(xe);X===t.FLOAT&&(ae=t.RGBA32F),X===t.HALF_FLOAT&&(ae=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ae=Te===Cr?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function T($,L,X){return k($,X)===!0||$.isFramebufferTexture&&$.minFilter!==pa&&$.minFilter!==wo?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function R($){return $===pa||$===PG||$===Nk?t.NEAREST:t.LINEAR}function U($){const L=$.target;L.removeEventListener("dispose",U),q(L),L.isVideoTexture&&b.delete(L)}function O($){const L=$.target;L.removeEventListener("dispose",O),W(L)}function q($){const L=r.get($);if(L.__webglInit===void 0)return;const X=$.source,xe=x.get(X);if(xe){const _e=xe[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&j($),Object.keys(xe).length===0&&x.delete(X)}r.remove($)}function j($){const L=r.get($);t.deleteTexture(L.__webglTexture);const X=$.source,xe=x.get(X);delete xe[L.__cacheKey],o.memory.textures--}function W($){const L=$.texture,X=r.get($),xe=r.get(L);if(xe.__webglTexture!==void 0&&(t.deleteTexture(xe.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(X.__webglFramebuffer[_e]))for(let ae=0;ae<X.__webglFramebuffer[_e].length;ae++)t.deleteFramebuffer(X.__webglFramebuffer[_e][ae]);else t.deleteFramebuffer(X.__webglFramebuffer[_e]);X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer[_e])}else{if(Array.isArray(X.__webglFramebuffer))for(let _e=0;_e<X.__webglFramebuffer.length;_e++)t.deleteFramebuffer(X.__webglFramebuffer[_e]);else t.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&t.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let _e=0;_e<X.__webglColorRenderbuffer.length;_e++)X.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(X.__webglColorRenderbuffer[_e]);X.__webglDepthRenderbuffer&&t.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let _e=0,ae=L.length;_e<ae;_e++){const Te=r.get(L[_e]);Te.__webglTexture&&(t.deleteTexture(Te.__webglTexture),o.memory.textures--),r.remove(L[_e])}r.remove(L),r.remove($)}let K=0;function G(){K=0}function J(){const $=K;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),K+=1,$}function ie($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function re($,L){const X=r.get($);if($.isVideoTexture&&Le($),$.isRenderTargetTexture===!1&&$.version>0&&X.__version!==$.version){const xe=$.image;if(xe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{me(X,$,L);return}}n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function z($,L){const X=r.get($);if($.version>0&&X.__version!==$.version){me(X,$,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function V($,L){const X=r.get($);if($.version>0&&X.__version!==$.version){me(X,$,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function Z($,L){const X=r.get($);if($.version>0&&X.__version!==$.version){we(X,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const ne={[SR]:t.REPEAT,[Zo]:t.CLAMP_TO_EDGE,[MR]:t.MIRRORED_REPEAT},he={[pa]:t.NEAREST,[PG]:t.NEAREST_MIPMAP_NEAREST,[Nk]:t.NEAREST_MIPMAP_LINEAR,[wo]:t.LINEAR,[bFe]:t.LINEAR_MIPMAP_NEAREST,[Y0]:t.LINEAR_MIPMAP_LINEAR},fe={[kFe]:t.NEVER,[LFe]:t.ALWAYS,[jFe]:t.LESS,[Wee]:t.LEQUAL,[PFe]:t.EQUAL,[OFe]:t.GEQUAL,[RFe]:t.GREATER,[DFe]:t.NOTEQUAL};function le($,L,X){if(X?(t.texParameteri($,t.TEXTURE_WRAP_S,ne[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ne[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ne[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,he[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,he[L.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Zo||L.wrapT!==Zo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,R(L.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,R(L.minFilter)),L.minFilter!==pa&&L.minFilter!==wo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,fe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const xe=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===pa||L.minFilter!==Nk&&L.minFilter!==Y0||L.type===Jc&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===Z0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf($,xe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee($,L){let X=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",U));const xe=L.source;let _e=x.get(xe);_e===void 0&&(_e={},x.set(xe,_e));const ae=ie(L);if(ae!==$.__cacheKey){_e[ae]===void 0&&(_e[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,X=!0),_e[ae].usedTimes++;const Te=_e[$.__cacheKey];Te!==void 0&&(_e[$.__cacheKey].usedTimes--,Te.usedTimes===0&&j(L)),$.__cacheKey=ae,$.__webglTexture=_e[ae].texture}return X}function me($,L,X){let xe=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(xe=t.TEXTURE_3D);const _e=Ee($,L),ae=L.source;n.bindTexture(xe,$.__webglTexture,t.TEXTURE0+X);const Te=r.get(ae);if(ae.version!==Te.__version||_e===!0){n.activeTexture(t.TEXTURE0+X);const Pe=hr.getPrimaries(hr.workingColorSpace),Xe=L.colorSpace===Mo?null:hr.getPrimaries(L.colorSpace),Je=L.colorSpace===Mo||Pe===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Je);const Ze=A(L)&&N(L.image)===!1;let oe=M(L.image,Ze,!1,d);oe=Se(L,oe);const ye=N(oe)||l,Ce=a.convert(L.format,L.colorSpace);let $e=a.convert(L.type),lt=D(L.internalFormat,Ce,$e,L.colorSpace,L.isVideoTexture);le(xe,L,ye);let se;const ze=L.mipmaps,ve=l&&L.isVideoTexture!==!0&&lt!==Hee,He=Te.__version===void 0||_e===!0,Oe=T(L,oe,ye);if(L.isDepthTexture)lt=t.DEPTH_COMPONENT,l?L.type===Jc?lt=t.DEPTH_COMPONENT32F:L.type===Cd?lt=t.DEPTH_COMPONENT24:L.type===Ef?lt=t.DEPTH24_STENCIL8:lt=t.DEPTH_COMPONENT16:L.type===Jc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===Nf&&lt===t.DEPTH_COMPONENT&&L.type!==hL&&L.type!==Cd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Cd,$e=a.convert(L.type)),L.format===Rg&&lt===t.DEPTH_COMPONENT&&(lt=t.DEPTH_STENCIL,L.type!==Ef&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Ef,$e=a.convert(L.type))),He&&(ve?n.texStorage2D(t.TEXTURE_2D,1,lt,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,lt,oe.width,oe.height,0,Ce,$e,null));else if(L.isDataTexture)if(ze.length>0&&ye){ve&&He&&n.texStorage2D(t.TEXTURE_2D,Oe,lt,ze[0].width,ze[0].height);for(let Ne=0,Be=ze.length;Ne<Be;Ne++)se=ze[Ne],ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,se.width,se.height,Ce,$e,se.data):n.texImage2D(t.TEXTURE_2D,Ne,lt,se.width,se.height,0,Ce,$e,se.data);L.generateMipmaps=!1}else ve?(He&&n.texStorage2D(t.TEXTURE_2D,Oe,lt,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,Ce,$e,oe.data)):n.texImage2D(t.TEXTURE_2D,0,lt,oe.width,oe.height,0,Ce,$e,oe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ve&&He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,lt,ze[0].width,ze[0].height,oe.depth);for(let Ne=0,Be=ze.length;Ne<Be;Ne++)se=ze[Ne],L.format!==So?Ce!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ne,0,0,0,se.width,se.height,oe.depth,Ce,se.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ne,lt,se.width,se.height,oe.depth,0,se.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,se.width,se.height,oe.depth,Ce,$e,se.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ne,lt,se.width,se.height,oe.depth,0,Ce,$e,se.data)}else{ve&&He&&n.texStorage2D(t.TEXTURE_2D,Oe,lt,ze[0].width,ze[0].height);for(let Ne=0,Be=ze.length;Ne<Be;Ne++)se=ze[Ne],L.format!==So?Ce!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,Ne,0,0,se.width,se.height,Ce,se.data):n.compressedTexImage2D(t.TEXTURE_2D,Ne,lt,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,se.width,se.height,Ce,$e,se.data):n.texImage2D(t.TEXTURE_2D,Ne,lt,se.width,se.height,0,Ce,$e,se.data)}else if(L.isDataArrayTexture)ve?(He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,lt,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ce,$e,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,lt,oe.width,oe.height,oe.depth,0,Ce,$e,oe.data);else if(L.isData3DTexture)ve?(He&&n.texStorage3D(t.TEXTURE_3D,Oe,lt,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ce,$e,oe.data)):n.texImage3D(t.TEXTURE_3D,0,lt,oe.width,oe.height,oe.depth,0,Ce,$e,oe.data);else if(L.isFramebufferTexture){if(He)if(ve)n.texStorage2D(t.TEXTURE_2D,Oe,lt,oe.width,oe.height);else{let Ne=oe.width,Be=oe.height;for(let at=0;at<Oe;at++)n.texImage2D(t.TEXTURE_2D,at,lt,Ne,Be,0,Ce,$e,null),Ne>>=1,Be>>=1}}else if(ze.length>0&&ye){ve&&He&&n.texStorage2D(t.TEXTURE_2D,Oe,lt,ze[0].width,ze[0].height);for(let Ne=0,Be=ze.length;Ne<Be;Ne++)se=ze[Ne],ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,Ce,$e,se):n.texImage2D(t.TEXTURE_2D,Ne,lt,Ce,$e,se);L.generateMipmaps=!1}else ve?(He&&n.texStorage2D(t.TEXTURE_2D,Oe,lt,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ce,$e,oe)):n.texImage2D(t.TEXTURE_2D,0,lt,Ce,$e,oe);k(L,ye)&&C(xe),Te.__version=ae.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function we($,L,X){if(L.image.length!==6)return;const xe=Ee($,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+X);const ae=r.get(_e);if(_e.version!==ae.__version||xe===!0){n.activeTexture(t.TEXTURE0+X);const Te=hr.getPrimaries(hr.workingColorSpace),Pe=L.colorSpace===Mo?null:hr.getPrimaries(L.colorSpace),Xe=L.colorSpace===Mo||Te===Pe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const Je=L.isCompressedTexture||L.image[0].isCompressedTexture,Ze=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let Ne=0;Ne<6;Ne++)!Je&&!Ze?oe[Ne]=M(L.image[Ne],!1,!0,u):oe[Ne]=Ze?L.image[Ne].image:L.image[Ne],oe[Ne]=Se(L,oe[Ne]);const ye=oe[0],Ce=N(ye)||l,$e=a.convert(L.format,L.colorSpace),lt=a.convert(L.type),se=D(L.internalFormat,$e,lt,L.colorSpace),ze=l&&L.isVideoTexture!==!0,ve=ae.__version===void 0||xe===!0;let He=T(L,ye,Ce);le(t.TEXTURE_CUBE_MAP,L,Ce);let Oe;if(Je){ze&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,se,ye.width,ye.height);for(let Ne=0;Ne<6;Ne++){Oe=oe[Ne].mipmaps;for(let Be=0;Be<Oe.length;Be++){const at=Oe[Be];L.format!==So?$e!==null?ze?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,0,0,at.width,at.height,$e,at.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,se,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,0,0,at.width,at.height,$e,lt,at.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be,se,at.width,at.height,0,$e,lt,at.data)}}}else{Oe=L.mipmaps,ze&&ve&&(Oe.length>0&&He++,n.texStorage2D(t.TEXTURE_CUBE_MAP,He,se,oe[0].width,oe[0].height));for(let Ne=0;Ne<6;Ne++)if(Ze){ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,oe[Ne].width,oe[Ne].height,$e,lt,oe[Ne].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,se,oe[Ne].width,oe[Ne].height,0,$e,lt,oe[Ne].data);for(let Be=0;Be<Oe.length;Be++){const Rt=Oe[Be].image[Ne].image;ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,0,0,Rt.width,Rt.height,$e,lt,Rt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,se,Rt.width,Rt.height,0,$e,lt,Rt.data)}}else{ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,$e,lt,oe[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,se,$e,lt,oe[Ne]);for(let Be=0;Be<Oe.length;Be++){const at=Oe[Be];ze?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,0,0,$e,lt,at.image[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Be+1,se,$e,lt,at.image[Ne])}}}k(L,Ce)&&C(t.TEXTURE_CUBE_MAP),ae.__version=_e.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function De($,L,X,xe,_e,ae){const Te=a.convert(X.format,X.colorSpace),Pe=a.convert(X.type),Xe=D(X.internalFormat,Te,Pe,X.colorSpace);if(!r.get(L).__hasExternalTextures){const Ze=Math.max(1,L.width>>ae),oe=Math.max(1,L.height>>ae);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ae,Xe,Ze,oe,L.depth,0,Te,Pe,null):n.texImage2D(_e,ae,Xe,Ze,oe,0,Te,Pe,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,_e,r.get(X).__webglTexture,0,de(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,_e,r.get(X).__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ee($,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer&&!L.stencilBuffer){let xe=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(X||Ae(L)){const _e=L.depthTexture;_e&&_e.isDepthTexture&&(_e.type===Jc?xe=t.DEPTH_COMPONENT32F:_e.type===Cd&&(xe=t.DEPTH_COMPONENT24));const ae=de(L);Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ae,xe,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ae,xe,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,xe,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(L.depthBuffer&&L.stencilBuffer){const xe=de(L);X&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,L.width,L.height):Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const xe=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let _e=0;_e<xe.length;_e++){const ae=xe[_e],Te=a.convert(ae.format,ae.colorSpace),Pe=a.convert(ae.type),Xe=D(ae.internalFormat,Te,Pe,ae.colorSpace),Je=de(L);X&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,Xe,L.width,L.height):Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Je,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Qe($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),re(L.depthTexture,0);const xe=r.get(L.depthTexture).__webglTexture,_e=de(L);if(L.depthTexture.format===Nf)Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0);else if(L.depthTexture.format===Rg)Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0);else throw new Error("Unknown depthTexture format")}function B($){const L=r.get($),X=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");Qe(L.__webglFramebuffer,$)}else if(X){L.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[xe]),L.__webglDepthbuffer[xe]=t.createRenderbuffer(),ee(L.__webglDepthbuffer[xe],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ee(L.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function te($,L,X){const xe=r.get($);L!==void 0&&De(xe.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&B($)}function Y($){const L=$.texture,X=r.get($),xe=r.get(L);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=L.version,o.memory.textures++);const _e=$.isWebGLCubeRenderTarget===!0,ae=$.isWebGLMultipleRenderTargets===!0,Te=N($)||l;if(_e){X.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Pe]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)X.__webglFramebuffer[Pe][Xe]=t.createFramebuffer()}else X.__webglFramebuffer[Pe]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Pe=0;Pe<L.mipmaps.length;Pe++)X.__webglFramebuffer[Pe]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(ae)if(i.drawBuffers){const Pe=$.texture;for(let Xe=0,Je=Pe.length;Xe<Je;Xe++){const Ze=r.get(Pe[Xe]);Ze.__webglTexture===void 0&&(Ze.__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&&$.samples>0&&Ae($)===!1){const Pe=ae?L:[L];X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let Xe=0;Xe<Pe.length;Xe++){const Je=Pe[Xe];X.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[Xe]);const Ze=a.convert(Je.format,Je.colorSpace),oe=a.convert(Je.type),ye=D(Je.internalFormat,Ze,oe,Je.colorSpace,$.isXRRenderTarget===!0),Ce=de($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ce,ye,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,X.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),ee(X.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),le(t.TEXTURE_CUBE_MAP,L,Te);for(let Pe=0;Pe<6;Pe++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)De(X.__webglFramebuffer[Pe][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Xe);else De(X.__webglFramebuffer[Pe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0);k(L,Te)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){const Pe=$.texture;for(let Xe=0,Je=Pe.length;Xe<Je;Xe++){const Ze=Pe[Xe],oe=r.get(Ze);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),le(t.TEXTURE_2D,Ze,Te),De(X.__webglFramebuffer,$,Ze,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),k(Ze,Te)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Pe=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Pe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Pe,xe.__webglTexture),le(Pe,L,Te),l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)De(X.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,Pe,Xe);else De(X.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Pe,0);k(L,Te)&&C(Pe),n.unbindTexture()}$.depthBuffer&&B($)}function H($){const L=N($)||l,X=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let xe=0,_e=X.length;xe<_e;xe++){const ae=X[xe];if(k(ae,L)){const Te=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Pe=r.get(ae).__webglTexture;n.bindTexture(Te,Pe),C(Te),n.unbindTexture()}}}function F($){if(l&&$.samples>0&&Ae($)===!1){const L=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],X=$.width,xe=$.height;let _e=t.COLOR_BUFFER_BIT;const ae=[],Te=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Pe=r.get($),Xe=$.isWebGLMultipleRenderTargets===!0;if(Xe)for(let Je=0;Je<L.length;Je++)n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Pe.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Pe.__webglFramebuffer);for(let Je=0;Je<L.length;Je++){ae.push(t.COLOR_ATTACHMENT0+Je),$.depthBuffer&&ae.push(Te);const Ze=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Ze===!1&&($.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Pe.__webglColorRenderbuffer[Je]),Ze===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Te]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Te])),Xe){const oe=r.get(L[Je]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,X,xe,0,0,X,xe,_e,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ae)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let Je=0;Je<L.length;Je++){n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.RENDERBUFFER,Pe.__webglColorRenderbuffer[Je]);const Ze=r.get(L[Je]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Je,t.TEXTURE_2D,Ze,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Pe.__webglMultisampledFramebuffer)}}function de($){return Math.min(f,$.samples)}function Ae($){const L=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Le($){const L=o.render.frame;b.get($)!==L&&(b.set($,L),$.update())}function Se($,L){const X=$.colorSpace,xe=$.format,_e=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===NR||X!==vu&&X!==Mo&&(hr.getTransfer(X)===Cr?l===!1?e.has("EXT_sRGB")===!0&&xe===So?($.format=NR,$.minFilter=wo,$.generateMipmaps=!1):L=Xee.sRGBToLinear(L):(xe!==So||_e!==$d)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),L}this.allocateTextureUnit=J,this.resetTextureUnits=G,this.setTexture2D=re,this.setTexture2DArray=z,this.setTexture3D=V,this.setTextureCube=Z,this.rebindTextures=te,this.setupRenderTarget=Y,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=F,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=De,this.useMultisampledRTT=Ae}function X8e(t,e,n){const r=n.isWebGL2;function i(a,o=Mo){let l;const c=hr.getTransfer(o);if(a===$d)return t.UNSIGNED_BYTE;if(a===Fee)return t.UNSIGNED_SHORT_4_4_4_4;if(a===Uee)return t.UNSIGNED_SHORT_5_5_5_1;if(a===yFe)return t.BYTE;if(a===vFe)return t.SHORT;if(a===hL)return t.UNSIGNED_SHORT;if(a===Iee)return t.INT;if(a===Cd)return t.UNSIGNED_INT;if(a===Jc)return t.FLOAT;if(a===Z0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===_Fe)return t.ALPHA;if(a===So)return t.RGBA;if(a===wFe)return t.LUMINANCE;if(a===SFe)return t.LUMINANCE_ALPHA;if(a===Nf)return t.DEPTH_COMPONENT;if(a===Rg)return t.DEPTH_STENCIL;if(a===NR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===MFe)return t.RED;if(a===zee)return t.RED_INTEGER;if(a===EFe)return t.RG;if(a===Bee)return t.RG_INTEGER;if(a===$ee)return t.RGBA_INTEGER;if(a===Ak||a===Tk||a===Ck||a===kk)if(c===Cr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===Ak)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Tk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Ck)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===kk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===Ak)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Tk)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Ck)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===kk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===RG||a===DG||a===OG||a===LG)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===RG)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===DG)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===OG)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===LG)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Hee)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===IG||a===FG)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===IG)return c===Cr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===FG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===UG||a===zG||a===BG||a===$G||a===HG||a===VG||a===GG||a===WG||a===qG||a===KG||a===XG||a===YG||a===ZG||a===QG)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===UG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===zG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===BG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===$G)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===HG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===VG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===GG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===WG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===qG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===KG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===XG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===YG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===ZG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===QG)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===jk||a===JG||a===e7)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===jk)return c===Cr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===JG)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===e7)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===NFe||a===t7||a===n7||a===r7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===jk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===t7)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===n7)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===r7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Ef?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 Y8e extends Is{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Gb extends Za{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z8e={type:"move"};class ej{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gb,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 Gb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Fe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Fe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Fe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Fe),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 y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-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(Z8e)))}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 Gb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class Q8e extends dm{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,m=null,p=null,b=null;const y=n.getContextAttributes();let x=null,v=null;const S=[],M=[],N=new pn;let A=null;const k=new Is;k.layers.enable(1),k.viewport=new mr;const C=new Is;C.layers.enable(2),C.viewport=new mr;const D=[k,C],T=new Y8e;T.layers.enable(1),T.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let ne=S[Z];return ne===void 0&&(ne=new ej,S[Z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(Z){let ne=S[Z];return ne===void 0&&(ne=new ej,S[Z]=ne),ne.getGripSpace()},this.getHand=function(Z){let ne=S[Z];return ne===void 0&&(ne=new ej,S[Z]=ne),ne.getHandSpace()};function O(Z){const ne=M.indexOf(Z.inputSource);if(ne===-1)return;const he=S[ne];he!==void 0&&(he.update(Z.inputSource,Z.frame,u||o),he.dispatchEvent({type:Z.type,data:Z.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let Z=0;Z<S.length;Z++){const ne=M[Z];ne!==null&&(M[Z]=null,S[Z].disconnect(ne))}R=null,U=null,e.setRenderTarget(x),p=null,m=null,f=null,i=null,v=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){a=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){l=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(Z){u=Z},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ne={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ne),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new Jf(p.framebufferWidth,p.framebufferHeight,{format:So,type:$d,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ne=null,he=null,fe=null;y.depth&&(fe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ne=y.stencil?Rg:Nf,he=y.stencil?Ef:Cd);const le={colorFormat:n.RGBA8,depthFormat:fe,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(le),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new Jf(m.textureWidth,m.textureHeight,{format:So,type:$d,depthTexture:new ote(m.textureWidth,m.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ee=e.properties.get(v);Ee.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),V.setContext(i),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(Z){for(let ne=0;ne<Z.removed.length;ne++){const he=Z.removed[ne],fe=M.indexOf(he);fe>=0&&(M[fe]=null,S[fe].disconnect(he))}for(let ne=0;ne<Z.added.length;ne++){const he=Z.added[ne];let fe=M.indexOf(he);if(fe===-1){for(let Ee=0;Ee<S.length;Ee++)if(Ee>=M.length){M.push(he),fe=Ee;break}else if(M[Ee]===null){M[Ee]=he,fe=Ee;break}if(fe===-1)break}const le=S[fe];le&&le.connect(he)}}const W=new Fe,K=new Fe;function G(Z,ne,he){W.setFromMatrixPosition(ne.matrixWorld),K.setFromMatrixPosition(he.matrixWorld);const fe=W.distanceTo(K),le=ne.projectionMatrix.elements,Ee=he.projectionMatrix.elements,me=le[14]/(le[10]-1),we=le[14]/(le[10]+1),De=(le[9]+1)/le[5],ee=(le[9]-1)/le[5],Qe=(le[8]-1)/le[0],B=(Ee[8]+1)/Ee[0],te=me*Qe,Y=me*B,H=fe/(-Qe+B),F=H*-Qe;ne.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(F),Z.translateZ(H),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const de=me+H,Ae=we+H,Le=te-F,Se=Y+(fe-F),$=De*we/Ae*de,L=ee*we/Ae*de;Z.projectionMatrix.makePerspective(Le,Se,$,L,de,Ae),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function J(Z,ne){ne===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(ne.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;T.near=C.near=k.near=Z.near,T.far=C.far=k.far=Z.far,(R!==T.near||U!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),R=T.near,U=T.far);const ne=Z.parent,he=T.cameras;J(T,ne);for(let fe=0;fe<he.length;fe++)J(he[fe],ne);he.length===2?G(T,k,C):T.projectionMatrix.copy(k.projectionMatrix),ie(Z,T,ne)};function ie(Z,ne,he){he===null?Z.matrix.copy(ne.matrixWorld):(Z.matrix.copy(he.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(ne.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(ne.projectionMatrix),Z.projectionMatrixInverse.copy(ne.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=J0*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(Z){c=Z,m!==null&&(m.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)};let re=null;function z(Z,ne){if(d=ne.getViewerPose(u||o),b=ne,d!==null){const he=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let fe=!1;he.length!==T.cameras.length&&(T.cameras.length=0,fe=!0);for(let le=0;le<he.length;le++){const Ee=he[le];let me=null;if(p!==null)me=p.getViewport(Ee);else{const De=f.getViewSubImage(m,Ee);me=De.viewport,le===0&&(e.setRenderTargetTextures(v,De.colorTexture,m.ignoreDepthValues?void 0:De.depthStencilTexture),e.setRenderTarget(v))}let we=D[le];we===void 0&&(we=new Is,we.layers.enable(le),we.viewport=new mr,D[le]=we),we.matrix.fromArray(Ee.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(Ee.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(me.x,me.y,me.width,me.height),le===0&&(T.matrix.copy(we.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),fe===!0&&T.cameras.push(we)}}for(let he=0;he<S.length;he++){const fe=M[he],le=S[he];fe!==null&&le!==void 0&&le.update(fe,ne,u||o)}re&&re(Z,ne),ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ne}),b=null}const V=new ste;V.setAnimationLoop(z),this.setAnimationLoop=function(Z){re=Z},this.dispose=function(){}}}function J8e(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,rte(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,M,N){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(x,v):v.isMeshToonMaterial?(a(x,v),f(x,v)):v.isMeshPhongMaterial?(a(x,v),d(x,v)):v.isMeshStandardMaterial?(a(x,v),m(x,v),v.isMeshPhysicalMaterial&&p(x,v,N)):v.isMeshMatcapMaterial?(a(x,v),b(x,v)):v.isMeshDepthMaterial?a(x,v):v.isMeshDistanceMaterial?(a(x,v),y(x,v)):v.isMeshNormalMaterial?a(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,M):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===ys&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===ys&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(x.envMap.value=S,x.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap){x.lightMap.value=v.lightMap;const M=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=v.lightMapIntensity*M,n(v.lightMap,x.lightMapTransform)}v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),e.get(v).envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ys&&x.clearcoatNormalScale.value.negate())),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function e6e(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,M){const N=M.program;r.uniformBlockBinding(S,N)}function u(S,M){let N=i[S.id];N===void 0&&(b(S),N=d(S),i[S.id]=N,S.addEventListener("dispose",x));const A=M.program;r.updateUBOMapping(S,A);const k=e.render.frame;a[S.id]!==k&&(m(S),a[S.id]=k)}function d(S){const M=f();S.__bindingPointIndex=M;const N=t.createBuffer(),A=S.__size,k=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,M,N),N}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(S){const M=i[S.id],N=S.uniforms,A=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,M);for(let k=0,C=N.length;k<C;k++){const D=N[k];if(p(D,k,A)===!0){const T=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let U=0;for(let O=0;O<R.length;O++){const q=R[O],j=y(q);typeof q=="number"?(D.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,T+U,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=q.elements[0],D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=q.elements[0],D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=q.elements[0]):(q.toArray(D.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,T,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,N){const A=S.value;if(N[M]===void 0){if(typeof A=="number")N[M]=A;else{const k=Array.isArray(A)?A:[A],C=[];for(let D=0;D<k.length;D++)C.push(k[D].clone());N[M]=C}return!0}else if(typeof A=="number"){if(N[M]!==A)return N[M]=A,!0}else{const k=Array.isArray(N[M])?N[M]:[N[M]],C=Array.isArray(A)?A:[A];for(let D=0;D<k.length;D++){const T=k[D];if(T.equals(C[D])===!1)return T.copy(C[D]),!0}}return!1}function b(S){const M=S.uniforms;let N=0;const A=16;let k=0;for(let C=0,D=M.length;C<D;C++){const T=M[C],R={boundary:0,storage:0},U=Array.isArray(T.value)?T.value:[T.value];for(let O=0,q=U.length;O<q;O++){const j=U[O],W=y(j);R.boundary+=W.boundary,R.storage+=W.storage}if(T.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=N,C>0){k=N%A;const O=A-k;k!==0&&O-R.boundary<0&&(N+=A-k,T.__offset=N)}N+=R.storage}return k=N%A,k>0&&(N+=A-k),S.__size=N,S.__cache={},this}function y(S){const M={boundary:0,storage:0};return typeof S=="number"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),M}function x(S){const M=S.target;M.removeEventListener("dispose",x);const N=o.indexOf(M.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[M.id]),delete i[M.id],delete a[M.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class CR{constructor(e={}){const{canvas:n=ZFe(),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 m;r!==null?m=r.getContextAttributes().alpha:m=o;const p=new Uint32Array(4),b=new Int32Array(4);let y=null,x=null;const v=[],S=[];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=ga,this._useLegacyLights=!1,this.toneMapping=Bd,this.toneMappingExposure=1;const M=this;let N=!1,A=0,k=0,C=null,D=-1,T=null;const R=new mr,U=new mr;let O=null;const q=new en(0);let j=0,W=n.width,K=n.height,G=1,J=null,ie=null;const re=new mr(0,0,W,K),z=new mr(0,0,W,K);let V=!1;const Z=new mN;let ne=!1,he=!1,fe=null;const le=new Er,Ee=new pn,me=new Fe,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function De(){return C===null?G:1}let ee=r;function Qe(ce,Ue){for(let We=0;We<ce.length;We++){const rt=ce[We],et=n.getContext(rt,Ue);if(et!==null)return et}return null}try{const ce={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${dN}`),n.addEventListener("webglcontextlost",ze,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",He,!1),ee===null){const Ue=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Ue.shift(),ee=Qe(Ue,ce),ee===null)throw Qe(Ue)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ee instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ee.getShaderPrecisionFormat===void 0&&(ee.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let B,te,Y,H,F,de,Ae,Le,Se,$,L,X,xe,_e,ae,Te,Pe,Xe,Je,Ze,oe,ye,Ce,$e;function lt(){B=new dBe(ee),te=new iBe(ee,B,e),B.init(te),ye=new X8e(ee,B,te),Y=new q8e(ee,B,te),H=new mBe(ee),F=new R8e,de=new K8e(ee,B,Y,F,te,ye,H),Ae=new sBe(M),Le=new uBe(M),Se=new _5e(ee,te),Ce=new nBe(ee,B,Se,te),$=new hBe(ee,Se,H,Ce),L=new bBe(ee,$,Se,H),Je=new xBe(ee,te,de),Te=new aBe(F),X=new P8e(M,Ae,Le,B,te,Ce,Te),xe=new J8e(M,F),_e=new O8e,ae=new B8e(B,te),Xe=new tBe(M,Ae,Le,Y,L,m,c),Pe=new W8e(M,L,te),$e=new e6e(ee,H,te,Y),Ze=new rBe(ee,B,H,te),oe=new fBe(ee,B,H,te),H.programs=X.programs,M.capabilities=te,M.extensions=B,M.properties=F,M.renderLists=_e,M.shadowMap=Pe,M.state=Y,M.info=H}lt();const se=new Q8e(M,ee);this.xr=se,this.getContext=function(){return ee},this.getContextAttributes=function(){return ee.getContextAttributes()},this.forceContextLoss=function(){const ce=B.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=B.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(ce){ce!==void 0&&(G=ce,this.setSize(W,K,!1))},this.getSize=function(ce){return ce.set(W,K)},this.setSize=function(ce,Ue,We=!0){if(se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=ce,K=Ue,n.width=Math.floor(ce*G),n.height=Math.floor(Ue*G),We===!0&&(n.style.width=ce+"px",n.style.height=Ue+"px"),this.setViewport(0,0,ce,Ue)},this.getDrawingBufferSize=function(ce){return ce.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(ce,Ue,We){W=ce,K=Ue,G=We,n.width=Math.floor(ce*We),n.height=Math.floor(Ue*We),this.setViewport(0,0,ce,Ue)},this.getCurrentViewport=function(ce){return ce.copy(R)},this.getViewport=function(ce){return ce.copy(re)},this.setViewport=function(ce,Ue,We,rt){ce.isVector4?re.set(ce.x,ce.y,ce.z,ce.w):re.set(ce,Ue,We,rt),Y.viewport(R.copy(re).multiplyScalar(G).floor())},this.getScissor=function(ce){return ce.copy(z)},this.setScissor=function(ce,Ue,We,rt){ce.isVector4?z.set(ce.x,ce.y,ce.z,ce.w):z.set(ce,Ue,We,rt),Y.scissor(U.copy(z).multiplyScalar(G).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(ce){Y.setScissorTest(V=ce)},this.setOpaqueSort=function(ce){J=ce},this.setTransparentSort=function(ce){ie=ce},this.getClearColor=function(ce){return ce.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor.apply(Xe,arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha.apply(Xe,arguments)},this.clear=function(ce=!0,Ue=!0,We=!0){let rt=0;if(ce){let et=!1;if(C!==null){const Ct=C.texture.format;et=Ct===$ee||Ct===Bee||Ct===zee}if(et){const Ct=C.texture.type,yt=Ct===$d||Ct===Cd||Ct===hL||Ct===Ef||Ct===Fee||Ct===Uee,Mt=Xe.getClearColor(),Vt=Xe.getClearAlpha(),ue=Mt.r,je=Mt.g,Ge=Mt.b;yt?(p[0]=ue,p[1]=je,p[2]=Ge,p[3]=Vt,ee.clearBufferuiv(ee.COLOR,0,p)):(b[0]=ue,b[1]=je,b[2]=Ge,b[3]=Vt,ee.clearBufferiv(ee.COLOR,0,b))}else rt|=ee.COLOR_BUFFER_BIT}Ue&&(rt|=ee.DEPTH_BUFFER_BIT),We&&(rt|=ee.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ee.clear(rt)},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",ze,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",He,!1),_e.dispose(),ae.dispose(),F.dispose(),Ae.dispose(),Le.dispose(),L.dispose(),Ce.dispose(),$e.dispose(),X.dispose(),se.dispose(),se.removeEventListener("sessionstart",nn),se.removeEventListener("sessionend",Lt),fe&&(fe.dispose(),fe=null),ln.stop()};function ze(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const ce=H.autoReset,Ue=Pe.enabled,We=Pe.autoUpdate,rt=Pe.needsUpdate,et=Pe.type;lt(),H.autoReset=ce,Pe.enabled=Ue,Pe.autoUpdate=We,Pe.needsUpdate=rt,Pe.type=et}function He(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function Oe(ce){const Ue=ce.target;Ue.removeEventListener("dispose",Oe),Ne(Ue)}function Ne(ce){Be(ce),F.remove(ce)}function Be(ce){const Ue=F.get(ce).programs;Ue!==void 0&&(Ue.forEach(function(We){X.releaseProgram(We)}),ce.isShaderMaterial&&X.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,Ue,We,rt,et,Ct){Ue===null&&(Ue=we);const yt=et.isMesh&&et.matrixWorld.determinant()<0,Mt=vt(ce,Ue,We,rt,et);Y.setMaterial(rt,yt);let Vt=We.index,ue=1;if(rt.wireframe===!0){if(Vt=$.getWireframeAttribute(We),Vt===void 0)return;ue=2}const je=We.drawRange,Ge=We.attributes.position;let qe=je.start*ue,Ve=(je.start+je.count)*ue;Ct!==null&&(qe=Math.max(qe,Ct.start*ue),Ve=Math.min(Ve,(Ct.start+Ct.count)*ue)),Vt!==null?(qe=Math.max(qe,0),Ve=Math.min(Ve,Vt.count)):Ge!=null&&(qe=Math.max(qe,0),Ve=Math.min(Ve,Ge.count));const xt=Ve-qe;if(xt<0||xt===1/0)return;Ce.setup(et,rt,Mt,We,Vt);let Pt,_t=Ze;if(Vt!==null&&(Pt=Se.get(Vt),_t=oe,_t.setIndex(Pt)),et.isMesh)rt.wireframe===!0?(Y.setLineWidth(rt.wireframeLinewidth*De()),_t.setMode(ee.LINES)):_t.setMode(ee.TRIANGLES);else if(et.isLine){let pt=rt.linewidth;pt===void 0&&(pt=1),Y.setLineWidth(pt*De()),et.isLineSegments?_t.setMode(ee.LINES):et.isLineLoop?_t.setMode(ee.LINE_LOOP):_t.setMode(ee.LINE_STRIP)}else et.isPoints?_t.setMode(ee.POINTS):et.isSprite&&_t.setMode(ee.TRIANGLES);if(et.isBatchedMesh)_t.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)_t.renderInstances(qe,xt,et.count);else if(We.isInstancedBufferGeometry){const pt=We._maxInstanceCount!==void 0?We._maxInstanceCount:1/0,St=Math.min(We.instanceCount,pt);_t.renderInstances(qe,xt,St)}else _t.render(qe,xt)};function at(ce,Ue,We){ce.transparent===!0&&ce.side===Kc&&ce.forceSinglePass===!1?(ce.side=ys,ce.needsUpdate=!0,Nr(ce,Ue,We),ce.side=eh,ce.needsUpdate=!0,Nr(ce,Ue,We),ce.side=Kc):Nr(ce,Ue,We)}this.compile=function(ce,Ue,We=null){We===null&&(We=ce),x=ae.get(We),x.init(),S.push(x),We.traverseVisible(function(et){et.isLight&&et.layers.test(Ue.layers)&&(x.pushLight(et),et.castShadow&&x.pushShadow(et))}),ce!==We&&ce.traverseVisible(function(et){et.isLight&&et.layers.test(Ue.layers)&&(x.pushLight(et),et.castShadow&&x.pushShadow(et))}),x.setupLights(M._useLegacyLights);const rt=new Set;return ce.traverse(function(et){const Ct=et.material;if(Ct)if(Array.isArray(Ct))for(let yt=0;yt<Ct.length;yt++){const Mt=Ct[yt];at(Mt,We,et),rt.add(Mt)}else at(Ct,We,et),rt.add(Ct)}),S.pop(),x=null,rt},this.compileAsync=function(ce,Ue,We=null){const rt=this.compile(ce,Ue,We);return new Promise(et=>{function Ct(){if(rt.forEach(function(yt){F.get(yt).currentProgram.isReady()&&rt.delete(yt)}),rt.size===0){et(ce);return}setTimeout(Ct,10)}B.get("KHR_parallel_shader_compile")!==null?Ct():setTimeout(Ct,10)})};let Rt=null;function Tt(ce){Rt&&Rt(ce)}function nn(){ln.stop()}function Lt(){ln.start()}const ln=new ste;ln.setAnimationLoop(Tt),typeof self<"u"&&ln.setContext(self),this.setAnimationLoop=function(ce){Rt=ce,se.setAnimationLoop(ce),ce===null?ln.stop():ln.start()},se.addEventListener("sessionstart",nn),se.addEventListener("sessionend",Lt),this.render=function(ce,Ue){if(Ue!==void 0&&Ue.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Ue.parent===null&&Ue.matrixWorldAutoUpdate===!0&&Ue.updateMatrixWorld(),se.enabled===!0&&se.isPresenting===!0&&(se.cameraAutoUpdate===!0&&se.updateCamera(Ue),Ue=se.getCamera()),ce.isScene===!0&&ce.onBeforeRender(M,ce,Ue,C),x=ae.get(ce,S.length),x.init(),S.push(x),le.multiplyMatrices(Ue.projectionMatrix,Ue.matrixWorldInverse),Z.setFromProjectionMatrix(le),he=this.localClippingEnabled,ne=Te.init(this.clippingPlanes,he),y=_e.get(ce,v.length),y.init(),v.push(y),ft(ce,Ue,0,M.sortObjects),y.finish(),M.sortObjects===!0&&y.sort(J,ie),this.info.render.frame++,ne===!0&&Te.beginShadows();const We=x.state.shadowsArray;if(Pe.render(We,ce,Ue),ne===!0&&Te.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(y,ce),x.setupLights(M._useLegacyLights),Ue.isArrayCamera){const rt=Ue.cameras;for(let et=0,Ct=rt.length;et<Ct;et++){const yt=rt[et];Xt(y,ce,yt,yt.viewport)}}else Xt(y,ce,Ue);C!==null&&(de.updateMultisampleRenderTarget(C),de.updateRenderTargetMipmap(C)),ce.isScene===!0&&ce.onAfterRender(M,ce,Ue),Ce.resetDefaultState(),D=-1,T=null,S.pop(),S.length>0?x=S[S.length-1]:x=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function ft(ce,Ue,We,rt){if(ce.visible===!1)return;if(ce.layers.test(Ue.layers)){if(ce.isGroup)We=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(Ue);else if(ce.isLight)x.pushLight(ce),ce.castShadow&&x.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||Z.intersectsSprite(ce)){rt&&me.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(le);const yt=L.update(ce),Mt=ce.material;Mt.visible&&y.push(ce,yt,Mt,We,me.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||Z.intersectsObject(ce))){const yt=L.update(ce),Mt=ce.material;if(rt&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),me.copy(ce.boundingSphere.center)):(yt.boundingSphere===null&&yt.computeBoundingSphere(),me.copy(yt.boundingSphere.center)),me.applyMatrix4(ce.matrixWorld).applyMatrix4(le)),Array.isArray(Mt)){const Vt=yt.groups;for(let ue=0,je=Vt.length;ue<je;ue++){const Ge=Vt[ue],qe=Mt[Ge.materialIndex];qe&&qe.visible&&y.push(ce,yt,qe,We,me.z,Ge)}}else Mt.visible&&y.push(ce,yt,Mt,We,me.z,null)}}const Ct=ce.children;for(let yt=0,Mt=Ct.length;yt<Mt;yt++)ft(Ct[yt],Ue,We,rt)}function Xt(ce,Ue,We,rt){const et=ce.opaque,Ct=ce.transmissive,yt=ce.transparent;x.setupLightsView(We),ne===!0&&Te.setGlobalState(M.clippingPlanes,We),Ct.length>0&&tn(et,Ct,Ue,We),rt&&Y.viewport(R.copy(rt)),et.length>0&&wt(et,Ue,We),Ct.length>0&&wt(Ct,Ue,We),yt.length>0&&wt(yt,Ue,We),Y.buffers.depth.setTest(!0),Y.buffers.depth.setMask(!0),Y.buffers.color.setMask(!0),Y.setPolygonOffset(!1)}function tn(ce,Ue,We,rt){if((We.isScene===!0?We.overrideMaterial:null)!==null)return;const Ct=te.isWebGL2;fe===null&&(fe=new Jf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?Z0:$d,minFilter:Y0,samples:Ct?4:0})),M.getDrawingBufferSize(Ee),Ct?fe.setSize(Ee.x,Ee.y):fe.setSize(qS(Ee.x),qS(Ee.y));const yt=M.getRenderTarget();M.setRenderTarget(fe),M.getClearColor(q),j=M.getClearAlpha(),j<1&&M.setClearColor(16777215,.5),M.clear();const Mt=M.toneMapping;M.toneMapping=Bd,wt(ce,We,rt),de.updateMultisampleRenderTarget(fe),de.updateRenderTargetMipmap(fe);let Vt=!1;for(let ue=0,je=Ue.length;ue<je;ue++){const Ge=Ue[ue],qe=Ge.object,Ve=Ge.geometry,xt=Ge.material,Pt=Ge.group;if(xt.side===Kc&&qe.layers.test(rt.layers)){const _t=xt.side;xt.side=ys,xt.needsUpdate=!0,gr(qe,We,rt,Ve,xt,Pt),xt.side=_t,xt.needsUpdate=!0,Vt=!0}}Vt===!0&&(de.updateMultisampleRenderTarget(fe),de.updateRenderTargetMipmap(fe)),M.setRenderTarget(yt),M.setClearColor(q,j),M.toneMapping=Mt}function wt(ce,Ue,We){const rt=Ue.isScene===!0?Ue.overrideMaterial:null;for(let et=0,Ct=ce.length;et<Ct;et++){const yt=ce[et],Mt=yt.object,Vt=yt.geometry,ue=rt===null?yt.material:rt,je=yt.group;Mt.layers.test(We.layers)&&gr(Mt,Ue,We,Vt,ue,je)}}function gr(ce,Ue,We,rt,et,Ct){ce.onBeforeRender(M,Ue,We,rt,et,Ct),ce.modelViewMatrix.multiplyMatrices(We.matrixWorldInverse,ce.matrixWorld),ce.normalMatrix.getNormalMatrix(ce.modelViewMatrix),et.onBeforeRender(M,Ue,We,rt,ce,Ct),et.transparent===!0&&et.side===Kc&&et.forceSinglePass===!1?(et.side=ys,et.needsUpdate=!0,M.renderBufferDirect(We,Ue,rt,et,ce,Ct),et.side=eh,et.needsUpdate=!0,M.renderBufferDirect(We,Ue,rt,et,ce,Ct),et.side=Kc):M.renderBufferDirect(We,Ue,rt,et,ce,Ct),ce.onAfterRender(M,Ue,We,rt,et,Ct)}function Nr(ce,Ue,We){Ue.isScene!==!0&&(Ue=we);const rt=F.get(ce),et=x.state.lights,Ct=x.state.shadowsArray,yt=et.state.version,Mt=X.getParameters(ce,et.state,Ct,Ue,We),Vt=X.getProgramCacheKey(Mt);let ue=rt.programs;rt.environment=ce.isMeshStandardMaterial?Ue.environment:null,rt.fog=Ue.fog,rt.envMap=(ce.isMeshStandardMaterial?Le:Ae).get(ce.envMap||rt.environment),ue===void 0&&(ce.addEventListener("dispose",Oe),ue=new Map,rt.programs=ue);let je=ue.get(Vt);if(je!==void 0){if(rt.currentProgram===je&&rt.lightsStateVersion===yt)return er(ce,Mt),je}else Mt.uniforms=X.getUniforms(ce),ce.onBuild(We,Mt,M),ce.onBeforeCompile(Mt,M),je=X.acquireProgram(Mt,Vt),ue.set(Vt,je),rt.uniforms=Mt.uniforms;const Ge=rt.uniforms;return(!ce.isShaderMaterial&&!ce.isRawShaderMaterial||ce.clipping===!0)&&(Ge.clippingPlanes=Te.uniform),er(ce,Mt),rt.needsLights=Nn(ce),rt.lightsStateVersion=yt,rt.needsLights&&(Ge.ambientLightColor.value=et.state.ambient,Ge.lightProbe.value=et.state.probe,Ge.directionalLights.value=et.state.directional,Ge.directionalLightShadows.value=et.state.directionalShadow,Ge.spotLights.value=et.state.spot,Ge.spotLightShadows.value=et.state.spotShadow,Ge.rectAreaLights.value=et.state.rectArea,Ge.ltc_1.value=et.state.rectAreaLTC1,Ge.ltc_2.value=et.state.rectAreaLTC2,Ge.pointLights.value=et.state.point,Ge.pointLightShadows.value=et.state.pointShadow,Ge.hemisphereLights.value=et.state.hemi,Ge.directionalShadowMap.value=et.state.directionalShadowMap,Ge.directionalShadowMatrix.value=et.state.directionalShadowMatrix,Ge.spotShadowMap.value=et.state.spotShadowMap,Ge.spotLightMatrix.value=et.state.spotLightMatrix,Ge.spotLightMap.value=et.state.spotLightMap,Ge.pointShadowMap.value=et.state.pointShadowMap,Ge.pointShadowMatrix.value=et.state.pointShadowMatrix),rt.currentProgram=je,rt.uniformsList=null,je}function _r(ce){if(ce.uniformsList===null){const Ue=ce.currentProgram.getUniforms();ce.uniformsList=gw.seqWithValue(Ue.seq,ce.uniforms)}return ce.uniformsList}function er(ce,Ue){const We=F.get(ce);We.outputColorSpace=Ue.outputColorSpace,We.batching=Ue.batching,We.instancing=Ue.instancing,We.instancingColor=Ue.instancingColor,We.skinning=Ue.skinning,We.morphTargets=Ue.morphTargets,We.morphNormals=Ue.morphNormals,We.morphColors=Ue.morphColors,We.morphTargetsCount=Ue.morphTargetsCount,We.numClippingPlanes=Ue.numClippingPlanes,We.numIntersection=Ue.numClipIntersection,We.vertexAlphas=Ue.vertexAlphas,We.vertexTangents=Ue.vertexTangents,We.toneMapping=Ue.toneMapping}function vt(ce,Ue,We,rt,et){Ue.isScene!==!0&&(Ue=we),de.resetTextureUnits();const Ct=Ue.fog,yt=rt.isMeshStandardMaterial?Ue.environment:null,Mt=C===null?M.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:vu,Vt=(rt.isMeshStandardMaterial?Le:Ae).get(rt.envMap||yt),ue=rt.vertexColors===!0&&!!We.attributes.color&&We.attributes.color.itemSize===4,je=!!We.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),Ge=!!We.morphAttributes.position,qe=!!We.morphAttributes.normal,Ve=!!We.morphAttributes.color;let xt=Bd;rt.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(xt=M.toneMapping);const Pt=We.morphAttributes.position||We.morphAttributes.normal||We.morphAttributes.color,_t=Pt!==void 0?Pt.length:0,pt=F.get(rt),St=x.state.lights;if(ne===!0&&(he===!0||ce!==T)){const Gt=ce===T&&rt.id===D;Te.setState(rt,ce,Gt)}let Ot=!1;rt.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==St.state.version||pt.outputColorSpace!==Mt||et.isBatchedMesh&&pt.batching===!1||!et.isBatchedMesh&&pt.batching===!0||et.isInstancedMesh&&pt.instancing===!1||!et.isInstancedMesh&&pt.instancing===!0||et.isSkinnedMesh&&pt.skinning===!1||!et.isSkinnedMesh&&pt.skinning===!0||et.isInstancedMesh&&pt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&pt.instancingColor===!1&&et.instanceColor!==null||pt.envMap!==Vt||rt.fog===!0&&pt.fog!==Ct||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==Te.numPlanes||pt.numIntersection!==Te.numIntersection)||pt.vertexAlphas!==ue||pt.vertexTangents!==je||pt.morphTargets!==Ge||pt.morphNormals!==qe||pt.morphColors!==Ve||pt.toneMapping!==xt||te.isWebGL2===!0&&pt.morphTargetsCount!==_t)&&(Ot=!0):(Ot=!0,pt.__version=rt.version);let Ft=pt.currentProgram;Ot===!0&&(Ft=Nr(rt,Ue,et));let be=!1,kt=!1,rn=!1;const zt=Ft.getUniforms(),cn=pt.uniforms;if(Y.useProgram(Ft.program)&&(be=!0,kt=!0,rn=!0),rt.id!==D&&(D=rt.id,kt=!0),be||T!==ce){zt.setValue(ee,"projectionMatrix",ce.projectionMatrix),zt.setValue(ee,"viewMatrix",ce.matrixWorldInverse);const Gt=zt.map.cameraPosition;Gt!==void 0&&Gt.setValue(ee,me.setFromMatrixPosition(ce.matrixWorld)),te.logarithmicDepthBuffer&&zt.setValue(ee,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&zt.setValue(ee,"isOrthographic",ce.isOrthographicCamera===!0),T!==ce&&(T=ce,kt=!0,rn=!0)}if(et.isSkinnedMesh){zt.setOptional(ee,et,"bindMatrix"),zt.setOptional(ee,et,"bindMatrixInverse");const Gt=et.skeleton;Gt&&(te.floatVertexTextures?(Gt.boneTexture===null&&Gt.computeBoneTexture(),zt.setValue(ee,"boneTexture",Gt.boneTexture,de)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(zt.setOptional(ee,et,"batchingTexture"),zt.setValue(ee,"batchingTexture",et._matricesTexture,de));const $t=We.morphAttributes;if(($t.position!==void 0||$t.normal!==void 0||$t.color!==void 0&&te.isWebGL2===!0)&&Je.update(et,We,Ft),(kt||pt.receiveShadow!==et.receiveShadow)&&(pt.receiveShadow=et.receiveShadow,zt.setValue(ee,"receiveShadow",et.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(cn.envMap.value=Vt,cn.flipEnvMap.value=Vt.isCubeTexture&&Vt.isRenderTargetTexture===!1?-1:1),kt&&(zt.setValue(ee,"toneMappingExposure",M.toneMappingExposure),pt.needsLights&&on(cn,rn),Ct&&rt.fog===!0&&xe.refreshFogUniforms(cn,Ct),xe.refreshMaterialUniforms(cn,rt,G,K,fe),gw.upload(ee,_r(pt),cn,de)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(gw.upload(ee,_r(pt),cn,de),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&zt.setValue(ee,"center",et.center),zt.setValue(ee,"modelViewMatrix",et.modelViewMatrix),zt.setValue(ee,"normalMatrix",et.normalMatrix),zt.setValue(ee,"modelMatrix",et.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const Gt=rt.uniformsGroups;for(let an=0,wi=Gt.length;an<wi;an++)if(te.isWebGL2){const Qs=Gt[an];$e.update(Qs,Ft),$e.bind(Qs,Ft)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Ft}function on(ce,Ue){ce.ambientLightColor.needsUpdate=Ue,ce.lightProbe.needsUpdate=Ue,ce.directionalLights.needsUpdate=Ue,ce.directionalLightShadows.needsUpdate=Ue,ce.pointLights.needsUpdate=Ue,ce.pointLightShadows.needsUpdate=Ue,ce.spotLights.needsUpdate=Ue,ce.spotLightShadows.needsUpdate=Ue,ce.rectAreaLights.needsUpdate=Ue,ce.hemisphereLights.needsUpdate=Ue}function Nn(ce){return ce.isMeshLambertMaterial||ce.isMeshToonMaterial||ce.isMeshPhongMaterial||ce.isMeshStandardMaterial||ce.isShadowMaterial||ce.isShaderMaterial&&ce.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(ce,Ue,We){F.get(ce.texture).__webglTexture=Ue,F.get(ce.depthTexture).__webglTexture=We;const rt=F.get(ce);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=We===void 0,rt.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),rt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ce,Ue){const We=F.get(ce);We.__webglFramebuffer=Ue,We.__useDefaultFramebuffer=Ue===void 0},this.setRenderTarget=function(ce,Ue=0,We=0){C=ce,A=Ue,k=We;let rt=!0,et=null,Ct=!1,yt=!1;if(ce){const Vt=F.get(ce);Vt.__useDefaultFramebuffer!==void 0?(Y.bindFramebuffer(ee.FRAMEBUFFER,null),rt=!1):Vt.__webglFramebuffer===void 0?de.setupRenderTarget(ce):Vt.__hasExternalTextures&&de.rebindTextures(ce,F.get(ce.texture).__webglTexture,F.get(ce.depthTexture).__webglTexture);const ue=ce.texture;(ue.isData3DTexture||ue.isDataArrayTexture||ue.isCompressedArrayTexture)&&(yt=!0);const je=F.get(ce).__webglFramebuffer;ce.isWebGLCubeRenderTarget?(Array.isArray(je[Ue])?et=je[Ue][We]:et=je[Ue],Ct=!0):te.isWebGL2&&ce.samples>0&&de.useMultisampledRTT(ce)===!1?et=F.get(ce).__webglMultisampledFramebuffer:Array.isArray(je)?et=je[We]:et=je,R.copy(ce.viewport),U.copy(ce.scissor),O=ce.scissorTest}else R.copy(re).multiplyScalar(G).floor(),U.copy(z).multiplyScalar(G).floor(),O=V;if(Y.bindFramebuffer(ee.FRAMEBUFFER,et)&&te.drawBuffers&&rt&&Y.drawBuffers(ce,et),Y.viewport(R),Y.scissor(U),Y.setScissorTest(O),Ct){const Vt=F.get(ce.texture);ee.framebufferTexture2D(ee.FRAMEBUFFER,ee.COLOR_ATTACHMENT0,ee.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Vt.__webglTexture,We)}else if(yt){const Vt=F.get(ce.texture),ue=Ue||0;ee.framebufferTextureLayer(ee.FRAMEBUFFER,ee.COLOR_ATTACHMENT0,Vt.__webglTexture,We||0,ue)}D=-1},this.readRenderTargetPixels=function(ce,Ue,We,rt,et,Ct,yt){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=F.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&yt!==void 0&&(Mt=Mt[yt]),Mt){Y.bindFramebuffer(ee.FRAMEBUFFER,Mt);try{const Vt=ce.texture,ue=Vt.format,je=Vt.type;if(ue!==So&&ye.convert(ue)!==ee.getParameter(ee.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ge=je===Z0&&(B.has("EXT_color_buffer_half_float")||te.isWebGL2&&B.has("EXT_color_buffer_float"));if(je!==$d&&ye.convert(je)!==ee.getParameter(ee.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===Jc&&(te.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!Ge){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ue>=0&&Ue<=ce.width-rt&&We>=0&&We<=ce.height-et&&ee.readPixels(Ue,We,rt,et,ye.convert(ue),ye.convert(je),Ct)}finally{const Vt=C!==null?F.get(C).__webglFramebuffer:null;Y.bindFramebuffer(ee.FRAMEBUFFER,Vt)}}},this.copyFramebufferToTexture=function(ce,Ue,We=0){const rt=Math.pow(2,-We),et=Math.floor(Ue.image.width*rt),Ct=Math.floor(Ue.image.height*rt);de.setTexture2D(Ue,0),ee.copyTexSubImage2D(ee.TEXTURE_2D,We,0,0,ce.x,ce.y,et,Ct),Y.unbindTexture()},this.copyTextureToTexture=function(ce,Ue,We,rt=0){const et=Ue.image.width,Ct=Ue.image.height,yt=ye.convert(We.format),Mt=ye.convert(We.type);de.setTexture2D(We,0),ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,We.flipY),ee.pixelStorei(ee.UNPACK_PREMULTIPLY_ALPHA_WEBGL,We.premultiplyAlpha),ee.pixelStorei(ee.UNPACK_ALIGNMENT,We.unpackAlignment),Ue.isDataTexture?ee.texSubImage2D(ee.TEXTURE_2D,rt,ce.x,ce.y,et,Ct,yt,Mt,Ue.image.data):Ue.isCompressedTexture?ee.compressedTexSubImage2D(ee.TEXTURE_2D,rt,ce.x,ce.y,Ue.mipmaps[0].width,Ue.mipmaps[0].height,yt,Ue.mipmaps[0].data):ee.texSubImage2D(ee.TEXTURE_2D,rt,ce.x,ce.y,yt,Mt,Ue.image),rt===0&&We.generateMipmaps&&ee.generateMipmap(ee.TEXTURE_2D),Y.unbindTexture()},this.copyTextureToTexture3D=function(ce,Ue,We,rt,et=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ct=ce.max.x-ce.min.x+1,yt=ce.max.y-ce.min.y+1,Mt=ce.max.z-ce.min.z+1,Vt=ye.convert(rt.format),ue=ye.convert(rt.type);let je;if(rt.isData3DTexture)de.setTexture3D(rt,0),je=ee.TEXTURE_3D;else if(rt.isDataArrayTexture)de.setTexture2DArray(rt,0),je=ee.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,rt.flipY),ee.pixelStorei(ee.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),ee.pixelStorei(ee.UNPACK_ALIGNMENT,rt.unpackAlignment);const Ge=ee.getParameter(ee.UNPACK_ROW_LENGTH),qe=ee.getParameter(ee.UNPACK_IMAGE_HEIGHT),Ve=ee.getParameter(ee.UNPACK_SKIP_PIXELS),xt=ee.getParameter(ee.UNPACK_SKIP_ROWS),Pt=ee.getParameter(ee.UNPACK_SKIP_IMAGES),_t=We.isCompressedTexture?We.mipmaps[0]:We.image;ee.pixelStorei(ee.UNPACK_ROW_LENGTH,_t.width),ee.pixelStorei(ee.UNPACK_IMAGE_HEIGHT,_t.height),ee.pixelStorei(ee.UNPACK_SKIP_PIXELS,ce.min.x),ee.pixelStorei(ee.UNPACK_SKIP_ROWS,ce.min.y),ee.pixelStorei(ee.UNPACK_SKIP_IMAGES,ce.min.z),We.isDataTexture||We.isData3DTexture?ee.texSubImage3D(je,et,Ue.x,Ue.y,Ue.z,Ct,yt,Mt,Vt,ue,_t.data):We.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ee.compressedTexSubImage3D(je,et,Ue.x,Ue.y,Ue.z,Ct,yt,Mt,Vt,_t.data)):ee.texSubImage3D(je,et,Ue.x,Ue.y,Ue.z,Ct,yt,Mt,Vt,ue,_t),ee.pixelStorei(ee.UNPACK_ROW_LENGTH,Ge),ee.pixelStorei(ee.UNPACK_IMAGE_HEIGHT,qe),ee.pixelStorei(ee.UNPACK_SKIP_PIXELS,Ve),ee.pixelStorei(ee.UNPACK_SKIP_ROWS,xt),ee.pixelStorei(ee.UNPACK_SKIP_IMAGES,Pt),et===0&&rt.generateMipmaps&&ee.generateMipmap(je),Y.unbindTexture()},this.initTexture=function(ce){ce.isCubeTexture?de.setTextureCube(ce,0):ce.isData3DTexture?de.setTexture3D(ce,0):ce.isDataArrayTexture||ce.isCompressedArrayTexture?de.setTexture2DArray(ce,0):de.setTexture2D(ce,0),Y.unbindTexture()},this.resetState=function(){A=0,k=0,C=null,Y.reset(),Ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===fL?"display-p3":"srgb",n.unpackColorSpace=hr.workingColorSpace===fN?"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===ga?Af:Vee}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Af?ga:vu}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 t6e extends CR{}t6e.prototype.isWebGL1Renderer=!0;class yL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new en(e),this.near=n,this.far=r}clone(){return new yL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class n6e extends Za{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 r6e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=ER,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=su()}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=su()),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=su()),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 $a=new Fe;class kd{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++)$a.fromBufferAttribute(this,n),$a.applyMatrix4(e),this.setXYZ(n,$a.x,$a.y,$a.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)$a.fromBufferAttribute(this,n),$a.applyNormalMatrix(e),this.setXYZ(n,$a.x,$a.y,$a.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)$a.fromBufferAttribute(this,n),$a.transformDirection(e),this.setXYZ(n,$a.x,$a.y,$a.z);return this}setX(e,n){return this.normalized&&(n=dr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=dr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=dr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=dr(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=Il(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Il(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Il(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Il(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=dr(n,this.array),r=dr(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=dr(n,this.array),r=dr(r,this.array),i=dr(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=dr(n,this.array),r=dr(r,this.array),i=dr(i,this.array),a=dr(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 Ws(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 kd(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 i6e extends vs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=pa,d=pa,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function a6e(t,e){return t.z-e.z}function s6e(t,e){return e.z-t.z}class o6e{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 jp="batchId",cd=new Er,G7=new Er,l6e=new Er,W7=new Er,tj=new mN,S1=new To,Gh=new Kl,Cb=new Fe,nj=new o6e,ka=new el,M1=[];function c6e(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 u6e extends el{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ua,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 i6e(n,e,e,So,Jc);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,m=new u.constructor(r*d),p=new c.constructor(m,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Ws(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(jp,new Ws(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(jp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${jp}"`);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===jp)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 To);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,cd),this.getBoundingBoxAt(i,S1).applyMatrix4(cd),n.union(S1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Kl);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,cd),this.getBoundingSphereAt(i,Gh).applyMatrix4(cd),n.union(Gh))}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,m=this._active,p=this._matricesTexture,b=this._matricesTexture.image.data;f.push(!0),m.push(!0);const y=this._geometryCount;this._geometryCount++,l6e.toArray(b,y*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new To,sphereInitialized:!1,sphere:new Kl});const x=this.geometry.getAttribute(jp);for(let v=0;v<i.vertexCount;v++)x.setX(i.vertexStart+v,y);return x.needsUpdate=!0,this.setGeometryAt(y,e),y}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 p in r.attributes){if(p===jp)continue;const b=n.getAttribute(p),y=r.getAttribute(p);c6e(b,y,c);const x=b.itemSize;for(let v=b.count,S=u;v<S;v++){const M=c+v;for(let N=0;N<x;N++)y.setComponent(M,N,0)}y.needsUpdate=!0}if(i){const p=l.indexStart;for(let b=0;b<o.count;b++)a.setX(p+b,c+o.getX(b));for(let b=o.count,y=l.indexCount;b<y;b++)a.setX(p+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],m=n.getAttribute("position");return f.count=i?o.count:m.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const 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 m=d;l&&(m=l.getX(m)),a.expandByPoint(Cb.fromBufferAttribute(c,m))}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,S1),S1.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),Cb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Cb))}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;ka.material=this.material,ka.geometry.index=c.index,ka.geometry.attributes=c.attributes,ka.geometry.boundingBox===null&&(ka.geometry.boundingBox=new To),ka.geometry.boundingSphere===null&&(ka.geometry.boundingSphere=new Kl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];ka.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ka.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ka.geometry.boundingBox),this.getBoundingSphereAt(u,ka.geometry.boundingSphere),ka.raycast(e,M1);for(let f=0,m=M1.length;f<m;f++){const p=M1[f];p.object=this,p.batchId=u,n.push(p)}M1.length=0}ka.material=null,ka.geometry.index=null,ka.geometry.attributes={},ka.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,m=this.perObjectFrustumCulled;m&&(W7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),tj.setFromProjectionMatrix(W7,e.isWebGPURenderer?Q0:Hl));let p=0;if(this.sortObjects){G7.copy(this.matrixWorld).invert(),Cb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(G7);for(let x=0,v=c.length;x<v;x++)if(c[x]){this.getMatrixAt(x,cd),this.getBoundingSphereAt(x,Gh).applyMatrix4(cd);let S=!1;if(m&&(S=!tj.intersectsSphere(Gh)),!S){const M=Cb.distanceTo(Gh.center);nj.push(f[x],M)}}const b=nj.list,y=this.customSort;y===null?b.sort(a.transparent?s6e:a6e):y.call(this,b,r);for(let x=0,v=b.length;x<v;x++){const S=b[x];u[p]=S.start*l,d[p]=S.count,p++}nj.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let x=!1;if(m&&(this.getMatrixAt(b,cd),this.getBoundingSphereAt(b,Gh).applyMatrix4(cd),x=!tj.intersectsSphere(Gh)),!x){const v=f[b];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class Wy extends ux{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new en(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 q7=new Fe,K7=new Fe,X7=new Er,rj=new pL,E1=new Kl;class d6e extends Za{constructor(e=new Ua,n=new Wy){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++)q7.fromBufferAttribute(n,i-1),K7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=q7.distanceTo(K7);e.setAttribute("lineDistance",new ci(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(),E1.copy(r.boundingSphere),E1.applyMatrix4(i),E1.radius+=a,e.ray.intersectsSphere(E1)===!1)return;X7.copy(i).invert(),rj.copy(e.ray).applyMatrix4(X7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Fe,d=new Fe,f=new Fe,m=new Fe,p=this.isLineSegments?2:1,b=r.index,x=r.attributes.position;if(b!==null){const v=Math.max(0,o.start),S=Math.min(b.count,o.start+o.count);for(let M=v,N=S-1;M<N;M+=p){const A=b.getX(M),k=b.getX(M+1);if(u.fromBufferAttribute(x,A),d.fromBufferAttribute(x,k),rj.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let M=v,N=S-1;M<N;M+=p){if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),rj.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:M,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 Y7=new Fe,Z7=new Fe;class gN extends d6e{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)Y7.fromBufferAttribute(n,i),Z7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Y7.distanceTo(Z7);e.setAttribute("lineDistance",new ci(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class h6e extends Ua{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Fe,a=new Fe;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],m=f.start,p=f.count;for(let b=m,y=m+p;b<y;b+=3)for(let x=0;x<3;x++){const v=l.getX(b+x),S=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,S),Q7(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),Q7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new ci(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Q7(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 f6e extends ux{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new en(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new en(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gee,this.normalScale=new pn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=dL,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 m6e extends Wy{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 fte extends Za{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new en(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 ij=new Er,J7=new Fe,e9=new Fe;class p6e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pn(512,512),this.map=null,this.mapPass=null,this.matrix=new Er,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new mN,this._frameExtents=new pn(1,1),this._viewportCount=1,this._viewports=[new mr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;J7.setFromMatrixPosition(e.matrixWorld),n.position.copy(J7),e9.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(e9),n.updateMatrixWorld(),ij.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ij),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(ij)}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 t9=new Er,kb=new Fe,aj=new Fe;class g6e extends p6e{constructor(){super(new Is(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pn(4,2),this._viewportCount=6,this._viewports=[new mr(2,1,1,1),new mr(0,1,1,1),new mr(3,1,1,1),new mr(1,1,1,1),new mr(3,0,1,1),new mr(1,0,1,1)],this._cubeDirections=[new Fe(1,0,0),new Fe(-1,0,0),new Fe(0,0,1),new Fe(0,0,-1),new Fe(0,1,0),new Fe(0,-1,0)],this._cubeUps=[new Fe(0,1,0),new Fe(0,1,0),new Fe(0,1,0),new Fe(0,1,0),new Fe(0,0,1),new Fe(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()),kb.setFromMatrixPosition(e.matrixWorld),r.position.copy(kb),aj.copy(r.position),aj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(aj),r.updateMatrixWorld(),i.makeTranslation(-kb.x,-kb.y,-kb.z),t9.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(t9)}}class x6e extends fte{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 g6e}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 b6e extends fte{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class y6e extends Ua{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 kR extends r6e{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 n9{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(xa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const r9=new Fe,N1=new Fe;class v6e{constructor(e=new Fe,n=new Fe){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){r9.subVectors(e,this.start),N1.subVectors(this.end,this.start);const r=N1.dot(N1);let a=N1.dot(r9)/r;return n&&(a=xa(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 _6e extends gN{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 Ua;i.setAttribute("position",new ci(n,3)),i.setAttribute("color",new ci(r,3));const a=new Wy({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new en,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:dN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=dN);class Xl{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"),Xl.nextNameID=Xl.nextNameID||0,this.$name.id=`lil-gui-name-${++Xl.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 w6e extends Xl{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 jR(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 S6e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:jR,toHexString:jR},ey={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},M6e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=ey.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 ey.toHexString(i)}},E6e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ey.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 ey.toHexString(i)}},N6e=[S6e,ey,M6e,E6e];function A6e(t){return N6e.find(e=>e.match(t))}class T6e extends Xl{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=A6e(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=jR(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 sj extends Xl{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 C6e extends Xl{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 S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const M=parseFloat(this.$input.value);isNaN(M)||(this._snapClampSetValue(M+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const m=5,p=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=S=>{if(o){const M=S.clientX-l,N=S.clientY-c;Math.abs(N)>m?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(M)>m&&y()}if(!o){const M=S.clientY-u;f-=M*this._step*this._arrowKeyMultiplier(S),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=S.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},x=()=>{this._inputFocused=!0},v=()=>{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",p),this.$input.addEventListener("focus",x),this.$input.addEventListener("blur",v)}_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=(v,S,M,N,A)=>(v-S)/(M-S)*(A-N)+N,n=v=>{const S=this.$slider.getBoundingClientRect();let M=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(M)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=v=>{if(o){const S=v.touches[0].clientX-l,M=v.touches[0].clientY-c;Math.abs(S)>Math.abs(M)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else v.preventDefault(),n(v.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),b=400;let y;const x=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const M=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+M),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,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 k6e extends Xl{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 j6e extends Xl{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 P6e=`.lil-gui {
  7525. font-family: var(--font-family);
  7526. font-size: var(--font-size);
  7527. line-height: 1;
  7528. font-weight: normal;
  7529. font-style: normal;
  7530. text-align: left;
  7531. color: var(--text-color);
  7532. user-select: none;
  7533. -webkit-user-select: none;
  7534. touch-action: manipulation;
  7535. --background-color: #1f1f1f;
  7536. --text-color: #ebebeb;
  7537. --title-background-color: #111111;
  7538. --title-text-color: #ebebeb;
  7539. --widget-color: #424242;
  7540. --hover-color: #4f4f4f;
  7541. --focus-color: #595959;
  7542. --number-color: #2cc9ff;
  7543. --string-color: #a2db3c;
  7544. --font-size: 11px;
  7545. --input-font-size: 11px;
  7546. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7547. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7548. --padding: 4px;
  7549. --spacing: 4px;
  7550. --widget-height: 20px;
  7551. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7552. --name-width: 45%;
  7553. --slider-knob-width: 2px;
  7554. --slider-input-width: 27%;
  7555. --color-input-width: 27%;
  7556. --slider-input-min-width: 45px;
  7557. --color-input-min-width: 45px;
  7558. --folder-indent: 7px;
  7559. --widget-padding: 0 0 0 3px;
  7560. --widget-border-radius: 2px;
  7561. --checkbox-size: calc(0.75 * var(--widget-height));
  7562. --scrollbar-width: 5px;
  7563. }
  7564. .lil-gui, .lil-gui * {
  7565. box-sizing: border-box;
  7566. margin: 0;
  7567. padding: 0;
  7568. }
  7569. .lil-gui.root {
  7570. width: var(--width, 245px);
  7571. display: flex;
  7572. flex-direction: column;
  7573. background: var(--background-color);
  7574. }
  7575. .lil-gui.root > .title {
  7576. background: var(--title-background-color);
  7577. color: var(--title-text-color);
  7578. }
  7579. .lil-gui.root > .children {
  7580. overflow-x: hidden;
  7581. overflow-y: auto;
  7582. }
  7583. .lil-gui.root > .children::-webkit-scrollbar {
  7584. width: var(--scrollbar-width);
  7585. height: var(--scrollbar-width);
  7586. background: var(--background-color);
  7587. }
  7588. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7589. border-radius: var(--scrollbar-width);
  7590. background: var(--focus-color);
  7591. }
  7592. @media (pointer: coarse) {
  7593. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7594. --widget-height: 28px;
  7595. --padding: 6px;
  7596. --spacing: 6px;
  7597. --font-size: 13px;
  7598. --input-font-size: 16px;
  7599. --folder-indent: 10px;
  7600. --scrollbar-width: 7px;
  7601. --slider-input-min-width: 50px;
  7602. --color-input-min-width: 65px;
  7603. }
  7604. }
  7605. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7606. --widget-height: 28px;
  7607. --padding: 6px;
  7608. --spacing: 6px;
  7609. --font-size: 13px;
  7610. --input-font-size: 16px;
  7611. --folder-indent: 10px;
  7612. --scrollbar-width: 7px;
  7613. --slider-input-min-width: 50px;
  7614. --color-input-min-width: 65px;
  7615. }
  7616. .lil-gui.autoPlace {
  7617. max-height: 100%;
  7618. position: fixed;
  7619. top: 0;
  7620. right: 15px;
  7621. z-index: 1001;
  7622. }
  7623. .lil-gui .controller {
  7624. display: flex;
  7625. align-items: center;
  7626. padding: 0 var(--padding);
  7627. margin: var(--spacing) 0;
  7628. }
  7629. .lil-gui .controller.disabled {
  7630. opacity: 0.5;
  7631. }
  7632. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7633. pointer-events: none !important;
  7634. }
  7635. .lil-gui .controller > .name {
  7636. min-width: var(--name-width);
  7637. flex-shrink: 0;
  7638. white-space: pre;
  7639. padding-right: var(--spacing);
  7640. line-height: var(--widget-height);
  7641. }
  7642. .lil-gui .controller .widget {
  7643. position: relative;
  7644. display: flex;
  7645. align-items: center;
  7646. width: 100%;
  7647. min-height: var(--widget-height);
  7648. }
  7649. .lil-gui .controller.string input {
  7650. color: var(--string-color);
  7651. }
  7652. .lil-gui .controller.boolean {
  7653. cursor: pointer;
  7654. }
  7655. .lil-gui .controller.color .display {
  7656. width: 100%;
  7657. height: var(--widget-height);
  7658. border-radius: var(--widget-border-radius);
  7659. position: relative;
  7660. }
  7661. @media (hover: hover) {
  7662. .lil-gui .controller.color .display:hover:before {
  7663. content: " ";
  7664. display: block;
  7665. position: absolute;
  7666. border-radius: var(--widget-border-radius);
  7667. border: 1px solid #fff9;
  7668. top: 0;
  7669. right: 0;
  7670. bottom: 0;
  7671. left: 0;
  7672. }
  7673. }
  7674. .lil-gui .controller.color input[type=color] {
  7675. opacity: 0;
  7676. width: 100%;
  7677. height: 100%;
  7678. cursor: pointer;
  7679. }
  7680. .lil-gui .controller.color input[type=text] {
  7681. margin-left: var(--spacing);
  7682. font-family: var(--font-family-mono);
  7683. min-width: var(--color-input-min-width);
  7684. width: var(--color-input-width);
  7685. flex-shrink: 0;
  7686. }
  7687. .lil-gui .controller.option select {
  7688. opacity: 0;
  7689. position: absolute;
  7690. width: 100%;
  7691. max-width: 100%;
  7692. }
  7693. .lil-gui .controller.option .display {
  7694. position: relative;
  7695. pointer-events: none;
  7696. border-radius: var(--widget-border-radius);
  7697. height: var(--widget-height);
  7698. line-height: var(--widget-height);
  7699. max-width: 100%;
  7700. overflow: hidden;
  7701. word-break: break-all;
  7702. padding-left: 0.55em;
  7703. padding-right: 1.75em;
  7704. background: var(--widget-color);
  7705. }
  7706. @media (hover: hover) {
  7707. .lil-gui .controller.option .display.focus {
  7708. background: var(--focus-color);
  7709. }
  7710. }
  7711. .lil-gui .controller.option .display.active {
  7712. background: var(--focus-color);
  7713. }
  7714. .lil-gui .controller.option .display:after {
  7715. font-family: "lil-gui";
  7716. content: "↕";
  7717. position: absolute;
  7718. top: 0;
  7719. right: 0;
  7720. bottom: 0;
  7721. padding-right: 0.375em;
  7722. }
  7723. .lil-gui .controller.option .widget,
  7724. .lil-gui .controller.option select {
  7725. cursor: pointer;
  7726. }
  7727. @media (hover: hover) {
  7728. .lil-gui .controller.option .widget:hover .display {
  7729. background: var(--hover-color);
  7730. }
  7731. }
  7732. .lil-gui .controller.number input {
  7733. color: var(--number-color);
  7734. }
  7735. .lil-gui .controller.number.hasSlider input {
  7736. margin-left: var(--spacing);
  7737. width: var(--slider-input-width);
  7738. min-width: var(--slider-input-min-width);
  7739. flex-shrink: 0;
  7740. }
  7741. .lil-gui .controller.number .slider {
  7742. width: 100%;
  7743. height: var(--widget-height);
  7744. background: var(--widget-color);
  7745. border-radius: var(--widget-border-radius);
  7746. padding-right: var(--slider-knob-width);
  7747. overflow: hidden;
  7748. cursor: ew-resize;
  7749. touch-action: pan-y;
  7750. }
  7751. @media (hover: hover) {
  7752. .lil-gui .controller.number .slider:hover {
  7753. background: var(--hover-color);
  7754. }
  7755. }
  7756. .lil-gui .controller.number .slider.active {
  7757. background: var(--focus-color);
  7758. }
  7759. .lil-gui .controller.number .slider.active .fill {
  7760. opacity: 0.95;
  7761. }
  7762. .lil-gui .controller.number .fill {
  7763. height: 100%;
  7764. border-right: var(--slider-knob-width) solid var(--number-color);
  7765. box-sizing: content-box;
  7766. }
  7767. .lil-gui-dragging .lil-gui {
  7768. --hover-color: var(--widget-color);
  7769. }
  7770. .lil-gui-dragging * {
  7771. cursor: ew-resize !important;
  7772. }
  7773. .lil-gui-dragging.lil-gui-vertical * {
  7774. cursor: ns-resize !important;
  7775. }
  7776. .lil-gui .title {
  7777. height: var(--title-height);
  7778. line-height: calc(var(--title-height) - 4px);
  7779. font-weight: 600;
  7780. padding: 0 var(--padding);
  7781. -webkit-tap-highlight-color: transparent;
  7782. cursor: pointer;
  7783. outline: none;
  7784. text-decoration-skip: objects;
  7785. }
  7786. .lil-gui .title:before {
  7787. font-family: "lil-gui";
  7788. content: "▾";
  7789. padding-right: 2px;
  7790. display: inline-block;
  7791. }
  7792. .lil-gui .title:active {
  7793. background: var(--title-background-color);
  7794. opacity: 0.75;
  7795. }
  7796. @media (hover: hover) {
  7797. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7798. background: var(--title-background-color);
  7799. opacity: 0.85;
  7800. }
  7801. .lil-gui .title:focus {
  7802. text-decoration: underline var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui.root > .title:focus {
  7806. text-decoration: none !important;
  7807. }
  7808. .lil-gui.closed > .title:before {
  7809. content: "▸";
  7810. }
  7811. .lil-gui.closed > .children {
  7812. transform: translateY(-7px);
  7813. opacity: 0;
  7814. }
  7815. .lil-gui.closed:not(.transition) > .children {
  7816. display: none;
  7817. }
  7818. .lil-gui.transition > .children {
  7819. transition-duration: 300ms;
  7820. transition-property: height, opacity, transform;
  7821. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7822. overflow: hidden;
  7823. pointer-events: none;
  7824. }
  7825. .lil-gui .children:empty:before {
  7826. content: "Empty";
  7827. padding: 0 var(--padding);
  7828. margin: var(--spacing) 0;
  7829. display: block;
  7830. height: var(--widget-height);
  7831. font-style: italic;
  7832. line-height: var(--widget-height);
  7833. opacity: 0.5;
  7834. }
  7835. .lil-gui.root > .children > .lil-gui > .title {
  7836. border: 0 solid var(--widget-color);
  7837. border-width: 1px 0;
  7838. transition: border-color 300ms;
  7839. }
  7840. .lil-gui.root > .children > .lil-gui.closed > .title {
  7841. border-bottom-color: transparent;
  7842. }
  7843. .lil-gui + .controller {
  7844. border-top: 1px solid var(--widget-color);
  7845. margin-top: 0;
  7846. padding-top: var(--spacing);
  7847. }
  7848. .lil-gui .lil-gui .lil-gui > .title {
  7849. border: none;
  7850. }
  7851. .lil-gui .lil-gui .lil-gui > .children {
  7852. border: none;
  7853. margin-left: var(--folder-indent);
  7854. border-left: 2px solid var(--widget-color);
  7855. }
  7856. .lil-gui .lil-gui .controller {
  7857. border: none;
  7858. }
  7859. .lil-gui label, .lil-gui input, .lil-gui button {
  7860. -webkit-tap-highlight-color: transparent;
  7861. }
  7862. .lil-gui input {
  7863. border: 0;
  7864. outline: none;
  7865. font-family: var(--font-family);
  7866. font-size: var(--input-font-size);
  7867. border-radius: var(--widget-border-radius);
  7868. height: var(--widget-height);
  7869. background: var(--widget-color);
  7870. color: var(--text-color);
  7871. width: 100%;
  7872. }
  7873. @media (hover: hover) {
  7874. .lil-gui input:hover {
  7875. background: var(--hover-color);
  7876. }
  7877. .lil-gui input:active {
  7878. background: var(--focus-color);
  7879. }
  7880. }
  7881. .lil-gui input:disabled {
  7882. opacity: 1;
  7883. }
  7884. .lil-gui input[type=text],
  7885. .lil-gui input[type=number] {
  7886. padding: var(--widget-padding);
  7887. -moz-appearance: textfield;
  7888. }
  7889. .lil-gui input[type=text]:focus,
  7890. .lil-gui input[type=number]:focus {
  7891. background: var(--focus-color);
  7892. }
  7893. .lil-gui input[type=checkbox] {
  7894. appearance: none;
  7895. width: var(--checkbox-size);
  7896. height: var(--checkbox-size);
  7897. border-radius: var(--widget-border-radius);
  7898. text-align: center;
  7899. cursor: pointer;
  7900. }
  7901. .lil-gui input[type=checkbox]:checked:before {
  7902. font-family: "lil-gui";
  7903. content: "✓";
  7904. font-size: var(--checkbox-size);
  7905. line-height: var(--checkbox-size);
  7906. }
  7907. @media (hover: hover) {
  7908. .lil-gui input[type=checkbox]:focus {
  7909. box-shadow: inset 0 0 0 1px var(--focus-color);
  7910. }
  7911. }
  7912. .lil-gui button {
  7913. outline: none;
  7914. cursor: pointer;
  7915. font-family: var(--font-family);
  7916. font-size: var(--font-size);
  7917. color: var(--text-color);
  7918. width: 100%;
  7919. height: var(--widget-height);
  7920. text-transform: none;
  7921. background: var(--widget-color);
  7922. border-radius: var(--widget-border-radius);
  7923. border: none;
  7924. }
  7925. @media (hover: hover) {
  7926. .lil-gui button:hover {
  7927. background: var(--hover-color);
  7928. }
  7929. .lil-gui button:focus {
  7930. box-shadow: inset 0 0 0 1px var(--focus-color);
  7931. }
  7932. }
  7933. .lil-gui button:active {
  7934. background: var(--focus-color);
  7935. }
  7936. @font-face {
  7937. font-family: "lil-gui";
  7938. 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");
  7939. }`;function R6e(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 i9=!1;class XS{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"),!i9&&l&&(R6e(P6e),i9=!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 k6e(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new C6e(this,e,n,r,i,a);case"boolean":return new w6e(this,e,n);case"string":return new j6e(this,e,n);case"function":return new sj(this,e,n)}console.error(`gui.add failed
  7940. property:`,n,`
  7941. object:`,e,`
  7942. value:`,o)}addColor(e,n,r=1){return new T6e(this,e,n,r)}addFolder(e){const n=new XS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof sj||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 sj)){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 oj(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 vL{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 vL(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 _L{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class a9 extends _L{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class ud extends _L{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class s9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class YS{constructor(e){this.lines=[],this.preamble=new s9(-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(`
  7943. `);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 a9(e,c,u,o);case"t0":return new ud(e,c,o,0);case"t1":return new ud(e,c,o,1);case"t2":return new ud(e,c,o,2);case"t3":return new ud(e,c,o,3);case"t4":return new ud(e,c,o,4);case"t5":return new ud(e,c,o,5);case"t6":return new ud(e,c,o,6);case"t7":return new ud(e,c,o,7);default:return new _L(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 a9){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 s9(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=vL.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}}}YS.prototype.parseGcode=YS.prototype.parseGCode;const o9={type:"change"},lj={type:"start"},l9={type:"end"},A1=new pL,c9=new xd,D6e=Math.cos(70*qee.DEG2RAD);class O6e extends dm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Fe,this.cursor=new Fe,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:fp.ROTATE,MIDDLE:fp.DOLLY,RIGHT:fp.PAN},this.touches={ONE:mp.ROTATE,TWO:mp.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(te){te.addEventListener("keydown",De),this._domElementKeyEvents=te},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",De),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(o9),r.update(),a=i.NONE},this.update=(function(){const te=new Fe,Y=new em().setFromUnitVectors(e.up,new Fe(0,1,0)),H=Y.clone().invert(),F=new Fe,de=new em,Ae=new Fe,Le=2*Math.PI;return function(Se=null){const $=r.object.position;te.copy($).sub(r.target),te.applyQuaternion(Y),l.setFromVector3(te),r.autoRotate&&a===i.NONE&&R((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,X=r.maxAzimuthAngle;isFinite(L)&&isFinite(X)&&(L<-Math.PI?L+=Le:L>Math.PI&&(L-=Le),X<-Math.PI?X+=Le:X>Math.PI&&(X-=Le),l.theta=L<=X?Math.max(L,Math.min(X,l.theta)):l.theta>(L+X)/2?Math.max(L,l.theta):Math.min(X,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&&k||r.object.isOrthographicCamera?l.radius=J(l.radius):l.radius=J(l.radius*u),te.setFromSpherical(l),te.applyQuaternion(H),$.copy(r.target).add(te),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 xe=!1;if(r.zoomToCursor&&k){let _e=null;if(r.object.isPerspectiveCamera){const ae=te.length();_e=J(ae*u);const Te=ae-_e;r.object.position.addScaledVector(N,Te),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ae=new Fe(A.x,A.y,0);ae.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0;const Te=new Fe(A.x,A.y,0);Te.unproject(r.object),r.object.position.sub(Te).add(ae),r.object.updateMatrixWorld(),_e=te.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(A1.origin.copy(r.object.position),A1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(A1.direction))<D6e?e.lookAt(r.target):(c9.setFromNormalAndCoplanarPoint(r.object.up,r.target),A1.intersectPlane(c9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0);return u=1,k=!1,!!(xe||F.distanceToSquared(r.object.position)>o||8*(1-de.dot(r.object.quaternion))>o||Ae.distanceToSquared(r.target)>0)&&(r.dispatchEvent(o9),F.copy(r.object.position),de.copy(r.object.quaternion),Ae.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ee),r.domElement.removeEventListener("pointerdown",le),r.domElement.removeEventListener("pointercancel",me),r.domElement.removeEventListener("wheel",we),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",me),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",De),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 n9,c=new n9;let u=1;const d=new Fe,f=new pn,m=new pn,p=new pn,b=new pn,y=new pn,x=new pn,v=new pn,S=new pn,M=new pn,N=new Fe,A=new pn;let k=!1;const C=[],D={};function T(){return Math.pow(.95,r.zoomSpeed)}function R(te){c.theta-=te}function U(te){c.phi-=te}const O=(function(){const te=new Fe;return function(Y,H){te.setFromMatrixColumn(H,0),te.multiplyScalar(-Y),d.add(te)}})(),q=(function(){const te=new Fe;return function(Y,H){r.screenSpacePanning===!0?te.setFromMatrixColumn(H,1):(te.setFromMatrixColumn(H,0),te.crossVectors(r.object.up,te)),te.multiplyScalar(Y),d.add(te)}})(),j=(function(){const te=new Fe;return function(Y,H){const F=r.domElement;if(r.object.isPerspectiveCamera){const de=r.object.position;te.copy(de).sub(r.target);let Ae=te.length();Ae*=Math.tan(r.object.fov/2*Math.PI/180),O(2*Y*Ae/F.clientHeight,r.object.matrix),q(2*H*Ae/F.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(Y*(r.object.right-r.object.left)/r.object.zoom/F.clientWidth,r.object.matrix),q(H*(r.object.top-r.object.bottom)/r.object.zoom/F.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(te){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=te:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(te){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=te:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(te){if(!r.zoomToCursor)return;k=!0;const Y=r.domElement.getBoundingClientRect(),H=te.clientX-Y.left,F=te.clientY-Y.top,de=Y.width,Ae=Y.height;A.x=H/de*2-1,A.y=-F/Ae*2+1,N.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function J(te){return Math.max(r.minDistance,Math.min(r.maxDistance,te))}function ie(te){f.set(te.clientX,te.clientY)}function re(te){b.set(te.clientX,te.clientY)}function z(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const te=.5*(C[0].pageX+C[1].pageX),Y=.5*(C[0].pageY+C[1].pageY);f.set(te,Y)}}function V(){if(C.length===1)b.set(C[0].pageX,C[0].pageY);else{const te=.5*(C[0].pageX+C[1].pageX),Y=.5*(C[0].pageY+C[1].pageY);b.set(te,Y)}}function Z(){const te=C[0].pageX-C[1].pageX,Y=C[0].pageY-C[1].pageY,H=Math.sqrt(te*te+Y*Y);v.set(0,H)}function ne(te){if(C.length==1)m.set(te.pageX,te.pageY);else{const H=B(te),F=.5*(te.pageX+H.x),de=.5*(te.pageY+H.y);m.set(F,de)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const Y=r.domElement;R(2*Math.PI*p.x/Y.clientHeight),U(2*Math.PI*p.y/Y.clientHeight),f.copy(m)}function he(te){if(C.length===1)y.set(te.pageX,te.pageY);else{const Y=B(te),H=.5*(te.pageX+Y.x),F=.5*(te.pageY+Y.y);y.set(H,F)}x.subVectors(y,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(y)}function fe(te){const Y=B(te),H=te.pageX-Y.x,F=te.pageY-Y.y,de=Math.sqrt(H*H+F*F);S.set(0,de),M.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),W(M.y),v.copy(S)}function le(te){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(te.pointerId),r.domElement.addEventListener("pointermove",Ee),r.domElement.addEventListener("pointerup",me)),(function(Y){C.push(Y)})(te),te.pointerType==="touch"?(function(Y){switch(Qe(Y),C.length){case 1:switch(r.touches.ONE){case mp.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case mp.PAN:if(r.enablePan===!1)return;V(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case mp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&Z(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case mp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&Z(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(lj)})(te):(function(Y){let H;switch(Y.button){case 0:H=r.mouseButtons.LEFT;break;case 1:H=r.mouseButtons.MIDDLE;break;case 2:H=r.mouseButtons.RIGHT;break;default:H=-1}switch(H){case fp.DOLLY:if(r.enableZoom===!1)return;(function(F){G(F),v.set(F.clientX,F.clientY)})(Y),a=i.DOLLY;break;case fp.ROTATE:if(Y.ctrlKey||Y.metaKey||Y.shiftKey){if(r.enablePan===!1)return;re(Y),a=i.PAN}else{if(r.enableRotate===!1)return;ie(Y),a=i.ROTATE}break;case fp.PAN:if(Y.ctrlKey||Y.metaKey||Y.shiftKey){if(r.enableRotate===!1)return;ie(Y),a=i.ROTATE}else{if(r.enablePan===!1)return;re(Y),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(lj)})(te))}function Ee(te){r.enabled!==!1&&(te.pointerType==="touch"?(function(Y){switch(Qe(Y),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ne(Y),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;he(Y),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(H){r.enableZoom&&fe(H),r.enablePan&&he(H)})(Y),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(H){r.enableZoom&&fe(H),r.enableRotate&&ne(H)})(Y),r.update();break;default:a=i.NONE}})(te):(function(Y){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(H){m.set(H.clientX,H.clientY),p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const F=r.domElement;R(2*Math.PI*p.x/F.clientHeight),U(2*Math.PI*p.y/F.clientHeight),f.copy(m),r.update()})(Y);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(H){S.set(H.clientX,H.clientY),M.subVectors(S,v),M.y>0?W(T()):M.y<0&&K(T()),v.copy(S),r.update()})(Y);break;case i.PAN:if(r.enablePan===!1)return;(function(H){y.set(H.clientX,H.clientY),x.subVectors(y,b).multiplyScalar(r.panSpeed),j(x.x,x.y),b.copy(y),r.update()})(Y)}})(te))}function me(te){(function(Y){delete D[Y.pointerId];for(let H=0;H<C.length;H++)if(C[H].pointerId==Y.pointerId)return void C.splice(H,1)})(te),C.length===0&&(r.domElement.releasePointerCapture(te.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",me)),r.dispatchEvent(l9),a=i.NONE}function we(te){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(te.preventDefault(),r.dispatchEvent(lj),(function(Y){G(Y),Y.deltaY<0?K(T()):Y.deltaY>0&&W(T()),r.update()})(te),r.dispatchEvent(l9))}function De(te){r.enabled!==!1&&r.enablePan!==!1&&(function(Y){let H=!1;switch(Y.code){case r.keys.UP:Y.ctrlKey||Y.metaKey||Y.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),H=!0;break;case r.keys.BOTTOM:Y.ctrlKey||Y.metaKey||Y.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),H=!0;break;case r.keys.LEFT:Y.ctrlKey||Y.metaKey||Y.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),H=!0;break;case r.keys.RIGHT:Y.ctrlKey||Y.metaKey||Y.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),H=!0}H&&(Y.preventDefault(),r.update())})(te)}function ee(te){r.enabled!==!1&&te.preventDefault()}function Qe(te){let Y=D[te.pointerId];Y===void 0&&(Y=new pn,D[te.pointerId]=Y),Y.set(te.pageX,te.pageY)}function B(te){const Y=te.pointerId===C[0].pointerId?C[1]:C[0];return D[Y.pointerId]}r.domElement.addEventListener("contextmenu",ee),r.domElement.addEventListener("pointerdown",le),r.domElement.addEventListener("pointercancel",me),r.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}Dt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new pn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},fs.line={uniforms:gL.merge([Dt.common,Dt.fog,Dt.line]),vertexShader:`
  7944. #include <common>
  7945. #include <color_pars_vertex>
  7946. #include <fog_pars_vertex>
  7947. #include <logdepthbuf_pars_vertex>
  7948. #include <clipping_planes_pars_vertex>
  7949. uniform float linewidth;
  7950. uniform vec2 resolution;
  7951. attribute vec3 instanceStart;
  7952. attribute vec3 instanceEnd;
  7953. attribute vec3 instanceColorStart;
  7954. attribute vec3 instanceColorEnd;
  7955. #ifdef WORLD_UNITS
  7956. varying vec4 worldPos;
  7957. varying vec3 worldStart;
  7958. varying vec3 worldEnd;
  7959. #ifdef USE_DASH
  7960. varying vec2 vUv;
  7961. #endif
  7962. #else
  7963. varying vec2 vUv;
  7964. #endif
  7965. #ifdef USE_DASH
  7966. uniform float dashScale;
  7967. attribute float instanceDistanceStart;
  7968. attribute float instanceDistanceEnd;
  7969. varying float vLineDistance;
  7970. #endif
  7971. void trimSegment( const in vec4 start, inout vec4 end ) {
  7972. // trim end segment so it terminates between the camera plane and the near plane
  7973. // conservative estimate of the near plane
  7974. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7975. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7976. float nearEstimate = - 0.5 * b / a;
  7977. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7978. end.xyz = mix( start.xyz, end.xyz, alpha );
  7979. }
  7980. void main() {
  7981. #ifdef USE_COLOR
  7982. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7983. #endif
  7984. #ifdef USE_DASH
  7985. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7986. vUv = uv;
  7987. #endif
  7988. float aspect = resolution.x / resolution.y;
  7989. // camera space
  7990. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7991. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7992. #ifdef WORLD_UNITS
  7993. worldStart = start.xyz;
  7994. worldEnd = end.xyz;
  7995. #else
  7996. vUv = uv;
  7997. #endif
  7998. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7999. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  8000. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  8001. // perhaps there is a more elegant solution -- WestLangley
  8002. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  8003. if ( perspective ) {
  8004. if ( start.z < 0.0 && end.z >= 0.0 ) {
  8005. trimSegment( start, end );
  8006. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  8007. trimSegment( end, start );
  8008. }
  8009. }
  8010. // clip space
  8011. vec4 clipStart = projectionMatrix * start;
  8012. vec4 clipEnd = projectionMatrix * end;
  8013. // ndc space
  8014. vec3 ndcStart = clipStart.xyz / clipStart.w;
  8015. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  8016. // direction
  8017. vec2 dir = ndcEnd.xy - ndcStart.xy;
  8018. // account for clip-space aspect ratio
  8019. dir.x *= aspect;
  8020. dir = normalize( dir );
  8021. #ifdef WORLD_UNITS
  8022. // get the offset direction as perpendicular to the view vector
  8023. vec3 worldDir = normalize( end.xyz - start.xyz );
  8024. vec3 offset;
  8025. if ( position.y < 0.5 ) {
  8026. offset = normalize( cross( start.xyz, worldDir ) );
  8027. } else {
  8028. offset = normalize( cross( end.xyz, worldDir ) );
  8029. }
  8030. // sign flip
  8031. if ( position.x < 0.0 ) offset *= - 1.0;
  8032. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  8033. // don't extend the line if we're rendering dashes because we
  8034. // won't be rendering the endcaps
  8035. #ifndef USE_DASH
  8036. // extend the line bounds to encompass endcaps
  8037. start.xyz += - worldDir * linewidth * 0.5;
  8038. end.xyz += worldDir * linewidth * 0.5;
  8039. // shift the position of the quad so it hugs the forward edge of the line
  8040. offset.xy -= dir * forwardOffset;
  8041. offset.z += 0.5;
  8042. #endif
  8043. // endcaps
  8044. if ( position.y > 1.0 || position.y < 0.0 ) {
  8045. offset.xy += dir * 2.0 * forwardOffset;
  8046. }
  8047. // adjust for linewidth
  8048. offset *= linewidth * 0.5;
  8049. // set the world position
  8050. worldPos = ( position.y < 0.5 ) ? start : end;
  8051. worldPos.xyz += offset;
  8052. // project the worldpos
  8053. vec4 clip = projectionMatrix * worldPos;
  8054. // shift the depth of the projected points so the line
  8055. // segments overlap neatly
  8056. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8057. clip.z = clipPose.z * clip.w;
  8058. #else
  8059. vec2 offset = vec2( dir.y, - dir.x );
  8060. // undo aspect ratio adjustment
  8061. dir.x /= aspect;
  8062. offset.x /= aspect;
  8063. // sign flip
  8064. if ( position.x < 0.0 ) offset *= - 1.0;
  8065. // endcaps
  8066. if ( position.y < 0.0 ) {
  8067. offset += - dir;
  8068. } else if ( position.y > 1.0 ) {
  8069. offset += dir;
  8070. }
  8071. // adjust for linewidth
  8072. offset *= linewidth;
  8073. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8074. offset /= resolution.y;
  8075. // select end
  8076. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8077. // back to clip space
  8078. offset *= clip.w;
  8079. clip.xy += offset;
  8080. #endif
  8081. gl_Position = clip;
  8082. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8083. #include <logdepthbuf_vertex>
  8084. #include <clipping_planes_vertex>
  8085. #include <fog_vertex>
  8086. }
  8087. `,fragmentShader:`
  8088. uniform vec3 diffuse;
  8089. uniform float opacity;
  8090. uniform float linewidth;
  8091. #ifdef USE_DASH
  8092. uniform float dashOffset;
  8093. uniform float dashSize;
  8094. uniform float gapSize;
  8095. #endif
  8096. varying float vLineDistance;
  8097. #ifdef WORLD_UNITS
  8098. varying vec4 worldPos;
  8099. varying vec3 worldStart;
  8100. varying vec3 worldEnd;
  8101. #ifdef USE_DASH
  8102. varying vec2 vUv;
  8103. #endif
  8104. #else
  8105. varying vec2 vUv;
  8106. #endif
  8107. #include <common>
  8108. #include <color_pars_fragment>
  8109. #include <fog_pars_fragment>
  8110. #include <logdepthbuf_pars_fragment>
  8111. #include <clipping_planes_pars_fragment>
  8112. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8113. float mua;
  8114. float mub;
  8115. vec3 p13 = p1 - p3;
  8116. vec3 p43 = p4 - p3;
  8117. vec3 p21 = p2 - p1;
  8118. float d1343 = dot( p13, p43 );
  8119. float d4321 = dot( p43, p21 );
  8120. float d1321 = dot( p13, p21 );
  8121. float d4343 = dot( p43, p43 );
  8122. float d2121 = dot( p21, p21 );
  8123. float denom = d2121 * d4343 - d4321 * d4321;
  8124. float numer = d1343 * d4321 - d1321 * d4343;
  8125. mua = numer / denom;
  8126. mua = clamp( mua, 0.0, 1.0 );
  8127. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8128. mub = clamp( mub, 0.0, 1.0 );
  8129. return vec2( mua, mub );
  8130. }
  8131. void main() {
  8132. #include <clipping_planes_fragment>
  8133. #ifdef USE_DASH
  8134. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8135. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8136. #endif
  8137. float alpha = opacity;
  8138. #ifdef WORLD_UNITS
  8139. // Find the closest points on the view ray and the line segment
  8140. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8141. vec3 lineDir = worldEnd - worldStart;
  8142. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8143. vec3 p1 = worldStart + lineDir * params.x;
  8144. vec3 p2 = rayEnd * params.y;
  8145. vec3 delta = p1 - p2;
  8146. float len = length( delta );
  8147. float norm = len / linewidth;
  8148. #ifndef USE_DASH
  8149. #ifdef USE_ALPHA_TO_COVERAGE
  8150. float dnorm = fwidth( norm );
  8151. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8152. #else
  8153. if ( norm > 0.5 ) {
  8154. discard;
  8155. }
  8156. #endif
  8157. #endif
  8158. #else
  8159. #ifdef USE_ALPHA_TO_COVERAGE
  8160. // artifacts appear on some hardware if a derivative is taken within a conditional
  8161. float a = vUv.x;
  8162. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8163. float len2 = a * a + b * b;
  8164. float dlen = fwidth( len2 );
  8165. if ( abs( vUv.y ) > 1.0 ) {
  8166. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8167. }
  8168. #else
  8169. if ( abs( vUv.y ) > 1.0 ) {
  8170. float a = vUv.x;
  8171. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8172. float len2 = a * a + b * b;
  8173. if ( len2 > 1.0 ) discard;
  8174. }
  8175. #endif
  8176. #endif
  8177. vec4 diffuseColor = vec4( diffuse, alpha );
  8178. #include <logdepthbuf_fragment>
  8179. #include <color_fragment>
  8180. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8181. #include <tonemapping_fragment>
  8182. #include <colorspace_fragment>
  8183. #include <fog_fragment>
  8184. #include <premultiplied_alpha_fragment>
  8185. }
  8186. `};class mte extends th{constructor(e){super({type:"LineMaterial",uniforms:gL.clone(fs.line.uniforms),vertexShader:fs.line.vertexShader,fragmentShader:fs.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 u9=new To,T1=new Fe;class pte extends y6e{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 ci([-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 ci([-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 kR(n,6,1);return this.setAttribute("instanceStart",new kd(r,3,0)),this.setAttribute("instanceEnd",new kd(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 kR(n,6,1);return this.setAttribute("instanceColorStart",new kd(r,3,0)),this.setAttribute("instanceColorEnd",new kd(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 h6e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new To);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),u9.setFromBufferAttribute(n),this.boundingBox.union(u9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Kl),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++)T1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(T1)),T1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(T1));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 d9=new Fe,h9=new Fe,ca=new mr,ua=new mr,Tl=new mr,cj=new Fe,uj=new Er,da=new v6e,f9=new Fe,C1=new To,k1=new Kl,Cl=new mr;let kl,nf;function m9(t,e,n){return Cl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Cl.multiplyScalar(1/Cl.w),Cl.x=nf/n.width,Cl.y=nf/n.height,Cl.applyMatrix4(t.projectionMatrixInverse),Cl.multiplyScalar(1/Cl.w),Math.abs(Math.max(Cl.x,Cl.y))}class L6e extends el{constructor(e=new pte,n=new mte({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)d9.fromBufferAttribute(n,o),h9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+d9.distanceTo(h9);const a=new kR(i,2,1);return e.setAttribute("instanceDistanceStart",new kd(a,1,0)),e.setAttribute("instanceDistanceEnd",new kd(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;kl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;nf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),k1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*nf:u=m9(i,Math.max(i.near,k1.distanceToPoint(kl.origin)),c.resolution),k1.radius+=u,kl.intersectsSphere(k1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),C1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*nf:d=m9(i,Math.max(i.near,C1.distanceToPoint(kl.origin)),c.resolution),C1.expandByScalar(d),kl.intersectsBox(C1)!==!1&&(r?(function(f,m){const p=f.matrixWorld,b=f.geometry,y=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let v=0,S=Math.min(b.instanceCount,y.count);v<S;v++){da.start.fromBufferAttribute(y,v),da.end.fromBufferAttribute(x,v),da.applyMatrix4(p);const M=new Fe,N=new Fe;kl.distanceSqToSegment(da.start,da.end,N,M),N.distanceTo(M)<.5*nf&&m.push({point:N,pointOnLine:M,distance:kl.origin.distanceTo(N),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,p){const b=m.projectionMatrix,y=f.material.resolution,x=f.matrixWorld,v=f.geometry,S=v.attributes.instanceStart,M=v.attributes.instanceEnd,N=Math.min(v.instanceCount,S.count),A=-m.near;kl.at(1,Tl),Tl.w=1,Tl.applyMatrix4(m.matrixWorldInverse),Tl.applyMatrix4(b),Tl.multiplyScalar(1/Tl.w),Tl.x*=y.x/2,Tl.y*=y.y/2,Tl.z=0,cj.copy(Tl),uj.multiplyMatrices(m.matrixWorldInverse,x);for(let k=0,C=N;k<C;k++){if(ca.fromBufferAttribute(S,k),ua.fromBufferAttribute(M,k),ca.w=1,ua.w=1,ca.applyMatrix4(uj),ua.applyMatrix4(uj),ca.z>A&&ua.z>A)continue;if(ca.z>A){const O=ca.z-ua.z,q=(ca.z-A)/O;ca.lerp(ua,q)}else if(ua.z>A){const O=ua.z-ca.z,q=(ua.z-A)/O;ua.lerp(ca,q)}ca.applyMatrix4(b),ua.applyMatrix4(b),ca.multiplyScalar(1/ca.w),ua.multiplyScalar(1/ua.w),ca.x*=y.x/2,ca.y*=y.y/2,ua.x*=y.x/2,ua.y*=y.y/2,da.start.copy(ca),da.start.z=0,da.end.copy(ua),da.end.z=0;const D=da.closestPointToPointParameter(cj,!0);da.at(D,f9);const T=qee.lerp(ca.z,ua.z,D),R=T>=-1&&T<=1,U=cj.distanceTo(f9)<.5*nf;if(R&&U){da.start.fromBufferAttribute(S,k),da.end.fromBufferAttribute(M,k),da.start.applyMatrix4(x),da.end.applyMatrix4(x);const O=new Fe,q=new Fe;kl.distanceSqToSegment(da.start,da.end,q,O),p.push({point:q,pointOnLine:O,distance:kl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class I6e extends gN{constructor(e,n,r,i,a=4473924,o=8947848){a=new en(a),o=new en(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Ua;f.setAttribute("position",new ci(c,3)),f.setAttribute("color",new ci(u,3)),super(f,new Wy({vertexColors:!0,toneMapped:!1}))}}function F6e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ua,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 ci(d,3)),u})(t,e,n),a=new gN(i,new m6e({color:new en(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var s0=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 s0.Panel("FPS","#0ff","#002")),c=n(new s0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new s0.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}};s0.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,m=15*o,p=74*o,b=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var x=y.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,m,p,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f,m,p,b),{dom:y,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,m),x.fillStyle=e,x.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(y,f+o,m,p-o,b,f,m,p-o,b),x.fillRect(f+p-o,m,o,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f+p-o,m,o,a((1-v/S)*b))}}};var U6e=s0;class p9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new XS,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 XS,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 z6e extends Ua{constructor(e=[new Fe],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 Fe,o=new Fe,l=new pn,c=[],u=[],d=[],f=[];function m(p){const[b,y,x]=(function(v){const S=e[v],M=new Fe,N=new Fe,A=new Fe,k=new Fe;M.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let C=Number.MAX_VALUE;const D=Math.abs(M.x),T=Math.abs(M.y),R=Math.abs(M.z);return D<=C&&(C=D,N.set(1,0,0)),T<=C&&(C=T,N.set(0,1,0)),R<=C&&N.set(0,0,1),k.crossVectors(M,N).normalize(),N.crossVectors(M,k),A.crossVectors(M,N),[S,N,A]})(p);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,M=Math.sin(S),N=-Math.cos(S);o.x=N*y.x+M*x.x,o.y=N*y.y+M*x.y,o.z=N*y.z+M*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 p=0;p<e.length;p++)m(p);m(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let b=0;b<=i;b++)l.x=p/e.length,l.y=b/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let b=1;b<=i;b++){const y=(i+1)*(p-1)+(b-1),x=(i+1)*p+(b-1),v=(i+1)*p+b,S=(i+1)*(p-1)+b;f.push(y,x,S),f.push(x,v,S)}})()})(),this.setIndex(f),this.setAttribute("position",new ci(c,3)),this.setAttribute("normal",new ci(u,3)),this.setAttribute("uv",new ci(d,2))}}class o0{static get initial(){const e=new o0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const dj={h:0,s:0,l:0};class lg{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=o0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=lg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new en(14737632),this._travelColor=new en(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 YS(this.minLayerThreshold),this.scene=new n6e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new en(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 U6e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new en(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new en(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new en(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,b]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new en(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+dN),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 CR({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new CR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Is(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new yL(this._backgroundColor,m,f),this.resize(),this.controls=new O6e(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 en(r)}else this._extrusionColor=new en(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?lg.defaultExtrusionColor:this._extrusionColor instanceof en?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:lg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new en(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new en(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new en(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new en(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 _6e(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 b6e(13421772,.3*Math.PI),n=new x6e(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 Gb;return n.name=e,n.quaternion.setFromEuler(new Vy(-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=o0.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 oj(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 m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,b={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,b,y,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,b,y))}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(dj),a=new en().setHSL(dj.h,dj.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 I6e(this.buildVolume.x,10,this.buildVolume.y,10));const e=F6e(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 YS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=o0.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,m=r.z;let p=r.r,b=r.i,y=r.j;if(p){const W=d-l,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,G);const J=Math.pow(W,2)+Math.pow(K,2),ie=Math.pow(p,2)-J/4;let re=Math.sqrt(ie/J);(a&&p<0||!a&&p>0)&&(re=-re),b=W/2+K*re,y=K/2-W*re}const x=l==d&&c==f,v=l+b,S=c+y,M=Math.sqrt(b*b+y*y),N=Math.atan2(-y,-b),A=Math.atan2(f-S,d-v);let k;x?k=2*Math.PI:(k=a?N-A:A-N,k<0&&(k+=2*Math.PI));let C=M*k/1.8;this.inches&&(C*=25),C<1&&(C=1);let D=k/C;D*=a?-1:1;const T=[];T.push({x:l,y:c,z:u});const R=(u-m)/C;let U=l,O=c,q=u,j=N;for(let W=0;W<C-1;W++)j+=D,U=v+M*Math.cos(j),O=S+M*Math.sin(j),q+=R,T.push({x:U,y:O,z:q});T.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<T.length-1;W++)o.push(T[W].x,T[W].y,T[W].z,T[W+1].x,T[W+1].y,T[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ua;i.setAttribute("position",new ci(e,3)),this.disposables.push(i);const a=new Wy({color:n});this.disposables.push(a);const o=new gN(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 Fe(l[0],l[1],l[2]),u=new Fe(l[3],l[4],l[5]),d=new Fe(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 z6e(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 pte;this.disposables.push(i);const a=new mte({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new L6e(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=>oj(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 f6e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new u6e(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 oj(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(`
  8187. `),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 p9(this):typeof this.devMode=="object"&&(this.devGui=new p9(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())}}lg.defaultExtrusionColor=new en("hotpink");function B6e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,p]=w.useState(!1),[b,y]=w.useState(0),[x,v]=w.useState(0),S=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const A=i.current,k=A.parentElement?.getBoundingClientRect();k&&(A.width=k.width,A.height=k.height);const C=n&&n.length>1,D=n?.[0]||"#00ae42",T=new lg({canvas:A,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=T,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const O=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=q.exec(U))!==null;){const re=parseInt(j[2],10);re<=15&&O.add(re)}const W=new Map,K=Array.from(O).sort((re,z)=>re-z);K.forEach((re,z)=>{W.set(re,z%8)});const G=[];K.forEach((re,z)=>{const V=n?.[re]||"#00ae42";G[z%8]=V});const J=U.split(`
  8188. `).map(re=>{const z=re.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const V=parseInt(z[2],10);if(V>15)return`; FILTERED: ${re.trim()}`;const Z=W.get(V)??0;return`${z[1]}T${Z}${z[3]||""}`}return re}).join(`
  8189. `);G.length>0&&(T.extrusionColor=G),T.processGCode(J);const ie=T.layers?.length||0;v(ie),y(ie),T.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const R=()=>{if(A.parentElement&&a.current){const U=A.parentElement.getBoundingClientRect();A.width=U.width,A.height=U.height,a.current.resize()}};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const M=w.useCallback(A=>{if(!a.current)return;const k=Math.max(1,Math.min(A,x));y(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=k,a.current.render())})},[x]),N=A=>{M(parseInt(A.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(dt,{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..."})]})}),m&&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(Gde,{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&&!m&&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&&!m&&x>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(al,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>M(b-1),disabled:b<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Lf,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:x,value:b,onChange:N,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>M(b+1),disabled:b>=x,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Ks,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function gte({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{pe.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}${pe.getArchiveForSlicer(t,d)}`;qc(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(Me,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(zr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Wt,{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(Fs,{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(yde,{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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(FIe,{url:a.has_source?pe.getSource3mfDownloadUrl(t):pe.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(B6e,{gcodeUrl:pe.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 g9={"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 $6e(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,m=r/255,p=i/255;a===f?c=((m-p)/d+(m<p?6:0))/6:a===m?c=((p-f)/d+2)/6:c=((f-m)/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 Og(t){const e=t.replace("#","").toLowerCase().substring(0,6);return g9[e]?g9[e]:$6e(t)}function ZS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function qi(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function nh(t,e,n=40){const r=qi(t),i=qi(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function xte(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function bte(t,e,n){return t*4+e}function H6e(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 V6e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function x9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function wL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=ZS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Og(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:xte(n.id,i.id,r),globalTrayId:bte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=ZS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Og(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function b9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=wL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&qi(m.color)===qi(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&nh(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function G6e(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=ZS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Og(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:xte(n.id,i.id,r),globalTrayId:bte(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=ZS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Og(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function yte(t,e,n){const r=G6e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const M=n[d],N=r.find(A=>A.globalTrayId===M);if(N){const A=N.type?.toUpperCase()===u.type?.toUpperCase(),k=qi(N.color)===qi(u.color)||nh(N.color,u.color);let C;return A&&k?C="match":A?C="type_only":C="mismatch",{...u,loaded:N,hasFilament:!0,typeMatch:A,colorMatch:k,status:C,isManual:!0}}}const f=r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&qi(M.color)===qi(u.color)),m=!f&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&nh(M.color,u.color)),p=!f&&!m&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()),b=f||m||p||void 0;b&&c.add(b.globalTrayId);const y=!!b,x=y,v=!!f||!!m;let S;return f||m?S="match":p?S="type_only":S="mismatch",{...u,loaded:b,hasFilament:y,typeMatch:x,colorMatch:v,status:S,isManual:!1}})},[t,r,n]),a=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:a,hasTypeMismatch:o,hasColorMismatch:l}}function W6e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const y=n[d],x=e.find(v=>v.globalTrayId===y);if(x){const v=x.type?.toUpperCase()===u.type?.toUpperCase(),S=qi(x.color)===qi(u.color)||nh(x.color,u.color);v&&S?r++:v?i++:a++;continue}}const f=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&qi(y.color)===qi(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&nh(y.color,u.color)),p=f||m?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),b=f??m??p;b&&o.add(b.globalTrayId),f||m?r++:p?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function q6e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=wL(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&qi(b.color)===qi(c.color)),f=d?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&nh(b.color,c.color)),m=d||f?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),a.push({slot_id:u,globalTrayId:p?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const y9={useDefault:!0,manualMappings:{},autoConfigured:!1};function K6e(t,e,n,r,i,a){const o=gue({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>pe.getPrinterStatus(b),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((b,y)=>{const x=o[y],v=x?.data,M=e?.find(R=>R.id===b)?.name||`Printer ${b}`,N=wL(v),A=i[b]||y9,k=b9(n,v),C=A.useDefault?r:A.manualMappings,D=q6e(n,v,C),T=W6e(n?.filaments,N,C);return{printerId:b,printerName:M,status:v,isLoading:x?.isLoading??!1,loadedFilaments:N,autoMapping:k,finalMapping:D,matchStatus:T.status,exactMatches:T.exactMatches,typeOnlyMatches:T.typeOnlyMatches,missingTypes:T.missingTypes,totalSlots:T.totalSlots,config:A}}),[t,o,e,n,i,r]),c=o.some(b=>b.isLoading),u=(b,y)=>{a(x=>({...x,[b]:{...x[b]||y9,...y}}))},d=b=>{const y=l.find(S=>S.printerId===b);if(!y||!y.status||!n?.filaments)return;const x=b9(n,y.status);if(!x)return;const v={};x.forEach((S,M)=>{S!==-1&&(v[M+1]=S)}),u(b,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const b of t)d(b)},m=b=>l.find(x=>x.printerId===b)?.finalMapping,p=l.every(b=>b.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function X6e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=un(),[i,a]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{a(!0);try{await pe.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(y=>y.globalTrayId===f),p=!0;else{const y=new Set(Object.values(t.config.manualMappings)),x=t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&qi(M.color)===qi(u.color)),v=x?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&nh(M.color,u.color)),S=x||v?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase());m=x??v??S}let b="mismatch";if(m){const y=m.type?.toUpperCase()===u.type?.toUpperCase(),x=qi(m.color)===qi(u.color)||nh(m.color,u.color);y&&x?b="match":y&&(b="type_only")}return{req:u,loaded:m,status:b,isManual:p}});return 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:"Custom slot mapping"}),s.jsxs("button",{type:"button",onClick:l,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:i,children:[s.jsx(Mr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},p)=>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: ${u.type} - ${Og(u.color)}`,children:s.jsx(hP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange:b=>o(u.slot_id||0,b.target.value),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 ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(b=>s.jsxs("option",{value:b.globalTrayId,className:"bg-bambu-dark text-white",children:[b.label,": ",b.type," (",b.colorName,")"]},b.globalTrayId))]}),f==="match"?s.jsx(ws,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Rn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Rn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function Y6e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u}){const d=a?t:t.filter(M=>M.is_active),f=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(d.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(Qi,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const m=M=>{i?e.includes(M)?n(e.filter(N=>N!==M)):n([...e,M]):n([M])},p=()=>{n(d.map(M=>M.id))},b=()=>{n([])},y=(M,N,A)=>{A.stopPropagation(),!(!c||!u)&&(N?c(M):u(M,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},x=M=>e.includes(M),v=e.length,S=M=>o?.find(N=>N.printerId===M);return s.jsxs("div",{className:"space-y-2 mb-6",children:[i&&d.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:v===0?"Select printers":`${v} printer${v!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[v<d.length&&s.jsx("button",{type:"button",onClick:p,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),v>0&&s.jsx("button",{type:"button",onClick:b,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d.map(M=>{const N=x(M.id),A=S(M.id),k=A&&!A.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>m(M.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${N?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${M.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${N?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Br,{className:`w-5 h-5 ${N?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[M.name,!M.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[M.model||"Unknown model"," • ",M.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${N?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:N&&s.jsx(ws,{className:"w-3 h-3 text-white"})})]}),N&&f&&A&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:C=>C.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:k,onChange:C=>y(M.id,C.target.checked,C),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${A.matchStatus==="full"?"text-bambu-green":A.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",A.exactMatches,"/",A.totalSlots," matched)"]}),A.isLoading&&s.jsx(Mr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),k&&s.jsxs("button",{type:"button",onClick:C=>{C.stopPropagation(),c(M.id)},className:"ml-auto 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",children:[s.jsx(Tme,{className:"w-3 h-3"}),"Auto"]})]}),k&&s.jsx(X6e,{printerResult:A,filamentReqs:l.filaments,onUpdateConfig:C=>u(M.id,C)})]})]},M.id)}),v===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(Qi,{className:"w-3 h-3"}),"Select at least one printer"]})]})}function Z6e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(al,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Rn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.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(al,{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:i.name||`Plate ${i.index}`}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${H6e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(ws,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function Q6e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=un(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ut({queryKey:["printer-status",t],queryFn:()=>pe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:b}=yte(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const x=p?"#f97316":b?"#facc15":"#00ae42",v=(M,N)=>{if(M>0)if(N===""){const A={...n};delete A[M],r(A)}else r({...n,[M]:parseInt(N,10)})},S=async()=>{l(!0);try{await pe.refreshPrinterStatus(t),await new Promise(M=>setTimeout(M,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(hP,{className:"w-4 h-4",fill:x,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),p?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):b?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(uu,{className:"w-4 h-4 ml-auto"}):s.jsx(Zi,{className:"w-4 h-4 ml-auto"})]}),c&&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:S,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:o,children:[s.jsx(Mr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((M,N)=>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: ${M.type} - ${Og(M.color)}`,children:s.jsx(hP,{className:"w-3 h-3",fill:M.color,stroke:M.color})}),s.jsxs("span",{className:"text-white truncate",children:[M.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",M.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:M.loaded?.globalTrayId??"",onChange:A=>v(M.slot_id||0,A.target.value),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 ${M.status==="match"?"border-bambu-green/50 text-bambu-green":M.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${M.isManual?"ring-1 ring-blue-400/50":""}`,title:M.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(A=>s.jsxs("option",{value:A.globalTrayId,className:"bg-bambu-dark text-white",children:[A.label,": ",A.type," (",A.colorName,")"]},A.globalTrayId))]}),M.status==="match"?s.jsx(ws,{className:"w-3 h-3 text-bambu-green"}):M.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Rn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Rn,{className:"w-3 h-3 text-orange-400"})})]},N)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const J6e=[{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"}];function e$e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(uE,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(uu,{className:"w-4 h-4 ml-auto"}):s.jsx(Zi,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:J6e.map(({key:o,label:l,desc:c})=>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:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function t$e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return s.jsxs("div",{className:"space-y-4",children:[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 ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[s.jsx(Yn,{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 ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[s.jsx(ti,{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 ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[s.jsx(hK,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="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:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:V6e(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.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:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.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(_u,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="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."})]})}const Pp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},n$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function rh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=un(),{showToast:c}=qn(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,p]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[b,y]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Pp.bed_levelling,flow_cali:i.flow_cali??Pp.flow_cali,vibration_cali:i.vibration_cali??Pp.vibration_cali,layer_inspect:i.layer_inspect??Pp.layer_inspect,timelapse:i.timelapse??Pp.timelapse}:Pp),[x,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $="asap";i.manual_start?$="manual":i.scheduled_time&&!x9(i.scheduled_time)&&($="scheduled");let L="";return i.scheduled_time&&!x9(i.scheduled_time)&&(L=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$,scheduledTime:L,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return n$e}),[S,M]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $={};return i.ams_mapping.forEach((L,X)=>{L!==-1&&($[X+1]=L)}),$}return{}}),[N,A]=w.useState({}),[k]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[C]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[D,T]=w.useState(!1),[R,U]=w.useState({current:0,total:0}),[O,q]=w.useState(new Set),j=d.length,W=d.length>0?d[0]:null,{data:K}=ut({queryKey:["settings"],queryFn:pe.getSettings}),{data:G,isLoading:J}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:ie,isError:re}=ut({queryKey:["archive-plates",e],queryFn:()=>pe.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:z}=ut({queryKey:["library-file-plates",n],queryFn:()=>pe.getLibraryFilePlates(n),enabled:u&&!!n}),V=u?z:ie,{data:Z,isError:ne}=ut({queryKey:["archive-filaments",e,m],queryFn:()=>pe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!V?.is_multi_plate),retry:!1}),{data:he}=ut({queryKey:["library-file-filaments",n,m],queryFn:()=>pe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!V?.is_multi_plate)}),fe=!u&&(re||ne),le=u?he:Z,{data:Ee}=ut({queryKey:["printer-status",W],queryFn:()=>pe.getPrinterStatus(W),enabled:!!W}),{amsMapping:me}=yte(le,Ee,S),we=K6e(d,G,le,S,N,A);w.useEffect(()=>{V?.plates?.length===1&&!m&&p(V.plates[0].index)},[V,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $=G?.filter(L=>L.is_active)||[];$.length===1&&d.length===0&&f([$[0].id])},[t,G,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==C)&&(M({}),A({}),q(new Set)):(M({}),A({}),q(new Set))},[t,d,m,k,C]),w.useEffect(()=>{if(!K?.per_printer_mapping_expanded||d.length<=1)return;const $=d.filter(L=>{if(O.has(L))return!1;const X=we.printerResults.find(xe=>xe.printerId===L);return X&&X.status&&!X.isLoading});$.length>0&&(q(L=>{const X=new Set(L);return $.forEach(xe=>X.add(xe)),X}),$.forEach(L=>{we.autoConfigurePrinter(L)}))},[K?.per_printer_mapping_expanded,d,O,we]),w.useEffect(()=>{const $=L=>{L.key==="Escape"&&!D&&a()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,D]);const De=V?.is_multi_plate??!1,ee=V?.plates??[],Qe=ht({mutationFn:$=>pe.addToQueue($)}),B=ht({mutationFn:$=>pe.updateQueueItem(i.id,$),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$=>{c($.message||"Failed to update queue item","error")}}),te=async $=>{if($?.preventDefault(),d.length===0){c("Please select at least one printer","error");return}T(!0),U({current:0,total:d.length});const L={success:0,failed:0,errors:[]},X=_e=>{if(d.length>1){const ae=N[_e];if(ae&&!ae.useDefault)return we.getFinalMapping(_e)}return me},xe=_e=>({printer_id:_e,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:X(_e),plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():void 0,...b});for(let _e=0;_e<d.length;_e++){const ae=d[_e];U({current:_e+1,total:d.length});try{if(t==="reprint"){const Te=X(ae);u?await pe.printLibraryFile(n,ae,{ams_mapping:Te,...b}):await pe.reprintArchive(e,ae,{plate_id:m??void 0,ams_mapping:Te,...b})}else if(t==="edit-queue-item"&&_e===0){const Te=X(ae),Pe={printer_id:ae,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Te,plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():null,...b};await B.mutateAsync(Pe)}else await Qe.mutateAsync(xe(ae));L.success++}catch(Te){L.failed++;const Pe=G?.find(Xe=>Xe.id===ae)?.name||`Printer ${ae}`;L.errors.push(`${Pe}: ${Te.message}`)}}if(T(!1),L.failed===0){const _e=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";L.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${_e} printer`):c(`Print ${_e} ${L.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else L.success===0?c(`Failed: ${L.errors[0]}`,"error"):(c(`${L.success} succeeded, ${L.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},Y=D||B.isPending,H=w.useMemo(()=>!(Y||d.length===0||!u&&De&&!m),[d.length,De,m,Y,u]),de=(()=>{const $=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Br,submitText:$>1?`Print to ${$} Printers`:"Print",submitIcon:Br,loadingText:R.total>1?`Sending ${R.current}/${R.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:ti,submitText:$>1?`Queue to ${$} Printers`:"Add to Queue",submitIcon:ti,loadingText:R.total>1?`Adding ${R.current}/${R.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Ia,submitText:"Save",submitIcon:Ia,loadingText:R.total>1?`Saving ${R.current}/${R.total}...`:"Saving..."}})(),Ae=de.icon,Le=de.submitIcon,Se=W&&(u||(De?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:D?void 0:a,children:s.jsx(Et,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:s.jsxs(At,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ae,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:de.title})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,disabled:D,children:s.jsx(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:te,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(Z6e,{plates:ee,isMultiPlate:De,selectedPlate:m,onSelect:p}),s.jsx(Y6e,{printers:G||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:J,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:we.printerResults,filamentReqs:le,onAutoConfigurePrinter:we.autoConfigurePrinter,onUpdatePrinterConfig:we.updatePrinterConfig}),fe&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(Qi,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),Se&&!fe&&d.length===1&&s.jsx(Q6e,{printerId:W,filamentReqs:le,manualMappings:S,onManualMappingChange:M,defaultExpanded:K?.per_printer_mapping_expanded??!1}),(t==="reprint"||j>0)&&s.jsx(e$e,{options:b,onChange:y}),t!=="reprint"&&s.jsx(t$e,{options:x,onChange:v}),B.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:B.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:D,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!H,className:"flex-1",children:Y?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),de.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Le,{className:"w-4 h-4"}),de.submitText]})})]})]})]})})})}function r$e({onClose:t,initialFiles:e}){const n=un(),{showToast:r}=qn(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(),[f,m]=w.useState(null);w.useEffect(()=>{const C=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:p}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),b=ht({mutationFn:C=>pe.uploadArchivesBulk(C,u),onSuccess:C=>{m(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(D=>D.map(T=>{const R=C.results.find(O=>O.filename===T.file.name),U=C.errors.find(O=>O.filename===T.file.name);return R?{...T,status:"success",archiveId:R.id}:U?{...T,status:"error",error:U.error}:T})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{o(C=>C.map(D=>({...D,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=w.useCallback(C=>{C.preventDefault(),c(!0)},[]),x=w.useCallback(C=>{C.preventDefault(),c(!1)},[]),v=w.useCallback(C=>{C.preventDefault(),c(!1);const D=Array.from(C.dataTransfer.files).filter(T=>T.name.endsWith(".3mf"));D.length>0&&o(T=>[...T,...D.map(R=>({file:R,status:"pending"}))])},[]),S=w.useCallback(C=>{const D=Array.from(C.target.files||[]).filter(T=>T.name.endsWith(".3mf"));D.length>0&&o(T=>[...T,...D.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),M=w.useCallback(C=>{o(D=>D.filter((T,R)=>R!==C))},[]),N=()=>{if(a.length===0)return;const C=a.filter(D=>D.status==="pending");C.length!==0&&(o(D=>D.map(T=>T.status==="pending"?{...T,status:"uploading"}:T)),b.mutate(C.map(D=>D.file)))},A=a.filter(C=>C.status==="pending").length,k=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(Et,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(At,{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(Wt,{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:y,onDragLeave:x,onDrop:v,children:[s.jsx(oi,{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(Me,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:S})]})}),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:C=>d(C.target.value?Number(C.target.value):void 0),disabled:k,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(C=>s.jsx("option",{value:C.id,children:C.name},C.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((C,D)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(tE,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&s.jsx("button",{onClick:()=>M(D),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Wt,{className:"w-4 h-4"})}),C.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&s.jsx(Gn,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:C.error}),s.jsx(Qi,{className:"w-4 h-4 text-red-400"})]})]},`${C.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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Me,{onClick:N,disabled:A===0||k,className:"flex-1",children:k?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(oi,{className:"w-4 h-4"}),"Upload ",A>0&&`(${A})`]})})]})]})})})}const i$e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],a$e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function vte({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const le=Ee=>{Ee.key==="Escape"&&e()};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[e]);const r=un(),[i,a]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.tags||""),[b,y]=w.useState(t.failure_reason||""),[x,v]=w.useState(t.status),[S,M]=w.useState(t.quantity??1),[N,A]=w.useState(t.photos||[]),[k,C]=w.useState(t.external_url||""),[D,T]=w.useState(!1),[R,U]=w.useState(!1),O=w.useRef(null),q=w.useRef(null),j=w.useRef(null),{data:W}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:K}=ut({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:G}=ut({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,1e3,0),enabled:n.length===0}),J=n.length>0?n:[...new Set(G?.flatMap(le=>le.tags?.split(",").map(Ee=>Ee.trim())||[]).filter(Boolean)||[])].sort(),ie=m.split(",").map(le=>le.trim()).filter(Boolean),re=J.filter(le=>!ie.includes(le)),z=le=>{if(!ie.includes(le)){const Ee=[...ie,le].join(", ");p(Ee)}j.current!==null&&clearTimeout(j.current),O.current?.focus()},V=le=>{const Ee=ie.filter(me=>me!==le).join(", ");p(Ee)},Z=ht({mutationFn:le=>pe.updateArchive(t.id,le),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ne=async le=>{const Ee=le.target.files?.[0];if(Ee){T(!0);try{const me=await pe.uploadArchivePhoto(t.id,Ee);A(me.photos),r.invalidateQueries({queryKey:["archives"]})}catch(me){console.error("Failed to upload photo:",me)}finally{T(!1),q.current&&(q.current.value="")}}},he=async le=>{try{const Ee=await pe.deleteArchivePhoto(t.id,le);A(Ee.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Ee){console.error("Failed to delete photo:",Ee)}},fe=le=>{le.preventDefault();const Ee={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:S,external_url:k||null};x!==t.status&&(Ee.status=x),x==="failed"||x==="aborted"?Ee.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Ee.failure_reason=null),Z.mutate(Ee)};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:le=>le.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(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:fe,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:le=>a(le.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:le=>l(le.target.value?Number(le.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"}),W?.map(le=>s.jsx("option",{value:le.id,children:le.name},le.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(wa,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:le=>u(le.target.value?Number(le.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"}),K?.map(le=>s.jsx("option",{value:le.id,children:le.name},le.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(bhe,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:S,onChange:le=>M(Math.max(1,parseInt(le.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:le=>f(le.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.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Xg,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),s.jsx("input",{type:"url",value:k,onChange:le=>C(le.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:"https://printables.com/model/..."}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Link to Printables, Thingiverse, or other source"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),ie.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ie.map(le=>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(gg,{className:"w-3 h-3"}),le,s.jsx("button",{type:"button",onClick:()=>V(le),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Wt,{className:"w-3 h-3"})})]},le))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:O,type:"text",value:m,onChange:le=>p(le.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),U(!0)},onBlur:()=>{j.current=window.setTimeout(()=>U(!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:ie.length>0?"Add more tags...":"Add tags..."}),R&&re.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:re.map(le=>s.jsx("button",{type:"button",onClick:()=>z(le),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:le},le))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:x,onChange:le=>{v(le.target.value),le.target.value==="completed"&&y("")},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:a$e.map(le=>s.jsx("option",{value:le.value,children:le.label},le.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:le=>y(le.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..."}),i$e.map(le=>s.jsx("option",{value:le,children:le},le))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(fg,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[N.map(le=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:pe.getArchivePhotoUrl(t.id,le),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>he(le),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(fn,{className:"w-3 h-3 text-white"})})]},le)),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:q,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ne,className:"hidden",disabled:D}),D?s.jsx(dt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(Qn,{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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Z.isPending,className:"flex-1",children:[s.jsx(ps,{className:"w-4 h-4"}),Z.isPending?"Saving...":"Save"]})]})]})]})})}function _te({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[a,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,p]=w.useState({});w.useEffect(()=>{const x=M=>{i.current&&!i.current.contains(M.target)&&r()},v=M=>{M.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight,M=8;let N=t,A=e;t+x.width>v-M&&(N=Math.max(M,v-x.width-M)),N<M&&(N=M),e+x.height>S-M&&(A=Math.max(M,S-x.height-M)),A<M&&(A=M);const k=180,C=v-N-x.width,D=N;f(C<k&&D>k),u({x:N,y:A,visible:!0})}},[t,e]);const b=(x,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),M=window.innerHeight,N=300,C=M-S.top-8<N&&S.top>N;p(D=>({...D,[x]:C?"bottom":"top"})),o(x)},y=()=>{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,v)=>{if(x.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=x.submenu&&x.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:M=>S&&b(v,M.currentTarget),onMouseLeave:()=>S&&y(),children:[s.jsxs("button",{onMouseEnter:M=>S&&b(v,M.currentTarget.parentElement),onClick:()=>{S?o(a===v?null:v):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"} ${S&&a===v?"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}),S&&s.jsx(Ks,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===v&&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"} ${m[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:x.submenu.map((M,N)=>s.jsxs("button",{onClick:()=>{M.disabled||(M.onClick(),r())},disabled:M.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${M.disabled?"text-bambu-gray cursor-not-allowed":M.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[M.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:M.icon}),M.label]},N))})]},v)})})}function s$e({selectedIds:t,existingTags:e,onClose:n}){const r=un(),{showToast:i}=qn(),[a,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const y=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=ht({mutationFn:async()=>{const y=Array.from(l);let x=0;for(const v of t)try{const S=await pe.getArchive(v),M=S.tags?S.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let N;u==="add"?N=[...new Set([...M,...y])]:N=M.filter(A=>!l.has(A)),await pe.updateArchive(v,{tags:N.join(", ")}),x++}catch(S){throw console.error(`Failed to update archive ${v}:`,S),new Error(`Failed on archive ${v}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:x,mode:u,tags:y}},onSuccess:({count:y,mode:x,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${x==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),m=y=>{c(x=>{const v=new Set(x);return v.has(y)?v.delete(y):v.add(y),v})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Et,{className:"w-full max-w-md",children:s.jsxs(At,{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(gg,{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(Wt,{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(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Me,{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:y=>o(y.target.value),onKeyDown:b}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(Qn,{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(y=>s.jsx("button",{onClick:()=>m(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),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(y=>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:[y,s.jsx("button",{onClick:()=>m(y),className:"hover:opacity-70",children:s.jsx(Wt,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Me,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gg,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function o$e({selectedIds:t,onClose:e}){const n=un(),{showToast:r}=qn(),{data:i,isLoading:a}=ut({queryKey:["projects"],queryFn:()=>pe.getProjects()});w.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 pe.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.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 pe.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(Et,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(At,{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(wa,{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(Wt,{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(dt,{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(Ya,{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(dt,{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(wa,{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(dt,{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(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function l$e(t,e){return new Date(t,e+1,0).getDate()}function c$e(t,e){return new Date(t,e,1).getDay()}const u$e=["January","February","March","April","May","June","July","August","September","October","November","December"],d$e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function h$e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const A=new Map;return t.forEach(k=>{const C=gi(k.completed_at||k.created_at)||new Date,D=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,T=A.get(D)||[];T.push(k),A.set(D,T)}),A},[t]),p=l$e(o,i),b=c$e(o,i),y=()=>{i===0?(a(11),l(o-1)):a(i-1)},x=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},S=[];for(let A=0;A<b;A++)S.push(null);for(let A=1;A<=p;A++)S.push(A);const M=c?m.get(c)||[]:[],N=A=>{A!==c&&f(null),u(A)};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:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Lf,{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:[u$e[i]," ",o]}),s.jsx("button",{onClick:v,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(Ks,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:d$e.map(A=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:A},A))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((A,k)=>{if(A===null)return s.jsx("div",{className:"aspect-square"},`empty-${k}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(A).padStart(2,"0")}`,D=m.get(C)||[],T=D.length>0,R=A===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=C===c,O=D.filter(j=>j.status==="completed").length,q=D.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>N(U?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${R&&!U?"text-bambu-green":""}`,children:A}),T&&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 ${q>0&&O===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:D.length})]})]},A)})}),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(A=>{const k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.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(A=>{const k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.getFullYear()===o&&A.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(A=>{const k=new Date(A.completed_at||A.created_at);return k.getMonth()===i&&k.getFullYear()===o&&A.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"})}),M.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:M.map(A=>{const k=A.id===d||A.id===n;return s.jsxs("button",{onClick:()=>{f(A.id),e?.(A)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[A.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(A.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:A.print_name||A.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:A.status==="failed"?"text-red-400":"text-green-400",children:A.status==="failed"?"Failed":"Completed"}),A.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:A.filament_color.split(",").map((C,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},D))})]})]})]},A.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 wte({archiveId:t,archiveName:e,onClose:n}){const r=pe.getArchiveQRCodeUrl(t,300);w.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(Wt,{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(Me,{onClick:i,className:"w-full",children:[s.jsx(Ir,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Ste({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.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=pe.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},m=()=>{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:p=>p.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(Me,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Ir,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Me,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(fn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Wt,{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(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Lf,{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(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Ks,{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((p,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:pe.getArchivePhotoUrl(t,p),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},p))})]}),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 fa(t){this.content=t}fa.prototype={constructor:fa,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 fa(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 fa(n)},addToStart:function(t,e){return new fa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new fa(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 fa(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=fa.from(t),t.size?new fa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=fa.from(t),t.size?new fa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=fa.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}};fa.from=function(t){if(t instanceof fa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new fa(e)};function Mte(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=Mte(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Ete(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=Ete(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Nt{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 Nt(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 Nt(r,i)}cutByIndex(e,n){return e==n?Nt.empty:e==0&&n==this.content.length?this:new Nt(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 Nt(i,a)}addToStart(e){return new Nt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Nt(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 Mte(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ete(this,e,n,r)}findIndex(e){if(e==0)return j1(0,e);if(e==this.size)return j1(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?j1(n+1,a):j1(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 Nt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Nt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Nt.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 Nt(n||e,r)}static from(e){if(!e)return Nt.empty;if(e instanceof Nt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Nt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Nt.empty=new Nt([],0);const hj={index:0,offset:0};function j1(t,e){return hj.index=t,hj.offset=e,hj}function QS(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(!QS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!QS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let br=class PR{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&&QS(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 PR.none;if(e instanceof PR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};br.none=[];class JS extends Error{}class Bt{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=Ate(this.content,e+this.openStart,n);return r&&new Bt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Bt(Nte(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 Bt.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 Bt(Nt.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 Bt(e,r,i)}}Bt.empty=new Bt(Nt.empty,0,0);function Nte(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(Nte(a.content,e-i-1,n-i-1)))}function Ate(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=Ate(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function f$e(t,e,n){if(n.openStart>t.depth)throw new JS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new JS("Inconsistent open depths");return Tte(t,e,n,0)}function Tte(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=Tte(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 Cf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=m$e(n,t);return Cf(a,kte(t,o,l,e,r))}else return Cf(a,eM(t,e,r))}function Cte(t,e){if(!e.type.compatibleContent(t.type))throw new JS("Cannot join "+e.type.name+" onto "+t.type.name)}function RR(t,e,n){let r=t.node(n);return Cte(r,e.node(n)),r}function Tf(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 l0(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&&(Tf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Tf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Tf(e.nodeBefore,r)}function Cf(t,e){return t.type.checkContent(e),t.copy(e)}function kte(t,e,n,r,i){let a=t.depth>i&&RR(t,e,i+1),o=r.depth>i&&RR(n,r,i+1),l=[];return l0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Cte(a,o),Tf(Cf(a,kte(t,e,n,r,i+1)),l)):(a&&Tf(Cf(a,eM(t,e,i+1)),l),l0(e,n,i,l),o&&Tf(Cf(o,eM(n,r,i+1)),l)),l0(r,null,i,l),new Nt(l)}function eM(t,e,n){let r=[];if(l0(null,t,n,r),t.depth>n){let i=RR(t,e,n+1);Tf(Cf(i,eM(t,e,n+1)),r)}return l0(e,null,n,r),new Nt(r)}function m$e(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(Nt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ty{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 br.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 tM(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 ty(n,r,a)}static resolveCached(e,n){let r=v9.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 v9.set(e,r=new p$e);let i=r.elts[r.i]=ty.resolve(e,n);return r.i=(r.i+1)%g$e,i}}class p$e{constructor(){this.elts=[],this.i=0}}const g$e=12,v9=new WeakMap;class tM{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 x$e=Object.create(null);let Hd=class DR{constructor(e,n,r,i=br.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Nt.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&&QS(this.attrs,n||e.defaultAttrs||x$e)&&br.sameSet(this.marks,r||br.none)}copy(e=null){return e==this.content?this:new DR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new DR(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 Bt.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 Bt(u,i.depth-o,a.depth-o)}replace(e,n,r){return f$e(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 ty.resolveCached(this,e)}resolveNoCache(e){return ty.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()+")"),jte(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=Nt.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=br.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(!br.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=Nt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Hd.prototype.text=void 0;class nM extends Hd{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):jte(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 nM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nM(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 jte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new b$e(e,n);if(r.next==null)return tm.empty;let i=Pte(r);r.next&&r.err("Unexpected trailing text");let a=E$e(M$e(i));return N$e(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 Nt.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 m=a(f,l.concat(d));if(m)return m}}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(`
  8190. `)}}tm.empty=new tm(!0);class b$e{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 Pte(t){let e=[];do e.push(y$e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function y$e(t){let e=[];do e.push(v$e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function v$e(t){let e=S$e(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=_$e(t,e);else break;return e}function _9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function _$e(t,e){let n=_9(t),r=n;return t.eat(",")&&(t.next!="}"?r=_9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function w$e(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 S$e(t){if(t.eat("(")){let e=Pte(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=w$e(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 M$e(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 Rte(t,e){return e-t}function w9(t,e){let n=[];return r(e),n.sort(Rte);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 E$e(t){let e=Object.create(null);return n(w9(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]);w9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new tm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Rte);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function N$e(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 Dte(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 Ote(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 Lte(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 Ite(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new T$e(t,r,e[r]);return n}let S9=class Fte{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=Ite(e,r.attrs),this.defaultAttrs=Dte(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==tm.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:Ote(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Hd(this,this.computeAttrs(e),Nt.from(n),br.setFrom(r))}createChecked(e=null,n,r){return n=Nt.from(n),this.checkContent(n),new Hd(this,this.computeAttrs(e),n,br.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Nt.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(Nt.empty,!0);return a?new Hd(this,e,n.append(a),br.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){Lte(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:br.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Fte(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 A$e(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 T$e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?A$e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class xN{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Ite(e,i.attrs),this.excluded=null;let a=Dte(this.attrs);this.instance=a?new br(this,a):null}create(e=null){return!e&&this.instance?this.instance:new br(this,Ote(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new xN(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){Lte(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ute{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=fa.from(e.nodes),n.marks=fa.from(e.marks||{}),this.nodes=S9.compile(this.spec.nodes,this),this.marks=xN.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]=tm.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?M9(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==""?[]:M9(this,o.split(" "))}this.nodeFromJSON=i=>Hd.fromJSON(this,i),this.markFromJSON=i=>br.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 S9){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 nM(r,r.defaultAttrs,e,br.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 M9(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 C$e(t){return t.tag!=null}function k$e(t){return t.style!=null}let c0=class OR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(C$e(i))this.tags.push(i);else if(k$e(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 N9(this,n,!1);return r.addAll(e,br.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new N9(this,n,!0);return r.addAll(e,br.none,n.from,n.to),Bt.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(R$e(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=A9(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=A9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new OR(e,OR.schemaRules(e)))}};const zte={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},j$e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bte={ol:!0,ul:!0},ny=1,LR=2,u0=4;function E9(t,e,n){return e!=null?(e?ny:0)|(e==="full"?LR:0):t&&t.whitespace=="pre"?ny|LR:n&~u0}class P1{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=br.none,this.match=a||(o&u0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Nt.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&ny)){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=Nt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Nt.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&&!zte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class N9{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=E9(null,n.preserveWhitespace,0)|(r?u0:0);i?a=new P1(i.type,i.attrs,br.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new P1(null,null,br.none,!0,null,o):a=new P1(e.schema.topNodeType,null,br.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&LR?"full":this.localPreserveWS||(i.options&ny)>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,`
  8191. `);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;Bte.hasOwnProperty(o)&&this.parser.normalizeLists&&P$e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:j$e.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(zte.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(`
  8192. `),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=br.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):T9(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=E9(e,a,o.options);o.options&u0&&o.content.length==0&&(l|=u0);let c=br.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):T9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new P1(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|=ny)}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 P$e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Bte.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function R$e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function A9(t){let e={};for(let n in t)e[n]=t[n];return e}function T9(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 hm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=fj(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}=xw(fj(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&&xw(fj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return xw(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=C9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return C9(e.marks)}}function C9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function fj(t){return t.document||window.document}const k9=new WeakMap;function D$e(t){let e=k9.get(t);return e===void 0&&k9.set(t,e=O$e(t)),e}function O$e(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 xw(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=D$e(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 m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+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 m=e[f];if(m===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:p,contentDOM:b}=xw(t,m,n,r);if(c.appendChild(p),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const $te=65535,Hte=Math.pow(2,16);function L$e(t,e){return t+e*Hte}function j9(t){return t&$te}function I$e(t){return(t-(t&$te))/Hte}const Vte=1,Gte=2,bw=4,Wte=8;class IR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Wte)>0}get deletedBefore(){return(this.delInfo&(Vte|bw))>0}get deletedAfter(){return(this.delInfo&(Gte|bw))>0}get deletedAcross(){return(this.delInfo&bw)>0}}class Bs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Bs.empty)return Bs.empty}recover(e){let n=0,r=j9(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+I$e(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 m=u?e==c?-1:e==f?1:n:n,p=c+i+(m<0?0:d);if(r)return p;let b=e==(n<0?c:f)?null:L$e(l/3,e-c),y=e==c?Gte:e==f?Vte:bw;return(n<0?e!=c:e!=f)&&(y|=Wte),new IR(p,y,b)}i+=d-u}return r?e+i:new IR(e+i,0,null)}touches(e,n){let r=0,i=j9(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 Bs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Bs.empty:new Bs(e<0?[0,-e,0]:[0,0,e])}}Bs.empty=new Bs([]);class ry{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 ry(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 ry;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 IR(e,i,null)}}const mj=Object.create(null);class za{getMap(){return Bs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=mj[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 mj)throw new RangeError("Duplicate use of step JSON ID "+e);return mj[e]=n,n.prototype.jsonID=e,n}}class yi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new yi(e,null)}static fail(e){return new yi(null,e)}static fromReplace(e,n,r,i){try{return yi.ok(e.replace(n,r,i))}catch(a){if(a instanceof JS)return yi.fail(a.message);throw a}}}function SL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(SL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return Nt.fromArray(r)}class jd extends za{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 Bt(SL(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 yi.fromReplace(e,this.from,this.to,a)}invert(){return new tl(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 jd(n.pos,r.pos,this.mark)}merge(e){return e instanceof jd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jd(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 jd(n.from,n.to,e.markFromJSON(n.mark))}}za.jsonID("addMark",jd);class tl extends za{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 Bt(SL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return yi.fromReplace(e,this.from,this.to,r)}invert(){return new jd(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 tl(n.pos,r.pos,this.mark)}merge(e){return e instanceof tl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tl(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 tl(n.from,n.to,e.markFromJSON(n.mark))}}za.jsonID("removeMark",tl);class Pd extends za{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return yi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return yi.fromReplace(e,this.pos,this.pos+1,new Bt(Nt.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 Pd(this.pos,n.marks[i]);return new Pd(this.pos,this.mark)}}return new nm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pd(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 Pd(n.pos,e.markFromJSON(n.mark))}}za.jsonID("addNodeMark",Pd);class nm extends za{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return yi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return yi.fromReplace(e,this.pos,this.pos+1,new Bt(Nt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Pd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nm(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 nm(n.pos,e.markFromJSON(n.mark))}}za.jsonID("removeNodeMark",nm);class Gi extends za{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&FR(e,this.from,this.to)?yi.fail("Structure replace would overwrite content"):yi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Bs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gi(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 Gi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Gi)||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?Bt.empty:new Bt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gi(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?Bt.empty:new Bt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gi(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 Gi(n.from,n.to,Bt.fromJSON(e,n.slice),!!n.structure)}}za.jsonID("replace",Gi);class Xi extends za{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&&(FR(e,this.from,this.gapFrom)||FR(e,this.gapTo,this.to)))return yi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return yi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?yi.fromReplace(e,this.from,this.to,r):yi.fail("Content does not fit in gap")}getMap(){return new Bs([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,Bt.fromJSON(e,n.slice),n.insert,!!n.structure)}}za.jsonID("replaceAround",Xi);function FR(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 F$e(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 m=Math.max(u,e),p=Math.min(u+c.nodeSize,n),b=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(b)||(o&&o.to==m&&o.mark.eq(f[y])?o.to=p:i.push(o=new tl(m,p,f[y])));l&&l.to==m?l.to=p:a.push(l=new jd(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function U$e(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 xN){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],m;for(let p=0;p<i.length;p++){let b=i[p];b.step==a-1&&f.eq(i[p].style)&&(m=b)}m?(m.to=u,m.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new tl(o.from,o.to,o.style)))}function ML(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 Gi(l,d,Bt.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new tl(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,b;for(;m=p.exec(u.text);)b||(b=new Bt(Nt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Gi(l+m.index,l+m.index+m[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(Nt.empty,!0);t.replace(l,l,new Bt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function z$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hx(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||!z$e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function B$e(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=Nt.empty,f=0;for(let b=a,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=Nt.from(r.node(b).copy(d)),f++):c--;let m=Nt.empty,p=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,m=Nt.from(i.node(b).copy(m)),p++):u++;t.step(new Xi(c,u,o,l,new Bt(d.append(m),f,p),d.size-f,!0))}function EL(t,e,n=null,r=t){let i=$$e(t,e),a=i&&H$e(r,e);return a?i.map(P9).concat({type:e,attrs:n}).concat(a.map(P9)):null}function P9(t){return{type:t,attrs:null}}function $$e(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 H$e(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 V$e(t,e,n){let r=Nt.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=Nt.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 Bt(r,0,0),n.length,!0))}function G$e(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)&&W$e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!b?u=!1:!p&&b&&(u=!0)}u===!1&&Kte(t,o,l,a),ML(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new Xi(f,m,f+1,m-1,new Bt(Nt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&qte(t,o,l,a),!1}})}function qte(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 Kte(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(`
  8193. `))}})}function W$e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function q$e(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 Bt(Nt.from(o),0,0),1,!0))}function ou(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),m=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(m,f.childCount),b=r&&r[d+1];b&&(p=p.replaceChild(0,b.type.create(b.attrs)));let y=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!y.type.validContent(p))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 K$e(t,e,n=1,r){let i=t.doc.resolve(e),a=Nt.empty,o=Nt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=Nt.from(i.node(l).copy(a));let d=r&&r[u];o=Nt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Gi(e,e,new Bt(a.append(o),n,n),!0))}function mh(t,e){let n=t.resolve(e),r=n.index();return Xte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function X$e(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 Xte(t,e){return!!(t&&e&&!t.isLeaf&&X$e(t,e))}function bN(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&&Xte(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 Y$e(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);Kte(t,d.node(),d.before(),l)}o.inlineContent&&ML(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 Gi(u,c.map(e+n,-1),Bt.empty,!0)),r===!0){let d=t.doc.resolve(u);qte(t,d.node(),d.before(),t.steps.length)}return t}function Z$e(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 Yte(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 yN(t,e,n=e,r=Bt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Zte(i,a,r)?new Gi(e,n,r):new Q$e(i,a,r).fit()}function Zte(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Q$e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Nt.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=Nt.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 Bt(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 Gi(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=pj(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(Nt.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=pj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Bt(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=pj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Bt(Wb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Bt(Wb(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 y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),x=f.matchType(y.type);if(!x)break;u++,(u>1||c==0||y.content.size)&&(f=x,d.push(Qte(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let b=u==l.childCount;b||(p=-1),this.placed=qb(this.placed,n,Nt.from(d)),this.frontier[n].match=f,b&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=l;y<p;y++){let v=x.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),x=v.content}this.unplaced=b?e==0?Bt.empty:new Bt(Wb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Bt(Wb(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||!gj(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=gj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=gj(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=qb(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=qb(this.placed,this.depth,Nt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Nt.empty,!0);n.childCount&&(this.placed=qb(this.placed,this.frontier.length,n))}}function Wb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Wb(t.firstChild.content,e-1,n)))}function qb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(qb(t.lastChild.content,e-1,n)))}function pj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Qte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Qte(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(Nt.empty,!0)))),t.copy(r)}function gj(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&&!J$e(n,a.content,o)?l:null}function J$e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function eHe(t){return t.spec.defining||t.spec.definingForContent}function tHe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Zte(i,a,r))return t.step(new Gi(e,n,r));let o=ene(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,p=i.pos-1;m>0;m--,p--){let b=i.node(m).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==p&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,p=0;;p++){let b=m.firstChild;if(u.push(b),p==r.openStart)break;m=b.content}for(let m=d-1;m>=0;m--){let p=u[m],b=eHe(p.type);if(b&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(b||!p.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let p=(m+d+1)%(r.openStart+1),b=u[p];if(b)for(let y=0;y<o.length;y++){let x=o[(y+c)%o.length],v=!0;x<0&&(v=!1,x=-x);let S=i.node(x-1),M=i.index(x-1);if(S.canReplaceWith(M,M,b.type,b.marks))return t.replace(i.before(x),v?a.after(x):n,new Bt(Jte(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let p=o[m];p<0||(e=i.before(p),n=a.after(p))}}function Jte(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Jte(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(Nt.empty,!0))}return t}function nHe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Z$e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Bt(Nt.from(r),0,0))}function rHe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=ene(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 ene(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 cg extends za{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 yi.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 yi.fromReplace(e,this.pos,this.pos+1,new Bt(Nt.from(i),0,n.isLeaf?0:1))}getMap(){return Bs.empty}invert(e){return new cg(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 cg(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 cg(n.pos,n.attr,n.value)}}za.jsonID("attr",cg);class iy extends za{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 yi.ok(r)}getMap(){return Bs.empty}invert(e){return new iy(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 iy(n.attr,n.value)}}za.jsonID("docAttr",iy);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 tne{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ry}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}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((a,o,l,c)=>{e=Math.min(e,l),n=Math.max(n,c)})}return e==1e9?null:{from:e,to:n}}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=Bt.empty){let i=yN(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Bt(Nt.from(r),0,0))}delete(e,n){return this.replace(e,n,Bt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return tHe(this,e,n,r),this}replaceRangeWith(e,n,r){return nHe(this,e,n,r),this}deleteRange(e,n){return rHe(this,e,n),this}lift(e,n){return B$e(this,e,n),this}join(e,n=1){return Y$e(this,e,n),this}wrap(e,n){return V$e(this,e,n),this}setBlockType(e,n=e,r,i=null){return G$e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return q$e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new cg(e,n,r)),this}setDocAttribute(e,n){return this.step(new iy(e,n)),this}addNodeMark(e,n){return this.step(new Pd(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 br)n.isInSet(r.marks)&&this.step(new nm(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new nm(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 K$e(this,e,n,r),this}addMark(e,n,r){return F$e(this,e,n,r),this}removeMark(e,n,r){return U$e(this,e,n,r),this}clearIncompatible(e,n,r){return ML(this,e,n,r),this}}const xj=Object.create(null);class En{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new iHe(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=Bt.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?Bt.empty:n),l==0&&O9(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),O9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new mn(e):Bp(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?Bp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Bp(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 qs(e.node(0))}static atStart(e){return Bp(e,e,0,0,1)||new qs(e)}static atEnd(e){return Bp(e,e,e.content.size,e.childCount,-1)||new qs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xj[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 xj)throw new RangeError("Duplicate use of selection JSON ID "+e);return xj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return mn.between(this.$anchor,this.$head).getBookmark()}}En.prototype.visible=!0;class iHe{constructor(e,n){this.$from=e,this.$to=n}}let R9=!1;function D9(t){!R9&&!t.parent.inlineContent&&(R9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class mn extends En{constructor(e,n=e){D9(e),D9(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 En.near(r);let i=e.resolve(n.map(this.anchor));return new mn(i.parent.inlineContent?i:r,r)}replace(e,n=Bt.empty){if(super.replace(e,n),n==Bt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new vN(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 mn(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=En.findFrom(n,r,!0)||En.findFrom(n,-r,!0);if(a)n=a.$head;else return En.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(En.findFrom(e,-r,!0)||En.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new mn(e,n)}}En.jsonID("text",mn);class vN{constructor(e,n){this.anchor=e,this.head=n}map(e){return new vN(e.map(this.anchor),e.map(this.head))}resolve(e){return mn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Jt extends En{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?En.near(a):new Jt(a)}content(){return new Bt(Nt.from(this.node),0,0)}eq(e){return e instanceof Jt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new NL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Jt(e.resolve(n.anchor))}static create(e,n){return new Jt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Jt.prototype.visible=!1;En.jsonID("node",Jt);class NL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new vN(r,r):new NL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Jt.isSelectable(r)?new Jt(n):En.near(n)}}class qs extends En{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Bt.empty){if(n==Bt.empty){e.delete(0,e.doc.content.size);let r=En.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new qs(e)}map(e){return new qs(e)}eq(e){return e instanceof qs}getBookmark(){return aHe}}En.jsonID("all",qs);const aHe={map(){return this},resolve(t){return new qs(t)}};function Bp(t,e,n,r,i,a=!1){if(e.inlineContent)return mn.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&&Jt.isSelectable(l))return Jt.create(t,n-(i<0?l.nodeSize:0))}else{let c=Bp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function O9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Gi||i instanceof Xi))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}const L9=1,R1=2,I9=4;class sHe extends tne{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|L9)&~R1,this.storedMarks=null,this}get selectionSet(){return(this.updated&L9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=R1,this}ensureMarks(e){return br.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&R1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~R1,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)||br.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(En.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|=I9,this}get scrolledIntoView(){return(this.updated&I9)>0}}function F9(t,e){return!e||!t?t:t.bind(e)}class Kb{constructor(e,n,r){this.name=e,this.init=F9(n.init,r),this.apply=F9(n.apply,r)}}const oHe=[new Kb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Kb("selection",{init(t,e){return t.selection||En.atStart(e.doc)},apply(t){return t.selection}}),new Kb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Kb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class bj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=oHe.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 Kb(r.key,r.spec.state,r))})}}class Yp{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 Yp(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 sHe(this)}static create(e){let n=new bj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Yp(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 bj(this.schema,e.plugins),r=n.fields,i=new Yp(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 bj(e.schema,e.plugins),a=new Yp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Hd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=En.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 nne(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=nne(i,e,{})),n[r]=i}return n}class Gr{constructor(e){this.spec=e,this.props={},e.props&&nne(e.props,this,this.props),this.key=e.key?e.key.key:rne("plugin")}getState(e){return e[this.key]}}const yj=Object.create(null);function rne(t){return t in yj?t+"$"+ ++yj[t]:(yj[t]=0,t+"$")}class Li{constructor(e="key"){this.key=rne(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const AL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ine(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ane=(t,e,n)=>{let r=ine(t,n);if(!r)return!1;let i=TL(r);if(!i){let o=r.blockRange(),l=o&&hx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(mne(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Ig(a,"end")||Jt.isSelectable(a)))for(let o=r.depth;;o--){let l=yN(t.doc,r.before(o),r.after(o),Bt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Ig(a,"end")?En.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Jt.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},lHe=(t,e,n)=>{let r=ine(t,n);if(!r)return!1;let i=TL(r);return i?sne(t,i,e):!1},cHe=(t,e,n)=>{let r=lne(t,n);if(!r)return!1;let i=CL(r);return i?sne(t,i,e):!1};function sne(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=yN(t.doc,a,c,Bt.empty);if(!u||u.from!=a||u instanceof Gi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(mn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Ig(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 one=(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=TL(r)}let o=a&&a.nodeBefore;return!o||!Jt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Jt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function TL(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 lne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const cne=(t,e,n)=>{let r=lne(t,n);if(!r)return!1;let i=CL(r);if(!i)return!1;let a=i.nodeAfter;if(mne(t,i,e,1))return!0;if(r.parent.content.size==0&&(Ig(a,"start")||Jt.isSelectable(a))){let o=yN(t.doc,r.before(),r.after(),Bt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ig(a,"start")?En.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Jt.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},une=(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=CL(r)}let o=a&&a.nodeAfter;return!o||!Jt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Jt.create(t.doc,a.pos)).scrollIntoView()),!0)};function CL(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 uHe=(t,e)=>{let n=t.selection,r=n instanceof Jt,i;if(r){if(n.node.isTextblock||!mh(t.doc,n.from))return!1;i=n.from}else if(i=bN(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Jt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},dHe=(t,e)=>{let n=t.selection,r;if(n instanceof Jt){if(n.node.isTextblock||!mh(t.doc,n.to))return!1;r=n.to}else if(r=bN(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},hHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&hx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},dne=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8194. `).scrollIntoView()),!0)};function kL(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 fHe=(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=kL(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(En.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},hne=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof qs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=kL(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(mn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},fne=(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(ou(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function mHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Jt&&e.selection.node.isBlock)return!r.parentOffset||!ou(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 p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=kL(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof mn||e.selection instanceof qs)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=ou(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=ou(d.doc,f,a.length,a)),!m)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),b=d.doc.resolve(p);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 pHe=mHe(),gHe=(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(Jt.create(t.doc,i))),!0)};function xHe(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||mh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function mne(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&xHe(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 p=e.pos+a.nodeSize,b=Nt.empty;for(let v=o.length-1;v>=0;v--)b=Nt.from(o[v].create(null,b));b=Nt.from(i.copy(b));let y=t.tr.step(new Xi(e.pos-1,p,e.pos,p,new Bt(b,1,0),o.length,!0)),x=y.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&mh(y.doc,x.pos)&&y.join(x.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:En.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&hx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Ig(a,"start",!0)&&Ig(i,"end")){let p=i,b=[];for(;b.push(p),!p.isTextblock;)p=p.lastChild;let y=a,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=Nt.empty;for(let M=b.length-1;M>=0;M--)v=Nt.from(b[M].copy(v));let S=t.tr.step(new Xi(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new Bt(v,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function pne(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(mn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const bHe=pne(-1),yHe=pne(1);function vHe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&EL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function U9(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 jL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}jL(AL,ane,one);jL(AL,cne,une);jL(dne,hne,fne,pHe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function _He(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 wHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function wHe(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 tM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new tM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=EL(a,n,r,e);return l?(t&&SHe(t,e,l,i,n),!0):!1}function SHe(t,e,n,r,i){let a=Nt.empty;for(let d=n.length-1;d>=0;d--)a=Nt.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 Bt(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,m=!0;d<f;d++,m=!1)!m&&ou(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function MHe(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?EHe(e,n,t,a):NHe(e,n,a):!0:!1}}function EHe(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 Bt(Nt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new tM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=hx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return mh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function NHe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,b=n.endIndex-1,y=n.startIndex;b>y;b--)p-=i.child(b).nodeSize,r.delete(p-1,p+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?Nt.empty:Nt.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new Xi(f-(l?1:0),m+(c?1:0),f+1,m-1,new Bt((l?Nt.empty:Nt.from(i.copy(Nt.empty))).append(c?Nt.empty:Nt.from(i.copy(Nt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function AHe(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=Nt.from(u?t.create():null),f=new Bt(Nt.from(t.create(null,Nt.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new Xi(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const ba=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Fg=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let UR=null;const Vc=function(t,e,n){let r=UR||(UR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},THe=function(){UR=null},rm=function(t,e,n,r){return n&&(z9(t,e,n,r,-1)||z9(t,e,n,r,1))},CHe=/^(img|br|input|textarea|hr)$/i;function z9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Eo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||qy(t)||CHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=ba(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?Eo(t):0}else return!1}}function Eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function kHe(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=Eo(t)}else if(t.parentNode&&!qy(t))e=ba(t),t=t.parentNode;else return null}}function jHe(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&&!qy(t))e=ba(t)+1,t=t.parentNode;else return null}}function PHe(t,e,n){for(let r=e==0,i=e==Eo(t);r||i;){if(t==n)return!0;let a=ba(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Eo(t)}}function qy(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 _N=function(t){return t.focusNode&&rm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function rf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function RHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function DHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Eo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Eo(r.startContainer),r.startOffset)}}}const ic=typeof navigator<"u"?navigator:null,B9=typeof document<"u"?document:null,ph=ic&&ic.userAgent||"",zR=/Edge\/(\d+)/.exec(ph),gne=/MSIE \d/.exec(ph),BR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ph),_s=!!(gne||BR||zR),Vd=gne?document.documentMode:BR?+BR[1]:zR?+zR[1]:0,Co=!_s&&/gecko\/(\d+)/i.test(ph);Co&&+(/Firefox\/(\d+)/.exec(ph)||[0,0])[1];const $R=!_s&&/Chrome\/(\d+)/.exec(ph),Ki=!!$R,xne=$R?+$R[1]:0,Ma=!_s&&!!ic&&/Apple Computer/.test(ic.vendor),Ug=Ma&&(/Mobile\/\w+/.test(ph)||!!ic&&ic.maxTouchPoints>2),yo=Ug||(ic?/Mac/.test(ic.platform):!1),bne=ic?/Win/.test(ic.platform):!1,eu=/Android \d/.test(ph),Ky=!!B9&&"webkitFontSmoothing"in B9.documentElement.style,OHe=Ky?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function LHe(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 Uc(t,e){return typeof t=="number"?t:t[e]}function IHe(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 $9(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=Fg(o);continue}let l=o,c=l==a.body,u=c?LHe(a):IHe(l),d=0,f=0;if(e.top<u.top+Uc(r,"top")?f=-(u.top-e.top+Uc(i,"top")):e.bottom>u.bottom-Uc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Uc(i,"top")-u.top:e.bottom-u.bottom+Uc(i,"bottom")),e.left<u.left+Uc(r,"left")?d=-(u.left-e.left+Uc(i,"left")):e.right>u.right-Uc(r,"right")&&(d=e.right-u.right+Uc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,b=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-p,x=l.scrollTop-b;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Fg(o)}}function FHe(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:yne(t.dom)}}function yne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Fg(r));return e}function UHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;vne(n,r==0?0:r-e)}function vne(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 Rp=null;function zHe(t){if(t.setActive)return t.setActive();if(Rp)return t.focus(Rp);let e=yne(t);t.focus(Rp==null?{get preventScroll(){return Rp={preventScroll:!0},!0}}:void 0),Rp||(Rp=!1,vne(e,0))}function _ne(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 m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Vc(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let b=m[p];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&y&&(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?BHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:_ne(n,i)}function BHe(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(t,a+1),r.setStart(t,a);let o=fd(r,1);if(o.top!=o.bottom&&PL(e,o)){i={node:t,offset:a+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function PL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function $He(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function HHe(t,e,n){let{node:r,offset:i}=_ne(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 VHe(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 wne(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(PL(e,u))return wne(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function GHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=DHe(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(!PL(e,u)||(o=wne(t.dom,e,u),!o))return null}if(Ma)for(let u=o;r&&u;u=Fg(u))u.draggable&&(r=void 0);if(o=$He(o,e),r){if(Co&&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;Ky&&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=VHe(t,r,i,e))}l==null&&(l=HHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function H9(t){return t.top<t.bottom||t.left<t.right}function fd(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(H9(r))return r}return Array.prototype.find.call(n,H9)||t.getBoundingClientRect()}const WHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Sne(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Ky||Co;if(r.nodeType==3)if(o&&(WHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=fd(Vc(r,i,i),n);if(Co&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=fd(Vc(r,i-1,i-1),-1);if(u.top==c.top){let d=fd(Vc(r,i,i+1),-1);if(d.top!=c.top)return jb(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++,jb(fd(Vc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Eo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return vj(c.getBoundingClientRect(),!1)}if(a==null&&i<Eo(r)){let c=r.childNodes[i];if(c.nodeType==1)return vj(c.getBoundingClientRect(),!0)}return vj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Eo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Vc(c,Eo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return jb(fd(u,1),!1)}if(a==null&&i<Eo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Vc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return jb(fd(u,-1),!0)}return jb(fd(r.nodeType==3?Vc(r):r,-n),n>=0)}function jb(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 vj(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 Mne(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 qHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Mne(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=Sne(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=Vc(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 KHe=/[\u0590-\u08ac]/;function XHe(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?!KHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:Mne(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),x=b&&!p.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),x}):r.pos==r.start()||r.pos==r.end()}let V9=null,G9=null,W9=!1;function YHe(t,e,n){return V9==e&&G9==n?W9:(V9=e,G9=n,W9=n=="up"||n=="down"?qHe(t,e,n):XHe(t,e,n))}const ko=0,q9=1,pf=2,ac=3;class Xy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ko,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>ba(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 Nne){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 Ene&&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?ba(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?ba(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 m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=ba(m.dom)+1;break}e-=m.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=ba(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 p=0,b=0;p<this.children.length;p++){let y=this.children[p],x=b+y.size;if(a>b&&o<x)return y.setSelection(e-b-y.border,n-b-y.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((Co||Ma)&&e==n){let{node:p,offset:b}=l;if(p.nodeType==3){if(f=!!(b&&p.nodeValue[b-1]==`
  8195. `),f&&b==p.nodeValue.length)for(let y=p,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:ba(x)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[b-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Co&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ma)&&rm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&rm(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&Co)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let b=l;l=c,c=b}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}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?pf:q9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=ac:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?pf:ac}r=o}this.dirty=pf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?pf:q9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ene extends Xy{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==ko&&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 ZHe extends Xy{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 im extends Xy{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=hm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new im(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ac||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ac&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ko){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ko}}slice(e,n,r){let i=im.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=VR(a,n,o,r)),e>0&&(a=VR(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 Gd extends Xy{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}=hm.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 m=d;return d=Cne(d,r,n),u?c=new QHe(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new wN(e,n,r,i,d,m,a):new Gd(e,n,r,i,d,f||null,m,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=()=>Nt.empty)}return e}matchesNode(e,n,r){return this.dirty==ko&&e.eq(this.node)&&rM(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 eVe(this,o&&o.node,e);rVe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e,d):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?br.none:this.node.child(d).marks,r,e,d),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e,m);let p;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==pf)&&(o&&this.protectLocalComposition(e,o),Ane(this.contentDOM,this.children,e),Ug&&iVe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof mn)||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=aVe(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 ZHe(this,a,n,i);e.input.compositionNodes.push(o),this.children=VR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==ac||!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=ko}updateOuterDeco(e){if(rM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Tne(this.dom,this.nodeDOM,HR(this.outerDeco,this.node,n),HR(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 K9(t,e,n,r,i){Cne(r,e,t);let a=new Gd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class wN extends Gd{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==ac||this.dirty!=ko&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ko||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=ko,!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 wN(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=ac)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nne extends Xy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ko&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class QHe extends Gd{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==ac)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 Ane(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=X9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof im){let c=r?r.previousSibling:t.lastChild;Ane(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=X9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const d0=function(t){t&&(this.nodeName=t)};d0.prototype=Object.create(null);const gf=[new d0];function HR(t,e,n){if(t.length==0)return gf;let r=n?gf[0]:new d0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new d0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new d0(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 Tne(t,e,n,r){if(n==gf&&r==gf)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=gf[0]),i=c}JHe(i,l||gf[0],o)}return i}function JHe(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 Cne(t,e,n){return Tne(t,t,gf,HR(e,n,t.nodeType!=1))}function rM(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 X9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class eVe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tVe(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,i){let a=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;a<l&&(a==o-1?this.top:this.stack[a+1<<1]).matchesMark(e[a])&&e[a].type.spec.spanning!==!1;)a++;for(;a<o;)this.destroyRest(),this.top.dirty=ko,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let f=this.top.children[d];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){c=d;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=im.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}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==ac&&o.dom==o.contentDOM&&(o.dirty=pf),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 Gd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=ac&&rM(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(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=pf,f.updateChildren(i,o+1),f.dirty=ko),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)||!rM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Gd.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=Gd.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 Ene(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 im;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof wN)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ma||Ki)&&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 Nne(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 tVe(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 im)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 nVe(t,e){return t.type.side-e.type.side}function rVe(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(nVe);for(let x=0;x<f.length;x++)n(f[x],u,!!c)}else n(d,u,!!c);let m,p;if(c)p=-1,m=c,c=null;else if(u<t.childCount)p=u,m=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+m.nodeSize;if(m.isText){let x=b;o<i.length&&i[o].from<x&&(x=i[o].from);for(let v=0;v<l.length;v++)l[v].to<x&&(x=l[v].to);x<b&&(c=m.cut(x-a),m=m.cut(0,x-a),b=x,p=-1)}else for(;o<i.length&&i[o].to<b;)o++;let y=m.isInline&&!m.isLeaf?l.filter(x=>!x.inline):l.slice();r(m,y,e.forChild(a,m),p),a=b}}function iVe(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 aVe(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 VR(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 RL(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(_N(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Jt.isSelectable(f)&&i.parent&&!(f.isInline&&PHe(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new Jt(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let p=0;p<n.rangeCount;p++){let b=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],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=DL(t,d,l,f)}return u}function kne(t){return t.editable?t.hasFocus():Pne(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function lu(t,e=!1){let n=t.state.selection;if(jne(t,n),!!kne(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ki){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&rm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)oVe(t);else{let{anchor:r,head:i}=n,a,o;Y9&&!(n instanceof mn)&&(n.$from.parent.inlineContent||(a=Z9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Z9(t,n.to))),t.docView.setSelection(r,i,t,e),Y9&&(a&&Q9(a),o&&Q9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sVe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Y9=Ma||Ki&&xne<63;function Z9(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(Ma&&i&&i.contentEditable=="false")return _j(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return _j(i);if(a)return _j(a)}}function _j(t){return t.contentEditable="true",Ma&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Q9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function sVe(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(()=>{(!kne(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function oVe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ba(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_s&&Vd<=11&&(n.disabled=!0,n.disabled=!1)}function jne(t,e){if(e instanceof Jt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(J9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else J9(t)}function J9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function DL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||mn.between(e,n,r)}function eW(t){return t.editable&&!t.hasFocus()?!1:Pne(t)}function Pne(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 lVe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return rm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function GR(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&&En.findFrom(a,e)}function bd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function tW(t,e,n){let r=t.state.selection;if(r instanceof mn)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 bd(t,new mn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=GR(t.state,e);return i&&i instanceof Jt?bd(t,i):!1}else if(!(yo&&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?Jt.isSelectable(a)?bd(t,new Jt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Ky?bd(t,new mn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Jt&&r.node.isInline)return bd(t,new mn(e>0?r.$to:r.$from));{let i=GR(t.state,e);return i?bd(t,i):!1}}}function iM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function h0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Dp(t,e){return e<0?cVe(t):uVe(t)}function cVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Co&&n.nodeType==1&&r<iM(n)&&h0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(h0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Rne(n))break;{let l=n.previousSibling;for(;l&&h0(l,-1);)i=n.parentNode,a=ba(l),l=l.previousSibling;if(l)n=l,r=iM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?WR(t,n,r):i&&WR(t,i,a)}function uVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=iM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(h0(l,1))a=n,o=++r;else break}else{if(Rne(n))break;{let l=n.nextSibling;for(;l&&h0(l,1);)a=l.parentNode,o=ba(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=iM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&WR(t,a,o)}function Rne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function dVe(t,e){for(;t&&e==t.childNodes.length&&!qy(t);)e=ba(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 hVe(t,e){for(;t&&!e&&!qy(t);)e=ba(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 WR(t,e,n){if(e.nodeType!=3){let a,o;(o=dVe(e,n))?(e=o,n=0):(a=hVe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(_N(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&&lu(t)},50)}function nW(t,e){let n=t.state.doc.resolve(e);if(!(Ki||bne)&&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 rW(t,e,n){let r=t.state.selection;if(r instanceof mn&&!r.empty||n.indexOf("s")>-1||yo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=GR(t.state,e);if(o&&o instanceof Jt)return bd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof qs?En.near(o,e):En.findFrom(o,e);return l?bd(t,l):!1}return!1}function iW(t,e){if(!(t.state.selection instanceof mn))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 aW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function fVe(t){if(!Ma||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;aW(t,r,"true"),setTimeout(()=>aW(t,r,"false"),20)}return!1}function mVe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function pVe(t,e){let n=e.keyCode,r=mVe(e);if(n==8||yo&&n==72&&r=="c")return iW(t,-1)||Dp(t,-1);if(n==46&&!e.shiftKey||yo&&n==68&&r=="c")return iW(t,1)||Dp(t,1);if(n==13||n==27)return!0;if(n==37||yo&&n==66&&r=="c"){let i=n==37?nW(t,t.state.selection.from)=="ltr"?-1:1:-1;return tW(t,i,r)||Dp(t,i)}else if(n==39||yo&&n==70&&r=="c"){let i=n==39?nW(t,t.state.selection.from)=="ltr"?1:-1:1;return tW(t,i,r)||Dp(t,i)}else{if(n==38||yo&&n==80&&r=="c")return rW(t,-1,r)||Dp(t,-1);if(n==40||yo&&n==78&&r=="c")return fVe(t)||rW(t,1,r)||Dp(t,1);if(r==(yo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function OL(t,e){t.someProp("transformCopied",p=>{e=p(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 p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||hm.fromSchema(t.state.schema),l=Une(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Fne[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let b=l.createElement(d[p]);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 m=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8196. `);return{dom:c,text:m,slice:e}}function Dne(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",m=>{e=m(e,a||r,t)}),a)return l=new Bt(Nt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8197. `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:p}=t.state,b=hm.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=o.appendChild(document.createElement("p"));y&&x.appendChild(b.serializeNode(p.text(y,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=yVe(n),Ky&&vVe(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 m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||c0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!gVe.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=_Ve(sW(l,+d[1],+d[2]),d[4]);else if(l=Bt.maxOpen(xVe(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;m<l.openEnd&&!p.type.spec.isolating;m++,p=p.lastChild);l=sW(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const gVe=/^(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 xVe(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&&Lne(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ine(o[o.length-1],a.length));let d=One(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return Nt.from(o)}return t}function One(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Nt.from(t));return t}function Lne(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Lne(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(Nt.from(One(n,t,i+1))))}}function Ine(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ine(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Nt.empty,!0);return t.copy(n.append(r))}function qR(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=qR(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(Nt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function sW(t,e,n){return e<t.openStart&&(t=new Bt(qR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Bt(qR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Fne={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 oW=null;function Une(){return oW||(oW=document.implementation.createHTMLDocument("title"))}let wj=null;function bVe(t){let e=window.trustedTypes;return e?(wj||(wj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),wj.createHTML(t)):t}function yVe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Une().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Fne[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=bVe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function vVe(t){let e=t.querySelectorAll(Ki?"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 _Ve(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=Nt.from(c.create(r[l+1],i)),a++,o++}return new Bt(i,a,o)}const es={},ts={},wVe={touchstart:!0,touchmove:!0};class SVe{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function MVe(t){for(let e in es){let n=es[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{NVe(t,r)&&!LL(t,r)&&(t.editable||!(r.type in ts))&&n(t,r)},wVe[e]?{passive:!0}:void 0)}Ma&&t.dom.addEventListener("input",()=>null),KR(t)}function Rd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function EVe(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 KR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>LL(t,r))})}function LL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function NVe(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 AVe(t,e){!LL(t,e)&&es[e.type]&&(t.editable||!(e.type in ts))&&es[e.type](t,e)}ts.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Bne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(eu&&Ki&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ug&&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,rf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||pVe(t,n)?n.preventDefault():Rd(t,"key")};ts.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ts.keypress=(t,e)=>{let n=e;if(Bne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||yo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof mn)||!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 SN(t){return{left:t.clientX,top:t.clientY}}function TVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function IL(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 ug(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 CVe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Jt.isSelectable(r)?(ug(t,new Jt(n)),!0):!1}function kVe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Jt&&(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(Jt.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?(ug(t,Jt.create(t.state.doc,i)),!0):!1}function jVe(t,e,n,r,i){return IL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?kVe(t,n):CVe(t,n))}function PVe(t,e,n,r){return IL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function RVe(t,e,n,r){return IL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||DVe(t,n,r)}function DVe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ug(t,mn.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)ug(t,mn.create(r,l+1,l+1+o.content.size));else if(Jt.isSelectable(o))ug(t,Jt.create(r,l));else continue;return!0}}function FL(t){return aM(t)}const zne=yo?"metaKey":"ctrlKey";es.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=FL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&TVe(n,t.input.lastClick)&&!n[zne]&&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(SN(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new OVe(t,o,n,!!r)):(a=="doubleClick"?PVe:RVe)(t,o.pos,o.inside,n)?n.preventDefault():Rd(t,"pointer"))};class OVe{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[zne],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 Jt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Co&&!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)),Rd(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(()=>lu(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(SN(e))),this.updateAllowDefault(e),this.allowDefault||!n?Rd(this.view,"pointer"):jVe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ma&&this.mightDrag&&!this.mightDrag.node.isAtom||Ki&&!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)?(ug(this.view,En.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Rd(this.view,"pointer")}move(e){this.updateAllowDefault(e),Rd(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)}}es.touchstart=t=>{t.input.lastTouch=Date.now(),FL(t),Rd(t,"pointer")};es.touchmove=t=>{t.input.lastTouch=Date.now(),Rd(t,"pointer")};es.contextmenu=t=>FL(t);function Bne(t,e){return t.composing?!0:Ma&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const LVe=eu?5e3:-1;ts.compositionstart=ts.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof mn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ki&&bne&&IVe(t)))t.markCursor=t.state.storedMarks||n.marks(),aM(t,!0),t.markCursor=null;else if(aM(t,!e.selection.empty),Co&&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}$ne(t,LVe)};function IVe(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}ts.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,$ne(t,20))};function $ne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>aM(t),e))}function Hne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=UVe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function FVe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=kHe(e.focusNode,e.focusOffset),r=jHe(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 UVe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function aM(t,e=!1){if(!(eu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Hne(t),e||t.docView&&t.docView.dirty){let n=RL(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 zVe(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 ay=_s&&Vd<15||Ug&&OHe<604;es.copy=ts.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ay?null:n.clipboardData,o=r.content(),{dom:l,text:c}=OL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):zVe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function BVe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $Ve(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?sy(t,r.value,null,i,e):sy(t,r.textContent,r.innerHTML,i,e)},50)}function sy(t,e,n,r,i){let a=Dne(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Bt.empty)))return!0;if(!a)return!1;let o=BVe(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 Vne(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," "):""}ts.paste=(t,e)=>{let n=e;if(t.composing&&!eu)return;let r=ay?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sy(t,Vne(r),r.getData("text/html"),i,n)?n.preventDefault():$Ve(t,n)};class Gne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const HVe=yo?"altKey":"ctrlKey";function Wne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[HVe]}es.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(SN(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Jt?i.to-1:i.to))){if(r&&r.mightDrag)o=Jt.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=Jt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=OL(t,l);(!n.dataTransfer.files.length||!Ki||xne>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ay?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ay||n.dataTransfer.setData("text/plain",u),t.dragging=new Gne(d,Wne(t,n),o)};es.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ts.dragover=ts.dragenter=(t,e)=>e.preventDefault();ts.drop=(t,e)=>{try{VVe(t,e,t.dragging)}finally{t.dragging=null}};function VVe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(SN(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",p=>{a=p(a,t,!1)}):a=Dne(t,Vne(e.dataTransfer),ay?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Wne(t,e));if(t.someProp("handleDrop",p=>p(t,e,a||Bt.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let l=a?Yte(t.state.doc,i.pos,a):i.pos;l==null&&(l=i.pos);let c=t.state.tr;if(o){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),d=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,a.content.firstChild):c.replaceRange(u,u,a),c.doc.eq(f))return;let m=c.doc.resolve(u);if(d&&Jt.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Jt(m));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,x,v)=>p=v),c.setSelection(DL(t,m,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}es.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())&&lu(t)},20))};es.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)};es.beforeinput=(t,e)=>{if(Ki&&eu&&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,rf(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 ts)es[t]=ts[t];function oy(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 sM{constructor(e,n){this.toDOM=e,this.spec=n||kf,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 Ka(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof sM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&oy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Wd{constructor(e,n){this.attrs=e,this.spec=n||kf}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 Ka(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Wd&&oy(this.attrs,e.attrs)&&oy(this.spec,e.spec)}static is(e){return e.type instanceof Wd}destroy(){}}class UL{constructor(e,n){this.attrs=e,this.spec=n||kf}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 Ka(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 UL&&oy(this.attrs,e.attrs)&&oy(this.spec,e.spec)}destroy(){}}class Ka{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ka(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 Ka(e,e,new sM(n,r))}static inline(e,n,r,i){return new Ka(e,n,new Wd(r,i))}static node(e,n,r,i){return new Ka(e,n,new UL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Wd}get widget(){return this.type instanceof sM}}const $p=[],kf={};class Ur{constructor(e,n){this.local=e.length?e:$p,this.children=n.length?n:$p}static create(e,n){return n.length?oM(n,e,0,kf):Pa}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==Pa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||kf)}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?GVe(this.children,o||[],e,n,r,i,a):o?new Ur(o.sort(jf),$p):Pa}add(e,n){return n.length?this==Pa?Ur.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=Kne(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,oM(d,l,u+1,kf)),a+=3}});let o=qne(a?Xne(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Ur(o.length?this.local.concat(o).sort(jf):this.local,i||this.children)}remove(e){return e.length==0||this==Pa?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!=Pa?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 Ur(i,r):Pa}forChild(e,n){if(this==Pa)return this;if(n.isLeaf)return Ur.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 Wd){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 Ur(i.sort(jf),$p);return r?new Md([l,r]):l}return r||Pa}eq(e){if(this==e)return!0;if(!(e instanceof Ur)||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 zL(this.localsInner(e))}localsInner(e){if(this==Pa)return $p;if(e.inlineContent||!this.local.some(Wd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Wd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Ur.empty=new Ur([],[]);Ur.removeOverlap=zL;const Pa=Ur.empty;class Md{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,kf));return Md.from(r)}forChild(e,n){if(n.isLeaf)return Ur.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Pa&&(a instanceof Md?r=r.concat(a.members):r.push(a))}return Md.from(r)}eq(e){if(!(e instanceof Md)||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?zL(r?n:n.sort(jf)):$p}static from(e){switch(e.length){case 0:return Pa;case 1:return e[0];default:return new Md(e.every(n=>n instanceof Ur)?e:e.reduce((n,r)=>n.concat(r instanceof Ur?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function GVe(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((m,p,b,y)=>{let x=y-b-(p-m);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||m>S+d-f)continue;let M=l[v]+d-f;p>=M?l[v+1]=m<=M?-2:-1:m>=d&&x&&(l[v]+=x,l[v+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 m=n.map(t[u+1]+a,-1),p=m-i,{index:b,offset:y}=r.content.findIndex(f),x=r.maybeChild(b);if(x&&y==f&&y+x.nodeSize==p){let v=l[u+2].mapInner(n,x,d+1,t[u]+a+1,o);v!=Pa?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=WVe(l,t,e,n,i,a,o),d=oM(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,m=0;f<d.children.length;f+=3){let p=d.children[f];for(;m<l.length&&l[m]<p;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Ur(e.sort(jf),l)}function qne(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 Ka(i.from+e,i.to+e,i.type))}return n}function WVe(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 Kne(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 Xne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function oM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Kne(t,l,c+n);if(u){a=!0;let d=oM(u,l,n+c+1,r);d!=Pa&&i.push(c,c+l.nodeSize,d)}});let o=qne(a?Xne(t):t,-n).sort(jf);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 Ur(o,i):Pa}function jf(t,e){return t.from-e.from||t.to-e.to}function zL(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),lW(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),lW(e,i,r.copy(a.from,r.to)));break}}}return e}function lW(t,e,n){for(;e<t.length&&jf(n,t[e])>0;)e++;t.splice(e,0,n)}function Sj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Pa&&e.push(r)}),t.cursorWrapper&&e.push(Ur.create(t.state.doc,[t.cursorWrapper.deco])),Md.from(e)}const qVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},KVe=_s&&Vd<=11;class XVe{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 YVe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new XVe,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]);_s&&Vd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ma&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),KVe&&(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,qVe)),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(eW(this.view)){if(this.suppressingSelectionUpdates)return lu(this.view);if(_s&&Vd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rm(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=Fg(a))n.add(a);for(let a=e.anchorNode;a;a=Fg(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)&&eW(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(Co&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||JVe(e,f)!=p)&&m.remove()}}}else if((Ki||Ma)&&c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let f=d.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&d.parentNode.removeChild(d)}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&_N(r)&&(u=RL(e))&&u.eq(En.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,lu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),ZVe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,eGe(e,c)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||lu(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(_s&&Vd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let o=i&&i.parentNode==e.target?ba(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?ba(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 cW=new WeakMap,uW=!1;function ZVe(t){if(!cW.has(t)&&(cW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Co,uW)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."),uW=!0}}function dW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return rm(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function QVe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return dW(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?dW(t,n):null}function JVe(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 eGe(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let a of e)if(((n=a.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=a.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(a,l.firstChild),r==a&&t.domSelection().collapse(a,i)}else a.parentNode.removeChild(a)}}function tGe(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}],_N(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ki&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let v=r.childNodes[x-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){a=x;break}if(!S||S.size)break}let f=t.state.doc,m=t.someProp("domParser")||c0.fromSchema(t.state.schema),p=f.resolve(o),b=null,y=m.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:nGe,context:p});if(u&&u[0].pos!=null){let x=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=x),b={anchor:x+o,head:v+o}}return{doc:y,sel:b,from:o,to:l}}function nGe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ma&&/^(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||Ma&&/^(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 rGe=/^(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 iGe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=RL(t,C);if(D&&!t.state.selection.eq(D)){if(Ki&&eu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,rf(13,"Enter"))))return;let T=t.state.tr.setSelection(D);C=="pointer"?T.setMeta("pointer",!0):C=="key"&&T.scrollIntoView(),a&&T.setMeta("composition",a),t.dispatch(T)}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=tGe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,p="end"):(m=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let b=oGe(f.content,u.doc.content,u.from,m,p);if(b&&t.input.domChangeCount++,(Ug&&t.input.lastIOSEnter>Date.now()-225||eu)&&i.some(C=>C.nodeType==1&&!rGe.test(C.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",C=>C(t,rf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof mn&&!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 C=hW(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let D=t.state.tr.setSelection(C);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 mn&&(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)),_s&&Vd<=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 y=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),v=d.resolve(b.start),S=y.sameParent(x)&&y.parent.inlineContent&&v.end()>=b.endA;if((Ug&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!S&&y.pos<u.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(u.doc.textBetween(y.pos,x.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,rf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&sGe(d,b.start,b.endA,y,x)&&t.someProp("handleKeyDown",C=>C(t,rf(8,"Backspace")))){eu&&Ki&&t.domObserver.suppressSelectionUpdates();return}Ki&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),eu&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.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(C){return C(t,rf(13,"Enter"))})},20));let M=b.start,N=b.endA,A=C=>{let D=C||t.state.tr.replace(M,N,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let T=hW(t,D.doc,u.sel);T&&!(Ki&&t.composing&&T.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==M||T.head==D.mapping.map(N)-1)||_s&&T.empty&&T.head==M)&&D.setSelection(T)}return a&&D.setMeta("composition",a),D.scrollIntoView()},k;if(S)if(y.pos==x.pos){_s&&Vd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>lu(t),20));let C=A(t.state.tr.delete(M,N)),D=d.resolve(b.start).marksAcross(d.resolve(b.endA));D&&C.ensureMarks(D),t.dispatch(C)}else if(b.endA==b.endB&&(k=aGe(y.parent.content.cut(y.parentOffset,x.parentOffset),v.parent.content.cut(v.parentOffset,b.endA-v.start())))){let C=A(t.state.tr);k.type=="add"?C.addMark(M,N,k.mark):C.removeMark(M,N,k.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,x.parentOffset),D=()=>A(t.state.tr.insertText(C,M,N));t.someProp("handleTextInput",T=>T(t,M,N,C,D))||t.dispatch(D())}else t.dispatch(A());else t.dispatch(A())}function hW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:DL(t,e.resolve(n.anchor),e.resolve(n.head))}function aGe(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(Nt.from(u).eq(t))return{mark:l,type:o}}function sGe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Mj(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(Mj(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Mj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Mj(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 oGe(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&&fW(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&&fW(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function fW(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 Yne{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 SVe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(bW),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=gW(this),pW(this),this.nodeViews=xW(this),this.docView=K9(this.state.doc,mW(this),Sj(this),this.dom,this),this.domObserver=new YVe(this,(r,i,a,o)=>iGe(this,r,i,a,o)),this.domObserver.start(),MVe(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&&KR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bW),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&&(Hne(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 p=xW(this);cGe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&KR(this),this.editable=gW(this),pW(this);let c=Sj(this),u=mW(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 m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&FHe(this);if(o){this.domObserver.stop();let p=f&&(_s||Ki)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&lGe(i.selection,e.selection);if(f){let b=Ki?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=FVe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=K9(e.doc,u,c,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lVe(this))?lu(this,p):(jne(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():m&&UHe(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Jt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&$9(this,n.getBoundingClientRect(),e)}else $9(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 Gne(e.slice,e.move,i<0?void 0:Jt.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(_s){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&&zHe(this.dom),lu(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 GHe(this,e)}coordsAtPos(e,n=1){return Sne(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 YHe(this,n||this.state,e)}pasteHTML(e,n){return sy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return sy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return OL(this,e)}destroy(){this.docView&&(EVe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Sj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,THe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return AVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ma&&this.root.nodeType===11&&RHe(this.dom.ownerDocument)==this.dom&&QVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Yne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function mW(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"),[Ka.node(0,t.state.doc.content.size,e)]}function pW(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:Ka.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function gW(t){return!t.someProp("editable",e=>e(t.state)===!1)}function lGe(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 xW(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 cGe(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 bW(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 ih={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:"'"},lM={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uGe=typeof navigator<"u"&&/Mac/.test(navigator.platform),dGe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ya=0;ya<10;ya++)ih[48+ya]=ih[96+ya]=String(ya);for(var ya=1;ya<=24;ya++)ih[ya+111]="F"+ya;for(var ya=65;ya<=90;ya++)ih[ya]=String.fromCharCode(ya+32),lM[ya]=String.fromCharCode(ya);for(var Ej in ih)lM.hasOwnProperty(Ej)||(lM[Ej]=ih[Ej]);function hGe(t){var e=uGe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dGe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?lM:ih)[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 fGe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),mGe=typeof navigator<"u"&&/Win/.test(navigator.platform);function pGe(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))fGe?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 gGe(t){let e=Object.create(null);for(let n in t)e[pGe(n)]=t[n];return e}function Nj(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 xGe(t){return new Gr({props:{handleKeyDown:Zne(t)}})}function Zne(t){let e=gGe(t);return function(n,r){let i=hGe(r),a,o=e[Nj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Nj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(mGe&&r.ctrlKey&&r.altKey)&&(a=ih[r.keyCode])&&a!=i){let l=e[Nj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var bGe=Object.defineProperty,BL=(t,e)=>{for(var n in e)bGe(t,n,{get:e[n],enumerable:!0})};function MN(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 EN=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,m])=>[f,(...b)=>{const y=this.buildProps(c,e),x=m(...b)(y);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:MN({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}},Qne={};BL(Qne,{blur:()=>yGe,clearContent:()=>vGe,clearNodes:()=>_Ge,command:()=>wGe,createParagraphNear:()=>SGe,cut:()=>MGe,deleteCurrentNode:()=>EGe,deleteNode:()=>NGe,deleteRange:()=>AGe,deleteSelection:()=>TGe,enter:()=>CGe,exitCode:()=>kGe,extendMarkRange:()=>jGe,first:()=>PGe,focus:()=>DGe,forEach:()=>OGe,insertContent:()=>LGe,insertContentAt:()=>UGe,joinBackward:()=>$Ge,joinDown:()=>BGe,joinForward:()=>HGe,joinItemBackward:()=>VGe,joinItemForward:()=>GGe,joinTextblockBackward:()=>WGe,joinTextblockForward:()=>qGe,joinUp:()=>zGe,keyboardShortcut:()=>XGe,lift:()=>YGe,liftEmptyBlock:()=>ZGe,liftListItem:()=>QGe,newlineInCode:()=>JGe,resetAttributes:()=>e7e,scrollIntoView:()=>t7e,selectAll:()=>n7e,selectNodeBackward:()=>r7e,selectNodeForward:()=>i7e,selectParentNode:()=>a7e,selectTextblockEnd:()=>s7e,selectTextblockStart:()=>o7e,setContent:()=>l7e,setMark:()=>T7e,setMeta:()=>C7e,setNode:()=>k7e,setNodeSelection:()=>j7e,setTextDirection:()=>P7e,setTextSelection:()=>R7e,sinkListItem:()=>D7e,splitBlock:()=>O7e,splitListItem:()=>L7e,toggleList:()=>I7e,toggleMark:()=>F7e,toggleNode:()=>U7e,toggleWrap:()=>z7e,undoInputRule:()=>B7e,unsetAllMarks:()=>$7e,unsetMark:()=>H7e,unsetTextDirection:()=>V7e,updateAttributes:()=>G7e,wrapIn:()=>W7e,wrapInList:()=>q7e});var yGe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),vGe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),_Ge=()=>({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)),m=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(m);if(!p)return;const b=hx(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(b||b===0)&&e.lift(p,b)})}),!0},wGe=t=>e=>t(e),SGe=()=>({state:t,dispatch:e})=>hne(t,e),MGe=(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 mn(r.doc.resolve(Math.max(o-1,0)))),!0},EGe=()=>({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 _i(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 NGe=t=>({tr:e,state:n,dispatch:r})=>{const i=_i(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},AGe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},TGe=()=>({state:t,dispatch:e})=>AL(t,e),CGe=()=>({commands:t})=>t.keyboardShortcut("Enter"),kGe=()=>({state:t,dispatch:e})=>fHe(t,e);function $L(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function cM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:$L(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Jne(t,e,n={}){return t.find(r=>r.type===e&&cM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function yW(t,e,n={}){return!!Jne(t,e,n)}function HL(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),!Jne([...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&&yW([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&yW([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Au(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 jGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Au(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=HL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=mn.create(o,f.from,f.to);n.setSelection(m)}}return!0},PGe=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 ere(t){return t instanceof mn}function xf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function tre(t,e=null){if(!e)return null;const n=En.atStart(t),r=En.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?mn.create(t,xf(0,i,a),xf(t.content.size,i,a)):mn.create(t,xf(e,i,a),xf(e,i,a))}function vW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function uM(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function RGe(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var DGe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(uM()||vW())&&r.dom.focus(),RGe()&&!uM()&&!vW()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!ere(n.state.selection))return o(),!0;const l=tre(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},OGe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),LGe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),nre=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&&nre(r)}return t};function D1(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 nre(n)}function ly(t,e,n){if(t instanceof Hd||t instanceof Nt)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 Nt.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),ly("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Ute({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?c0.fromSchema(c).parseSlice(D1(t),n.parseOptions):c0.fromSchema(c).parse(D1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=c0.fromSchema(e);return n.slice?a.parseSlice(D1(t),n.parseOptions).content:a.parse(D1(t),n.parseOptions)}return ly("",e,n)}function IGe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Gi||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(En.near(t.doc.resolve(o),n))}var FGe=t=>!("type"in t),UGe=(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{ly(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=ly(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},m=!0,p=!0;if((FGe(l)?l:[l]).forEach(x=>{x.check(),m=m?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),d===f&&p){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,f+=1)}let y;if(m){if(Array.isArray(e))y=e.map(x=>x.text||"").join("");else if(e instanceof Nt){let x="";e.forEach(v=>{v.text&&(x+=v.text)}),y=x}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const x=r.doc.resolve(d),v=x.node(),S=x.parentOffset===0,M=v.isText||v.isTextblock,N=v.content.size>0;S&&M&&N&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&IGe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},zGe=()=>({state:t,dispatch:e})=>uHe(t,e),BGe=()=>({state:t,dispatch:e})=>dHe(t,e),$Ge=()=>({state:t,dispatch:e})=>ane(t,e),HGe=()=>({state:t,dispatch:e})=>cne(t,e),VGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bN(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},GGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bN(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},WGe=()=>({state:t,dispatch:e})=>lHe(t,e),qGe=()=>({state:t,dispatch:e})=>cHe(t,e);function rre(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function KGe(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))uM()||rre()?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 XGe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=KGe(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 ah(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?_i(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const p=Math.max(r,m),b=Math.min(i,m+f.nodeSize);l.push({node:f,from:p,to:b})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>cM(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var YGe=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return ah(n,i,e)?hHe(n,r):!1},ZGe=()=>({state:t,dispatch:e})=>fne(t,e),QGe=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return MHe(r)(e,n)},JGe=()=>({state:t,dispatch:e})=>dne(t,e);function NN(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function _W(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 e7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=NN(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=Au(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,_W(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(_W(m.attrs,e))))})})}),c},t7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),n7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new qs(t.doc);t.setSelection(n)}return!0},r7e=()=>({state:t,dispatch:e})=>one(t,e),i7e=()=>({state:t,dispatch:e})=>une(t,e),a7e=()=>({state:t,dispatch:e})=>gHe(t,e),s7e=()=>({state:t,dispatch:e})=>yHe(t,e),o7e=()=>({state:t,dispatch:e})=>bHe(t,e);function XR(t,e,n={},r={}){return ly(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var l7e=(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=XR(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 ire(t,e){const n=Au(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 are(t,e){const n=new tne(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function c7e(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 u7e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function d7e(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 AN(t){return e=>d7e(e.$from,t)}function Zt(t,e,n){return t.config[e]===void 0&&t.parent?Zt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Zt(t.parent,e,n):null}):t.config[e]}function VL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Zt(e,"addExtensions",n);return r?[e,...VL(r())]:e}).flat(10)}function GL(t,e){const n=hm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function sre(t){return typeof t=="function"}function ir(t,e=void 0,...n){return sre(t)?e?t.bind(e)(...n):t(...n):t}function h7e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function zg(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 ore(t){const e=[],{nodeExtensions:n,markExtensions:r}=zg(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=Zt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,p])=>{e.push({type:f,name:m,attribute:{...a,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Zt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...a,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function ri(...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,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function cy(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)=>ri(n,r),{})}function f7e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function wW(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):f7e(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function SW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&h7e(n)?!1:n!=null))}function MW(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 m7e(t,e){var n;const r=ore(t),{nodeExtensions:i,markExtensions:a}=zg(t),o=(n=i.find(u=>Zt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((v,S)=>{const M=Zt(S,"extendNodeSchema",f);return{...v,...M?M(u):{}}},{}),p=SW({...m,content:ir(Zt(u,"content",f)),marks:ir(Zt(u,"marks",f)),group:ir(Zt(u,"group",f)),inline:ir(Zt(u,"inline",f)),atom:ir(Zt(u,"atom",f)),selectable:ir(Zt(u,"selectable",f)),draggable:ir(Zt(u,"draggable",f)),code:ir(Zt(u,"code",f)),whitespace:ir(Zt(u,"whitespace",f)),linebreakReplacement:ir(Zt(u,"linebreakReplacement",f)),defining:ir(Zt(u,"defining",f)),isolating:ir(Zt(u,"isolating",f)),attrs:Object.fromEntries(d.map(MW))}),b=ir(Zt(u,"parseHTML",f));b&&(p.parseDOM=b.map(v=>wW(v,d)));const y=Zt(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:cy(v,d)}));const x=Zt(u,"renderText",f);return x&&(p.toText=x),[u.name,p]})),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},m=t.reduce((x,v)=>{const S=Zt(v,"extendMarkSchema",f);return{...x,...S?S(u):{}}},{}),p=SW({...m,inclusive:ir(Zt(u,"inclusive",f)),excludes:ir(Zt(u,"excludes",f)),group:ir(Zt(u,"group",f)),spanning:ir(Zt(u,"spanning",f)),code:ir(Zt(u,"code",f)),attrs:Object.fromEntries(d.map(MW))}),b=ir(Zt(u,"parseHTML",f));b&&(p.parseDOM=b.map(x=>wW(x,d)));const y=Zt(u,"renderHTML",f);return y&&(p.toDOM=x=>y({mark:x,HTMLAttributes:cy(x,d)})),[u.name,p]}));return new Ute({topNode:o,nodes:l,marks:c})}function p7e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function dM(t){return t.sort((n,r)=>{const i=Zt(n,"priority")||100,a=Zt(r,"priority")||100;return i>a?-1:i<a?1:0})}function lre(t){const e=dM(VL(t)),n=p7e(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 cre(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8198. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=a);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function g7e(t,e){const n={from:0,to:t.content.size};return cre(t,n,e)}function ure(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function x7e(t,e){const n=_i(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 dre(t,e){const n=NN(typeof e=="string"?e:e.name,t.schema);return n==="node"?x7e(t,e):n==="mark"?ire(t,e):{}}function b7e(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 y7e(t){const e=b7e(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 hre(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),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),y7e(r)}function WL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=HL(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 v7e=(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 O1(t,e){return e.nodes[t]||e.marks[t]||null}function yw(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 _7e=(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 YR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Au(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>cM(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const p=f.pos,b=m.pos;t.doc.nodesBetween(p,b,(y,x)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(p,x),S=Math.min(b,x+y.nodeSize),M=S-v;o+=M,l.push(...y.marks.map(N=>({mark:N,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>cM(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function w7e(t,e,n={}){if(!e)return ah(t,null,n)||YR(t,null,n);const r=NN(e,t.schema);return r==="node"?ah(t,e,n):r==="mark"?YR(t,e,n):!1}var S7e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=AN(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)},M7e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function EW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function NW(t,e){const{nodeExtensions:n}=zg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=ir(Zt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function TN(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&&(TN(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function fre(t){return t instanceof Jt}var mre=class pre{constructor(e){this.position=e}static fromJSON(e){return new pre(e.position)}toJSON(){return{position:this.position}}};function E7e(t,e){const n=e.mapping.mapResult(t.position);return{position:new mre(n.pos),mapResult:n}}function N7e(t){return new mre(t)}function A7e(t,e,n){var r;const{selection:i}=e;let a=null;if(ere(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,m)=>{if(u)return!1;if(d.isInline){const p=!m||m.type.allowsMarkType(n),b=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=p&&b}return!u}),u})}var T7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Au(t,r.schema);if(i)if(o){const u=ire(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,(m,p)=>{const b=Math.max(p,d),y=Math.min(p+m.nodeSize,f);m.marks.find(v=>v.type===c)?m.marks.forEach(v=>{c===v.type&&n.addMark(b,y,c.create({...v.attrs,...e}))}):n.addMark(b,y,c.create(e))})});return A7e(r,n,c)},C7e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),k7e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=_i(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})=>U9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>U9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},j7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=xf(t,0,r.content.size),a=Jt.create(r,i);e.setSelection(a)}return!0},P7e=(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},R7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=mn.atStart(r).from,l=mn.atEnd(r).to,c=xf(i,o,l),u=xf(a,o,l),d=mn.create(r,c,u);e.setSelection(d)}return!0},D7e=t=>({state:e,dispatch:n})=>{const r=_i(t,e.schema);return AHe(r)(e,n)};function AW(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 O7e=({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=yw(u,l.node().type.name,l.node().attrs);if(a instanceof Jt&&a.node.isBlock)return!l.parentOffset||!ou(o,l.pos)?!1:(r&&(t&&AW(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:c7e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,b=ou(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&ou(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(b=!0,p=m?[{type:m,attrs:d}]:void 0),r){if(b&&(a instanceof mn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const y=e.mapping.map(l.before()),x=e.doc.resolve(y);l.node(-1).canReplaceWith(x.index(),x.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&AW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},L7e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=_i(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 m=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 v=Nt.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-S;D>=c.depth-3;D-=1)v=Nt.from(c.node(D).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,N={...yw(m,c.node().type.name,c.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(N))||void 0;v=v.append(Nt.from(l.createAndFill(null,A)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new Bt(v,4-S,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,T)=>{if(C>-1)return!1;D.isTextblock&&D.content.size===0&&(C=T+1)}),C>-1&&n.setSelection(mn.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...yw(m,f.type.name,f.attrs),...e},y={...yw(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const x=p?[{type:l,attrs:b},{type:p,attrs:y}]:[{type:l,attrs:b}];if(!ou(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=a.extensionManager,N=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!N||!i)return!0;const A=N.filter(k=>M.includes(k.type.name));n.ensureMarks(A)}return!0},Aj=(t,e)=>{const n=AN(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&&mh(t.doc,n.pos)&&t.join(n.pos),!0},Tj=(t,e)=>{const n=AN(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&&mh(t.doc,r)&&t.join(r),!0},I7e=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,p=_i(t,o.schema),b=_i(e,o.schema),{selection:y,storedMarks:x}=o,{$from:v,$to:S}=y,M=v.blockRange(S),N=x||y.$to.parentOffset&&y.$from.marks();if(!M)return!1;const A=AN(k=>NW(k.type.name,f))(y);if(M.depth>=1&&A&&M.depth-A.depth<=1){if(A.node.type===p)return u.liftListItem(b);if(NW(A.node.type.name,f)&&p.validContent(A.node.content)&&l)return c().command(()=>(a.setNodeMarkup(A.pos,p),!0)).command(()=>Aj(a,p)).command(()=>Tj(a,p)).run()}return!n||!N||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Aj(a,p)).command(()=>Tj(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),C=N.filter(D=>m.includes(D.type.name));return a.ensureMarks(C),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Aj(a,p)).command(()=>Tj(a,p)).run()},F7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Au(t,r.schema);return YR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},U7e=(t,e,n={})=>({state:r,commands:i})=>{const a=_i(t,r.schema),o=_i(e,r.schema),l=ah(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})},z7e=(t,e={})=>({state:n,commands:r})=>{const i=_i(t,n.schema);return ah(n,i,e)?r.lift(i):r.wrapIn(i,e)},B7e=()=>({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},$7e=()=>({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},H7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Au(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:p}=l;const b=(a=u.marks().find(x=>x.type===c))==null?void 0:a.attrs,y=HL(u,c,b);y&&(m=y.from,p=y.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},V7e=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},G7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=NN(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=_i(t,r.schema)),l==="mark"&&(o=Au(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,p,b,y;n.selection.empty?r.doc.nodesBetween(d,f,(x,v)=>{a&&a===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,f),m=v,p=x)}):r.doc.nodesBetween(d,f,(x,v)=>{v<d&&a&&a===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,f),m=v,p=x),v>=d&&v<=f&&(a&&a===x.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const M=Math.max(v,d),N=Math.min(v+x.nodeSize,f);n.addMark(M,N,o.create({...S.attrs,...e}))}}))}),p&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(x=>{o===x.type&&i&&n.addMark(b,y,o.create({...x.attrs,...e}))}))}),c},W7e=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return vHe(i,e)(n,r)},q7e=(t,e={})=>({state:n,dispatch:r})=>{const i=_i(t,n.schema);return _He(i,e)(n,r)},K7e=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={}}},CN=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},X7e=(t,e)=>{if($L(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 L1(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(m=>m.type.spec.code))return!1;let d=!1;const f=_7e(u)+a;return o.forEach(m=>{if(d)return;const p=X7e(f,m.find);if(!p)return;const b=c.state.tr,y=MN({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:v,chain:S,can:M}=new EN({editor:n,state:y});m.handler({state:y,range:x,match:p,commands:v,chain:S,can:M})===null||!b.steps.length||(m.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function Y7e(t){const{editor:e,rules:n}=t,r=new Gr({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=GL(Nt.from(d),o.schema);const{from:f}=c,m=f+d.length;L1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return L1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&L1({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?L1({editor:e,from:o.pos,to:o.pos,text:`
  8199. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Z7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function I1(t){return Z7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function gre(t,e){const n={...t};return I1(t)&&I1(e)&&Object.keys(e).forEach(r=>{I1(e[r])&&I1(t[r])?n[r]=gre(t[r],e[r]):n[r]=e[r]}),n}var qL=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{...ir(Zt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ir(Zt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>gre(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}},gh=class xre extends qL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new xre(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 Q7e(t){return typeof t=="number"}var J7e=class{constructor(t){this.find=t.find,this.handler=t.handler}},e9e=(t,e,n)=>{if($L(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 t9e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new EN({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,b)=>{var y,x,v,S,M;if((x=(y=p.type)==null?void 0:y.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const N=(M=(S=(v=p.content)==null?void 0:v.size)!=null?S:p.nodeSize)!=null?M:0,A=Math.max(r,b),k=Math.min(i,b+N);if(A>=k)return;const C=p.isText?p.text||"":p.textBetween(A-b,k-b,void 0,"");e9e(C,a.find,o).forEach(T=>{if(T.index===void 0)return;const R=A+T.index+1,U=R+T[0].length,O={from:n.tr.mapping.map(R),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:O,match:T,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var F1=null,n9e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function r9e(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:m,rule:p,pasteEvt:b})=>{const y=d.tr,x=MN({state:d,transaction:y});if(!(!t9e({editor:e,state:x,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:b,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Gr({view(f){const m=b=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(b.target)?f.dom.parentElement:null,r&&(F1=e)},p=()=>{F1&&(F1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=r===f.dom.parentElement,l=m,!a){const p=F1;p?.isEditable&&setTimeout(()=>{const b=p.state.selection;b&&p.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,m)=>{var p;const b=(p=m.clipboardData)==null?void 0:p.getData("text/html");return o=m,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,p)=>{const b=f[0],y=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!a,v=b.getMeta("applyPasteRules"),S=!!v;if(!y&&!x&&!S)return;if(S){let{text:A}=v;typeof A=="string"?A=A:A=GL(Nt.from(A),p.schema);const{from:k}=v,C=k+A.length,D=n9e(A);return c({rule:d,state:p,from:k,to:{b:C},pasteEvt:D})}const M=m.doc.content.findDiffStart(p.doc.content),N=m.doc.content.findDiffEnd(p.doc.content);if(!(!Q7e(M)||!N||M===N.b))return c({rule:d,state:p,from:M,to:N,pasteEvt:o})}}))}var kN=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=lre(t),this.schema=m7e(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:O1(e.name,this.schema)},r=Zt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return dM([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:O1(r.name,this.schema)},a=[],o=Zt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Zt(r,"exitable",i)&&(l.ArrowRight=()=>gh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([p,b])=>[p,()=>b({editor:t})]));l={...l,...m}}const c=xGe(l);a.push(c);const u=Zt(r,"addInputRules",i);if(EW(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=Y7e({editor:t,rules:m}),b=Array.isArray(p)?p:[p];a.push(...b)}}const d=Zt(r,"addPasteRules",i);if(EW(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=r9e({editor:t,rules:m});a.push(...p)}}const f=Zt(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return ore(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=zg(this.extensions);return Object.fromEntries(e.filter(n=>!!Zt(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:_i(n.name,this.schema)},a=Zt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const p=cy(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return dM([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:O1(i.name,this.schema)},o=Zt(i,"dispatchTransaction",a);return o?l=>{o.call(a,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=zg(this.extensions);return Object.fromEntries(e.filter(n=>!!Zt(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:Au(n.name,this.schema)},a=Zt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=cy(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{b9e(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:O1(e.name,this.schema)};e.type==="mark"&&((n=ir(Zt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Zt(e,"onBeforeCreate",r),a=Zt(e,"onCreate",r),o=Zt(e,"onUpdate",r),l=Zt(e,"onSelectionUpdate",r),c=Zt(e,"onTransaction",r),u=Zt(e,"onFocus",r),d=Zt(e,"onBlur",r),f=Zt(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)})}};kN.resolve=lre;kN.sort=dM;kN.flatten=VL;var i9e={};BL(i9e,{ClipboardTextSerializer:()=>yre,Commands:()=>vre,Delete:()=>_re,Drop:()=>wre,Editable:()=>Sre,FocusEvents:()=>Ere,Keymap:()=>Nre,Paste:()=>Are,Tabindex:()=>Tre,TextDirection:()=>Cre,focusEventsPluginKey:()=>Mre});var pr=class bre extends qL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new bre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yre=pr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Gr({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=ure(n);return cre(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),vre=pr.create({name:"commands",addCommands(){return{...Qne}}}),_re=pr.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=are(t.before,[t,...e]);hre(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(b,y)=>{const x=y+b.nodeSize-2,v=p.oldRange.from<=y&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:x,newFrom:d.mapping.map(y),newTo:d.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,b)=>{var y,x;if(p instanceof tl){const v=m.slice(b).map(p.from,-1),S=m.slice(b).map(p.to),M=m.invert().map(v,-1),N=m.invert().map(S),A=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(C=>C.eq(p.mark)),k=(x=d.doc.nodeAt(S))==null?void 0:x.marks.some(C=>C.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:M,to:N},newRange:{from:v,to:S},partial:!!(k||A),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()}}),wre=pr.create({name:"drop",addProseMirrorPlugins(){return[new Gr({key:new Li("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Sre=pr.create({name:"editable",addProseMirrorPlugins(){return[new Gr({key:new Li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mre=new Li("focusEvents"),Ere=pr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Gr({key:Mre,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}}}})]}}),Nre=pr.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:m,parent:p}=f,b=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,y=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,v=y&&b.parent.childCount===1?x===f.pos:En.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&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 uM()||rre()?a:i},addProseMirrorPlugins(){return[new Gr({key:new Li("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=En.atStart(e.doc).from,u=En.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!TN(n.doc))return;const m=n.tr,p=MN({state:n,transaction:m}),{commands:b}=new EN({editor:this.editor,state:p});if(b.clearNodes(),!!m.steps.length)return m}})]}}),Are=pr.create({name:"paste",addProseMirrorPlugins(){return[new Gr({key:new Li("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Tre=pr.create({name:"tabindex",addProseMirrorPlugins(){return[new Gr({key:new Li("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Cre=pr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=zg(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 Gr({key:new Li("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),a9e=class Xb{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 Xb(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 Xb(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 Xb(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=n.isInline,l=this.pos+r+(a?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const u=new Xb(c,this.editor,i,i||o?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)}),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)}},s9e=`.ProseMirror {
  8200. position: relative;
  8201. }
  8202. .ProseMirror {
  8203. word-wrap: break-word;
  8204. white-space: pre-wrap;
  8205. white-space: break-spaces;
  8206. -webkit-font-variant-ligatures: none;
  8207. font-variant-ligatures: none;
  8208. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8209. }
  8210. .ProseMirror [contenteditable="false"] {
  8211. white-space: normal;
  8212. }
  8213. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8214. white-space: pre-wrap;
  8215. }
  8216. .ProseMirror pre {
  8217. white-space: pre-wrap;
  8218. }
  8219. img.ProseMirror-separator {
  8220. display: inline !important;
  8221. border: none !important;
  8222. margin: 0 !important;
  8223. width: 0 !important;
  8224. height: 0 !important;
  8225. }
  8226. .ProseMirror-gapcursor {
  8227. display: none;
  8228. pointer-events: none;
  8229. position: absolute;
  8230. margin: 0;
  8231. }
  8232. .ProseMirror-gapcursor:after {
  8233. content: "";
  8234. display: block;
  8235. position: absolute;
  8236. top: -2px;
  8237. width: 20px;
  8238. border-top: 1px solid black;
  8239. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8240. }
  8241. @keyframes ProseMirror-cursor-blink {
  8242. to {
  8243. visibility: hidden;
  8244. }
  8245. }
  8246. .ProseMirror-hideselection *::selection {
  8247. background: transparent;
  8248. }
  8249. .ProseMirror-hideselection *::-moz-selection {
  8250. background: transparent;
  8251. }
  8252. .ProseMirror-hideselection * {
  8253. caret-color: transparent;
  8254. }
  8255. .ProseMirror-focused .ProseMirror-gapcursor {
  8256. display: block;
  8257. }`;function o9e(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 l9e=class extends K7e{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,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:E7e,createMappablePosition:N7e},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=tre(e,this.options.autofocus);this.editorState=Yp.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=o9e(s9e,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=sre(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?[Sre,yre.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vre,Ere,Nre,Tre,wre,Are,_re,Cre.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 kN(r,this)}createCommandManager(){this.commandManager=new EN({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=XR(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=XR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Yne(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const o=this.view.dom;o.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 dre(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return w7e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return GL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8258. `,textSerializers:n={}}=t||{};return g7e(this.state.doc,{blockSeparator:e,textSerializers:{...ure(this.schema),...n}})}get isEmpty(){return TN(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 a9e(e,this)}get $doc(){return this.$pos(0)}};function Bg(t){return new CN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ir(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(WL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const m=n.from+c+o.length;a.addMark(n.from+c,m,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function kre(t){return new CN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ir(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 ZR(t){return new CN({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=ir(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 $g(t){return new CN({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=ir(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&EL(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:p}=t.editor.extensionManager,b=m||f.$to.parentOffset&&f.$from.marks();if(b){const y=b.filter(x=>p.includes(x.type.name));o.ensureMarks(y)}}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&&mh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var c9e=t=>"touches"in t,u9e=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.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.touches[0];if(!c)return;const u=c.clientX-this.startX,d=c.clientY-this.startY;this.handleResize(u,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,c=this.element.offsetHeight;this.onCommit(l,c),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=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a,o;this.node=t.node,this.editor=t.editor,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||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}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.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",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=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}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,c9e(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 d9e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Jt){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 h9e={};BL(h9e,{createAtomBlockMarkdownSpec:()=>f9e,createBlockMarkdownSpec:()=>m9e,createInlineMarkdownSpec:()=>x9e,parseAttributes:()=>KL,parseIndentedBlocks:()=>QR,renderNestedMarkdownContent:()=>YL,serializeAttributes:()=>XL});function KL(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 m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];p&&(e[u]=p.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 XL(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 f9e(t){const{nodeName:e,name:n,parseAttributes:r=KL,serializeAttributes:i=XL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...a,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(p);if(!b)return;const y=b[1]||"",x=r(y);if(!o.find(S=>!(S in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function m9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=KL,serializeAttributes:a=XL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const b={...o,...f.attributes};return m.createNode(e,b,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),b=(m=f.match(p))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,p){var b;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(y);if(!x)return;const[v,S=""]=x,M=i(S);let N=1;const A=v.length;let k="";const C=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(A);for(C.lastIndex=0;;){const T=C.exec(D);if(T===null)break;const R=T.index,U=T[1];if(!((b=T[2])!=null&&b.endsWith(":::"))){if(U)N+=1;else if(N-=1,N===0){const O=D.slice(0,R);k=O.trim();const q=f.slice(0,A+R+T[0].length);let j=[];if(k)if(l==="block")for(j=p.blockTokens(O),j.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});j.length>0;){const W=j[j.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))j.pop();else break}else j=p.inlineTokens(k);return{type:e,raw:q,attributes:M,content:k,tokens:j}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),b=a(p),y=b?` {${b}}`:"",x=m.renderChildren(f.content||[],`
  8259. `);return`:::${u}${y}
  8260. ${x}
  8261. :::`}}}function p9e(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 g9e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function x9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=p9e,serializeAttributes:a=g9e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(b=>{const y=typeof b=="string"?b:b.name,x=typeof b=="string"?void 0:b.skipIfDefault;if(y in m){const v=m[y];if(x!==void 0&&v===x)return;p[y]=v}}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const b={...o,...m.attributes};if(l)return p.createNode(e,b);const y=r?r(m):m.content||"";return y?p.createNode(e,b,[p.createTextNode(y)]):p.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(m){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),b=m.match(p),y=b?.index;return y!==void 0?y:-1},tokenize(m,p,b){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),x=m.match(y);if(!x)return;let v="",S="";if(l){const[,N]=x;S=N}else{const[,N,A]=x;S=N,v=A||""}const M=i(S.trim());return{type:e,raw:x[0],content:v.trim(),attributes:M}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const b=d(m.attrs||{}),y=a(b),x=y?` ${y}`:"";return l?`[${u}${x}]`:`[${u}${x}]${p}[/${u}]`}}}function QR(t,e,n){var r,i,a,o;const l=t.split(`
  8262. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],p=m.match(e.itemPattern);if(!p){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
  8263. `;continue}else return}const b=e.extractItemData(p),{indentLevel:y,mainContent:x}=b;u=`${u}${m}
  8264. `;const v=[x];for(d+=1;d<l.length;){const A=l[d];if(A.trim()===""){const C=l.slice(d+1).findIndex(R=>R.trim()!=="");if(C===-1)break;if((((i=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(A),u=`${u}${A}
  8265. `,d+=1;continue}else break}if((((o=(a=A.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(A),u=`${u}${A}
  8266. `,d+=1;else break}let S;const M=v.slice(1);if(M.length>0){const A=M.map(k=>k.slice(y+f)).join(`
  8267. `);A.trim()&&(e.customNestedParser?S=e.customNestedParser(A):S=n.blockTokens(A))}const N=e.createToken(b,S);c.push(N)}if(c.length!==0)return{items:c,raw:u}}function YL(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(`
  8268. `).map(m=>m?e.indent(m):"").join(`
  8269. `);c.push(f)}}),c.join(`
  8270. `)}function b9e(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(p=>{if(p!==o)return!1;f=p}),!f)return;let m=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(m=!0)}),m){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var Ms=class jre extends qL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new jre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function am(t){return new J7e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=ir(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),m=f+l.length;if(WL(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;m<n.to&&o.delete(m,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)}}})}const{getOwnPropertyNames:y9e,getOwnPropertySymbols:v9e}=Object,{hasOwnProperty:_9e}=Object.prototype;function Cj(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function U1(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,o=a.get(n),l=a.get(r);if(o&&l)return o===r&&l===n;a.set(n,r),a.set(r,n);const c=t(n,r,i);return a.delete(n),a.delete(r),c}}function w9e(t){return t?.[Symbol.toStringTag]}function TW(t){return y9e(t).concat(v9e(t))}const S9e=Object.hasOwn||((t,e)=>_9e.call(t,e));function fm(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const M9e="__v",E9e="__o",N9e="_owner",{getOwnPropertyDescriptor:CW,keys:kW}=Object;function A9e(t,e){return t.byteLength===e.byteLength&&hM(new Uint8Array(t),new Uint8Array(e))}function T9e(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function C9e(t,e){return t.byteLength===e.byteLength&&hM(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function k9e(t,e){return fm(t.getTime(),e.getTime())}function j9e(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function P9e(t,e){return t===e}function jW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let o,l,c=0;for(;(o=a.next())&&!o.done;){const u=e.entries();let d=!1,f=0;for(;(l=u.next())&&!l.done;){if(i[f]){f++;continue}const m=o.value,p=l.value;if(n.equals(m[0],p[0],c,f,t,e,n)&&n.equals(m[1],p[1],m[0],p[0],t,e,n)){d=i[f]=!0;break}f++}if(!d)return!1;c++}return!0}const R9e=fm;function D9e(t,e,n){const r=kW(t);let i=r.length;if(kW(e).length!==i)return!1;for(;i-- >0;)if(!Pre(t,e,n,r[i]))return!1;return!0}function Pb(t,e,n){const r=TW(t);let i=r.length;if(TW(e).length!==i)return!1;let a,o,l;for(;i-- >0;)if(a=r[i],!Pre(t,e,n,a)||(o=CW(t,a),l=CW(e,a),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function O9e(t,e){return fm(t.valueOf(),e.valueOf())}function L9e(t,e){return t.source===e.source&&t.flags===e.flags}function PW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let o,l;for(;(o=a.next())&&!o.done;){const c=e.values();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(!i[d]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){u=i[d]=!0;break}d++}if(!u)return!1}return!0}function hM(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function I9e(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Pre(t,e,n,r){return(r===N9e||r===E9e||r===M9e)&&(t.$$typeof||e.$$typeof)?!0:S9e(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const F9e="[object ArrayBuffer]",U9e="[object Arguments]",z9e="[object Boolean]",B9e="[object DataView]",$9e="[object Date]",H9e="[object Error]",V9e="[object Map]",G9e="[object Number]",W9e="[object Object]",q9e="[object RegExp]",K9e="[object Set]",X9e="[object String]",Y9e={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Z9e="[object URL]",Q9e=Object.prototype.toString;function J9e({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:u,areRegExpsEqual:d,areSetsEqual:f,areTypedArraysEqual:m,areUrlsEqual:p,unknownTagComparators:b}){return function(x,v,S){if(x===v)return!0;if(x==null||v==null)return!1;const M=typeof x;if(M!==typeof v)return!1;if(M!=="object")return M==="number"?l(x,v,S):M==="function"?a(x,v,S):!1;const N=x.constructor;if(N!==v.constructor)return!1;if(N===Object)return c(x,v,S);if(Array.isArray(x))return e(x,v,S);if(N===Date)return r(x,v,S);if(N===RegExp)return d(x,v,S);if(N===Map)return o(x,v,S);if(N===Set)return f(x,v,S);const A=Q9e.call(x);if(A===$9e)return r(x,v,S);if(A===q9e)return d(x,v,S);if(A===V9e)return o(x,v,S);if(A===K9e)return f(x,v,S);if(A===W9e)return typeof x.then!="function"&&typeof v.then!="function"&&c(x,v,S);if(A===Z9e)return p(x,v,S);if(A===H9e)return i(x,v,S);if(A===U9e)return c(x,v,S);if(Y9e[A])return m(x,v,S);if(A===F9e)return t(x,v,S);if(A===B9e)return n(x,v,S);if(A===z9e||A===G9e||A===X9e)return u(x,v,S);if(b){let k=b[A];if(!k){const C=w9e(x);C&&(k=b[C])}if(k)return k(x,v,S)}return!1}}function eWe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:A9e,areArraysEqual:n?Pb:T9e,areDataViewsEqual:C9e,areDatesEqual:k9e,areErrorsEqual:j9e,areFunctionsEqual:P9e,areMapsEqual:n?Cj(jW,Pb):jW,areNumbersEqual:R9e,areObjectsEqual:n?Pb:D9e,arePrimitiveWrappersEqual:O9e,areRegExpsEqual:L9e,areSetsEqual:n?Cj(PW,Pb):PW,areTypedArraysEqual:n?Cj(hM,Pb):hM,areUrlsEqual:I9e,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=U1(r.areArraysEqual),a=U1(r.areMapsEqual),o=U1(r.areObjectsEqual),l=U1(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:l})}return r}function tWe(t){return function(e,n,r,i,a,o,l){return t(e,n,l)}}function nWe({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(l,c){const{cache:u=t?new WeakMap:void 0,meta:d}=n();return e(l,c,{cache:u,equals:r,meta:d,strict:i})};if(t)return function(l,c){return e(l,c,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(l,c){return e(l,c,a)}}const rWe=xh();xh({strict:!0});xh({circular:!0});xh({circular:!0,strict:!0});xh({createInternalComparator:()=>fm});xh({strict:!0,createInternalComparator:()=>fm});xh({circular:!0,createInternalComparator:()=>fm});xh({circular:!0,createInternalComparator:()=>fm,strict:!0});function xh(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=eWe(t),o=J9e(a),l=n?n(o):tWe(o);return nWe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var iWe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},aWe=({contentComponent:t})=>{const e=yD.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function sWe(){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]:Bce.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 oWe=class extends Dr.Component{constructor(t){var e;super(t),this.editorContentRef=Dr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=sWe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.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.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:iWe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(aWe,{contentComponent:t.contentComponent})]})}},lWe=w.forwardRef((t,e)=>{const n=Dr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Dr.createElement(oWe,{key:n,innerRef:e,...t})}),cWe=Dr.memo(lWe),uWe=typeof window<"u"?w.useLayoutEffect:w.useEffect,dWe=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 hWe(t){var e;const[n]=w.useState(()=>new dWe(t.editor)),r=hX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:rWe);return uWe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var fWe=!1,JR=typeof window>"u",mWe=JR||!!(typeof window<"u"&&window.next),pWe=class Rre{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?JR||mWe?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 l9e(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?Rre.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 gWe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new pWe(n)),i=yD.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),hWe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var xWe=w.createContext({editor:null});xWe.Consumer;var bWe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),yWe=()=>w.useContext(bWe);Dr.forwardRef((t,e)=>{const{onDragStart:n}=yWe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Dr.createContext({markViewContentRef:()=>{}});var fM=(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]},vWe=/^\s*>\s$/,_We=Ms.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return fM("blockquote",{...ri(this.options.HTMLAttributes,t),children:fM("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(`
  8271. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8272. `))}),r.join(`
  8273. ${n}
  8274. `)},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[$g({find:vWe,type:this.type})]}}),wWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,SWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,MWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,EWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,NWe=gh.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 fM("strong",{...ri(this.options.HTMLAttributes,t),children:fM("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[Bg({find:wWe,type:this.type}),Bg({find:MWe,type:this.type})]},addPasteRules(){return[am({find:SWe,type:this.type}),am({find:EWe,type:this.type})]}}),AWe=/(^|[^`])`([^`]+)`(?!`)$/,TWe=/(^|[^`])`([^`]+)`(?!`)/g,CWe=gh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ri(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[Bg({find:AWe,type:this.type})]},addPasteRules(){return[am({find:TWe,type:this.type})]}}),kj=4,kWe=/^```([a-z]+)?[\s\n]$/,jWe=/^~~~([a-z]+)?[\s\n]$/,PWe=Ms.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:kj,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",ri(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(`
  8275. `):r=`\`\`\`${i}
  8276. \`\`\``,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:kj,{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,p=r.doc.textBetween(u,d,`
  8277. `,`
  8278. `).split(`
  8279. `).map(b=>l+b).join(`
  8280. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:kj,{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(),p=r.doc.textBetween(d,f,`
  8281. `,`
  8282. `).split(`
  8283. `);let b=0,y=0;const x=u-d;for(let k=0;k<p.length;k+=1){if(y+p[k].length>=x){b=k;break}y+=p[k].length+1}const S=((c=p[b].match(/^ */))==null?void 0:c[0])||"",M=Math.min(S.length,n);if(M===0)return!0;let N=d;for(let k=0;k<b;k+=1)N+=p[k].length+1;return l.delete(N,N+M),u-N<=M&&l.setSelection(mn.create(l.doc,N)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8284. `,`
  8285. `).split(`
  8286. `).map(p=>{var b;const y=((b=p.match(/^ */))==null?void 0:b[0])||"",x=Math.min(y.length,n);return p.slice(x)}).join(`
  8287. `);return l.replaceWith(c,u,r.schema.text(m)),!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(`
  8288. `);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(En.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[ZR({find:kWe,type:this.type,getAttributes:t=>({language:t[1]})}),ZR({find:jWe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Gr({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,`
  8289. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(mn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),RWe=Ms.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8290. `):""}),DWe=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",ri(this.options.HTMLAttributes,t)]},renderText(){return`
  8291. `},renderMarkdown:()=>`
  8292. `,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(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),OWe=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]}`,ri(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=>ZR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),LWe=Ms.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ri(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!d9e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return fre(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(mn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Jt.create(o.doc,c.pos)):o.setSelection(mn.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(mn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[kre({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),IWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,FWe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,UWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,zWe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,BWe=gh.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",ri(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[Bg({find:IWe,type:this.type}),Bg({find:UWe,type:this.type})]},addPasteRules(){return[am({find:FWe,type:this.type}),am({find:zWe,type:this.type})]}});const $We="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",HWe="ελ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",eD="numeric",tD="ascii",nD="alpha",f0="asciinumeric",Yb="alphanumeric",rD="domain",Dre="emoji",VWe="scheme",GWe="slashscheme",jj="whitespace";function WWe(t,e){return t in e||(e[t]=[]),e[t]}function bf(t,e,n){e[eD]&&(e[f0]=!0,e[Yb]=!0),e[tD]&&(e[f0]=!0,e[nD]=!0),e[f0]&&(e[Yb]=!0),e[nD]&&(e[Yb]=!0),e[Yb]&&(e[rD]=!0),e[Dre]&&(e[rD]=!0);for(const r in e){const i=WWe(r,n);i.indexOf(t)<0&&i.push(t)}}function qWe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ms(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ms.groups={};ms.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||ms.groups;let i;return e&&e.j?i=e:(i=new ms(e),n&&r&&bf(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||ms.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 ms,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new ms,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(qWe(o.t,r),n);bf(a,c,r)}else n&&bf(a,n,r);o.t=a}return i.j[t]=o,o}};const _n=(t,e,n,r,i)=>t.ta(e,n,r,i),Kr=(t,e,n,r,i)=>t.tr(e,n,r,i),RW=(t,e,n,r,i)=>t.ts(e,n,r,i),jt=(t,e,n,r,i)=>t.tt(e,n,r,i),Hc="WORD",iD="UWORD",Ore="ASCIINUMERICAL",Lre="ALPHANUMERICAL",uy="LOCALHOST",aD="TLD",sD="UTLD",vw="SCHEME",Hp="SLASH_SCHEME",ZL="NUM",oD="WS",QL="NL",m0="OPENBRACE",p0="CLOSEBRACE",mM="OPENBRACKET",pM="CLOSEBRACKET",gM="OPENPAREN",xM="CLOSEPAREN",bM="OPENANGLEBRACKET",yM="CLOSEANGLEBRACKET",vM="FULLWIDTHLEFTPAREN",_M="FULLWIDTHRIGHTPAREN",wM="LEFTCORNERBRACKET",SM="RIGHTCORNERBRACKET",MM="LEFTWHITECORNERBRACKET",EM="RIGHTWHITECORNERBRACKET",NM="FULLWIDTHLESSTHAN",AM="FULLWIDTHGREATERTHAN",TM="AMPERSAND",CM="APOSTROPHE",kM="ASTERISK",yd="AT",jM="BACKSLASH",PM="BACKTICK",RM="CARET",Ed="COLON",JL="COMMA",DM="DOLLAR",jl="DOT",OM="EQUALS",eI="EXCLAMATION",go="HYPHEN",g0="PERCENT",LM="PIPE",IM="PLUS",FM="POUND",x0="QUERY",tI="QUOTE",Ire="FULLWIDTHMIDDLEDOT",nI="SEMI",Pl="SLASH",b0="TILDE",UM="UNDERSCORE",Fre="EMOJI",zM="SYM";var Ure=Object.freeze({__proto__:null,ALPHANUMERICAL:Lre,AMPERSAND:TM,APOSTROPHE:CM,ASCIINUMERICAL:Ore,ASTERISK:kM,AT:yd,BACKSLASH:jM,BACKTICK:PM,CARET:RM,CLOSEANGLEBRACKET:yM,CLOSEBRACE:p0,CLOSEBRACKET:pM,CLOSEPAREN:xM,COLON:Ed,COMMA:JL,DOLLAR:DM,DOT:jl,EMOJI:Fre,EQUALS:OM,EXCLAMATION:eI,FULLWIDTHGREATERTHAN:AM,FULLWIDTHLEFTPAREN:vM,FULLWIDTHLESSTHAN:NM,FULLWIDTHMIDDLEDOT:Ire,FULLWIDTHRIGHTPAREN:_M,HYPHEN:go,LEFTCORNERBRACKET:wM,LEFTWHITECORNERBRACKET:MM,LOCALHOST:uy,NL:QL,NUM:ZL,OPENANGLEBRACKET:bM,OPENBRACE:m0,OPENBRACKET:mM,OPENPAREN:gM,PERCENT:g0,PIPE:LM,PLUS:IM,POUND:FM,QUERY:x0,QUOTE:tI,RIGHTCORNERBRACKET:SM,RIGHTWHITECORNERBRACKET:EM,SCHEME:vw,SEMI:nI,SLASH:Pl,SLASH_SCHEME:Hp,SYM:zM,TILDE:b0,TLD:aD,UNDERSCORE:UM,UTLD:sD,UWORD:iD,WORD:Hc,WS:oD});const zc=/[a-z]/,Rb=new RegExp("\\p{L}","u"),Pj=new RegExp("\\p{Emoji}","u"),Bc=/\d/,Rj=/\s/,DW="\r",Dj=`
  8293. `,KWe="️",XWe="‍",Oj="";let z1=null,B1=null;function YWe(t=[]){const e={};ms.groups=e;const n=new ms;z1==null&&(z1=OW($We)),B1==null&&(B1=OW(HWe)),jt(n,"'",CM),jt(n,"{",m0),jt(n,"}",p0),jt(n,"[",mM),jt(n,"]",pM),jt(n,"(",gM),jt(n,")",xM),jt(n,"<",bM),jt(n,">",yM),jt(n,"(",vM),jt(n,")",_M),jt(n,"「",wM),jt(n,"」",SM),jt(n,"『",MM),jt(n,"』",EM),jt(n,"<",NM),jt(n,">",AM),jt(n,"&",TM),jt(n,"*",kM),jt(n,"@",yd),jt(n,"`",PM),jt(n,"^",RM),jt(n,":",Ed),jt(n,",",JL),jt(n,"$",DM),jt(n,".",jl),jt(n,"=",OM),jt(n,"!",eI),jt(n,"-",go),jt(n,"%",g0),jt(n,"|",LM),jt(n,"+",IM),jt(n,"#",FM),jt(n,"?",x0),jt(n,'"',tI),jt(n,"/",Pl),jt(n,";",nI),jt(n,"~",b0),jt(n,"_",UM),jt(n,"\\",jM),jt(n,"・",Ire);const r=Kr(n,Bc,ZL,{[eD]:!0});Kr(r,Bc,r);const i=Kr(r,zc,Ore,{[f0]:!0}),a=Kr(r,Rb,Lre,{[Yb]:!0}),o=Kr(n,zc,Hc,{[tD]:!0});Kr(o,Bc,i),Kr(o,zc,o),Kr(i,Bc,i),Kr(i,zc,i);const l=Kr(n,Rb,iD,{[nD]:!0});Kr(l,zc),Kr(l,Bc,a),Kr(l,Rb,l),Kr(a,Bc,a),Kr(a,zc),Kr(a,Rb,a);const c=jt(n,Dj,QL,{[jj]:!0}),u=jt(n,DW,oD,{[jj]:!0}),d=Kr(n,Rj,oD,{[jj]:!0});jt(n,Oj,d),jt(u,Dj,c),jt(u,Oj,d),Kr(u,Rj,d),jt(d,DW),jt(d,Dj),Kr(d,Rj,d),jt(d,Oj,d);const f=Kr(n,Pj,Fre,{[Dre]:!0});jt(f,"#"),Kr(f,Pj,f),jt(f,KWe,f);const m=jt(f,XWe);jt(m,"#"),Kr(m,Pj,f);const p=[[zc,o],[Bc,i]],b=[[zc,null],[Rb,l],[Bc,a]];for(let y=0;y<z1.length;y++)dd(n,z1[y],aD,Hc,p);for(let y=0;y<B1.length;y++)dd(n,B1[y],sD,iD,b);bf(aD,{tld:!0,ascii:!0},e),bf(sD,{utld:!0,alpha:!0},e),dd(n,"file",vw,Hc,p),dd(n,"mailto",vw,Hc,p),dd(n,"http",Hp,Hc,p),dd(n,"https",Hp,Hc,p),dd(n,"ftp",Hp,Hc,p),dd(n,"ftps",Hp,Hc,p),bf(vw,{scheme:!0,ascii:!0},e),bf(Hp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,x)=>y[0]>x[0]?1:-1);for(let y=0;y<t.length;y++){const x=t[y][0],S=t[y][1]?{[VWe]:!0}:{[GWe]:!0};x.indexOf("-")>=0?S[rD]=!0:zc.test(x)?Bc.test(x)?S[f0]=!0:S[tD]=!0:S[eD]=!0,RW(n,x,x,S)}return RW(n,"localhost",uy,{ascii:!0}),n.jd=new ms(zM),{start:n,tokens:Object.assign({groups:e},Ure)}}function zre(t,e){const n=ZWe(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,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function ZWe(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 dd(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 ms(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new ms(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function OW(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 dy={defaultProtocol:"http",events:null,format:LW,formatHref:LW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function rI(t,e=null){let n=Object.assign({},dy);t&&(n=Object.assign(n,t instanceof rI?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}rI.prototype={o:dy,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]:dy[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 LW(t){return t}function Bre(t,e){this.t="token",this.v=t,this.tk=e}Bre.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=dy.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 jN(t,e){class n extends Bre{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 IW=jN("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),FW=jN("text"),QWe=jN("nl"),$1=jN("url",{isLink:!0,toHref(t=dy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==uy&&t[1].t===Ed}}),fo=t=>new ms(t);function JWe({groups:t}){const e=t.domain.concat([TM,kM,yd,jM,PM,RM,DM,OM,go,ZL,g0,LM,IM,FM,Pl,zM,b0,UM]),n=[CM,Ed,JL,jl,eI,g0,x0,tI,nI,bM,yM,m0,p0,pM,mM,gM,xM,vM,_M,wM,SM,MM,EM,NM,AM],r=[TM,CM,kM,jM,PM,RM,DM,OM,go,m0,p0,g0,LM,IM,FM,x0,Pl,zM,b0,UM],i=fo(),a=jt(i,b0);_n(a,r,a),_n(a,t.domain,a);const o=fo(),l=fo(),c=fo();_n(i,t.domain,o),_n(i,t.scheme,l),_n(i,t.slashscheme,c),_n(o,r,a),_n(o,t.domain,o);const u=jt(o,yd);jt(a,yd,u),jt(l,yd,u),jt(c,yd,u);const d=jt(a,jl);_n(d,r,a),_n(d,t.domain,a);const f=fo();_n(u,t.domain,f),_n(f,t.domain,f);const m=jt(f,jl);_n(m,t.domain,f);const p=fo(IW);_n(m,t.tld,p),_n(m,t.utld,p),jt(u,uy,p);const b=jt(f,go);jt(b,go,b),_n(b,t.domain,f),_n(p,t.domain,f),jt(p,jl,m),jt(p,go,b);const y=jt(p,Ed);_n(y,t.numeric,IW);const x=jt(o,go),v=jt(o,jl);jt(x,go,x),_n(x,t.domain,o),_n(v,r,a),_n(v,t.domain,o);const S=fo($1);_n(v,t.tld,S),_n(v,t.utld,S),_n(S,t.domain,o),_n(S,r,a),jt(S,jl,v),jt(S,go,x),jt(S,yd,u);const M=jt(S,Ed),N=fo($1);_n(M,t.numeric,N);const A=fo($1),k=fo();_n(A,e,A),_n(A,n,k),_n(k,e,A),_n(k,n,k),jt(S,Pl,A),jt(N,Pl,A);const C=jt(l,Ed),D=jt(c,Ed),T=jt(D,Pl),R=jt(T,Pl);_n(l,t.domain,o),jt(l,jl,v),jt(l,go,x),_n(c,t.domain,o),jt(c,jl,v),jt(c,go,x),_n(C,t.domain,A),jt(C,Pl,A),jt(C,x0,A),_n(R,t.domain,A),_n(R,e,A),jt(R,Pl,A);const U=[[m0,p0],[mM,pM],[gM,xM],[bM,yM],[vM,_M],[wM,SM],[MM,EM],[NM,AM]];for(let O=0;O<U.length;O++){const[q,j]=U[O],W=jt(A,q);jt(k,q,W),jt(W,j,A);const K=fo($1);_n(W,e,K);const G=fo();_n(W,n),_n(K,e,K),_n(K,n,G),_n(G,e,K),_n(G,n,G),jt(K,j,A),jt(G,j,A)}return jt(i,uy,S),jt(i,QL,QWe),{start:i,tokens:Ure}}function eqe(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,m=-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()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Lj(FW,e,o)),o=[]),i-=m,d-=m;const p=f.t,b=n.slice(i-d,i);a.push(Lj(p,e,b))}}return o.length>0&&a.push(Lj(FW,e,o)),a}function Lj(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 tqe=typeof console<"u"&&console&&console.warn||(()=>{}),nqe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",kr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function rqe(){return ms.groups={},kr.scanner=null,kr.parser=null,kr.tokenQueue=[],kr.pluginQueue=[],kr.customSchemes=[],kr.initialized=!1,kr}function UW(t,e=!1){if(kr.initialized&&tqe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${nqe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8294. 1. Must only contain digits, lowercase ASCII letters or "-"
  8295. 2. Cannot start or end with "-"
  8296. 3. "-" cannot repeat`);kr.customSchemes.push([t,e])}function iqe(){kr.scanner=YWe(kr.customSchemes);for(let t=0;t<kr.tokenQueue.length;t++)kr.tokenQueue[t][1]({scanner:kr.scanner});kr.parser=JWe(kr.scanner.tokens);for(let t=0;t<kr.pluginQueue.length;t++)kr.pluginQueue[t][1]({scanner:kr.scanner,parser:kr.parser});return kr.initialized=!0,kr}function iI(t){return kr.initialized||iqe(),eqe(kr.parser.start,t,zre(kr.scanner.start,t))}iI.scan=zre;function $re(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 rI(n),i=iI(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 aI="[\0-   ᠎ -\u2029  ]",aqe=new RegExp(aI),sqe=new RegExp(`${aI}$`),oqe=new RegExp(aI,"g");function lqe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function cqe(t){return new Gr({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=are(n.doc,[...e]);if(hre(l).forEach(({newRange:u})=>{const d=u7e(r.doc,u,p=>p.isTextblock);let f,m;if(d.length>1)f=d[0],m=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!sqe.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(aqe).filter(Boolean);if(p.length<=0)return!1;const b=p[p.length-1],y=f.pos+m.lastIndexOf(b);if(!b)return!1;const x=iI(b).map(v=>v.toObject(t.defaultProtocol));if(!lqe(x))return!1;x.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{WL(v.from,v.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function uqe(t){return new Gr({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{const c=r.target;if(!c)return!1;const u=t.editor.view.dom;o=c.closest("a"),o&&!u.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=dre(e.state,t.type.name),u=(i=o.href)!=null?i:c.href,d=(a=o.target)!=null?a:c.target;u&&(window.open(u,d),l=!0)}return l}}})}function dqe(t){return new Gr({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=$re(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.value)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function Wh(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(oqe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Hre=gh.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"){UW(t);return}UW(t.scheme,t.optionalSlashes)})},onDestroy(){rqe()},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)=>!!Wh(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!Wh(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=>!!Wh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ri(this.options.HTMLAttributes,t),0]:["a",ri(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=>!!Wh(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=>!!Wh(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[am({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=$re(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Wh(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(cqe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Wh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(uqe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(dqe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),hqe=Hre,fqe=Object.defineProperty,mqe=(t,e)=>{for(var n in e)fqe(t,n,{get:e[n],enumerable:!0})},pqe="listItem",zW="textStyle",BW=/^\s*([-+*])\s$/,Vre=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",ri(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,`
  8297. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(pqe,this.editor.getAttributes(zW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$g({find:BW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$g({find:BW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(zW),editor:this.editor})),[t]}}),Gre=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",ri(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)=>YL(t,e,r=>{var i,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:a.start)||1)+r.index}. `:"- "},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)}}}),gqe={};mqe(gqe,{findListItemPos:()=>Yy,getNextListDepth:()=>sI,handleBackspace:()=>lD,handleDelete:()=>cD,hasListBefore:()=>Wre,hasListItemAfter:()=>xqe,hasListItemBefore:()=>qre,listItemHasSubList:()=>Kre,nextListIsDeeper:()=>Xre,nextListIsHigher:()=>Yre});var Yy=(t,e)=>{const{$from:n}=e.selection,r=_i(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}},sI=(t,e)=>{const n=Yy(t,e);if(!n)return!1;const[,r]=v7e(e,t,n.$pos.pos+4);return r},Wre=(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))},qre=(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)},Kre=(t,e,n)=>{if(!n)return!1;const r=_i(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},lD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ah(t.state,e)&&Wre(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,p)=>{m.type.name===e&&u.push({node:m,pos:p})});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(!ah(t.state,e)||!M7e(t.state))return!1;const r=Yy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Kre(e,t.state,a);return qre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Xre=(t,e)=>{const n=sI(t,e),r=Yy(t,e);return!r||!n?!1:n>r.depth},Yre=(t,e)=>{const n=sI(t,e),r=Yy(t,e);return!r||!n?!1:n<r.depth},cD=(t,e)=>{if(!ah(t.state,e)||!S7e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Xre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Yre(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},xqe=(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)},Zre=pr.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&&cD(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&&cD(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&&lD(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&&lD(t,n,r)&&(e=!0)}),e}}}}),$W=/^(\s*)(\d+)\.\s+(.*)$/,bqe=/^\s/;function yqe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match($W);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match($W))break;if(p.trim()==="")m.push(p),d+=`
  8298. `,f+=1;else if(p.match(bqe))m.push(p),d+=`
  8299. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
  8300. `)}),r=f,n=f}return[e,r]}function Qre(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(`
  8301. `),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(`
  8302. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const p=Math.min(...m.map(y=>y.indent)),b=Qre(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:b,raw:m.map(y=>y.raw).join(`
  8303. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function vqe(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 _qe="listItem",HW="textStyle",VW=/^(\d+)\.\s$/,Jre=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",ri(this.options.HTMLAttributes,n),0]:["ol",ri(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?vqe(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,`
  8304. `):"",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(`
  8305. `),[a,o]=yqe(i);if(a.length===0)return;const l=Qre(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(`
  8306. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_qe,this.editor.getAttributes(HW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$g({find:VW,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=$g({find:VW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(HW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),wqe=/^\s*(\[([( |x])?\])\s$/,Sqe=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",ri(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 YL(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=f=>{var m,p;l.ariaLabel=((p=(m=this.options.a11y)==null?void 0:m.checkboxLabel)==null?void 0:p.call(m,f,l.checked))||`Task item checkbox for ${f.textContent||"empty task item"}`};u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",f=>f.preventDefault()),l.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:m}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const b=n();if(typeof b!="number")return!1;const y=p.doc.nodeAt(b);return p.setNodeMarkup(b,void 0,{...y?.attrs,checked:m}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,m)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,m])=>{i.setAttribute(f,m)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([f,m])=>{i.setAttribute(f,m)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:c,update:f=>{if(f.type!==this.type)return!1;i.dataset.checked=f.attrs.checked,l.checked=f.attrs.checked,u(f);const m=r.extensionManager.attributes,p=cy(f,m),b=new Set(Object.keys(p)),y=this.options.HTMLAttributes;return d.forEach(x=>{b.has(x)||(x in y?i.setAttribute(x,y[x]):i.removeAttribute(x))}),Object.entries(p).forEach(([x,v])=>{v==null?x in y?i.setAttribute(x,y[x]):i.removeAttribute(x):i.setAttribute(x,v)}),d=b,!0}}}},addInputRules(){return[$g({find:wqe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Mqe=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",ri(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,`
  8307. `):"",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=QR(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=QR(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()}}});pr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Vre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Gre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Zre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Jre.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Sqe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Mqe.configure(this.options.taskList)),t}});var GW="&nbsp;",Eqe=" ",Nqe=Ms.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ri(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===GW||r[0].text===Eqe)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?GW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Aqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Tqe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Cqe=gh.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",ri(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[Bg({find:Aqe,type:this.type})]},addPasteRules(){return[am({find:Tqe,type:this.type})]}}),kqe=Ms.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),eie=gh.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",ri(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()}}}),jqe=eie;function Pqe(t={}){return new Gr({view(e){return new Rqe(e,t)}})}class Rqe{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,m=e.nodeAfter;if(f||m){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let b=p.getBoundingClientRect(),y=f?b.bottom:b.top;f&&m&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:y-x,bottom:y+x}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,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(),m=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*p}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=Yte(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 Jr extends En{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Jr.valid(r)?new Jr(r):En.near(r)}content(){return Bt.empty}eq(e){return e instanceof Jr&&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 Jr(e.resolve(n.pos))}getBookmark(){return new oI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Dqe(e)||!Oqe(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&&Jr.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(Jr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Jt.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(Jr.valid(l))return l}return null}}}Jr.prototype.visible=!1;Jr.findFrom=Jr.findGapCursorFrom;En.jsonID("gapcursor",Jr);class oI{constructor(e){this.pos=e}map(e){return new oI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Jr.valid(n)?new Jr(n):En.near(n)}}function tie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Dqe(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||tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Oqe(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||tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Lqe(){return new Gr({props:{decorations:zqe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Jr.valid(n)?new Jr(n):null},handleClick:Fqe,handleKeyDown:Iqe,handleDOMEvents:{beforeinput:Uqe}}})}const Iqe=Zne({ArrowLeft:H1("horiz",-1),ArrowRight:H1("horiz",1),ArrowUp:H1("vert",-1),ArrowDown:H1("vert",1)});function H1(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 mn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Jr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Jr(u))),!0):!1}}function Fqe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Jr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Jt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Jr(r))),!0)}function Uqe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Jr))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=Nt.empty;for(let o=r.length-1;o>=0;o--)i=Nt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Bt(i,0,0));return a.setSelection(mn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function zqe(t){if(!(t.selection instanceof Jr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ur.create(t.doc,[Ka.widget(t.selection.head,e,{key:"gapcursor"})])}var BM=200,Yi=function(){};Yi.prototype.append=function(e){return e.length?(e=Yi.from(e),!this.length&&e||e.length<BM&&this.leafAppend(e)||this.length<BM&&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 Bqe(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 nie(e):Yi.empty};var nie=(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<=BM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=BM)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 nie([]);var Bqe=(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 $qe=500;class Qo{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,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new Rl(f.map));let p=f.step.map(i.slice(a)),b;p&&o.maybeStep(p).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],u.push(new Rl(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 Qo(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]),m=new Rl(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>Vqe&&(l=Hqe(l,u),o-=u),new Qo(l.append(a),o)}remapping(e,n){let r=new ry;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 Qo(this.items.append(e.map(n=>new Rl(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(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let b=a.maps[p];if(m.step){let y=e.steps[p].invert(e.docs[p]),x=m.selection&&m.selection.map(a.slice(c+1,p));x&&l++,r.push(new Rl(b,y,x))}else r.push(new Rl(b))},i);let u=[];for(let m=n;m<o;m++)u.push(new Rl(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new Qo(d,l);return f.emptyItemCount()>$qe&&(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 Rl(u.invert(),c,d),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new Qo(Yi.from(i.reverse()),a)}}Qo.empty=new Qo(Yi.empty,0);function Hqe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Rl{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 Rl(n.getMap().invert(),n,this.selection)}}}class vd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const Vqe=20;function Gqe(t,e,n,r){let i=n.getMeta(Pf),a;if(i)return i.historyState;n.getMeta(Kqe)&&(t=new vd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Pf))return o.getMeta(Pf).redo?new vd(t.done.addTransform(n,void 0,r,_w(e)),t.undone,WW(n.mapping.maps),t.prevTime,t.prevComposition):new vd(t.done,t.undone.addTransform(n,void 0,r,_w(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||!Wqe(n,t.prevRanges)),u=o?Ij(t.prevRanges,n.mapping):WW(n.mapping.maps);return new vd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,_w(e)),Qo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new vd(t.done.rebased(n,a),t.undone.rebased(n,a),Ij(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new vd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ij(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Wqe(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 WW(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 Ij(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 qqe(t,e,n){let r=_w(e),i=Pf.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 vd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Pf,{redo:n,historyState:c})}let Fj=!1,qW=null;function _w(t){let e=t.plugins;if(qW!=e){Fj=!1,qW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Fj=!0;break}}return Fj}const Pf=new Li("history"),Kqe=new Li("closeHistory");function Xqe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Gr({key:Pf,state:{init(){return new vd(Qo.empty,Qo.empty,null,0,-1)},apply(e,n,r){return Gqe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?iie:r=="historyRedo"?aie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function rie(t,e){return(n,r)=>{let i=Pf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=qqe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const iie=rie(!1,!0),aie=rie(!0,!0);pr.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 Gr({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 Yqe=pr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Pqe(this.options)]}});pr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Gr({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 Ur.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(Ka.node(u,u+c.nodeSize,{class:this.options.className}))}),Ur.create(t,a)}}})]}});var Zqe=pr.create({name:"gapCursor",addProseMirrorPlugins(){return[Lqe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ir(Zt(t,"allowGapCursor",n)))!=null?e:null}}});pr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Gr({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&&TN(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ka.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}),Ur.create(t,i)}}})]}});pr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Gr({key:new Li("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||fre(n.selection)||t.view.dragging?null:Ur.create(n.doc,[Ka.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function KW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Qqe=pr.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 Gr({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!KW({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!KW({node:o,types:r})}}})]}}),Jqe=pr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>iie(t,e),redo:()=>({state:t,dispatch:e})=>aie(t,e)}},addProseMirrorPlugins(){return[Xqe(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()}}}),eKe=pr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(NWe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(_We.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Vre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(CWe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(PWe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(RWe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(Yqe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(Zqe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(DWe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(OWe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Jqe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(LWe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(BWe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Gre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Zre.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Hre.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Jre.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Nqe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Cqe.configure(this.options.strike)),this.options.text!==!1&&i.push(kqe.configure(this.options.text)),this.options.underline!==!1&&i.push(eie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(Qqe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),tKe=eKe,nKe=pr.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")}}}),rKe=nKe,iKe=20,sie=(t,e=0)=>{const n=[];return!t.children.length||e>iKe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...sie(r,e+1))}),n},aKe=t=>{if(!t.children.length)return;const e=sie(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}`)})},oie=gh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&aKe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ri(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}}}}),sKe=pr.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()}}}),lie=pr.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()}}}),oKe=pr.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()}}}),lKe=pr.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()}}}),cKe=pr.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()}}});pr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(sKe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(lie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(oKe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(lKe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(cKe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(oie.configure(this.options.textStyle)),t}});var uKe=lie,dKe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hKe=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",ri(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?`![${c}](${l} "${u}")`:`![${c}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:l})=>{const c=document.createElement("img");Object.entries(o).forEach(([f,m])=>{if(m!=null)switch(f){case"width":case"height":break;default:c.setAttribute(f,m);break}}),c.src=o.src;const u=new u9e({element:c,editor:l,node:i,getPos:a,onResize:(f,m)=>{c.style.width=`${f}px`,c.style.height=`${m}px`},onCommit:(f,m)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:f,height:m}).run()},onUpdate:(f,m,p)=>f.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",c.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[kre({find:dKe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),fKe=hKe;function uD({content:t,onChange:e,placeholder:n}){const r=gWe({extensions:[tKe.configure({heading:!1,codeBlock:!1,code:!1}),jqe,hqe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),rKe.configure({types:["paragraph"]}),oie,uKe,fKe.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(Iue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(The,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(xme,{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(oE,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(fK,{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(cme,{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(ame,{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(ome,{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(Xg,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(zD,{className:"w-4 h-4"})})]}),s.jsx(cWe,{editor:r})]})}function cie({archiveId:t,archiveName:e,onClose:n}){const r=un(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ut({queryKey:["archive-project-page",t],queryFn:()=>pe.getArchiveProjectPage(t)}),p=ht({mutationFn:A=>pe.updateArchiveProjectPage(t,A),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[o,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{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=()=>{p.mutate(c)},v=()=>{a(!1),u({})},S=A=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(A,"text/html"),D=T=>{if(T.nodeType===Node.TEXT_NODE)return T.textContent||"";if(T.nodeType===Node.ELEMENT_NODE){const R=T,U=R.tagName.toLowerCase();if(!k.includes(U))return Array.from(R.childNodes).map(D).join("");let O="";if(U==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(O=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";O=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(U)?`<${U}${O} />`:`<${U}${O}>${q}</${U}>`}return""};return Array.from(C.body.childNodes).map(D).join("")},M=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),N=A=>{A.target===A.currentTarget&&n()};return s.jsxs("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 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(Wa,{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&&M&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(Ff,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Me,{variant:"primary",size:"sm",onClick:x,disabled:p.isPending,children:[s.jsx(ps,{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(Wt,{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"})}),m&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!M&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Wa,{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&&M&&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:A=>u({...c,title:A.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(vP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:A=>u({...c,designer:A.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(vP,{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(zr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(ti,{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(Wa,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:A=>u({...c,license:A.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(Wa,{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(uD,{content:c.description||"",onChange:A=>u({...c,description:A}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(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:A=>u({...c,profile_title:A.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(uD,{content:c.profile_description||"",onChange:A=>u({...c,profile_description:A}),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:S(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(by,{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((A,k)=>s.jsx("button",{onClick:()=>l(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:A.url,alt:A.name,className:"w-full h-full object-cover"})},A.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(zr,{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:A=>{A.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(Lf,{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:A=>A.stopPropagation()}),s.jsx("button",{onClick:A=>{A.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(Ks,{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(Wt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const mKe=[.25,.5,.75,1,1.5,2,3,4];function Op(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function pKe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=qn(),a=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[p,b]=w.useState(0),[y,x]=w.useState(0),[v,S]=w.useState(1),[M,N]=w.useState(null),[A,k]=w.useState(null),[C,D]=w.useState(.8),[T,R]=w.useState(!1),{data:U,isLoading:O}=ut({queryKey:["timelapse-info",t],queryFn:()=>pe.getTimelapseInfo(t)}),{data:q}=ut({queryKey:["timelapse-thumbnails",t],queryFn:()=>pe.getTimelapseThumbnails(t,15)}),j=ht({mutationFn:()=>pe.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,saveMode:"replace"},M||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});w.useEffect(()=>{U?.duration&&y===0&&x(U.duration)},[U?.duration,y]),w.useEffect(()=>{const z=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const V=()=>{const fe=z.currentTime;d(fe),fe>=y&&(z.currentTime=p)},Z=()=>{m(z.duration),y===0&&x(z.duration)},ne=()=>c(!0),he=()=>c(!1);return z.addEventListener("timeupdate",V),z.addEventListener("durationchange",Z),z.addEventListener("play",ne),z.addEventListener("pause",he),()=>{z.removeEventListener("timeupdate",V),z.removeEventListener("durationchange",Z),z.removeEventListener("play",ne),z.removeEventListener("pause",he)}},[p,y]),w.useEffect(()=>{const z=o.current,V=a.current;!z||!V||!A||(z.currentTime=V.currentTime,z.playbackRate=V.playbackRate,l&&!T?z.play().catch(()=>{}):z.pause())},[l,A,T]),w.useEffect(()=>{o.current&&(o.current.volume=T?0:C)},[C,T]),w.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const W=w.useCallback(()=>{const z=a.current;z&&(l?z.pause():(z.currentTime<p&&(z.currentTime=p),z.play()))},[l,p]),K=z=>{const V=a.current;V&&(V.currentTime=Math.max(p,Math.min(y,z)))},G=z=>{const V=z.target.files?.[0];V&&(A&&URL.revokeObjectURL(A),N(V),k(URL.createObjectURL(V)))},J=()=>{A&&URL.revokeObjectURL(A),N(null),k(null)};w.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);const ie=y-p,re=ie/v;return O?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(dt,{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(Ld,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ps,{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(Wt,{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:W,muted:!!A}),!l&&s.jsx("button",{onClick:W,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(sl,{className:"w-8 h-8 text-white"})})}),A&&s.jsx("audio",{ref:o,src:A,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(Rfe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Op(p)," - ",Op(y)," (",Op(ie),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:q?.thumbnails.map((z,V)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},V))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-y)/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:p,onChange:z=>{const V=parseFloat(z.target.value);V<y-1&&(b(V),a.current&&a.current.currentTime<V&&(a.current.currentTime=V))},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:y,onChange:z=>{const V=parseFloat(z.target.value);V>p+1&&x(V)},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:z=>K(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8308. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8309. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8310. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:W,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(FD,{className:"w-5 h-5 text-white"}):s.jsx(sl,{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(rE,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Op(re),")"]})]}),s.jsx("div",{className:"flex gap-1",children:mKe.map(z=>s.jsxs("button",{onClick:()=>S(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[z,"x"]},z))})]}),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(bP,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),M?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(bP,{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:M.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(M.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!T),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:T?s.jsx(Nme,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Mme,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:z=>D(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8311. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8312. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:J,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(fn,{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(oi,{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:"})," ",Op(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Op(re)," @ ",v,"x speed",M&&" + music overlay"]})]})]}),j.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(dt,{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 gKe=[.25,.5,.75,1,1.5,2,3,4];function uie({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[p,b]=w.useState(0),[y,x]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=u)},[u]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const D=()=>m(C.currentTime),T=()=>b(C.duration),R=()=>c(!0),U=()=>c(!1);return C.addEventListener("timeupdate",D),C.addEventListener("durationchange",T),C.addEventListener("play",R),C.addEventListener("pause",U),()=>{C.removeEventListener("timeupdate",D),C.removeEventListener("durationchange",T),C.removeEventListener("play",R),C.removeEventListener("pause",U)}},[]);const v=()=>{const C=o.current;C&&(l?C.pause():C.play())},S=C=>{const D=o.current;D&&(D.currentTime=parseFloat(C.target.value))},M=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},N=()=>{const C=o.current;C&&(C.currentTime=Math.min(p,C.currentTime+5))},A=C=>{const D=Math.floor(C/60),T=Math.floor(C%60);return`${D}:${T.toString().padStart(2,"0")}`},k=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.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(Ld,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[s.jsx(Ia,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(Ir,{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(Wt,{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:v}),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:A(f)}),s.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8313. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8314. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8315. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:A(p)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:M,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Vfe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(FD,{className:"w-5 h-5 text-white"}):s.jsx(sl,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(Dw,{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:gKe.map(C=>s.jsxs("button",{onClick:()=>d(C),className:`px-2 py-1 text-xs rounded transition-colors ${u===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),y&&r&&s.jsx(pKe,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function xKe({archiveIds:t,onClose:e}){w.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}=ut({queryKey:["archive-comparison",t],queryFn:()=>pe.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(Wt,{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(dt,{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(Rn,{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(bKe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function bKe({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-status-ok":e.status==="failed"?"text-status-error":"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(Rn,{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(Rn,{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(ws,{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 yKe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function vKe(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 _Ke({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.project_id),[b,y]=w.useState(!1);return s.jsx(Et,{children:s.jsxs(At,{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(vf,{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:yKe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Yn,{className:"w-3 h-3"}),vKe(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(uu,{className:"w-5 h-5"}):s.jsx(Zi,{className:"w-5 h-5"})}),s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Xa,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{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),y(!1)},onCancel:()=>y(!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:m||"",onChange:x=>p(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 wKe(){const t=un(),{showToast:e}=qn(),[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=ut({queryKey:["pending-uploads"],queryFn:Fp.list,refetchInterval:1e4}),{data:m}=ut({queryKey:["projects"],queryFn:()=>pe.getProjects()}),p=ht({mutationFn:({id:v,data:S})=>Fp.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:M})=>{l(N=>{const A=new Set(N);return A.delete(M),A})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),b=ht({mutationFn:v=>Fp.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,M)=>{u(N=>{const A=new Set(N);return A.delete(M),A})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=ht({mutationFn:Fp.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),x=ht({mutationFn:Fp.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?s.jsx(Et,{children:s.jsx(At,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(Et,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oi,{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(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Xa,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(At,{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(v=>s.jsx(_Ke,{upload:v,projects:m||[],onArchive:(S,M)=>p.mutate({id:S,data:M}),onDiscard:S=>b.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.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:()=>{y.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 $M(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Db(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function af(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function SKe({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=un(),{showToast:u}=qn(),d=TK(),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(!1),[M,N]=w.useState(!1),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,J]=w.useState(!1),[ie,re]=w.useState(!1),[z,V]=w.useState(null),Z=w.useRef(null),ne=w.useRef(null),he=ht({mutationFn:F=>pe.uploadSource3mf(t.id,F),onSuccess:F=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${F.filename}`)},onError:F=>{u(F.message||"Failed to upload source 3MF","error")}}),fe=ht({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:F=>{u(F.message||"Failed to remove source 3MF","error")}}),le=ht({mutationFn:F=>pe.uploadF3d(t.id,F),onSuccess:F=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${F.filename}`)},onError:F=>{u(F.message||"Failed to upload F3D","error")}}),Ee=ht({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:F=>{u(F.message||"Failed to remove F3D","error")}}),me=ht({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:F=>{F.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${F.filename}`)):F.status==="exists"?u("Timelapse already attached"):F.status==="not_found"&&F.available_files&&F.available_files.length>0?(D(F.available_files),k(!0)):u(F.message||"No matching timelapse found","warning")},onError:F=>{u(F.message||"Failed to scan for timelapse","error")}}),we=ht({mutationFn:F=>pe.selectArchiveTimelapse(t.id,F),onSuccess:F=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${F.filename}`),k(!1),D([])},onError:F=>{u(F.message||"Failed to attach timelapse","error")}}),De=ht({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),ee=ht({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:F=>{c.invalidateQueries({queryKey:["archives"]}),u(F.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Qe}=ut({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),B=ht({mutationFn:F=>pe.updateArchive(t.id,{project_id:F}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),te=F=>{F.preventDefault(),V({x:F.clientX,y:F.clientY})},H=[...af(t.filename)?[{label:"Print",icon:s.jsx(Br,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(ti,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"Open in Bambu Studio",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const F=t.print_name||t.filename||"model",de=`${window.location.origin}${pe.getArchiveForSlicer(t.id,F)}`;qc(de)}}]:[{label:"Slice",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const F=t.print_name||t.filename||"model",de=`${window.location.origin}${pe.getArchiveForSlicer(t.id,F)}`;qc(de)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Id,{className:"w-4 h-4"}),onClick:()=>{const F=t.external_url||t.makerworld_url;F&&window.open(F,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Fs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Ld,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(bK,{className:"w-4 h-4"}),onClick:()=>me.mutate(),disabled:!t.printer_id||!!t.timelapse_path||me.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(kw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const F=document.createElement("a");F.href=pe.getSource3mfDownloadUrl(t.id),F.download=`${t.print_name||t.filename}_source.3mf`,F.click()}else Z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(oi,{className:"w-4 h-4"}),onClick:()=>Z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Fs,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>{const F=document.createElement("a");F.href=pe.getF3dDownloadUrl(t.id),F.download=`${t.print_name||t.filename}.f3d`,F.click()}},{label:"Remove F3D",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>re(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>{const F=document.createElement("a");F.href=pe.getArchiveDownload(t.id),F.download=`${t.print_name||t.filename}.3mf`,F.click()}},{label:"Copy Download Link",icon:s.jsx(rl,{className:"w-4 h-4"}),onClick:()=>{const F=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(F).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(xK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(fg,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Wa,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Uf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ee.mutate()},{label:"Edit",icon:s.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>S(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(wa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(wa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const F=[];if(t.project_id&&F.push({label:"Remove from Project",icon:s.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>B.mutate(null)}),!a)F.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const de=a.filter(Ae=>Ae.status==="active");de.length===0?F.push({label:"No projects available",icon:s.jsx(wa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):de.forEach(Ae=>{F.push({label:Ae.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ae.color||"#888"}}),onClick:()=>B.mutate(Ae.id),disabled:t.project_id===Ae.id})})}return F})()},{label:n?"Deselect":"Select",icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return s.jsxs(Et,{"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:te,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:F=>{F.stopPropagation(),r(t.id)},children:n?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{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:pe.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(by,{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:F=>{F.stopPropagation();const de=F.currentTarget.getBoundingClientRect();V({x:de.left,y:de.bottom+4})},title:"Right-click for more options",children:s.jsx(Od,{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:F=>{F.stopPropagation(),ee.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(Uf,{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-status-error/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(rl,{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:F=>{F.stopPropagation();const de=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ae=`${window.location.origin}${pe.getSource3mfForSlicer(t.id,de)}`;qc(Ae)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(kw,{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:F=>{F.stopPropagation(),window.location.href=pe.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Fs,{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:F=>{F.stopPropagation(),N(!0)},title:"View timelapse",children:s.jsx(Ld,{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:F=>{F.stopPropagation(),O(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(fg,{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})]}),Qe&&Qe.length>0&&s.jsx(hs,{to:`/files?folder=${Qe[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:F=>F.stopPropagation(),title:`Open folder: ${Qe[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(il,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(At,{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 ${af(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:af(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:af(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(F=>F.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(F=>F.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: ${Db(t.print_time_seconds||0)}
  8316. Actual: ${Db(t.actual_time_seconds||0)}
  8317. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Db(t.actual_time_seconds)}`:`Estimated: ${Db(t.print_time_seconds||0)}`,children:[s.jsx(Yn,{className:"w-3 h-3"}),Db(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(Zl,{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(al,{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(Fs,{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((F,de)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:F},title:F},de))})]})]}),(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(vK,{className:"w-3 h-3"})}),t.tags?.split(",").map((F,de)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:F.trim()},de))]}),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:bg(t.created_at,l)}),s.jsx("span",{children:$M(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[af(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),children:[s.jsx(Br,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const F=t.print_name||t.filename||"model",de=`${window.location.origin}${pe.getArchiveForSlicer(t.id,F)}`;qc(de)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const F=t.print_name||t.filename||"model",de=`${window.location.origin}${pe.getArchiveForSlicer(t.id,F)}`;qc(de)},title:"Open in Bambu Studio to slice",children:[s.jsx(zr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const F=t.external_url||t.makerworld_url;F&&window.open(F,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:s.jsx(Id,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Fs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const F=document.createElement("a");F.href=pe.getArchiveDownload(t.id),F.download=`${t.print_name||t.filename}.3mf`,F.click()},title:"Download",children:s.jsx(Ir,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>S(!0),title:"Edit",children:s.jsx(Ia,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:s.jsx(fn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(vte,{archive:t,onClose:()=>S(!1)}),f&&s.jsx(gte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(rh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),y&&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:()=>{De.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:()=>{fe.mutate(),J(!1)},onCancel:()=>J(!1)}),ie&&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:()=>{Ee.mutate(),re(!1)},onCancel:()=>re(!1)}),z&&s.jsx(_te,{x:z.x,y:z.y,items:H,onClose:()=>V(null)}),M&&t.timelapse_path&&s.jsx(uie,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>N(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),N(!1)}}),A&&C.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:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Wt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(F=>s.jsxs("button",{onClick:()=>we.mutate(F.name),disabled:we.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(Ld,{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:F.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[$M(F.size),F.mtime&&` • ${bg(F.mtime,l)}`]})]})]},F.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Me,{variant:"secondary",onClick:()=>{k(!1),D([])},className:"w-full",children:"Cancel"})})]})}),T&&s.jsx(wte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async F=>{try{await pe.deleteArchivePhoto(t.id,F),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(cie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),W&&s.jsx(rh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),s.jsx("input",{ref:Z,type:"file",accept:".3mf",className:"hidden",onChange:F=>{const de=F.target.files?.[0];de&&he.mutate(de),F.target.value=""}}),s.jsx("input",{ref:ne,type:"file",accept:".f3d",className:"hidden",onChange:F=>{const de=F.target.files?.[0];de&&le.mutate(de),F.target.value=""}})]})}function MKe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=un(),{showToast:c}=qn(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(!1),[v,S]=w.useState(!1),[M,N]=w.useState(!1),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,J]=w.useState(!1),[ie,re]=w.useState(null),z=w.useRef(null),V=w.useRef(null),Z=ht({mutationFn:Y=>pe.uploadSource3mf(t.id,Y),onSuccess:Y=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${Y.filename}`)},onError:Y=>{c(Y.message||"Failed to upload source 3MF","error")}}),ne=ht({mutationFn:()=>pe.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:Y=>{c(Y.message||"Failed to remove source 3MF","error")}}),he=ht({mutationFn:Y=>pe.uploadF3d(t.id,Y),onSuccess:Y=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${Y.filename}`)},onError:Y=>{c(Y.message||"Failed to upload F3D","error")}}),fe=ht({mutationFn:()=>pe.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:Y=>{c(Y.message||"Failed to remove F3D","error")}}),le=ht({mutationFn:()=>pe.scanArchiveTimelapse(t.id),onSuccess:Y=>{Y.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${Y.filename}`)):Y.status==="exists"?c("Timelapse already attached"):Y.status==="not_found"&&Y.available_files&&Y.available_files.length>0?(D(Y.available_files),k(!0)):c(Y.message||"No matching timelapse found","warning")},onError:Y=>{c(Y.message||"Failed to scan for timelapse","error")}}),Ee=ht({mutationFn:Y=>pe.selectArchiveTimelapse(t.id,Y),onSuccess:Y=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${Y.filename}`),k(!1),D([])},onError:Y=>{c(Y.message||"Failed to attach timelapse","error")}}),me=ht({mutationFn:()=>pe.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),we=ht({mutationFn:()=>pe.toggleFavorite(t.id),onSuccess:Y=>{l.invalidateQueries({queryKey:["archives"]}),c(Y.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:De}=ut({queryKey:["archive-folders",t.id],queryFn:()=>pe.getLibraryFoldersByArchive(t.id)}),ee=ht({mutationFn:Y=>pe.updateArchive(t.id,{project_id:Y}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Qe=Y=>{Y.preventDefault(),re({x:Y.clientX,y:Y.clientY})},te=[...af(t.filename)?[{label:"Print",icon:s.jsx(Br,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(ti,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Open in Bambu Studio",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const Y=t.print_name||t.filename||"model",H=`${window.location.origin}${pe.getArchiveForSlicer(t.id,Y)}`;qc(H)}}]:[{label:"Slice",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const Y=t.print_name||t.filename||"model",H=`${window.location.origin}${pe.getArchiveForSlicer(t.id,Y)}`;qc(H)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(Id,{className:"w-4 h-4"}),onClick:()=>{const Y=t.external_url||t.makerworld_url;Y&&window.open(Y,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Fs,{className:"w-4 h-4"}),onClick:()=>S(!0)},{label:"View Timelapse",icon:s.jsx(Ld,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(bK,{className:"w-4 h-4"}),onClick:()=>le.mutate(),disabled:!t.printer_id||!!t.timelapse_path||le.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(kw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const Y=document.createElement("a");Y.href=pe.getSource3mfDownloadUrl(t.id),Y.download=`${t.print_name||t.filename}_source.3mf`,Y.click()}else z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(oi,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Fs,{className:"w-4 h-4"}),onClick:()=>V.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>{const Y=document.createElement("a");Y.href=pe.getF3dDownloadUrl(t.id),Y.download=`${t.print_name||t.filename}.f3d`,Y.click()}},{label:"Remove F3D",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Ir,{className:"w-4 h-4"}),onClick:()=>{const Y=document.createElement("a");Y.href=pe.getArchiveDownload(t.id),Y.download=`${t.print_name||t.filename}.3mf`,Y.click()}},{label:"Copy Download Link",icon:s.jsx(rl,{className:"w-4 h-4"}),onClick:()=>{const Y=`${window.location.origin}${pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Y).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(xK,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(fg,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Wa,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Uf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>we.mutate()},{label:"Edit",icon:s.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(wa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(wa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const Y=[];if(t.project_id&&Y.push({label:"Remove from Project",icon:s.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>ee.mutate(null)}),!a)Y.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const H=a.filter(F=>F.status==="active");H.length===0?Y.push({label:"No projects available",icon:s.jsx(wa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):H.forEach(F=>{Y.push({label:F.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:F.color||"#888"}}),onClick:()=>ee.mutate(F.id),disabled:t.project_id===F.id})})}return Y})()},{label:n?"Deselect":"Select",icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(fn,{className:"w-4 h-4"}),onClick:()=>m(!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:Qe,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(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:pe.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(by,{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(Ld,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),De&&De.length>0&&s.jsx(hs,{to:`/files?folder=${De[0].id}`,className:"flex-shrink-0",title:`Open folder: ${De[0].name}`,onClick:Y=>Y.stopPropagation(),children:s.jsx(il,{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((Y,H)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Y},title:Y},H))})]})]}),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:xg(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:$M(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const Y=t.print_name||t.filename||"model",H=`${window.location.origin}${pe.getArchiveForSlicer(t.id,Y)}`;qc(H)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:s.jsx(Id,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const Y=document.createElement("a");Y.href=pe.getArchiveDownload(t.id),Y.download=`${t.print_name||t.filename}.3mf`,Y.click()},title:"Download",children:s.jsx(Ir,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(fn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:Y=>{const H=Y.currentTarget.getBoundingClientRect();re({x:H.left,y:H.bottom+4})},title:"More options",children:s.jsx(Od,{className:"w-4 h-4"})})]})]}),u&&s.jsx(vte,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(gte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>S(!1)}),p&&s.jsx(rh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),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:()=>{me.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&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:()=>{ne.mutate(),K(!1)},onCancel:()=>K(!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:()=>{fe.mutate(),J(!1)},onCancel:()=>J(!1)}),ie&&s.jsx(_te,{x:ie.x,y:ie.y,items:te,onClose:()=>re(null)}),M&&t.timelapse_path&&s.jsx(uie,{src:pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>N(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),N(!1)}}),A&&C.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:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Wt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(Y=>s.jsxs("button",{onClick:()=>Ee.mutate(Y.name),disabled:Ee.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:Y.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:$M(Y.size)}),Y.mtime&&s.jsx("span",{children:xg(Y.mtime)})]})]},Y.name))})]})}),T&&s.jsx(wte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&s.jsx(Ste,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async Y=>{try{await pe.deleteArchivePhoto(t.id,Y),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(cie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),y&&s.jsx(rh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),s.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:Y=>{const H=Y.target.files?.[0];H&&Z.mutate(H),Y.target.value=""}}),s.jsx("input",{ref:V,type:"file",accept:".f3d",className:"hidden",onChange:Y=>{const H=Y.target.files?.[0];H&&he.mutate(H),Y.target.value=""}})]})}const EKe=[{id:"all",label:"All Archives",icon:s.jsx(il,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Yn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(ti,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(ti,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(Uf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(Qi,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(rl,{className:"w-4 h-4"})}];function NKe(){const t=un(),{showToast:e}=qn(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const se=localStorage.getItem("archiveFilterPrinter");return se?Number(se):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const se=localStorage.getItem("archiveFilterColors");return se?new Set(JSON.parse(se)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,b]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,x]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,S]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[M,N]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[A,k]=w.useState(!1),[C,D]=w.useState([]),[T,R]=w.useState(!1),[U,O]=w.useState(new Set),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,J]=w.useState(!1),[ie,re]=w.useState(!1),[z,V]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[Z,ne]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[he,fe]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[le,Ee]=w.useState(!1),[me,we]=w.useState(!1),[De,ee]=w.useState(!1),[Qe,B]=w.useState(null);w.useEffect(()=>{if(Qe){const se=setTimeout(()=>{const ve=document.querySelector(`[data-archive-id="${Qe}"]`);ve&&ve.scrollIntoView({behavior:"smooth",block:"center"})},100),ze=setTimeout(()=>B(null),5e3);return()=>{clearTimeout(se),clearTimeout(ze)}}},[Qe]);const{data:te,isLoading:Y}=ut({queryKey:["archives",a],queryFn:()=>pe.getArchives(a||void 0)}),{data:H}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:F}=ut({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:de}=ut({queryKey:["settings"],queryFn:pe.getSettings}),Ae=de?.time_format||"system",Le=ht({mutationFn:async se=>(await Promise.all(se.map(ze=>pe.deleteArchive(ze))),se.length),onSuccess:se=>{t.invalidateQueries({queryKey:["archives"]}),O(new Set),e(`${se} archive${se!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]),w.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",M)},[M]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",Z)},[Z]),w.useEffect(()=>{localStorage.setItem("archiveCollection",he)},[he]);const Se=new Map(H?.map(se=>[se.id,se.name])||[]),$=[...new Set(te?.flatMap(se=>se.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),L=[...new Set(te?.flatMap(se=>se.filament_color?.split(",")||[]).filter(Boolean)||[])],X=[...new Set(te?.flatMap(se=>se.tags?.split(",").map(ze=>ze.trim())||[]).filter(Boolean)||[])].sort(),xe=te?.filter(se=>{const ze=new Date,ve=gi(se.created_at)||new Date(0);let He=!0;switch(he){case"recent":He=ze.getTime()-ve.getTime()<1440*60*1e3;break;case"this-week":He=ze.getTime()-ve.getTime()<10080*60*1e3;break;case"this-month":He=ve.getMonth()===ze.getMonth()&&ve.getFullYear()===ze.getFullYear();break;case"favorites":He=se.is_favorite===!0;break;case"failed":He=se.status==="failed"||se.status==="aborted";break;case"duplicates":He=se.duplicate_count>0;break}const Oe=(se.print_name||se.filename).toLowerCase().includes(r.toLowerCase()),Ne=!l||se.filament_type?.split(", ").includes(l),Be=se.filament_color?.split(",")||[],at=u.size===0||(f==="or"?Be.some(Xt=>u.has(Xt)):[...u].every(Xt=>Be.includes(Xt))),Rt=he==="favorites"||!p||se.is_favorite,Tt=he==="failed"||!y||se.status!=="failed"&&se.status!=="aborted",nn=se.tags?.split(",").map(Xt=>Xt.trim())||[],Lt=!v||nn.includes(v),ln=af(se.filename);return He&&Oe&&Ne&&at&&Rt&&Tt&&Lt&&(M==="all"||M==="gcode"&&ln||M==="source"&&!ln)}).sort((se,ze)=>{switch(Z){case"date-desc":return(gi(ze.created_at)?.getTime()||0)-(gi(se.created_at)?.getTime()||0);case"date-asc":return(gi(se.created_at)?.getTime()||0)-(gi(ze.created_at)?.getTime()||0);case"name-asc":return(se.print_name||se.filename).localeCompare(ze.print_name||ze.filename);case"name-desc":return(ze.print_name||ze.filename).localeCompare(se.print_name||se.filename);case"size-desc":return ze.file_size-se.file_size;case"size-asc":return se.file_size-ze.file_size;default:return 0}}),_e=q||U.size>0,ae=se=>{O(ze=>{const ve=new Set(ze);return ve.has(se)?ve.delete(se):ve.add(se),ve})},Te=()=>{xe&&O(new Set(xe.map(se=>se.id)))},Pe=()=>{O(new Set),j(!1)},Xe=se=>{d(ze=>{const ve=new Set(ze);return ve.has(se)?ve.delete(se):ve.add(se),ve})},Je=()=>{d(new Set)},Ze=()=>{i(""),o(null),c(null),b(!1),x(!1),S(null),N("all")},oe=r||a||l||p||y||v||M!=="all",ye=w.useCallback(se=>{se.preventDefault(),se.dataTransfer.types.includes("Files")&&R(!0)},[]),Ce=w.useCallback(se=>{se.preventDefault(),se.currentTarget===se.target&&R(!1)},[]),$e=w.useCallback(se=>{se.preventDefault(),R(!1);const ze=Array.from(se.dataTransfer.files).filter(ve=>ve.name.endsWith(".3mf"));ze.length>0?(D(ze),k(!0)):se.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),lt=w.useCallback(se=>{const ze=se.target;if(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.isContentEditable){se.key==="Escape"&&ze.blur();return}switch(se.key){case"/":se.preventDefault(),n.current?.focus();break;case"u":case"U":!se.metaKey&&!se.ctrlKey&&(se.preventDefault(),k(!0));break;case"Escape":_e&&Pe();break}},[_e]);return w.useEffect(()=>(document.addEventListener("keydown",lt),()=>document.removeEventListener("keydown",lt)),[lt]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:ye,onDragLeave:Ce,onDrop:$e,children:[T&&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(oi,{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"})]})}),_e&&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(Me,{variant:"secondary",size:"sm",onClick:Pe,children:[s.jsx(Wt,{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:[U.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Te,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[s.jsx(gg,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>re(!0),children:[s.jsx(wa,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>{const se=Array.from(U);Promise.all(se.map(ze=>pe.toggleFavorite(ze))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${se.length} archive${se.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(Uf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[s.jsx(fn,{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:he,onChange:se=>fe(se.target.value),children:EKe.map(se=>s.jsx("option",{value:se.id,children:se.label},se.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[xe?.length||0," of ",te?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>Ee(!le),disabled:me,children:[me?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(jw,{className:"w-4 h-4"}),"Export"]}),le&&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()=>{Ee(!1),we(!0);try{const{blob:se,filename:ze}=await pe.exportArchives({format:"csv",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(se),He=document.createElement("a");He.href=ve,He.download=ze,He.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{we(!1)}},children:[s.jsx(Wa,{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()=>{Ee(!1),we(!0);try{const{blob:se,filename:ze}=await pe.exportArchives({format:"xlsx",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(se),He=document.createElement("a");He.href=ve,He.download=ze,He.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{we(!1)}},children:[s.jsx(jw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Me,{variant:"secondary",onClick:()=>ee(!0),children:[s.jsx(Zp,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!_e&&s.jsxs(Me,{variant:"secondary",onClick:()=>j(!0),children:[s.jsx(ol,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(oi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(Et,{className:"mb-6",children:s.jsxs(At,{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(va,{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:se=>i(se.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(nE,{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:se=>o(se.target.value?Number(se.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),H?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Zl,{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:se=>c(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),$.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(kw,{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:M,onChange:se=>N(se.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(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(Uf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>x(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(Qi,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),X.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(gg,{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:v||"",onChange:se=>S(se.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),X.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(oK,{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:Z,onChange:se=>ne(se.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 ${z==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("grid"),title:"Grid view",children:s.jsx(sE,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("list"),title:"List view",children:s.jsx(oE,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("calendar"),title:"Calendar view",children:s.jsx(Yue,{className:"w-4 h-4"})})]})]}),oe&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:Ze,className:"text-bambu-gray hover:text-white",children:[s.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),L.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:()=>m(se=>se==="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:L.map(se=>s.jsx("button",{onClick:()=>Xe(se),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(se)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:se},title:se},se))}),u.size>0&&s.jsxs("button",{onClick:Je,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(wKe,{}),Y?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):xe?.length===0?s.jsx(Et,{children:s.jsxs(At,{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"})]})}):z==="calendar"?s.jsx(Et,{className:"p-6",children:s.jsx(h$e,{archives:xe||[],onArchiveClick:se=>{i(""),V("grid"),B(se.id)},highlightedArchiveId:Qe})}):z==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:xe?.map(se=>s.jsx(SKe,{archive:se,printerName:se.printer_id?Se.get(se.printer_id)||"Unknown":"No Printer",isSelected:U.has(se.id),onSelect:ae,selectionMode:_e,projects:F,isHighlighted:se.id===Qe,timeFormat:Ae},se.id))}):z==="list"?s.jsx(Et,{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"})]}),xe?.map(se=>s.jsx(MKe,{archive:se,printerName:se.printer_id?Se.get(se.printer_id)||"Unknown":"No Printer",isSelected:U.has(se.id),onSelect:ae,selectionMode:_e,projects:F,isHighlighted:se.id===Qe},se.id))]})}):null,A&&s.jsx(r$e,{onClose:()=>{k(!1),D([])},initialFiles:C}),W&&s.jsx(Un,{title:"Delete Archives",message:`Are you sure you want to delete ${U.size} archive${U.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${U.size}`,variant:"danger",onConfirm:()=>{Le.mutate(Array.from(U)),K(!1)},onCancel:()=>K(!1)}),G&&s.jsx(s$e,{selectedIds:Array.from(U),existingTags:X,onClose:()=>J(!1)}),ie&&s.jsx(o$e,{selectedIds:Array.from(U),onClose:()=>re(!1)}),De&&U.size>=2&&U.size<=5&&s.jsx(xKe,{archiveIds:Array.from(U),onClose:()=>{ee(!1),O(new Set),j(!1)}})]})}function AKe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const PN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function lI(t){return"nodeType"in t}function Es(t){var e,n;return t?fx(t)?t:lI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function cI(t){const{Document:e}=Es(t);return t instanceof e}function Zy(t){return fx(t)?!1:t instanceof Es(t).HTMLElement}function die(t){return t instanceof Es(t).SVGElement}function mx(t){return t?fx(t)?t.document:lI(t)?cI(t)?t:Zy(t)||die(t)?t.ownerDocument:document:document:document}const sc=PN?w.useLayoutEffect:w.useEffect;function uI(t){const e=w.useRef(t);return sc(()=>{e.current=t}),w.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 TKe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function hy(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return sc(()=>{n.current!==t&&(n.current=t)},e),n}function Qy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function HM(t){const e=uI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function dD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let Uj={};function Jy(t,e){return w.useMemo(()=>{if(e)return e;const n=Uj[t]==null?0:Uj[t]+1;return Uj[t]=n,t+"-"+n},[t,e])}function hie(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 dg=hie(1),fy=hie(-1);function CKe(t){return"clientX"in t&&"clientY"in t}function dI(t){if(!t)return!1;const{KeyboardEvent:e}=Es(t.target);return e&&t instanceof e}function kKe(t){if(!t)return!1;const{TouchEvent:e}=Es(t.target);return e&&t instanceof e}function hD(t){if(kKe(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 CKe(t)?{x:t.clientX,y:t.clientY}:null}const Hg=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[Hg.Translate.toString(t),Hg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),XW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function jKe(t){return t.matches(XW)?t:t.querySelector(XW)}const PKe={display:"none"};function RKe(t){let{id:e,value:n}=t;return Dr.createElement("div",{id:e,style:PKe},n)}function DKe(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 Dr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function OKe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const fie=w.createContext(null);function LKe(t){const e=w.useContext(fie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function IKe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.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 FKe={draggable:`
  8318. To pick up a draggable item, press the space bar.
  8319. While dragging, use the arrow keys to move the item.
  8320. Press space again to drop the item in its new position, or press escape to cancel.
  8321. `},UKe={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 zKe(t){let{announcements:e=UKe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=FKe}=t;const{announce:a,announcement:o}=OKe(),l=Jy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),LKe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:p}=f;e.onDragMove&&a(e.onDragMove({active:m,over:p}))},onDragOver(f){let{active:m,over:p}=f;a(e.onDragOver({active:m,over:p}))},onDragEnd(f){let{active:m,over:p}=f;a(e.onDragEnd({active:m,over:p}))},onDragCancel(f){let{active:m,over:p}=f;a(e.onDragCancel({active:m,over:p}))}}),[a,e])),!c)return null;const d=Dr.createElement(Dr.Fragment,null,Dr.createElement(RKe,{id:r,value:i.draggable}),Dr.createElement(DKe,{id:l,announcement:o}));return n?Xc.createPortal(d,n):d}var Ai;(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"})(Ai||(Ai={}));function VM(){}function GM(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function mie(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const hl=Object.freeze({x:0,y:0});function pie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function gie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function BKe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function YW(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 xie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function ZW(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 bie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=ZW(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=pie(ZW(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(gie)},$Ke=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=YW(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=YW(c),d=i.reduce((m,p,b)=>m+pie(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(gie)};function HKe(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 VKe=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=HKe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(BKe)};function GKe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function yie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:hl}function WKe(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 qKe=WKe(1);function KKe(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 XKe(t,e,n){const r=KKe(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 YKe={ignoreTransform:!1};function px(t,e){e===void 0&&(e=YKe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Es(t).getComputedStyle(t);u&&(n=XKe(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 QW(t){return px(t,{ignoreTransform:!0})}function ZKe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function QKe(t,e){return e===void 0&&(e=Es(t).getComputedStyle(t)),e.position==="fixed"}function JKe(t,e){e===void 0&&(e=Es(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 RN(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(cI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Zy(i)||die(i)||n.includes(i))return n;const a=Es(t).getComputedStyle(i);return i!==t&&JKe(i,a)&&n.push(i),QKe(i,a)?n:r(i.parentNode)}return t?r(t):n}function vie(t){const[e]=RN(t,1);return e??null}function zj(t){return!PN||!t?null:fx(t)?t:lI(t)?cI(t)||t===mx(t).scrollingElement?window:Zy(t)?t:null:null}function _ie(t){return fx(t)?t.scrollX:t.scrollLeft}function wie(t){return fx(t)?t.scrollY:t.scrollTop}function fD(t){return{x:_ie(t),y:wie(t)}}var Vi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Vi||(Vi={}));function Sie(t){return!PN||!t?!1:t===document.scrollingElement}function Mie(t){const e={x:0,y:0},n=Sie(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 eXe={x:.2,y:.2};function tXe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=eXe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=Mie(t),p={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Vi.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Vi.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(p.x=Vi.Forward,b.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Vi.Backward,b.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:b}}function nXe(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 Eie(t){return t.reduce((e,n)=>dg(e,fD(n)),hl)}function rXe(t){return t.reduce((e,n)=>e+_ie(n),0)}function iXe(t){return t.reduce((e,n)=>e+wie(n),0)}function aXe(t,e){if(e===void 0&&(e=px),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);vie(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const sXe=[["x",["left","right"],rXe],["y",["top","bottom"],iXe]];class hI{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=RN(n),i=Eie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of sXe)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 y0{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 oXe(t){const{EventTarget:e}=Es(t);return t instanceof e?t:mx(t)}function Bj(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 vo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(vo||(vo={}));function JW(t){t.preventDefault()}function lXe(t){t.stopPropagation()}var In;(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"})(In||(In={}));const Nie={start:[In.Space,In.Enter],cancel:[In.Esc],end:[In.Space,In.Enter,In.Tab]},cXe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case In.Right:return{...n,x:n.x+25};case In.Left:return{...n,x:n.x-25};case In.Down:return{...n,y:n.y+25};case In.Up:return{...n,y:n.y-25}}};class DN{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 y0(mx(n)),this.windowListeners=new y0(Es(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vo.Resize,this.handleCancel),this.windowListeners.add(vo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&aXe(r),n(hl)}handleKeyDown(e){if(dI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Nie,coordinateGetter:o=cXe,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}:hl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=fy(f,d),p={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const x=e.code,{isTop:v,isRight:S,isLeft:M,isBottom:N,maxScroll:A,minScroll:k}=Mie(y),C=nXe(y),D={x:Math.min(x===In.Right?C.right-C.width/2:C.right,Math.max(x===In.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(x===In.Down?C.bottom-C.height/2:C.bottom,Math.max(x===In.Down?C.top:C.top+C.height/2,f.y))},T=x===In.Right&&!S||x===In.Left&&!M,R=x===In.Down&&!N||x===In.Up&&!v;if(T&&D.x!==f.x){const U=y.scrollLeft+m.x,O=x===In.Right&&U<=A.x||x===In.Left&&U>=k.x;if(O&&!m.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=x===In.Right?y.scrollLeft-A.x:y.scrollLeft-k.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(R&&D.y!==f.y){const U=y.scrollTop+m.y,O=x===In.Down&&U<=A.y||x===In.Up&&U>=k.y;if(O&&!m.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=x===In.Down?y.scrollTop-A.y:y.scrollTop-k.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,dg(fy(f,this.referenceCoordinates),p))}}}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()}}DN.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Nie,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 eq(t){return!!(t&&"distance"in t)}function tq(t){return!!(t&&"delay"in t)}class fI{constructor(e,n,r){var i;r===void 0&&(r=oXe(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=mx(o),this.documentListeners=new y0(this.document),this.listeners=new y0(r),this.windowListeners=new y0(Es(o)),this.initialCoordinates=(i=hD(a))!=null?i:hl,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(vo.Resize,this.handleCancel),this.windowListeners.add(vo.DragStart,JW),this.windowListeners.add(vo.VisibilityChange,this.handleCancel),this.windowListeners.add(vo.ContextMenu,JW),this.documentListeners.add(vo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(tq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(eq(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(vo.Click,lXe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vo.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=hD(e))!=null?n:hl,u=fy(i,c);if(!r&&l){if(eq(l)){if(l.tolerance!=null&&Bj(u,l.tolerance))return this.handleCancel();if(Bj(u,l.distance))return this.handleStart()}if(tq(l)&&Bj(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===In.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const uXe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ON extends fI{constructor(e){const{event:n}=e,r=mx(n.target);super(e,uXe,r)}}ON.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 dXe={move:{name:"mousemove"},end:{name:"mouseup"}};var mD;(function(t){t[t.RightClick=2]="RightClick"})(mD||(mD={}));class hXe extends fI{constructor(e){super(e,dXe,mx(e.event.target))}}hXe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===mD.RightClick?!1:(r?.({event:n}),!0)}}];const $j={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fXe extends fI{constructor(e){super(e,$j)}static setup(){return window.addEventListener($j.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener($j.move.name,e)};function e(){}}}fXe.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 v0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(v0||(v0={}));var WM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(WM||(WM={}));function mXe(t){let{acceleration:e,activator:n=v0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=WM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=gXe({delta:f,disabled:!a}),[b,y]=TKe(),x=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),S=w.useMemo(()=>{switch(n){case v0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case v0.DraggableRect:return i}},[n,i,c]),M=w.useRef(null),N=w.useCallback(()=>{const k=M.current;if(!k)return;const C=x.current.x*v.current.x,D=x.current.y*v.current.y;k.scrollBy(C,D)},[]),A=w.useMemo(()=>l===WM.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!S){y();return}for(const k of A){if(r?.(k)===!1)continue;const C=u.indexOf(k),D=d[C];if(!D)continue;const{direction:T,speed:R}=tXe(k,D,S,e,m);for(const U of["x","y"])p[U][T[U]]||(R[U]=0,T[U]=0);if(R.x>0||R.y>0){y(),M.current=k,b(N,o),x.current=R,v.current=T;return}}x.current={x:0,y:0},v.current={x:0,y:0},y()},[e,N,r,y,a,o,JSON.stringify(S),JSON.stringify(p),b,u,A,d,JSON.stringify(m)])}const pXe={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function gXe(t){let{delta:e,disabled:n}=t;const r=dD(e);return Qy(i=>{if(n||!r||!i)return pXe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Vi.Backward]:i.x[Vi.Backward]||a.x===-1,[Vi.Forward]:i.x[Vi.Forward]||a.x===1},y:{[Vi.Backward]:i.y[Vi.Backward]||a.y===-1,[Vi.Forward]:i.y[Vi.Forward]||a.y===1}}},[n,e,r])}function xXe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Qy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function bXe(t,e){return w.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 my;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(my||(my={}));var pD;(function(t){t.Optimized="optimized"})(pD||(pD={}));const nq=new Map;function yXe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=x(),m=hy(f),p=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(S=>S===null?v:S.concat(v.filter(M=>!S.includes(M))))},[m]),b=w.useRef(null),y=Qy(v=>{if(f&&!n)return nq;if(!v||v===nq||d.current!==t||a!=null){const S=new Map;for(let M of t){if(!M)continue;if(a&&a.length>0&&!a.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const N=M.node.current,A=N?new hI(c(N),N):null;M.rect.current=A,A&&S.set(M.id,A)}return S}return v},[t,a,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||p()},[n,f]),w.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),w.useEffect(()=>{f||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{p(),b.current=null},l))},[l,f,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:a!=null};function x(){switch(u){case my.Always:return!1;case my.BeforeDragging:return n;default:return!n}}}function Aie(t,e){return Qy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function vXe(t,e){return Aie(t,e)}function _Xe(t){let{callback:e,disabled:n}=t;const r=uI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function LN(t){let{callback:e,disabled:n}=t;const r=uI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function wXe(t){return new hI(px(t),t)}function rq(t,e,n){e===void 0&&(e=wXe);const[r,i]=w.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=_Xe({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=LN({callback:a});return sc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function SXe(t){const e=Aie(t);return yie(t,e)}const iq=[];function MXe(t){const e=w.useRef(t),n=Qy(r=>t?r&&r!==iq&&t&&e.current&&t.parentNode===e.current.parentNode?r:RN(t):iq,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function EXe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=zj(a.target);o&&n(l=>l?(l.set(o,fD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=zj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,fD(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=zj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>dg(a,o),hl):Eie(t):hl,[t,e])}function aq(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==hl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?fy(t,n.current):hl}function NXe(t){w.useEffect(()=>{if(!PN)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 AXe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Tie(t){return w.useMemo(()=>t?ZKe(t):null,[t])}const sq=[];function TXe(t,e){e===void 0&&(e=px);const[n]=t,r=Tie(n?Es(n):null),[i,a]=w.useState(sq);function o(){a(()=>t.length?t.map(c=>Sie(c)?r:new hI(e(c),c)):sq)}const l=LN({callback:o});return sc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function CXe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Zy(e)?e:t}function kXe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Zy(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=LN({callback:i}),o=w.useCallback(u=>{const d=CXe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=HM(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const jXe=[{sensor:ON,options:{}},{sensor:DN,options:{}}],PXe={current:{}},ww={draggable:{measure:QW},droppable:{measure:QW,strategy:my.WhileDragging,frequency:pD.Optimized},dragOverlay:{measure:px}};class _0 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 RXe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:VM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ww,measureDroppableContainers:VM,windowRect:null,measuringScheduled:!1},DXe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:VM,draggableNodes:new Map,over:null,measureDroppableContainers:VM},IN=w.createContext(DXe),Cie=w.createContext(RXe);function OXe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _0}}}function LXe(t,e){switch(e.type){case Ai.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ai.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 Ai.DragEnd:case Ai.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ai.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new _0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ai.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 _0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Ai.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new _0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function IXe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(IN),a=dD(r),o=dD(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!dI(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=jKe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function FXe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function UXe(t){return w.useMemo(()=>({draggable:{...ww.draggable,...t?.draggable},droppable:{...ww.droppable,...t?.droppable},dragOverlay:{...ww.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function zXe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;sc(()=>{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=yie(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 m=vie(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const kie=w.createContext({...hl,scaleX:1,scaleY:1});var _d;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(_d||(_d={}));const jie=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=jXe,collisionDetection:f=VKe,measuring:m,modifiers:p,...b}=e;const y=w.useReducer(LXe,void 0,OXe),[x,v]=y,[S,M]=IKe(),[N,A]=w.useState(_d.Uninitialized),k=N===_d.Initialized,{draggable:{active:C,nodes:D,translate:T},droppable:{containers:R}}=x,U=C!=null?D.get(C):null,O=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var He;return C!=null?{id:C,data:(He=U?.data)!=null?He:PXe,rect:O}:null},[C,U]),j=w.useRef(null),[W,K]=w.useState(null),[G,J]=w.useState(null),ie=hy(b,Object.values(b)),re=Jy("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),V=UXe(m),{droppableRects:Z,measureDroppableContainers:ne,measuringScheduled:he}=yXe(z,{dragging:k,dependencies:[T.x,T.y],config:V.droppable}),fe=xXe(D,C),le=w.useMemo(()=>G?hD(G):null,[G]),Ee=ve(),me=vXe(fe,V.draggable.measure);zXe({activeNode:C!=null?D.get(C):null,config:Ee.layoutShiftCompensation,initialRect:me,measure:V.draggable.measure});const we=rq(fe,V.draggable.measure,me),De=rq(fe?fe.parentElement:null),ee=w.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:Z,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Qe=R.getNodeFor((n=ee.current.over)==null?void 0:n.id),B=kXe({measure:V.dragOverlay.measure}),te=(r=B.nodeRef.current)!=null?r:fe,Y=k?(i=B.rect)!=null?i:we:null,H=!!(B.nodeRef.current&&B.rect),F=SXe(H?null:we),de=Tie(te?Es(te):null),Ae=MXe(k?Qe??fe:null),Le=TXe(Ae),Se=FXe(p,{transform:{x:T.x-F.x,y:T.y-F.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:we,containerNodeRect:De,draggingNodeRect:Y,over:ee.current.over,overlayNodeRect:B.rect,scrollableAncestors:Ae,scrollableAncestorRects:Le,windowRect:de}),$=le?dg(le,T):null,L=EXe(Ae),X=aq(L),xe=aq(L,[we]),_e=dg(Se,X),ae=Y?qKe(Y,Se):null,Te=q&&ae?f({active:q,collisionRect:ae,droppableRects:Z,droppableContainers:z,pointerCoordinates:$}):null,Pe=xie(Te,"id"),[Xe,Je]=w.useState(null),Ze=H?Se:dg(Se,xe),oe=GKe(Ze,(a=Xe?.rect)!=null?a:null,we),ye=w.useRef(null),Ce=w.useCallback((He,Oe)=>{let{sensor:Ne,options:Be}=Oe;if(j.current==null)return;const at=D.get(j.current);if(!at)return;const Rt=He.nativeEvent,Tt=new Ne({active:j.current,activeNode:at,event:Rt,options:Be,context:ee,onAbort(Lt){if(!D.get(Lt))return;const{onDragAbort:ft}=ie.current,Xt={id:Lt};ft?.(Xt),S({type:"onDragAbort",event:Xt})},onPending(Lt,ln,ft,Xt){if(!D.get(Lt))return;const{onDragPending:wt}=ie.current,gr={id:Lt,constraint:ln,initialCoordinates:ft,offset:Xt};wt?.(gr),S({type:"onDragPending",event:gr})},onStart(Lt){const ln=j.current;if(ln==null)return;const ft=D.get(ln);if(!ft)return;const{onDragStart:Xt}=ie.current,tn={activatorEvent:Rt,active:{id:ln,data:ft.data,rect:O}};Xc.unstable_batchedUpdates(()=>{Xt?.(tn),A(_d.Initializing),v({type:Ai.DragStart,initialCoordinates:Lt,active:ln}),S({type:"onDragStart",event:tn}),K(ye.current),J(Rt)})},onMove(Lt){v({type:Ai.DragMove,coordinates:Lt})},onEnd:nn(Ai.DragEnd),onCancel:nn(Ai.DragCancel)});ye.current=Tt;function nn(Lt){return async function(){const{active:ft,collisions:Xt,over:tn,scrollAdjustedTranslate:wt}=ee.current;let gr=null;if(ft&&wt){const{cancelDrop:Nr}=ie.current;gr={activatorEvent:Rt,active:ft,collisions:Xt,delta:wt,over:tn},Lt===Ai.DragEnd&&typeof Nr=="function"&&await Promise.resolve(Nr(gr))&&(Lt=Ai.DragCancel)}j.current=null,Xc.unstable_batchedUpdates(()=>{v({type:Lt}),A(_d.Uninitialized),Je(null),K(null),J(null),ye.current=null;const Nr=Lt===Ai.DragEnd?"onDragEnd":"onDragCancel";if(gr){const _r=ie.current[Nr];_r?.(gr),S({type:Nr,event:gr})}})}}},[D]),$e=w.useCallback((He,Oe)=>(Ne,Be)=>{const at=Ne.nativeEvent,Rt=D.get(Be);if(j.current!==null||!Rt||at.dndKit||at.defaultPrevented)return;const Tt={active:Rt};He(Ne,Oe.options,Tt)===!0&&(at.dndKit={capturedBy:Oe.sensor},j.current=Be,Ce(Ne,Oe))},[D,Ce]),lt=bXe(d,$e);NXe(d),sc(()=>{we&&N===_d.Initializing&&A(_d.Initialized)},[we,N]),w.useEffect(()=>{const{onDragMove:He}=ie.current,{active:Oe,activatorEvent:Ne,collisions:Be,over:at}=ee.current;if(!Oe||!Ne)return;const Rt={active:Oe,activatorEvent:Ne,collisions:Be,delta:{x:_e.x,y:_e.y},over:at};Xc.unstable_batchedUpdates(()=>{He?.(Rt),S({type:"onDragMove",event:Rt})})},[_e.x,_e.y]),w.useEffect(()=>{const{active:He,activatorEvent:Oe,collisions:Ne,droppableContainers:Be,scrollAdjustedTranslate:at}=ee.current;if(!He||j.current==null||!Oe||!at)return;const{onDragOver:Rt}=ie.current,Tt=Be.get(Pe),nn=Tt&&Tt.rect.current?{id:Tt.id,rect:Tt.rect.current,data:Tt.data,disabled:Tt.disabled}:null,Lt={active:He,activatorEvent:Oe,collisions:Ne,delta:{x:at.x,y:at.y},over:nn};Xc.unstable_batchedUpdates(()=>{Je(nn),Rt?.(Lt),S({type:"onDragOver",event:Lt})})},[Pe]),sc(()=>{ee.current={activatorEvent:G,active:q,activeNode:fe,collisionRect:ae,collisions:Te,droppableRects:Z,draggableNodes:D,draggingNode:te,draggingNodeRect:Y,droppableContainers:R,over:Xe,scrollableAncestors:Ae,scrollAdjustedTranslate:_e},O.current={initial:Y,translated:ae}},[q,fe,Te,ae,D,te,Y,Z,R,Xe,Ae,_e]),mXe({...Ee,delta:T,draggingRect:ae,pointerCoordinates:$,scrollableAncestors:Ae,scrollableAncestorRects:Le});const se=w.useMemo(()=>({active:q,activeNode:fe,activeNodeRect:we,activatorEvent:G,collisions:Te,containerNodeRect:De,dragOverlay:B,draggableNodes:D,droppableContainers:R,droppableRects:Z,over:Xe,measureDroppableContainers:ne,scrollableAncestors:Ae,scrollableAncestorRects:Le,measuringConfiguration:V,measuringScheduled:he,windowRect:de}),[q,fe,we,G,Te,De,B,D,R,Z,Xe,ne,Ae,Le,V,he,de]),ze=w.useMemo(()=>({activatorEvent:G,activators:lt,active:q,activeNodeRect:we,ariaDescribedById:{draggable:re},dispatch:v,draggableNodes:D,over:Xe,measureDroppableContainers:ne}),[G,lt,q,we,v,re,D,Xe,ne]);return Dr.createElement(fie.Provider,{value:M},Dr.createElement(IN.Provider,{value:ze},Dr.createElement(Cie.Provider,{value:se},Dr.createElement(kie.Provider,{value:oe},u)),Dr.createElement(IXe,{disabled:l?.restoreFocus===!1})),Dr.createElement(zKe,{...l,hiddenTextDescribedById:re}));function ve(){const He=W?.autoScrollEnabled===!1,Oe=typeof c=="object"?c.enabled===!1:c===!1,Ne=k&&!He&&!Oe;return typeof c=="object"?{...c,enabled:Ne}:{enabled:Ne}}}),BXe=w.createContext(null),oq="button",$Xe="Draggable";function HXe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Jy($Xe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(IN),{role:p=oq,roleDescription:b="draggable",tabIndex:y=0}=i??{},x=c?.id===e,v=w.useContext(x?kie:BXe),[S,M]=HM(),[N,A]=HM(),k=AXe(o,e),C=hy(n);sc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:N,data:C}),()=>{const T=f.get(e);T&&T.key===a&&f.delete(e)}),[f,e]);const D=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":x&&p===oq?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,p,y,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:x,listeners:r?void 0:k,node:S,over:m,setNodeRef:M,setActivatorNodeRef:A,transform:v}}function VXe(){return w.useContext(Cie)}const GXe="Droppable",WXe={timeout:25};function qXe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Jy(GXe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(IN),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:x}={...WXe,...i},v=hy(y??r),S=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},x)},[x]),M=LN({callback:S,disabled:b||!o}),N=w.useCallback((D,T)=>{M&&(T&&(M.unobserve(T),f.current=!1),D&&M.observe(D))},[M]),[A,k]=HM(N),C=hy(e);return w.useEffect(()=>{!M||!A.current||(M.disconnect(),f.current=!1,M.observe(A.current))},[A,M]),w.useEffect(()=>(l({type:Ai.RegisterDroppable,element:{id:r,key:a,disabled:n,node:A,rect:m,data:C}}),()=>l({type:Ai.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Ai.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:m,isOver:c?.id===r,node:A,over:c,setNodeRef:k}}function FN(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function KXe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function V1(t){return t!==null&&t>=0}function XXe(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 YXe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const mI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=FN(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}},G1={scaleX:1,scaleY:1},ZXe=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,...G1}:null}const c=QXe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...G1}:i<n&&i>=o?{x:0,y:l.height+c,...G1}:{x:0,y:0,...G1}};function QXe(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 Pie="Sortable",Rie=Dr.createContext({activeIndex:-1,containerId:Pie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:mI,disabled:{draggable:!1,droppable:!1}});function Die(t){let{children:e,id:n,items:r,strategy:i=mI,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=VXe(),f=Jy(Pie,n),m=l.rect!==null,p=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),b=o!=null,y=o?p.indexOf(o.id):-1,x=u?p.indexOf(u.id):-1,v=w.useRef(p),S=!XXe(p,v.current),M=x!==-1&&y===-1||S,N=YXe(a);sc(()=>{S&&b&&d(p)},[S,p,b,d]),w.useEffect(()=>{v.current=p},[p]);const A=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:N,disableTransforms:M,items:p,overIndex:x,useDragOverlay:m,sortedRects:KXe(p,c),strategy:i}),[y,f,N.draggable,N.droppable,M,p,x,c,m,i]);return Dr.createElement(Rie.Provider,{value:A},e)}const JXe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return FN(n,r,i).indexOf(e)},eYe=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},tYe={duration:200,easing:"ease"},Oie="transform",nYe=Hg.Transition.toString({property:Oie,duration:0,easing:"linear"}),rYe={roleDescription:"sortable"};function iYe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return sc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=px(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]),w.useEffect(()=>{a&&o(null)},[a]),a}function Lie(t){let{animateLayoutChanges:e=eYe,attributes:n,disabled:r,data:i,getNewIndex:a=JXe,id:o,strategy:l,resizeObserverConfig:c,transition:u=tYe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:y,overIndex:x,useDragOverlay:v,strategy:S}=w.useContext(Rie),M=aYe(r,p),N=d.indexOf(o),A=w.useMemo(()=>({sortable:{containerId:f,index:N,items:d},...i}),[f,i,N,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:C,node:D,isOver:T,setNodeRef:R}=qXe({id:o,data:A,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:U,activatorEvent:O,activeNodeRect:q,attributes:j,setNodeRef:W,listeners:K,isDragging:G,over:J,setActivatorNodeRef:ie,transform:re}=HXe({id:o,data:A,attributes:{...rYe,...n},disabled:M.draggable}),z=AKe(R,W),V=!!U,Z=V&&!b&&V1(m)&&V1(x),ne=!v&&G,he=ne&&Z?re:null,le=Z?he??(l??S)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:x,index:N}):null,Ee=V1(m)&&V1(x)?a({id:o,items:d,activeIndex:m,overIndex:x}):N,me=U?.id,we=w.useRef({activeId:me,items:d,newIndex:Ee,containerId:f}),De=d!==we.current.items,ee=e({active:U,containerId:f,isDragging:G,isSorting:V,id:o,index:N,items:d,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:u,wasDragging:we.current.activeId!=null}),Qe=iYe({disabled:!ee,index:N,node:D,rect:C});return w.useEffect(()=>{V&&we.current.newIndex!==Ee&&(we.current.newIndex=Ee),f!==we.current.containerId&&(we.current.containerId=f),d!==we.current.items&&(we.current.items=d)},[V,Ee,f,d]),w.useEffect(()=>{if(me===we.current.activeId)return;if(me!=null&&we.current.activeId==null){we.current.activeId=me;return}const te=setTimeout(()=>{we.current.activeId=me},50);return()=>clearTimeout(te)},[me]),{active:U,activeIndex:m,attributes:j,data:A,rect:C,index:N,newIndex:Ee,items:d,isOver:T,isSorting:V,isDragging:G,listeners:K,node:D,overIndex:x,over:J,setNodeRef:z,setActivatorNodeRef:ie,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:Qe??le,transition:B()};function B(){if(Qe||De&&we.current.newIndex===N)return nYe;if(!(ne&&!dI(O)||!u)&&(V||ee))return Hg.Transition.toString({...u,property:Oie})}}function aYe(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 qM(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 sYe=[In.Down,In.Right,In.Up,In.Left],Iie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(sYe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case In.Down:r.top<m.top&&c.push(f);break;case In.Up:r.top>m.top&&c.push(f);break;case In.Left:r.left>m.left&&c.push(f);break;case In.Right:r.left<m.left&&c.push(f);break}});const u=$Ke({collisionRect:r,droppableRects:i,droppableContainers:c});let d=xie(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),m=a.get(d),p=m?i.get(m.id):null,b=m?.node.current;if(b&&p&&f&&m){const x=RN(b).some((k,C)=>l[C]!==k),v=Fie(f,m),S=oYe(f,m),M=x||!v?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},N={x:p.left,y:p.top};return M.x&&M.y?N:fy(N,M)}}}};function Fie(t,e){return!qM(t)||!qM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function oYe(t,e){return!qM(t)||!qM(e)||!Fie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Uie(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 lYe(t,e="system"){if(!t)return"ASAP";const n=gi(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`:bg(t,e)}function cYe({status:t}){const e={pending:{icon:Yn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:sl,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Gn,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:Ya,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:Dw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,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 Hj({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:m,transition:p,isDragging:b}=Lie({id:t.id,disabled:t.status!=="pending"}),y={transform:Hg.Transform.toString(m),transition:p},x=t.status==="printing",v=t.status==="pending",S=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:y,className:`
  8322. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8323. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8324. ${b?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8325. ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8326. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?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(pg,{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:pe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(t.library_file_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(al,{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||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?s.jsx(hs,{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(zr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(hs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:s.jsx(zr,{className:"w-3.5 h-3.5"})}):null]}),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(Br,{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(Nd,{className:"w-3.5 h-3.5"}),Uie(t.print_time_seconds)]}),v&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Yn,{className:"w-3.5 h-3.5"}),lYe(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(hK,{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(_u,{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(Qi,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(cYe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[x&&s.jsx(Me,{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(fde,{className:"w-4 h-4"})}),v&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Me,{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(sl,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Wt,{className:"w-4 h-4"})})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{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(Mr,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(fn,{className:"w-4 h-4"})})]})]})]})})}function uYe(){const t=un(),{showToast:e}=qn(),[n,r]=w.useState(null),[i,a]=w.useState(""),[o,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(null),[m,p]=w.useState(null),[b,y]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,v]=w.useState(()=>{const Z=localStorage.getItem("queue.historySortAsc");return Z!==null?Z==="true":!1}),[S,M]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[N,A]=w.useState(()=>{const Z=localStorage.getItem("queue.pendingSortAsc");return Z!==null?Z==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",b)},[b]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",S)},[S]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(N))},[N]);const k=mie(GM(ON,{activationConstraint:{distance:8}}),GM(DN,{coordinateGetter:Iie})),{data:C}=ut({queryKey:["settings"],queryFn:pe.getSettings}),D=C?.time_format||"system",{data:T,isLoading:R}=ut({queryKey:["queue",n,i],queryFn:()=>pe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:U}=ut({queryKey:["printers"],queryFn:()=>pe.getPrinters()}),O=ht({mutationFn:Z=>pe.cancelQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),q=ht({mutationFn:Z=>pe.removeFromQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),j=ht({mutationFn:Z=>pe.stopQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),W=ht({mutationFn:Z=>pe.startQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),K=ht({mutationFn:Z=>pe.reorderQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),G=ht({mutationFn:async()=>{const Z=T?.filter(ne=>["completed","failed","skipped","cancelled"].includes(ne.status))||[];for(const ne of Z)await pe.removeFromQueue(ne.id);return Z.length},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Z} history item${Z!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),J=w.useMemo(()=>{const Z=T?.filter(he=>he.status==="pending")||[],ne=he=>{if(!he.scheduled_time)return 0;const fe=new Date(he.scheduled_time).getTime(),le=Date.now()+4320*60*60*1e3;return fe>le?0:fe};return[...Z].sort((he,fe)=>{let le;if(S==="name"){const Ee=he.archive_name||he.library_file_name||"",me=fe.archive_name||fe.library_file_name||"";le=Ee.localeCompare(me)}else S==="printer"?le=(he.printer_name||"").localeCompare(fe.printer_name||""):S==="time"?le=ne(he)-ne(fe):le=he.position-fe.position;return N?le:-le})},[T,S,N]),ie=T?.filter(Z=>Z.status==="printing")||[],re=w.useMemo(()=>[...T?.filter(ne=>["completed","failed","skipped","cancelled"].includes(ne.status))||[]].sort((ne,he)=>{let fe;if(b==="name"){const le=ne.archive_name||ne.library_file_name||"",Ee=he.archive_name||he.library_file_name||"";fe=le.localeCompare(Ee)}else b==="printer"?fe=(ne.printer_name||"").localeCompare(he.printer_name||""):fe=new Date(he.completed_at||he.created_at).getTime()-new Date(ne.completed_at||ne.created_at).getTime();return x?-fe:fe}),[T,b,x]),z=w.useMemo(()=>J.reduce((Z,ne)=>Z+(ne.print_time_seconds||0),0),[J]),V=Z=>{const{active:ne,over:he}=Z;if(!he||ne.id===he.id)return;const fe=J.findIndex(Ee=>Ee.id===ne.id),le=J.findIndex(Ee=>Ee.id===he.id);if(fe!==-1&&le!==-1){const me=FN(J,fe,le).map((we,De)=>({id:we.id,position:De+1}));K.mutate(me)}};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(fK,{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(Et,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(At,{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(sl,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ie.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(Et,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(At,{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(Yn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:J.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(Et,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(At,{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(Nd,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Uie(z)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Et,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(At,{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(Gn,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:re.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:Z=>{const ne=Z.target.value;r(ne==="unassigned"?-1:ne===""?null:Number(ne))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),U?.map(Z=>s.jsx("option",{value:Z.id,children:Z.name},Z.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:Z=>a(Z.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"}),re.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(fn,{className:"w-4 h-4"}),"Clear History"]})]}),R?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?s.jsxs(Et,{className:"p-12 text-center border-dashed",children:[s.jsx(ti,{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:[ie.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:ie.map(Z=>s.jsx(Hj,{item:Z,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:Z}),onRequeue:()=>{},onStart:()=>{},timeFormat:D},Z.id))})]}),J.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(Yn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",J.length," item",J.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:S,onChange:Z=>M(Z.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(Me,{variant:"ghost",size:"sm",onClick:()=>A(!N),title:N?"Ascending":"Descending",className:"px-2",children:N?s.jsx(hg,{className:"w-4 h-4"}):s.jsx(A0,{className:"w-4 h-4"})})]})]}),s.jsx(jie,{sensors:k,collisionDetection:bie,onDragEnd:V,children:s.jsx(Die,{items:J.map(Z=>Z.id),strategy:ZXe,children:s.jsx("div",{className:"space-y-3",children:J.map((Z,ne)=>s.jsx(Hj,{item:Z,position:ne+1,onEdit:()=>u(Z),onCancel:()=>p({type:"cancel",item:Z}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>W.mutate(Z.id),timeFormat:D},Z.id))})})})]}),re.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(Gn,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",re.length," item",re.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:Z=>y(Z.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(Me,{variant:"ghost",size:"sm",onClick:()=>v(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?s.jsx(hg,{className:"w-4 h-4"}):s.jsx(A0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:re.slice(0,20).map((Z,ne)=>s.jsx(Hj,{item:Z,position:ne+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:Z}),onStop:()=>{},onRequeue:()=>f(Z),onStart:()=>{},timeFormat:D},Z.id))})]})]}),c&&s.jsx(rh,{mode:"edit-queue-item",archiveId:c.archive_id??void 0,libraryFileId:c.library_file_id??void 0,archiveName:c.archive_name||c.library_file_name||`File #${c.archive_id||c.library_file_id}`,queueItem:c,onClose:()=>u(null)}),d&&s.jsx(rh,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&s.jsx(Un,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?O.mutate(m.item.id):m.type==="stop"?j.mutate(m.item.id):q.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Un,{title:"Clear History",message:`Are you sure you want to remove all ${re.length} item${re.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{G.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function dYe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const S=n.current;if(!S)return;const M=new ResizeObserver(N=>{const A=N[0]?.contentRect.width||0;i(A)});return M.observe(S),()=>M.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const S={};t.forEach(U=>{const O=U.split("T")[0];S[O]=(S[O]||0)+1});const M=new Date,N=new Date(M);N.setMonth(N.getMonth()-e),N.setDate(N.getDate()-N.getDay());const A=[],k=[];let C=[],D=-1;const T=new Date(N);let R=0;for(;T<=M;)T.getDay()===0&&C.length>0&&(A.push(C),C=[],R++),T.getMonth()!==D&&(k.push({month:T.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=T.getMonth()),C.push(new Date(T)),T.setDate(T.getDate()+1);return C.length>0&&A.push(C),{weeks:A,monthLabels:k,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const M=S/c;return M<=.25?"bg-bambu-green/30":M<=.5?"bg-bambu-green/50":M<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,m=32,p=2,b=r-m-16,y=f>0?Math.floor((b-(f-1)*p)/f):12,x=Math.max(8,Math.min(20,y)),v=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:m+4},children:o.map(({month:S,weekIndex:M},N)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:N===0?0:`${(M-(o[N-1]?.weekIndex||0))*(x+p)-24}px`},children:S},N))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:m},children:d.map((S,M)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:x,fontSize:v,visibility:M%2===1?"visible":"hidden"},children:S},S))}),a.map((S,M)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(N=>{const A=S.find(T=>T.getDay()===N);if(!A)return s.jsx("div",{style:{width:x,height:x}},N);const k=A.toISOString().split("T")[0],C=l[k]||0,D=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(C)} ${D?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${A.toLocaleDateString()}: ${C} print${C!==1?"s":""}`},N)})},M))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:p},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 W1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function hYe(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 fYe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=hYe(n);return t.filter(p=>(gi(p.completed_at||p.created_at)||new Date(0))>=m)},[t,n]),a=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const b=gi(p.completed_at||p.created_at)||new Date,y=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,x=m.get(y)||{date:y,filament:0,cost:0,prints:0};x.filament+=p.filament_used_grams||0,x.cost+=p.cost||0,x.prints+=1,m.set(y,x)}),Array.from(m.values()).sort((p,b)=>p.date.localeCompare(b.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return i.forEach(p=>{const b=gi(p.completed_at||p.created_at)||new Date,y=new Date(b);y.setDate(b.getDate()-b.getDay());const x=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(x)||{week:x,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,m.set(x,v)}),Array.from(m.values()).sort((p,b)=>p.week.localeCompare(b.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const y=(p.filament_type||"Unknown").split(", ");y.forEach(x=>{const v=(p.filament_used_grams||0)/y.length;m.set(x,(m.get(x)||0)+v)})}),Array.from(m.entries()).map(([p,b])=>({name:p,value:Math.round(b)})).sort((p,b)=>b.value-p.value)},[i]),c=w.useMemo(()=>{const m=new Date,p=[];for(let b=5;b>=0;b--){const y=new Date(m.getFullYear(),m.getMonth()-b,1),x=new Date(m.getFullYear(),m.getMonth()-b+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),S=t.filter(M=>{const N=gi(M.completed_at||M.created_at)||new Date(0);return N>=y&&N<=x});p.push({month:v,filament:Math.round(S.reduce((M,N)=>M+(N.filament_used_grams||0),0)),cost:S.reduce((M,N)=>M+(N.cost||0),0),prints:S.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,p)=>m+(p.filament_used_grams||0),0),f=i.reduce((m,p)=>m+(p.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(m=>s.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),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(nw,{width:"100%",height:250,children:s.jsxs(wPe,{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(kS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(DS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(OS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(MJ,{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(nw,{width:160,height:160,children:s.jsxs(vPe,{children:[s.jsx(YQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(zy,{fill:W1[p%W1.length]},`cell-${p}`))}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,p)=>{const b=l.reduce((x,v)=>x+v.value,0),y=b>0?(m.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:W1[p%W1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},m.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(nw,{width:"100%",height:200,children:s.jsxs(lPe,{data:c,children:[s.jsx(kS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(DS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(OS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(iw,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,p)=>[p==="filament"?`${m??0}g`:p==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),s.jsx(xO,{}),s.jsx(CJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function mYe({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:m}=Lie({id:t}),p={transform:Hg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"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(pg,{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(pK,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(mK,{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(eE,{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 pYe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const N={};return t.forEach(A=>{N[A.id]=A.defaultSize||4}),N},[l,c]=w.useState(()=>{const N=localStorage.getItem(e);if(N)try{const A=JSON.parse(N);return A.sizes||(A.sizes=o()),A}catch{}return{order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const N=()=>d(A=>!A);return window.addEventListener("toggle-hidden-panel",N),()=>window.removeEventListener("toggle-hidden-panel",N)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const A=t.map(k=>k.id).filter(k=>!l.order.includes(k));A.length>0&&c(k=>({...k,order:[...k.order,...A]}))},[t,l.order]);const f=mie(GM(ON,{activationConstraint:{distance:8}}),GM(DN,{coordinateGetter:Iie})),m=N=>{const{active:A,over:k}=N;k&&A.id!==k.id&&c(C=>{const D=C.order.indexOf(A.id),T=C.order.indexOf(k.id);return{...C,order:FN(C.order,D,T)}})},p=N=>{c(A=>({...A,hidden:A.hidden.includes(N)?A.hidden.filter(k=>k!==N):[...A.hidden,N]}))},b=N=>{c(A=>{const k=A.sizes[N]||4,C=k===1?2:k===2?4:1;return{...A,sizes:{...A.sizes,[N]:C}}})},y=()=>{const N={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()};c(N),i?.()},x=l.order.map(N=>t.find(A=>A.id===N)).filter(Boolean),v=x.filter(N=>!l.hidden.includes(N.id)),S=x.filter(N=>l.hidden.includes(N.id)),M=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return s.jsxs("div",{className:"space-y-4",children:[M,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(om,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(If,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.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:S.map(N=>s.jsxs("button",{onClick:()=>p(N.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(If,{className:"w-3 h-3"}),N.title]},N.id))})]}),s.jsx(jie,{sensors:f,collisionDetection:bie,onDragEnd:m,children:s.jsx(Die,{items:v.map(N=>N.id),strategy:mI,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(N=>s.jsx(mYe,{id:N.id,title:N.title,component:N.component,isHidden:l.hidden.includes(N.id),size:l.sizes[N.id]||2,onToggleVisibility:()=>p(N.id),onToggleSize:()=>b(N.id)},N.id))})})}),v.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Me,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function gYe({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(Zl,{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(Yn,{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(Zl,{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(fP,{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(zf,{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(fP,{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 xYe({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(Gn,{className:"w-4 h-4 text-status-ok 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(Ya,{className:"w-4 h-4 text-status-error 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 bYe({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,m=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];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(_K,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),p.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:p.map(([b,y])=>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 ${y>=95&&y<=105?"text-status-ok":y>105?"text-blue-400":"text-status-warning"}`,children:[y.toFixed(0),"%"]})]},b))})]})]})}function yYe({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 vYe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(dYe,{printDates:t,months:n})}function _Ye({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(Br,{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 wYe({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(fYe,{archives:t,currency:e})}function SYe({size:t=1}){const{data:e,isLoading:n}=ut({queryKey:["failureAnalysis"],queryFn:()=>pe.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(dt,{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(Rn,{className:`w-5 h-5 ${e.failure_rate>20?"text-status-error":e.failure_rate>10?"text-status-warning":"text-status-ok"}`}),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(SK,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),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 MYe(){const{showToast:t}=qn(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[a,o]=w.useState(0),[l,c]=w.useState(0),[u,d]=w.useState(!1);w.useEffect(()=>{const C=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const R=JSON.parse(T);c(R.hidden?.length||0)}}catch{c(0)}};C(),window.addEventListener("storage",C);const D=setInterval(C,500);return()=>{window.removeEventListener("storage",C),clearInterval(D)}},[a]);const{data:f,isLoading:m,refetch:p}=ut({queryKey:["archiveStats"],queryFn:pe.getArchiveStats}),{data:b}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:y}=ut({queryKey:["archives"],queryFn:()=>pe.getArchives(void 0,void 0,1e3,0)}),{data:x}=ut({queryKey:["settings"],queryFn:pe.getSettings}),v=async C=>{i(!1),n(!0);try{const{blob:D,filename:T}=await pe.exportStats({format:C,days:90}),R=URL.createObjectURL(D),U=document.createElement("a");U.href=R,U.download=T,U.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},S=async()=>{d(!0);try{const C=await pe.recalculateCosts();await p(),t(`Recalculated costs for ${C.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},M=x?.currency||"$",N=new Map(b?.map(C=>[String(C.id),C.name])||[]),A=y?.map(C=>C.created_at)||[];if(m)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 k=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(gYe,{stats:f,currency:M}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:C=>s.jsx(xYe,{stats:f,printerMap:N,size:C}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:C=>s.jsx(bYe,{stats:f,printerMap:N,size:C}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:C=>s.jsx(yYe,{stats:f,size:C}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:C=>s.jsx(SYe,{size:C}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:C=>s.jsx(vYe,{printDates:A,size:C}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(_Ye,{stats:f,printerMap:N}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(wYe,{archives:y||[],currency:M}),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(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(If,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(C=>C+1),t("Layout reset")},children:[s.jsx(om,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs(Me,{variant:"secondary",onClick:S,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Kue,{className:"w-4 h-4"}),"Recalculate Costs"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Me,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(jw,{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:()=>v("csv"),children:[s.jsx(Wa,{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:()=>v("xlsx"),children:[s.jsx(jw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(pYe,{widgets:k,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function EYe({plug:t,onEdit:e}){const n=un(),{showToast:r}=qn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>pe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),y=b?.find(D=>D.id===t.printer_id),x=ht({mutationFn:D=>pe.controlSmartPlug(t.id,D),onMutate:async D=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const T=n.getQueryData(["smart-plug-status",t.id]),R=D==="on"?"ON":D==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],U=>({...U,state:R})),{previousStatus:T}},onError:(D,T,R)=>{R?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],R.previousStatus),r(`Failed to turn ${T} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=ht({mutationFn:D=>pe.updateSmartPlug(t.id,D),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=ht({mutationFn:()=>pe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),M=m?.state==="ON",N=m?.reachable??!1,A=x.isPending,C=(()=>{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(Et,{className:"relative",children:s.jsxs(At,{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 ${N?M?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(aE,{className:`w-5 h-5 ${N?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Hs,{className:`w-5 h-5 ${N?M?"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:[p?s.jsx(dt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):N?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Qp,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:M?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(Yg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),C&&s.jsxs("a",{href:C,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(zr,{className:"w-3 h-3"}),"Admin"]})]})]}),y&&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:y.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(yf,{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(ti,{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(Me,{size:"sm",variant:M?"primary":"secondary",disabled:!N||A,onClick:()=>l(!0),className:"flex-1",children:[A?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_u,{className:"w-4 h-4"}),"On"]}),s.jsxs(Me,{size:"sm",variant:M?"secondary":"primary",disabled:!N||A,onClick:()=>u(!0),className:"flex-1",children:[A?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(cE,{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(qd,{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(sE,{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=>v.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=>v.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=>v.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=>v.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:()=>v.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(Yn,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>v.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(dE,{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=>v.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=>v.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(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(lE,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(fn,{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:()=>{S.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 NYe({plug:t,onClose:e}){const n=un(),r=!!t,[i,a]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,p]=w.useState(t?.password||""),[b,y]=w.useState(t?.ha_entity_id||""),[x,v]=w.useState(t?.ha_power_entity||""),[S,M]=w.useState(t?.ha_energy_today_entity||""),[N,A]=w.useState(t?.ha_energy_total_entity||""),[k,C]=w.useState(""),[D,T]=w.useState(""),[R,U]=w.useState(!1),O=w.useRef(null),[q,j]=w.useState(""),[W,K]=w.useState(!1),G=w.useRef(null),[J,ie]=w.useState(""),[re,z]=w.useState(!1),V=w.useRef(null),[Z,ne]=w.useState(""),[he,fe]=w.useState(!1),le=w.useRef(null),[Ee,me]=w.useState(t?.printer_id||null),[we,De]=w.useState(null),[ee,Qe]=w.useState(null),[B,te]=w.useState(t?.power_alert_enabled||!1),[Y,H]=w.useState(t?.power_alert_high?.toString()||""),[F,de]=w.useState(t?.power_alert_low?.toString()||""),[Ae,Le]=w.useState(t?.schedule_enabled||!1),[Se,$]=w.useState(t?.schedule_on_time||""),[L,X]=w.useState(t?.schedule_off_time||""),[xe,_e]=w.useState(t?.show_in_switchbar||!1),[ae,Te]=w.useState(!1),[Pe,Xe]=w.useState({scanned:0,total:0}),[Je,Ze]=w.useState([]),oe=w.useRef(null),{data:ye}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:Ce}=ut({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:$e}=ut({queryKey:["settings"],queryFn:pe.getSettings}),lt=!!($e?.ha_enabled&&$e?.ha_url&&$e?.ha_token);w.useEffect(()=>{const ft=setTimeout(()=>{T(k)},300);return()=>clearTimeout(ft)},[k]),w.useEffect(()=>{const ft=Xt=>{O.current&&!O.current.contains(Xt.target)&&U(!1),G.current&&!G.current.contains(Xt.target)&&K(!1),V.current&&!V.current.contains(Xt.target)&&z(!1),le.current&&!le.current.contains(Xt.target)&&fe(!1)};return document.addEventListener("mousedown",ft),()=>document.removeEventListener("mousedown",ft)},[]);const{data:se,isLoading:ze,error:ve}=ut({queryKey:["ha-entities",D],queryFn:()=>pe.getHAEntities(D||void 0),enabled:i==="homeassistant"&&lt,retry:!1,staleTime:0}),{data:He}=ut({queryKey:["ha-sensor-entities"],queryFn:pe.getHASensorEntities,enabled:i==="homeassistant"&&lt,retry:!1,staleTime:0});w.useEffect(()=>{const ft=Xt=>{Xt.key==="Escape"&&e()};return window.addEventListener("keydown",ft),()=>{window.removeEventListener("keydown",ft),oe.current&&clearInterval(oe.current)}},[e]);const Oe=async()=>{Te(!0),Ze([]),Xe({scanned:0,total:0}),Qe(null);try{await pe.startTasmotaScan();const ft=async()=>{try{const Xt=await pe.getTasmotaScanStatus();Xe({scanned:Xt.scanned,total:Xt.total});const tn=await pe.getDiscoveredTasmotaDevices();Ze(tn),Xt.running||(Te(!1),oe.current&&(clearInterval(oe.current),oe.current=null))}catch(Xt){console.error("Polling error:",Xt)}};await ft(),oe.current=setInterval(ft,500)}catch(ft){Te(!1);const Xt=ft instanceof Error?ft.message:typeof ft=="string"?ft:JSON.stringify(ft);Qe(Xt||"Failed to start scan")}},Ne=async()=>{try{await pe.stopTasmotaScan()}catch{}Te(!1),oe.current&&(clearInterval(oe.current),oe.current=null)},Be=ft=>{u(ft.ip_address),l(ft.name),De(null)},at=ht({mutationFn:()=>pe.testSmartPlugConnection(c,d||null,m||null),onSuccess:ft=>{De(ft),Qe(null),!o&&ft.device_name&&l(ft.device_name)},onError:ft=>{De(null),Qe(ft.message)}}),Rt=ht({mutationFn:ft=>pe.createSmartPlug(ft),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:ft=>{Qe(ft.message)}}),Tt=ht({mutationFn:ft=>pe.updateSmartPlug(t.id,ft),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:ft=>{Qe(ft.message)}}),nn=ye?.filter(ft=>!Ce?.some(tn=>tn.printer_id===ft.id&&tn.id!==t?.id)),Lt=ft=>{if(ft.preventDefault(),Qe(null),!o.trim()){Qe("Name is required");return}if(i==="tasmota"&&!c.trim()){Qe("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){Qe("Entity is required for Home Assistant plugs");return}const Xt={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?b:null,ha_power_entity:i==="homeassistant"&&x||null,ha_energy_today_entity:i==="homeassistant"&&S||null,ha_energy_total_entity:i==="homeassistant"&&N||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Ee,power_alert_enabled:B,power_alert_high:Y?parseFloat(Y):null,power_alert_low:F?parseFloat(F):null,schedule_enabled:Ae,schedule_on_time:Se||null,schedule_off_time:L||null,show_in_switchbar:xe};r?Tt.mutate(Xt):Rt.mutate(Xt)},ln=Rt.isPending||Tt.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:ft=>ft.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(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Lt,className:"p-6 space-y-4 overflow-y-auto",children:[ee&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:ee}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),De(null),Qe(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(Hs,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),De(null),Qe(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(aE,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[ae?s.jsxs(Me,{type:"button",variant:"secondary",onClick:Ne,className:"w-full",children:[s.jsx(Wt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Me,{type:"button",variant:"primary",onClick:Oe,className:"w-full",children:[s.jsx(va,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),ae&&Pe.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:[Pe.scanned," / ",Pe.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:`${Pe.scanned/Pe.total*100}%`}})})]}),Je.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Je.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Je.map(ft=>s.jsxs("button",{type:"button",onClick:()=>Be(ft),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(Hs,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:ft.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:ft.ip_address})]})]}),ft.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${ft.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(_u,{className:"w-3 h-3"}),ft.state]})]},ft.ip_address))})]}),!ae&&Je.length===0&&Pe.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:[!lt&&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..."})})]})]}),lt&&s.jsxs(s.Fragment,{children:[ze&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(dt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),ve&&s.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",ve.message]}),(()=>{const ft=Ce?.filter(wt=>wt.ha_entity_id&&wt.id!==t?.id).map(wt=>wt.ha_entity_id)||[],Xt=(se||[]).filter(wt=>!ft.includes(wt.entity_id)),tn=se?.find(wt=>wt.entity_id===b);return s.jsxs("div",{ref:O,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:R?k:tn?`${tn.friendly_name} (${tn.entity_id})`:"",onChange:wt=>{C(wt.target.value),R||U(!0)},onFocus:()=>{U(!0),C("")},placeholder:"Search entities...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),b&&!R&&s.jsx("button",{type:"button",onClick:()=>{y(""),C("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Wt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),ze&&s.jsx(dt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),R&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[ze&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!ze&&Xt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:D?`No entities found matching "${D}"`:"No entities available"}),!ze&&Xt.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{y(wt.entity_id),U(!1),C(""),o||l(wt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${wt.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:wt.entity_id}),s.jsx("span",{className:wt.state==="on"?"text-bambu-green":"",children:wt.state})]})]},wt.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:D?`Searching all entities (${Xt.length} found)`:`Showing switch, light, input_boolean (${Xt.length} available)`})]})})(),b&&He&&He.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const ft=He.filter(wt=>wt.unit_of_measurement==="W"||wt.unit_of_measurement==="kW"||wt.unit_of_measurement==="mW"),Xt=q?ft.filter(wt=>wt.entity_id.toLowerCase().includes(q.toLowerCase())||wt.friendly_name.toLowerCase().includes(q.toLowerCase())):ft,tn=He.find(wt=>wt.entity_id===x);return s.jsxs("div",{ref:G,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:W?q:tn?`${tn.friendly_name} (${tn.state} ${tn.unit_of_measurement})`:"",onChange:wt=>{j(wt.target.value),W||K(!0)},onFocus:()=>{K(!0),j("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!W&&s.jsx("button",{type:"button",onClick:()=>{v(""),j("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Wt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),W&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{v(""),K(!1),j("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Xt.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{v(wt.entity_id),K(!1),j("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),Xt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ft=He.filter(wt=>wt.unit_of_measurement==="kWh"||wt.unit_of_measurement==="Wh"||wt.unit_of_measurement==="MWh"),Xt=J?ft.filter(wt=>wt.entity_id.toLowerCase().includes(J.toLowerCase())||wt.friendly_name.toLowerCase().includes(J.toLowerCase())):ft,tn=He.find(wt=>wt.entity_id===S);return s.jsxs("div",{ref:V,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:re?J:tn?`${tn.friendly_name} (${tn.state} ${tn.unit_of_measurement})`:"",onChange:wt=>{ie(wt.target.value),re||z(!0)},onFocus:()=>{z(!0),ie("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),S&&!re&&s.jsx("button",{type:"button",onClick:()=>{M(""),ie("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Wt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),re&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{M(""),z(!1),ie("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Xt.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{M(wt.entity_id),z(!1),ie("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===S?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),Xt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ft=He.filter(wt=>wt.unit_of_measurement==="kWh"||wt.unit_of_measurement==="Wh"||wt.unit_of_measurement==="MWh"),Xt=Z?ft.filter(wt=>wt.entity_id.toLowerCase().includes(Z.toLowerCase())||wt.friendly_name.toLowerCase().includes(Z.toLowerCase())):ft,tn=He.find(wt=>wt.entity_id===N);return s.jsxs("div",{ref:le,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:he?Z:tn?`${tn.friendly_name} (${tn.state} ${tn.unit_of_measurement})`:"",onChange:wt=>{ne(wt.target.value),he||fe(!0)},onFocus:()=>{fe(!0),ne("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),N&&!he&&s.jsx("button",{type:"button",onClick:()=>{A(""),ne("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Wt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),he&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{A(""),fe(!1),ne("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Xt.map(wt=>s.jsxs("button",{type:"button",onClick:()=>{A(wt.entity_id),fe(!1),ne("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${wt.entity_id===N?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:wt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[wt.entity_id," • ",wt.state," ",wt.unit_of_measurement]})]},wt.entity_id)),Xt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),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:ft=>{u(ft.target.value),De(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(Me,{type:"button",variant:"secondary",onClick:()=>at.mutate(),disabled:!c.trim()||at.isPending,children:[at.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Qp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&we&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${we.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:we.success?s.jsxs(s.Fragment,{children:[s.jsx(Gn,{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:[we.device_name&&`Device: ${we.device_name} - `,"State: ",we.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yg,{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:ft=>l(ft.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:ft=>f(ft.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:m,onChange:ft=>p(ft.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:Ee??"",onChange:ft=>me(ft.target.value?Number(ft.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)"}),nn?.map(ft=>s.jsx("option",{value:ft.id,children:ft.name},ft.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(yf,{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:B,onChange:ft=>te(ft.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"})]})]}),B&&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:Y,onChange:ft=>H(ft.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:F,onChange:ft=>de(ft.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(Yn,{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:Ae,onChange:ft=>Le(ft.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"})]})]}),Ae&&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:Se,onChange:ft=>$(ft.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:L,onChange:ft=>X(ft.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(sE,{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:xe,onChange:ft=>_e(ft.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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:ln,className:"flex-1",children:[ln?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ps,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Xn({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 AYe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function TYe({provider:t,onEdit:e}){const n=un(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=ht({mutationFn:y=>pe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=ht({mutationFn:()=>pe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ht({mutationFn:()=>pe.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),b=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(Et,{className:"relative",children:s.jsxs(At,{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(yf,{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:AYe[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-status-ok hidden sm:inline",children:["Last: ",xg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(gi(t.last_error_at)?.getTime()||0)>(gi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(Xn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),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(Rw,{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(ti,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Me,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(UD,{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(Gn,{className:"w-4 h-4"}):s.jsx(Ya,{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(qd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(uu,{className:"w-4 h-4"}):s.jsx(Zi,{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(Xn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),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(Xn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(Xn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(Xn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(Xn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),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(Xn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),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(Xn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(Xn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Xn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),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(Xn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),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(Xn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),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(Xn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),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(Xn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),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(Xn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),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(Rw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Xn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),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(Yn,{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(ti,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Xn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),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(Yn,{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(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(lE,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(fn,{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:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const lq=[{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 CYe({provider:t,onClose:e}){const n=un(),r=!!t,[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,p]=w.useState(t?.quiet_hours_start||"22:00"),[b,y]=w.useState(t?.quiet_hours_end||"07:00"),[x,v]=w.useState(t?.daily_digest_enabled||!1),[S,M]=w.useState(t?.daily_digest_time||"08:00"),[N,A]=w.useState(t?.on_print_start??!1),[k,C]=w.useState(t?.on_print_complete??!0),[D,T]=w.useState(t?.on_print_failed??!0),[R,U]=w.useState(t?.on_print_stopped??!0),[O,q]=w.useState(t?.on_print_progress??!1),[j,W]=w.useState(t?.on_printer_offline??!1),[K,G]=w.useState(t?.on_printer_error??!1),[J,ie]=w.useState(t?.on_filament_low??!1),[re,z]=w.useState(t?.on_maintenance_due??!1),[V,Z]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([H,F])=>[H,String(F)])):{}),[ne,he]=w.useState(null),[fe,le]=w.useState(null),{data:Ee}=ut({queryKey:["printers"],queryFn:pe.getPrinters});w.useEffect(()=>{const H=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[e]);const me=ht({mutationFn:()=>pe.testNotificationConfig({provider_type:o,config:V}),onSuccess:H=>{he(H),le(null)},onError:H=>{he({success:!1,message:H.message})}}),we=ht({mutationFn:H=>pe.createNotificationProvider(H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{le(H.message)}}),De=ht({mutationFn:H=>pe.updateNotificationProvider(t.id,H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{le(H.message)}}),ee=H=>{if(H.preventDefault(),le(null),!i.trim()){le("Name is required");return}const F=te(o);for(const Ae of F)if(!V[Ae.key]?.trim()){le(`${Ae.label} is required`);return}const de={name:i.trim(),provider_type:o,config:V,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?b:null,daily_digest_enabled:x,daily_digest_time:x?S:null,on_print_start:N,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:O,on_printer_offline:j,on_printer_error:K,on_filament_low:J,on_maintenance_due:re};r?De.mutate(de):we.mutate(de)},Qe=we.isPending||De.isPending,B=H=>{switch(H){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:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{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,showIf:F=>F.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:F=>F.payload_format!=="slack"}];default:return[]}},te=H=>B(H).filter(F=>F.required),Y=B(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:H=>H.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(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ee,className:"p-6 space-y-4",children:[fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),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:H=>a(H.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:H=>{l(H.target.value),Z({}),he(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:lq.map(H=>s.jsx("option",{value:H.value,children:H.label},H.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:lq.find(H=>H.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),Y.filter(H=>!("showIf"in H)||H.showIf?.(V)!==!1).map(H=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[H.label," ",H.required&&"*"]}),H.type==="select"&&"options"in H&&H.options?s.jsx("select",{value:V[H.key]||H.options[0]?.value||"",onChange:F=>{Z({...V,[H.key]:F.target.value}),he(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:H.options.map(F=>s.jsx("option",{value:F.value,children:F.label},F.value))}):s.jsx("input",{type:H.type,value:V[H.key]||"",onChange:F=>{Z({...V,[H.key]:F.target.value}),he(null)},placeholder:H.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},H.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{he(null),me.mutate()},disabled:me.isPending||!V[te(o)[0]?.key],className:"flex-1",children:[me.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(UD,{className:"w-4 h-4"}),"Test Configuration"]})}),ne&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ne.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:ne.success?s.jsxs(s.Fragment,{children:[s.jsx(Gn,{className:"w-5 h-5"}),s.jsx("span",{children:ne.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ya,{className:"w-5 h-5"}),s.jsx("span",{children:ne.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:H=>u(H.target.value?Number(H.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"}),Ee?.map(H=>s.jsx("option",{value:H.id,children:H.name},H.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(Xn,{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:m,onChange:H=>p(H.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:H=>y(H.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(Xn,{checked:x,onChange:v})]}),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:S,onChange:H=>M(H.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(Xn,{checked:N,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Xn,{checked:k,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Xn,{checked:D,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Xn,{checked:R,onChange:U})]}),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(Xn,{checked:O,onChange:q})]})]})]}),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(Xn,{checked:j,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Xn,{checked:K,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(Xn,{checked:J,onChange:ie})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Xn,{checked:re,onChange:z})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Qe,className:"flex-1",children:[Qe?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ps,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function kYe({template:t,onClose:e}){const n=un(),r=w.useRef(null),[i,a]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=ut({queryKey:["template-variables"],queryFn:pe.getTemplateVariables}),p=m?.find(A=>A.event_type===t.event_type),{data:b,isLoading:y}=ut({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>pe.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e]);const x=ht({mutationFn:A=>pe.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{u(A.message)}}),v=ht({mutationFn:()=>pe.resetNotificationTemplate(t.id),onSuccess:A=>{a(A.title_template),l(A.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:A=>{u(A.message)}}),S=A=>{if(A.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})},M=A=>{const k=r.current;if(!k)return;const C=k.selectionStart,D=k.selectionEnd,T=o,R=T.substring(0,C),U=T.substring(D),O=R+`{${A}}`+U;l(O),setTimeout(()=>{k.focus();const q=C+A.length+2;k.setSelectionRange(q,q)},0)},N=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(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,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:A=>a(A.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:A=>l(A.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..."})]}),p&&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:p.variables.map(A=>s.jsxs("button",{type:"button",onClick:()=>M(A),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(Qn,{className:"w-3 h-3"}),A]},A))}),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(If,{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:y?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(dt,{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(Me,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(om,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Me,{onClick:S,disabled:x.isPending||!N,children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ps,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const jYe={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"},PYe={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 RYe({onClose:t}){const e=un(),{showToast:n}=qn(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ut({queryKey:["settings"],queryFn:pe.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:b}=ut({queryKey:["notification-logs",r,l],queryFn:()=>pe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ut({queryKey:["notification-log-stats",r],queryFn:()=>pe.getNotificationLogStats(r)}),x=ht({mutationFn:()=>pe.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const M=gi(S);if(!M)return"";const A=new Date().getTime()-M.getTime();return A<6e4?"Just now":A<36e5?`${Math.floor(A/6e4)}m ago`:A<864e5?`${Math.floor(A/36e5)}h ago`:M.toLocaleDateString()+" "+qme(M,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(Pw,{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:"×"})]}),y&&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:y.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Gn,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Ya,{className:"w-4 h-4"}),y.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:S=>i(Number(S.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:S=>c(S.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(Me,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:b,children:[b?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(S=>s.jsx(DYe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:v,formatFullDate:M=>bg(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(Pw,{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 DYe({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(Gn,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Ya,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${PYe[t.event_type]||"text-bambu-gray"}`,children:jYe[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(uu,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Zi,{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 q1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(uE,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(yf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Wa,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Hs,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Xg,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Br,{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(ID,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Kd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Xa,{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(wa,{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(oi,{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(of,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function OYe({onClose:t,onExport:e}){const{t:n}=Gg(),[r,i]=w.useState(()=>{const b={};return q1.forEach(y=>{b[y.id]=y.default}),b}),[a,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const b=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(y=>({...y,[b]:!y[b]}))},d=()=>{const b={};q1.forEach(y=>{b[y.id]=!0}),i(b)},f=()=>{const b={};q1.forEach(y=>{b[y.id]=!1}),i(b)},m=Object.values(r).filter(Boolean).length,p=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(Et,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:s.jsxs(At,{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(Ir,{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(Wt,{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:q1.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(Xa,{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(of,{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(Xn,{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(Rn,{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:m,defaultValue:`${m} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Me,{onClick:p,disabled:m===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(dt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ir,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const cq={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 LYe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=w.useState("options"),[a,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,m]=w.useState(new Set),p=w.useRef(null);w.useEffect(()=>{const N=A=>{A.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t,n,r,u]);const b=N=>{const A=N.target.files?.[0];A&&c(A)},y=async()=>{if(l){i("restoring");try{const N=await e(l,a);d(N),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},x=()=>{u?.success&&n(),t()},v=N=>{m(A=>{const k=new Set(A);return k.has(N)?k.delete(N):k.add(N),k})},S=u?.restored?Object.values(u.restored).reduce((N,A)=>N+A,0)+(u.files_restored||0):0,M=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:N=>{N.target===N.currentTarget&&r!=="restoring"&&t()},children:s.jsx(Et,{className:"w-full max-w-lg",children:s.jsxs(At,{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(Gn,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(Rn,{className:"w-5 h-5"}):s.jsx(oi,{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(Wt,{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:p,type:"file",accept:".json,.zip",className:"hidden",onChange:b}),s.jsx("button",{type:"button",onClick:()=>p.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(Gn,{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(oi,{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(Rn,{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(Mr,{className:"w-4 h-4 text-orange-400"}):s.jsx(Dw,{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(Xn,{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(Rn,{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(Me,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Me,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(oi,{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(dt,{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:S}),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:M}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,N])=>N>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(Gn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,N])=>N>0).map(([N,A])=>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:cq[N]||N}),s.jsx("span",{className:"text-bambu-green font-medium",children:A})]},N)),(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(([,N])=>N>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(Dw,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,N])=>N>0).map(([N,A])=>{const k=u.skipped_details?.[N]||[],C=f.has(N);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>k.length>0&&v(N),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${k.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[cq[N]||N,k.length>0&&(C?s.jsx(uu,{className:"w-3 h-3"}):s.jsx(Zi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),C&&k.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:[k.slice(0,10).map((D,T)=>s.jsx("div",{children:D},T)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},N)})})]}),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(Rn,{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((N,A)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:N.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:N.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(N.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},A))})]})]}),S===0&&M===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(Me,{onClick:x,children:"Close"})})]})]})})})}async function IYe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function FYe(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 UYe(){const t=un(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[a,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[p,b]=w.useState(!1),{data:y,isLoading:x}=ut({queryKey:["spoolman-settings"],queryFn:IYe}),{data:v,isLoading:S,refetch:M}=ut({queryKey:["spoolman-status"],queryFn:pe.getSpoolmanStatus,refetchInterval:3e4}),{data:N}=ut({queryKey:["printers"],queryFn:pe.getPrinters});w.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),m(!0))},[y]),w.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{A.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const A=ht({mutationFn:()=>FYe({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)}}),k=ht({mutationFn:pe.connectSpoolman,onSuccess:()=>{M()}}),C=ht({mutationFn:pe.disconnectSpoolman,onSuccess:()=>{M()}}),D=ht({mutationFn:pe.syncAllPrintersAms,onSuccess:j=>{j.success}}),T=ht({mutationFn:j=>pe.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():T.mutate(u)},U=D.isPending||T.isPending,O=u==="all"?D.data:T.data,q=u==="all"?D.isSuccess:T.isSuccess;return x?s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(At,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),A.isPending&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(ws,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(At,{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(Yl,{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:j=>n(j.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:j=>i(j.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:j=>o(j.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:"}),S?s.jsx(dt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(ws,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dhe,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Me,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Vl,{className:"w-4 h-4"}),"Connect"]})})]}),k.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:k.error.message}),v?.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:j=>d(j.target.value==="all"?"all":Number(j.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"}),N?.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))]}),s.jsx(Zi,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:R,disabled:U,children:[U?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mr,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&O&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${O.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.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(Rn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&s.jsx("button",{onClick:()=>b(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?O.skipped:O.skipped.slice(0,5)).map((j,W)=>s.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),s.jsx("span",{children:j.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},W)),!p&&O.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.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:O.errors.map((j,W)=>s.jsx("li",{children:j},W))})]})]})]})]})]})}function zYe({link:t,onClose:e}){const n=un(),{mode:r}=sh(),i=!!t,a=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[b,y]=w.useState(t?.custom_icon?pe.getExternalLinkIconUrl(t.id):null),[x,v]=w.useState(null),[S,M]=w.useState(null);w.useEffect(()=>{const U=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const N=ht({mutationFn:async U=>{const O=await pe.createExternalLink(U);return x?await pe.uploadExternalLinkIcon(O.id,x):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),A=ht({mutationFn:async U=>{let O=await pe.updateExternalLink(t.id,U);return x?O=await pe.uploadExternalLinkIcon(t.id,x):!m&&t?.custom_icon&&(O=await pe.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),k=U=>{const O=U.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){M("Image file must be less than 1MB");return}v(O),p(!0);const j=new FileReader;j.onload=W=>{y(W.target?.result)},j.readAsDataURL(O)}},C=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},D=U=>{if(U.preventDefault(),M(null),!o.trim()){M("Name is required");return}if(!c.trim()){M("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){M("URL must start with http:// or https://");return}const O={name:o.trim(),url:c.trim(),icon:d};i?A.mutate(O):N.mutate(O)},T=N.isPending||A.isPending,R=hE(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:U=>U.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:m&&b?s.jsx("img",{src:b,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(R,{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(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),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:U=>l(U.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:U=>u(U.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:k}),m&&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:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(fn,{className:"w-4 h-4"})})]}):s.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(oi,{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."})]}),!m&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Bme,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:T,className:"flex-1",children:[T?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ps,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function BYe(){const t=un(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ut({queryKey:["external-links"],queryFn:pe.getExternalLinks}),f=ht({mutationFn:S=>pe.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=ht({mutationFn:S=>pe.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(S,M)=>{c(M),S.dataTransfer.effectAllowed="move"},b=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},y=(S,M)=>{if(S.preventDefault(),l===null||l===M||!u)return;const N=u.map(D=>D.id),A=N.indexOf(l),k=N.indexOf(M);if(A===-1||k===-1)return;const C=[...N];C.splice(A,1),C.splice(k,0,l),m.mutate(C),c(null)},x=S=>{o(S)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Vl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Me,{size:"sm",onClick:()=>n(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(At,{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(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(S=>{const M=hE(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:N=>p(N,S.id),onDragOver:b,onDrop:N=>y(N,S.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===S.id?"opacity-50":""}`,children:[s.jsx(pg,{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(M,{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:S.name}),s.jsx(zr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(S),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>x(S),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(fn,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Vl,{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(zYe,{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:v,onCancel:()=>o(null)})]})}function $Ye(){const t=un(),{showToast:e}=qn(),[n,r]=w.useState(!1),[i,a]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,p]=w.useState(null),{data:b,isLoading:y}=ut({queryKey:["virtual-printer-settings"],queryFn:Z1.getSettings,refetchInterval:1e4}),{data:x}=ut({queryKey:["virtual-printer-models"],queryFn:Z1.getModels});w.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 v=ht({mutationFn:D=>Z1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),b){r(b.enabled);const T=b.mode==="queue"?"review":b.mode;l(T==="print_queue"||T==="review"?T:"immediate"),u(b.model)}p(null)}}),S=()=>{const D=!n;if(D&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(D),p("toggle"),v.mutate({enabled:D,access_code:i||void 0,mode:o})},M=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),v.mutate({access_code:i}),a("")},N=D=>{l(D),p("mode"),v.mutate({mode:D})},A=D=>{u(D),p("model"),v.mutate({model:D})};if(y)return s.jsx(Et,{children:s.jsx(At,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=b?.status,C=k?.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(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Br,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${C?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-400 animate-pulse":"bg-gray-500"}`}),C?"Running":"Stopped"]})]})}),s.jsxs(At,{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:C?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:S,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="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=>A(D.target.value),disabled:m==="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],[,T])=>D.localeCompare(T)).map(([D,T])=>s.jsx("option",{value:D,children:T},D))}),s.jsx(Zi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&C&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Yl,{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(ws,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Rn,{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(eE,{className:"w-4 h-4"}):s.jsx(If,{className:"w-4 h-4"})})]}),s.jsx(Me,{onClick:M,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(dt,{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:()=>N("immediate"),disabled:m==="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:()=>N("review"),disabled:m==="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:()=>N("print_queue"),disabled:m==="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(Et,{className:"border-l-4 border-l-yellow-500",children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Rn,{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(zr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(Et,{children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Yl,{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'})]})]})]})})}),k&&C&&s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(At,{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:k.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:k.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:k.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}const HYe={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 VYe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Zb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Zb(t,VYe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Zb(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?[Zb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Zb(t,a,n+1);return r}return{};default:return null}}function GYe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,b]=w.useState(!1),[y,x]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const D={};for(const T of n.parameters)T.schema?.default!==void 0&&(D[T.name]=String(T.schema.default));c(T=>({...D,...T}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,T=Zb(r,D);d(JSON.stringify(T,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const D=[];for(const T of n.parameters||[])if(T.in==="path"||T.required){const R=l[T.name];(R===void 0||R==="")&&D.push(T.name)}return D})(),M=async()=>{if(S.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}b(!0),m(null);try{let D=t;const T=new URLSearchParams;for(const re of n.parameters||[]){const z=l[re.name];z!==void 0&&z!==""&&(re.in==="path"?D=D.replace(`{${re.name}}`,encodeURIComponent(z)):re.in==="query"&&T.append(re.name,z))}const R=T.toString(),U=`${D}${R?`?${R}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(q.body=u);const j=performance.now(),W=await fetch(U,q),K=Math.round(performance.now()-j),G={};W.headers.forEach((re,z)=>{G[z]=re});let J;W.headers.get("content-type")?.includes("application/json")?J=await W.json():J=await W.text(),m({status:W.status,statusText:W.statusText,headers:G,body:J,duration:K})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{b(!1)}},N=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 T=document.createElement("textarea");T.value=D,T.style.position="fixed",T.style.left="-999999px",document.body.appendChild(T),T.select(),document.execCommand("copy"),document.body.removeChild(T),x(!0),setTimeout(()=>x(!1),2e3)}}},A=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.in==="query"),C=["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(Zi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Ks,{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 ${HYe[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}),A.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:A.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:T=>c(R=>({...R,[D.name]:T.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))})]}),k.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:k.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:T=>c(R=>({...R,[D.name]:T.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(T=>s.jsx("option",{value:T,children:T},T))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:T=>c(R=>({...R,[D.name]:T.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&&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(Me,{onClick:M,disabled:p,children:[p?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(sl,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(Qi,{className:"w-3 h-3"}),"Fill in: ",S.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(Me,{variant:"secondary",size:"sm",onClick:N,children:y?s.jsx(Gn,{className:"w-3 h-3 text-green-400"}):s.jsx(rl,{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 WYe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[a,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function x(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}x()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(Et,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(Qi,{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,v]of Object.entries(e.paths))for(const[S,M]of Object.entries(v)){if(S==="parameters")continue;const N=M.tags||["Other"];for(const A of N)f[A]||(f[A]=[]),f[A].push({path:x,method:S,spec:M})}const m=Object.entries(f).map(([x,v])=>{if(!u)return{tag:x,endpoints:v};const S=v.filter(({path:M,method:N,spec:A})=>{const k=u.toLowerCase();return M.toLowerCase().includes(k)||N.toLowerCase().includes(k)||(A.summary?.toLowerCase()||"").includes(k)||(A.description?.toLowerCase()||"").includes(k)});return{tag:x,endpoints:S}}).filter(({endpoints:x})=>x.length>0).sort((x,v)=>x.tag.localeCompare(v.tag)),p=x=>{c(v=>{const S=new Set(v);return S.has(x)?S.delete(x):S.add(x),S})},b=()=>{c(new Set(m.map(x=>x.tag)))},y=()=>{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(Me,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:y,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(zr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((x,v)=>x+v.endpoints.length,0)," endpoints in ",m.length," categories"]}),s.jsx("div",{className:"space-y-3",children:m.map(({tag:x,endpoints:v})=>s.jsxs(Et,{children:[s.jsx("button",{onClick:()=>p(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(Zi,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Ks,{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:v.length})]})}),l.has(x)&&s.jsx(At,{className:"pt-0 space-y-2",children:v.map(({path:S,method:M,spec:N})=>s.jsx(GYe,{path:S,method:M,spec:N,schema:e,apiKey:t},`${M}-${S}`))})]},x))})]})}const qYe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users"];function KYe(){const t=un(),e=ml(),[n,r]=$q(),{t:i,i18n:a}=Gg(),{showToast:o,showPersistentToast:l,dismissToast:c}=qn(),{authEnabled:u,user:d,refreshAuth:f}=oh(),{mode:m,darkStyle:p,darkBackground:b,darkAccent:y,lightStyle:x,lightBackground:v,lightAccent:S,setDarkStyle:M,setDarkBackground:N,setDarkAccent:A,setLightStyle:k,setLightBackground:C,setLightAccent:D}=sh(),[T,R]=w.useState(null),[U,O]=w.useState(!1),[q,j]=w.useState(null),[W,K]=w.useState(!1),[G,J]=w.useState(null),[ie,re]=w.useState(null),[z,V]=w.useState(!1),[Z,ne]=w.useState(kK()),he=n.get("tab"),fe=he&&qYe.includes(he)?he:"general",[le,Ee]=w.useState(fe),me=be=>{Ee(be),be==="general"?n.delete("tab"):n.set("tab",be),r(n,{replace:!0})},[we,De]=w.useState(!1),[ee,Qe]=w.useState(""),[B,te]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[Y,H]=w.useState(null),[F,de]=w.useState(null),[Ae,Le]=w.useState(""),[Se,$]=w.useState(!1),[L,X]=w.useState(!1),[xe,_e]=w.useState(null),[ae,Te]=w.useState(!1),[Pe,Xe]=w.useState(!1),[Je,Ze]=w.useState(!1),[oe,ye]=w.useState(!1),[Ce,$e]=w.useState(null),[lt,se]=w.useState(!1),[ze,ve]=w.useState({}),[He,Oe]=w.useState({}),Ne=be=>{ne(be),Gme(be)},Be=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:at,isLoading:Rt}=ut({queryKey:["settings"],queryFn:pe.getSettings}),{data:Tt,isLoading:nn}=ut({queryKey:["smart-plugs"],queryFn:pe.getSmartPlugs}),{data:Lt,isLoading:ln}=ut({queryKey:["smart-plugs-energy",Tt?.map(be=>be.id)],queryFn:async()=>{if(!Tt||Tt.length===0)return null;const be=await Promise.all(Tt.filter(Gt=>Gt.enabled).map(async Gt=>{try{const an=await pe.getSmartPlugStatus(Gt.id);return{plug:Gt,status:an}}catch{return{plug:Gt,status:null}}}));let kt=0,rn=0,zt=0,cn=0,$t=0;for(const{status:Gt}of be)Gt?.reachable&&Gt.energy&&($t++,Gt.energy.power!=null&&(kt+=Gt.energy.power),Gt.energy.today!=null&&(rn+=Gt.energy.today),Gt.energy.yesterday!=null&&(zt+=Gt.energy.yesterday),Gt.energy.total!=null&&(cn+=Gt.energy.total));return{totalPower:kt,totalToday:rn,totalYesterday:zt,totalLifetime:cn,reachableCount:$t,totalPlugs:Tt.filter(Gt=>Gt.enabled).length}},enabled:le==="plugs"&&!!Tt&&Tt.length>0,refetchInterval:le==="plugs"?1e4:!1}),{data:ft,isLoading:Xt}=ut({queryKey:["notification-providers"],queryFn:pe.getNotificationProviders}),{data:tn,isLoading:wt}=ut({queryKey:["api-keys"],queryFn:pe.getAPIKeys}),gr=ht({mutationFn:be=>pe.createAPIKey(be),onSuccess:be=>{H(be.key||null),De(!1),Qe(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:be=>{o(`Failed to create API key: ${be.message}`,"error")}}),Nr=ht({mutationFn:be=>pe.deleteAPIKey(be),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:be=>{o(`Failed to delete API key: ${be.message}`,"error")}}),{data:_r}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:er,isLoading:vt}=ut({queryKey:["notification-templates"],queryFn:pe.getNotificationTemplates}),{data:on}=ut({queryKey:["virtual-printer-settings"],queryFn:Z1.getSettings,refetchInterval:1e4}),Nn=on?.status?.running??!1,{data:ce}=ut({queryKey:["ffmpeg-status"],queryFn:pe.checkFfmpeg}),{data:Ue}=ut({queryKey:["version"],queryFn:pe.getVersion}),{data:We,refetch:rt,isRefetching:et}=ut({queryKey:["updateCheck"],queryFn:pe.checkForUpdates,staleTime:300*1e3}),{data:Ct,refetch:yt}=ut({queryKey:["updateStatus"],queryFn:pe.getUpdateStatus,refetchInterval:be=>{const kt=be.state.data;return kt?.status==="downloading"||kt?.status==="installing"?1e3:!1}}),{data:Mt}=ut({queryKey:["mqtt-status"],queryFn:pe.getMQTTStatus,refetchInterval:le==="network"?5e3:!1}),Vt=ht({mutationFn:pe.applyUpdate,onSuccess:be=>{be.is_docker?o(be.message,"error"):yt()}}),[ue,je]=w.useState(null),Ge=ht({mutationFn:pe.testAllNotificationProviders,onSuccess:be=>{je(be),t.invalidateQueries({queryKey:["notification-providers"]}),be.failed===0?o(`All ${be.tested} providers tested successfully!`,"success"):o(`${be.success}/${be.tested} providers succeeded`,be.failed>0?"error":"success")},onError:be=>{o(`Failed to test providers: ${be.message}`,"error")}}),qe=ht({mutationFn:async be=>{if(!Tt)return{success:0,failed:0};const kt=Tt.filter(zt=>zt.enabled),rn=await Promise.all(kt.map(async zt=>{try{return await pe.controlSmartPlug(zt.id,be),{success:!0}}catch{return{success:!1}}}));return{success:rn.filter(zt=>zt.success).length,failed:rn.filter(zt=>!zt.success).length}},onSuccess:(be,kt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),be.failed===0?o(`All ${be.success} plugs turned ${kt}`,"success"):o(`${be.success} plugs turned ${kt}, ${be.failed} failed`,"error")},onError:be=>{o(`Failed: ${be.message}`,"error")}}),Ve=w.useRef(null),xt=w.useRef(!1),Pt=w.useRef(!0);w.useEffect(()=>{if(at&&!T){const be={...at,external_url:at.external_url||window.location.origin};R(be),setTimeout(()=>{Pt.current=!1},100)}},[at,T]);const _t=ht({mutationFn:pe.updateSettings,onSuccess:be=>{t.setQueryData(["settings"],be),R(be),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:be=>{o(`Failed to save: ${be.message}`,"error")},onSettled:()=>{xt.current=!1}}),pt=ht({mutationFn:({id:be,data:kt})=>pe.updatePrinter(be,kt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:be=>{o(`Failed to update printer: ${be.message}`,"error")}});w.useEffect(()=>{if(!(Pt.current||!T||!at||!(at.auto_archive!==T.auto_archive||at.save_thumbnails!==T.save_thumbnails||at.capture_finish_photo!==T.capture_finish_photo||at.default_filament_cost!==T.default_filament_cost||at.currency!==T.currency||at.energy_cost_per_kwh!==T.energy_cost_per_kwh||at.energy_tracking_mode!==T.energy_tracking_mode||at.check_updates!==T.check_updates||at.notification_language!==T.notification_language||at.ams_humidity_good!==T.ams_humidity_good||at.ams_humidity_fair!==T.ams_humidity_fair||at.ams_temp_good!==T.ams_temp_good||at.ams_temp_fair!==T.ams_temp_fair||at.ams_history_retention_days!==T.ams_history_retention_days||at.per_printer_mapping_expanded!==T.per_printer_mapping_expanded||at.date_format!==T.date_format||at.time_format!==T.time_format||at.default_printer_id!==T.default_printer_id||at.ftp_retry_enabled!==T.ftp_retry_enabled||at.ftp_retry_count!==T.ftp_retry_count||at.ftp_retry_delay!==T.ftp_retry_delay||at.ftp_timeout!==T.ftp_timeout||at.mqtt_enabled!==T.mqtt_enabled||at.mqtt_broker!==T.mqtt_broker||at.mqtt_port!==T.mqtt_port||at.mqtt_username!==T.mqtt_username||at.mqtt_password!==T.mqtt_password||at.mqtt_topic_prefix!==T.mqtt_topic_prefix||at.mqtt_use_tls!==T.mqtt_use_tls||at.external_url!==T.external_url||at.ha_enabled!==T.ha_enabled||at.ha_url!==T.ha_url||at.ha_token!==T.ha_token||(at.library_archive_mode??"ask")!==(T.library_archive_mode??"ask")||Number(at.library_disk_warning_gb??5)!==Number(T.library_disk_warning_gb??5)||(at.camera_view_mode??"window")!==(T.camera_view_mode??"window")))&&!xt.current)return Ve.current&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>{if(xt.current)return;xt.current=!0;const kt={auto_archive:T.auto_archive,save_thumbnails:T.save_thumbnails,capture_finish_photo:T.capture_finish_photo,default_filament_cost:T.default_filament_cost,currency:T.currency,energy_cost_per_kwh:T.energy_cost_per_kwh,energy_tracking_mode:T.energy_tracking_mode,check_updates:T.check_updates,notification_language:T.notification_language,ams_humidity_good:T.ams_humidity_good,ams_humidity_fair:T.ams_humidity_fair,ams_temp_good:T.ams_temp_good,ams_temp_fair:T.ams_temp_fair,ams_history_retention_days:T.ams_history_retention_days,per_printer_mapping_expanded:T.per_printer_mapping_expanded,date_format:T.date_format,time_format:T.time_format,default_printer_id:T.default_printer_id,ftp_retry_enabled:T.ftp_retry_enabled,ftp_retry_count:T.ftp_retry_count,ftp_retry_delay:T.ftp_retry_delay,ftp_timeout:T.ftp_timeout,mqtt_enabled:T.mqtt_enabled,mqtt_broker:T.mqtt_broker,mqtt_port:T.mqtt_port,mqtt_username:T.mqtt_username,mqtt_password:T.mqtt_password,mqtt_topic_prefix:T.mqtt_topic_prefix,mqtt_use_tls:T.mqtt_use_tls,external_url:T.external_url,ha_enabled:T.ha_enabled,ha_url:T.ha_url,ha_token:T.ha_token,library_archive_mode:T.library_archive_mode,library_disk_warning_gb:T.library_disk_warning_gb,camera_view_mode:T.camera_view_mode};_t.mutate(kt)},500),()=>{Ve.current&&clearTimeout(Ve.current)}},[T,at,_t]);const St=w.useCallback((be,kt)=>{R(rn=>rn?{...rn,[be]:kt}:null)},[]),Ot=async(be,kt,rn)=>{if(!kt){o("Please enter a camera URL","error");return}Oe(zt=>({...zt,[be]:!0})),ve(zt=>({...zt,[be]:null}));try{const zt=await pe.testExternalCamera(be,kt,rn);ve(cn=>({...cn,[be]:zt})),zt.success?o(`Camera connected${zt.resolution?` (${zt.resolution})`:""}`,"success"):o(zt.error||"Connection failed","error")}catch(zt){const cn=zt instanceof Error?zt.message:"Test failed";ve($t=>({...$t,[be]:{success:!1,error:cn}})),o(cn,"error")}finally{Oe(zt=>({...zt,[be]:!1}))}},Ft=(be,kt)=>{const rn={};kt.url!==void 0&&(rn.external_camera_url=kt.url||null),kt.type!==void 0&&(rn.external_camera_type=kt.type||null),kt.enabled!==void 0&&(rn.external_camera_enabled=kt.enabled),pt.mutate({id:be,data:rn})};return Rt||!T?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{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 overflow-x-auto",children:[s.jsx("button",{onClick:()=>me("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${le==="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:()=>me("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Hs,{className:"w-4 h-4"}),"Smart Plugs",Tt&&Tt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Tt.length})]}),s.jsxs("button",{onClick:()=>me("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(yf,{className:"w-4 h-4"}),"Notifications",ft&&ft.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ft.length})]}),s.jsxs("button",{onClick:()=>me("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(kde,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>me("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Qp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Mt?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>me("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(of,{className:"w-4 h-4"}),"API Keys",tn&&tn.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:tn.length})]}),s.jsxs("button",{onClick:()=>me("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Br,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Nn?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>me("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${le==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(lf,{className:"w-4 h-4"}),"Users",u&&s.jsx("span",{className:`w-2 h-2 rounded-full ${u?"bg-green-400":"bg-gray-500"}`})]})]}),le==="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(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Id,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:be=>a.changeLanguage(be.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:Ez.map(be=>s.jsxs("option",{value:be.code,children:[be.nativeName," (",be.name,")"]},be.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsx("select",{value:Z,onChange:be=>Ne(be.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:C0.map(be=>s.jsx("option",{value:be.to,children:i(be.labelKey)},be.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("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:T.date_format||"system",onChange:be=>St("date_format",be.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:T.time_format||"system",onChange:be=>St("time_format",be.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:T.default_printer_id??"",onChange:be=>St("default_printer_id",be.target.value?Number(be.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)"}),_r?.map(be=>s.jsx("option",{value:be.id,children:be.name},be.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(Me,{variant:"secondary",size:"sm",onClick:Be,children:[s.jsx(om,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ID,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(At,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${m==="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",m==="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:b,onChange:be=>{N(be.target.value),o("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:y,onChange:be=>{A(be.target.value),o("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:p,onChange:be=>{M(be.target.value),o("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 ${m==="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",m==="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:v,onChange:be=>{C(be.target.value),o("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:S,onChange:be=>{D(be.target.value),o("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:x,onChange:be=>{k(be.target.value),o("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(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(At,{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:T.auto_archive,onChange:be=>St("auto_archive",be.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:T.save_thumbnails,onChange:be=>St("save_thumbnails",be.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:T.capture_finish_photo,onChange:be=>St("capture_finish_photo",be.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"})]})]}),T.capture_finish_photo&&ce&&!ce.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(Rn,{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(Et,{children:[s.jsx(wr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(BD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:T.camera_view_mode??"window",onChange:be=>St("camera_view_mode",be.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:"window",children:"New Window"}),s.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:T.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:"External Cameras"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure network cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, and HTTP snapshots. When enabled, the external camera is used for live view and finish photos."}),_r&&_r.length>0?s.jsx("div",{className:"space-y-3",children:_r.map(be=>s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-white font-medium text-sm",children:be.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:be.external_camera_enabled,onChange:kt=>Ft(be.id,{enabled:kt.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 peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),be.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:"Camera URL (rtsp://... or http://...)",value:be.external_camera_url||"",onChange:kt=>Ft(be.id,{url:kt.target.value}),className:"w-full 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:"flex gap-2",children:[s.jsxs("select",{value:be.external_camera_type||"mjpeg",onChange:kt=>Ft(be.id,{type:kt.target.value}),className:"flex-1 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",children:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"})]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Ot(be.id,be.external_camera_url||"",be.external_camera_type||"mjpeg"),disabled:He[be.id]||!be.external_camera_url,children:He[be.id]?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),ze[be.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${ze[be.id]?.success?"text-green-500":"text-red-500"}`,children:ze[be.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Gn,{className:"w-3 h-3"}),"Connected",ze[be.id]?.resolution&&` (${ze[be.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(Ya,{className:"w-3 h-3"}),ze[be.id]?.error||"Connection failed"]})})]})]},be.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(At,{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:T.default_filament_cost,onChange:be=>St("default_filament_cost",parseFloat(be.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:T.currency,onChange:be=>St("currency",be.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:T.energy_cost_per_kwh,onChange:be=>St("energy_cost_per_kwh",parseFloat(be.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:T.energy_tracking_mode||"total",onChange:be=>St("energy_tracking_mode",be.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:T.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Wa,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(At,{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:T.library_archive_mode??"ask",onChange:be=>St("library_archive_mode",be.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:T.library_disk_warning_gb??5,onChange:be=>St("library_disk_warning_gb",parseFloat(be.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(BYe,{}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(At,{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:T.check_updates,onChange:be=>St("check_updates",be.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",Ue?.version||"..."]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>rt(),disabled:et,children:[et?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mr,{className:"w-4 h-4"}),"Check now"]})]}),We?.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",We.latest_version]}),We.release_name&&We.release_name!==We.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:We.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[We.release_notes&&s.jsx("button",{onClick:()=>Ze(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),We.release_url&&s.jsx("a",{href:We.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(zr,{className:"w-4 h-4"})})]})]}),Ct?.status==="downloading"||Ct?.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(dt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Ct.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:`${Ct.progress}%`}})})]}):Ct?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Ct.message}):Ct?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Ct.error||Ct.message}):We?.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(Me,{className:"mt-3",onClick:()=>Vt.mutate(),disabled:Vt.isPending,children:[Vt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ir,{className:"w-4 h-4"}),"Install Update"]})]}):We?.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: ",We.error]}):We&&!We.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(At,{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(Me,{variant:"secondary",size:"sm",onClick:()=>Te(!0),children:[s.jsx(Ir,{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(Me,{variant:"secondary",size:"sm",onClick:()=>Xe(!0),children:[s.jsx(oi,{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(Me,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[s.jsx(fn,{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(Me,{variant:"secondary",size:"sm",onClick:()=>X(!0),children:[s.jsx(fn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),le==="network"&&T&&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(Et,{children:[s.jsx(wr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Id,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(At,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:T.external_url??"",onChange:be=>St("external_url",be.target.value),placeholder:"http://192.168.1.100:8000",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:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Mr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(At,{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:T.ftp_retry_enabled??!0,onChange:be=>St("ftp_retry_enabled",be.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"})]})]}),T.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:T.ftp_retry_count??3,onChange:be=>St("ftp_retry_count",Math.min(10,Math.max(1,parseInt(be.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:T.ftp_retry_delay??2,onChange:be=>St("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(be.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:T.ftp_timeout??30,onChange:be=>St("ftp_timeout",Math.min(120,Math.max(10,parseInt(be.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("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(Et,{children:[s.jsx(wr,{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(aE,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),T.ha_enabled&&Ce&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ce.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ce.success?"text-green-400":"text-red-400"}`,children:Ce.success?"Connected":"Disconnected"})]})]})}),s.jsxs(At,{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:T.ha_enabled??!1,onChange:be=>St("ha_enabled",be.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"})]})]}),T.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:T.ha_url??"",onChange:be=>St("ha_url",be.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:T.ha_token??"",onChange:be=>St("ha_token",be.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"})]}),T.ha_url&&T.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Me,{variant:"secondary",size:"sm",disabled:lt,onClick:async()=>{se(!0),$e(null);try{const be=await pe.testHAConnection(T.ha_url,T.ha_token);$e(be)}catch(be){$e({success:!1,message:null,error:be instanceof Error?be.message:"Unknown error"})}finally{se(!1)}},children:[lt?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Qp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(Et,{children:[s.jsx(wr,{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(Qp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Mt?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Mt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Mt.connected?"text-green-400":"text-red-400"}`,children:Mt.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(At,{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:T.mqtt_enabled??!1,onChange:be=>St("mqtt_enabled",be.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"})]})]}),T.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:T.mqtt_broker??"",onChange:be=>St("mqtt_broker",be.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:T.mqtt_port??1883,onChange:be=>St("mqtt_port",Math.min(65535,Math.max(1,parseInt(be.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:T.mqtt_use_tls??!1,onChange:be=>{const kt=be.target.checked;St("mqtt_use_tls",kt);const rn=T.mqtt_port??1883;kt&&rn===1883?St("mqtt_port",8883):!kt&&rn===8883&&St("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:T.mqtt_username??"",onChange:be=>St("mqtt_username",be.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:T.mqtt_password??"",onChange:be=>St("mqtt_password",be.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:T.mqtt_topic_prefix??"bambuddy",onChange:be=>St("mqtt_topic_prefix",be.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: ",T.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Mt&&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 ${Mt.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Mt.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Mt.broker,":",Mt.port]})]}):"Not connected"})]})})]})]})]})]})]}),Ce&&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:[Ce.success?s.jsx(Gn,{className:"w-8 h-8 text-green-400"}):s.jsx(Ya,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Ce.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Ce.success?Ce.message||"Successfully connected to Home Assistant.":Ce.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Me,{variant:"primary",onClick:()=>$e(null),children:"OK"})})]})}),le==="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(Hs,{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:[Tt&&Tt.filter(be=>be.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>_e("on"),disabled:qe.isPending,title:"Turn all plugs on",children:[qe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(_u,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>_e("off"),disabled:qe.isPending,title:"Turn all plugs off",children:[qe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(cE,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{j(null),O(!0)},children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Tt&&Tt.length>0&&s.jsxs(Et,{className:"mb-6",children:[s.jsx(wr,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(zf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ln&&s.jsx(dt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(At,{children:Lt?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(zf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Lt.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:[Lt.reachableCount,"/",Lt.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(ti,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Lt.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Lt.totalToday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(MK,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Lt.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Lt.totalYesterday*T.energy_cost_per_kwh).toFixed(2)," ",T.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(fP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Lt.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),T&&T.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Lt.totalLifetime*T.energy_cost_per_kwh).toFixed(2)," ",T.currency]})]})]}):ln?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),nn?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Tt&&Tt.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Tt.map(be=>s.jsx(EYe,{plug:be,onEdit:kt=>{j(kt),O(!0)}},be.id))}):s.jsx(Et,{children:s.jsx(At,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Hs,{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(Me,{onClick:()=>{j(null),O(!0)},children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),le==="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(yf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>V(!0),children:[s.jsx(Pw,{className:"w-4 h-4"}),"Log"]}),ft&&ft.length>0&&s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{je(null),Ge.mutate()},disabled:Ge.isPending,children:[Ge.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(UD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Me,{size:"sm",onClick:()=>{J(null),K(!0)},children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Et,{className:"mb-4",children:s.jsx(At,{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:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:T.notification_language||"en",onChange:be=>St("notification_language",be.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:Ez.map(be=>s.jsx("option",{value:be.code,children:be.nativeName},be.code))})]})})}),ue&&s.jsx(Et,{className:"mb-4",children:s.jsxs(At,{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:()=>je(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(Gn,{className:"w-4 h-4"}),ue.success," passed"]}),ue.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Ya,{className:"w-4 h-4"}),ue.failed," failed"]})]}),ue.results.filter(be=>!be.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ue.results.filter(be=>!be.success).map(be=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[be.provider_name,":"]})," ",be.message]},be.provider_id))})]})}),Xt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ft&&ft.length>0?s.jsx("div",{className:"space-y-3",children:ft.map(be=>s.jsx(TYe,{provider:be,onEdit:kt=>{J(kt),K(!0)}},be.id))}):s.jsx(Et,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(yf,{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(Me,{size:"sm",onClick:()=>{J(null),K(!0)},children:[s.jsx(Qn,{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(Wa,{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."}),vt?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):er&&er.length>0?s.jsx("div",{className:"space-y-2",children:er.map(be=>s.jsx(Et,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>re(be),children:s.jsx(At,{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:be.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:be.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:kt=>{kt.stopPropagation(),re(be)},children:s.jsx(lE,{className:"w-4 h-4 text-bambu-gray"})})]})})},be.id))}):s.jsx(Et,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Wa,{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."})]})})})]})]}),le==="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(of,{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(Me,{size:"sm",onClick:()=>De(!0),className:"flex-shrink-0",children:[s.jsx(Qn,{className:"w-4 h-4"}),"Create Key"]})]}),Y&&s.jsx(Et,{className:"mb-6 border-bambu-green",children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Gn,{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:Y}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Y);else{const be=document.createElement("textarea");be.value=Y,be.style.position="fixed",be.style.left="-999999px",document.body.appendChild(be),be.select(),document.execCommand("copy"),document.body.removeChild(be)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(rl,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{Le(Y),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>H(null),children:"Dismiss"})]})]})]})})}),we&&s.jsxs(Et,{className:"mb-6",children:[s.jsx(wr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(At,{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:ee,onChange:be=>Qe(be.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:B.can_read_status,onChange:be=>te(kt=>({...kt,can_read_status:be.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:B.can_queue,onChange:be=>te(kt=>({...kt,can_queue:be.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:B.can_control_printer,onChange:be=>te(kt=>({...kt,can_control_printer:be.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(Me,{onClick:()=>gr.mutate({name:ee||"Unnamed Key",...B}),disabled:gr.isPending,children:[gr.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Qn,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Me,{variant:"secondary",onClick:()=>De(!1),children:"Cancel"})]})]})]}),wt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):tn&&tn.length>0?s.jsx("div",{className:"space-y-3",children:tn.map(be=>s.jsx(Et,{children:s.jsx(At,{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(of,{className:`w-5 h-5 ${be.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:be.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[be.key_prefix,"••••••••",be.last_used&&` · Last used: ${xg(be.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[be.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),be.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),be.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(Me,{variant:"secondary",size:"sm",onClick:()=>de(be.id),children:s.jsx(fn,{className:"w-4 h-4 text-red-400"})})]})]})})},be.id))}):s.jsx(Et,{children:s.jsx(At,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(of,{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(Me,{onClick:()=>De(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Et,{className:"mt-6",children:[s.jsx(wr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(At,{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(Id,{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(Et,{className:"mb-4",children:s.jsxs(At,{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:Ae,onChange:be=>Le(be.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(WYe,{apiKey:Ae})]})]}),le==="virtual-printer"&&s.jsx($Ye,{}),le==="filament"&&T&&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(Et,{children:[s.jsx(wr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(At,{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(LD,{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:T.ams_humidity_good??40,onChange:be=>St("ams_humidity_good",parseInt(be.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:T.ams_humidity_fair??60,onChange:be=>St("ams_humidity_fair",parseInt(be.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(dE,{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:T.ams_temp_good??28,onChange:be=>St("ams_temp_good",parseFloat(be.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:T.ams_temp_fair??35,onChange:be=>St("ams_temp_fair",parseFloat(be.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(mg,{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:T.ams_history_retention_days??30,onChange:be=>St("ams_history_retention_days",parseInt(be.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.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(Br,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:"Print Modal"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.per_printer_mapping_expanded??!1,onChange:be=>St("per_printer_mapping_expanded",be.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.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(UYe,{})})]}),F!==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:()=>{Nr.mutate(F),de(null)},onCancel:()=>de(null)}),U&&s.jsx(NYe,{plug:q,onClose:()=>{O(!1),j(null)}}),W&&s.jsx(CYe,{provider:G,onClose:()=>{K(!1),J(null)}}),ie&&s.jsx(kYe,{template:ie,onClose:()=>re(null)}),z&&s.jsx(RYe,{onClose:()=>V(!1)}),Se&&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()=>{$(!1);try{const be=await pe.clearNotificationLogs(30);o(be.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>$(!1)}),L&&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:()=>{X(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>X(!1)}),xe&&s.jsx(Un,{title:`Turn All Plugs ${xe==="on"?"On":"Off"}`,message:`This will turn ${xe==="on"?"ON":"OFF"} all ${Tt?.filter(be=>be.enabled).length||0} enabled smart plugs. ${xe==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${xe==="on"?"On":"Off"}`,variant:xe==="off"?"danger":"warning",onConfirm:()=>{const be=xe;_e(null),qe.mutate(be)},onCancel:()=>_e(null)}),ae&&s.jsx(OYe,{onClose:()=>Te(!1),onExport:async be=>{Te(!1);const kt="backup-progress",rn=be.archives;rn&&l(kt,i("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:zt,filename:cn}=await pe.exportBackup(be);rn&&c(kt);const $t=URL.createObjectURL(zt),Gt=document.createElement("a");Gt.href=$t,Gt.download=cn,Gt.click(),URL.revokeObjectURL($t),o(i("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{rn&&c(kt),o(i("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Pe&&s.jsx(LYe,{onClose:()=>Xe(!1),onRestore:async(be,kt)=>await pe.importBackup(be,kt),onSuccess:()=>{R(null),Pt.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"]})}}),Je&&We?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ze(!1),children:s.jsxs(Et,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[s.jsxs(wr,{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",We.latest_version]}),We.release_name&&We.release_name!==We.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:We.release_name})]}),s.jsx("button",{onClick:()=>Ze(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Wt,{className:"w-5 h-5"})})]}),s.jsx(At,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:We.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[We.release_url&&s.jsx("a",{href:We.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Me,{variant:"secondary",className:"w-full",children:[s.jsx(zr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Me,{onClick:()=>Ze(!1),className:"flex-1",children:"Close"})]})]})}),le==="users"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[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(lf,{className:"w-5 h-5 text-bambu-green"}),"User Authentication"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Enable authentication to secure your Bambuddy instance and manage user access."})]}),s.jsx(Et,{children:s.jsx(At,{className:"py-6",children:u?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center bg-green-500/20",children:s.jsx(iT,{className:"w-6 h-6 text-green-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),d&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Current User"}),s.jsx("p",{className:"text-white font-medium",children:d.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:d.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${d.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:d.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(Me,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(lf,{className:"w-4 h-4"}),"Manage Users"]}),d?.role==="admin"&&s.jsxs(Me,{onClick:()=>ye(!0),className:"w-full",variant:"secondary",children:[s.jsx(Gz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${u?"bg-green-500/20":"bg-gray-500/20"}`,children:u?s.jsx(iT,{className:"w-6 h-6 text-green-400"}):s.jsx(Gz,{className:"w-6 h-6 text-gray-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Require login to access the system"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage multiple users with different roles"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Control access to printer settings and user management"})]})]}),s.jsxs(Me,{type:"button",onClick:be=>{be.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(iT,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),u&&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(yP,{className:"w-5 h-5 text-bambu-green"}),"Role Permissions"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Overview of what each role can do."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:s.jsx(yP,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(At,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage printer settings"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Create, edit, and delete users"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(Et,{children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:s.jsx(lf,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(At,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Send print jobs"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage files and archives"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Gn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),oe&&s.jsx(Un,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await pe.disableAuth(),o("Authentication disabled successfully","success"),await f(),ye(!1),window.location.href="/"}catch(be){const kt=be instanceof Error?be.message:"Failed to disable authentication";o(kt,"error")}},onCancel:()=>ye(!1)})]})}const zie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},XYe=t=>t.startsWith("HH")?"HF":"S",YYe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},gD=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 Vj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=XYe(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(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{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:zie(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(vK,{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(rl,{className:"w-4 h-4"})})]})}function Gj({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}=qn(),[f,m]=w.useState(t?.name||""),[p,b]=w.useState(t?.k_value?zie(t.k_value):"0.020"),[y,x]=w.useState(t?.filament_id||""),[v,S]=w.useState(t?.nozzle_id?YYe(t.nozzle_id):"HH00"),[M,N]=w.useState(t?.nozzle_diameter||n),[A,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,D]=w.useState(!1),[T,R]=w.useState({current:0,total:0}),[U,O]=w.useState(a),q=Dr.useMemo(()=>{const re=new Map;for(const z of r)if(z.filament_id&&!re.has(z.filament_id)){const V=gD(z.name||"");re.set(z.filament_id,{id:z.filament_id,name:V||z.filament_id})}return Array.from(re.values()).sort((z,V)=>z.name.localeCompare(V.name))},[r]),j=ht({mutationFn:re=>(console.log("[KProfile] Calling API..."),pe.setKProfile(e,re)),onSuccess:re=>{if(console.log("[KProfile] Save success:",re),d("K-profile saved"),u&&U!==a){let z;U===""&&o?z=o:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${y}`,u(z,U)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:re=>{console.error("[KProfile] Save error:",re),d(re.message,"error"),D(!1)}}),W=ht({mutationFn:re=>(console.log("[KProfile] Deleting profile..."),pe.deleteKProfile(e,re)),onSuccess:re=>{console.log("[KProfile] Delete success:",re),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:re=>{console.error("[KProfile] Delete error:",re),d(re.message,"error"),D(!1)}}),[K,G]=w.useState(!1),J=()=>{t&&W.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})},ie=async re=>{if(re.preventDefault(),i&&!t&&A.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),V=`${v}-${M}`;if(t||A.length===1){const ne={name:f,k_value:z,filament_id:y,nozzle_id:V,nozzle_diameter:M,extruder_id:t?t.extruder_id:A[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ne),j.mutate(ne);return}D(!0),R({current:1,total:A.length});const Z=A.map(ne=>({name:f,k_value:z,filament_id:y,nozzle_id:V,nozzle_diameter:M,extruder_id:ne,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${Z.length} profiles in batch:`,Z);try{if(await pe.setKProfilesBatch(e,Z),d(`K-profile saved to ${A.length} extruders`),u&&U){const ne=`name_${f}_${y}`;u(ne,U)}}catch(ne){console.error("[KProfile] Failed to save batch:",ne),d("Failed to save K-profiles","error"),D(!1),R({current:0,total:0});return}R({current:A.length,total:A.length}),setTimeout(()=>{D(!1),R({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(Et,{className:"w-full max-w-md relative",children:[C&&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(dt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:T.total>1?`Saving to extruder ${T.current}/${T.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(At,{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:C,children:s.jsx(Wt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ie,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:re=>m(re.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:p,onChange:re=>{const z=re.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&b(z)},onBlur:re=>{const z=parseFloat(re.target.value);isNaN(z)||b((Math.trunc(z*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),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:y,onChange:re=>{const z=re.target.value;if(x(z),!t&&z&&!f){const V=q.find(Z=>Z.id===z);V&&m(`${v==="HH00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:q.find(re=>re.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(re=>s.jsx("option",{value:re.id,children:re.name},re.id))]}),!t&&q.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:v,onChange:re=>{const z=re.target.value;if(S(z),!t&&y&&!f){const V=q.find(Z=>Z.id===y);V&&m(`${z==="HS00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[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:M,onChange:re=>N(re.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:A.includes(1),onChange:re=>{re.target.checked?k([...A,1]):k(A.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:A.includes(0),onChange:re=>{re.target.checked?k([...A,0]):k(A.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:U,onChange:re=>O(re.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(Me,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{className:"w-4 h-4"})}),s.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:j.isPending||C,className:"flex-1",children:[j.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(rE,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(Et,{className:"w-full max-w-sm",children:s.jsxs(At,{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(fn,{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(Me,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>{G(!1),J()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const K1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function ZYe(){const{showToast:t}=qn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(K1.NOZZLE_DIAMETER)||"0.4"),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[p,b]=w.useState("all"),[y,x]=w.useState("all"),[v,S]=w.useState(()=>localStorage.getItem(K1.SORT_OPTION)||"name"),[M,N]=w.useState(!1),[A,k]=w.useState(new Set),[C,D]=w.useState(!1),[T,R]=w.useState(!1),U=w.useCallback(H=>`${H.slot_id}_${H.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(K1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(K1.SORT_OPTION,v)},[v]);const{data:O,isLoading:q}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:j,isLoading:W,isFetching:K,error:G,refetch:J}=ut({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const H=await pe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",H?.profiles?.length||0,"profiles"),H},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ie}=ut({queryKey:["kprofiles",e,"0.4"],queryFn:()=>pe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:re,refetch:z}=ut({queryKey:["kprofile-notes",e],queryFn:()=>pe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=G?.message?.includes("not connected");w.useEffect(()=>{if(!e&&O&&O.length>0){const H=O.find(F=>F.is_active);H&&n(H.id)}},[e,O]),w.useEffect(()=>{if(e){const H=setTimeout(()=>{J()},150);return()=>clearTimeout(H)}},[e,r]);const Z=O?.filter(H=>H.is_active)||[],ne=Dr.useMemo(()=>j?.profiles?j.profiles.filter(F=>{const de=f.toLowerCase(),Ae=!de||F.name.toLowerCase().includes(de)||F.filament_id.toLowerCase().includes(de),Le=p==="all"||p==="left"&&F.extruder_id===1||p==="right"&&F.extruder_id===0,Se=y==="all"||y==="hf"&&F.nozzle_id.startsWith("HH")||y==="s"&&F.nozzle_id.startsWith("HS");return Ae&&Le&&Se}).sort((F,de)=>{switch(v){case"k_value":return parseFloat(F.k_value)-parseFloat(de.k_value);case"filament":return gD(F.name).localeCompare(gD(de.name));default:return F.name.localeCompare(de.name)}}):[],[j?.profiles,f,p,y,v]),he=O?.find(H=>H.id===e),fe=he?.nozzle_count===2;w.useEffect(()=>{const H=F=>{F.target instanceof HTMLInputElement||F.target instanceof HTMLTextAreaElement||F.target instanceof HTMLSelectElement||a||l||u||(F.key==="r"||F.key==="R"?(F.preventDefault(),J()):F.key==="n"||F.key==="N"?(F.preventDefault(),c(!0)):F.key==="Escape"&&M&&(F.preventDefault(),N(!1),k(new Set)))};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[a,l,u,M,J]);const le=w.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const H={version:1,exported_at:new Date().toISOString(),printer:he?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(Le=>({name:Le.name,k_value:Le.k_value,filament_id:Le.filament_id,nozzle_id:Le.nozzle_id,nozzle_diameter:Le.nozzle_diameter,extruder_id:Le.extruder_id}))},F=new Blob([JSON.stringify(H,null,2)],{type:"application/json"}),de=URL.createObjectURL(F),Ae=document.createElement("a");Ae.href=de,Ae.download=`kprofiles_${he?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(de),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,he,r,t]),Ee=w.useCallback(()=>{const H=document.createElement("input");H.type="file",H.accept=".json",H.onchange=async F=>{const de=F.target.files?.[0];if(de)try{const Ae=await de.text(),Le=JSON.parse(Ae);if(!Le.profiles||!Array.isArray(Le.profiles)){t("Invalid file format","error");return}let Se=0;for(const $ of Le.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await pe.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",$.name,L)}t(`Imported ${Se} of ${Le.profiles.length} profiles`),J()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},H.click()},[e,r,t,J]),me=w.useCallback(H=>{k(F=>{const de=new Set(F);return de.has(H)?de.delete(H):de.add(H),de})},[]),we=w.useCallback(()=>{k(new Set(ne.map(H=>U(H))))},[ne,U]),De=w.useCallback(()=>{A.size!==0&&D(!0)},[A.size]),ee=w.useCallback(async()=>{const H=ne.filter(de=>A.has(U(de)));R(!0);let F=0;for(const de of H)try{await pe.deleteKProfile(e,{slot_id:de.slot_id,extruder_id:de.extruder_id,nozzle_id:de.nozzle_id,nozzle_diameter:de.nozzle_diameter,filament_id:de.filament_id,setting_id:de.setting_id}),F++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",de.name,Ae)}t(`Deleted ${F} profiles`),R(!1),D(!1),N(!1),k(new Set),J()},[e,A,ne,t,J,U]),Qe=w.useCallback(H=>{const F=[];return H.setting_id&&F.push(H.setting_id),F.push(`slot_${H.slot_id}_${H.filament_id}_${H.extruder_id}`),F.push(`name_${H.name}_${H.filament_id}`),F},[]),B=w.useCallback(async(H,F)=>{if(e)try{await pe.setKProfileNote(e,H,F),z()}catch(de){console.error("Failed to save note:",de),t("Failed to save note","error")}},[e,z,t]),te=w.useCallback(H=>{if(!re?.notes)return{note:"",key:null};const F=Qe(H);for(const de of F)if(re.notes[de])return{note:re.notes[de],key:de};return{note:"",key:null}},[re,Qe]),Y=w.useCallback(H=>te(H).note,[te]);return q?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!O||O.length===0?s.jsx(Et,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Qi,{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"})]})}):Z.length===0?s.jsx(Et,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Br,{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:[K&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(dt,{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:H=>n(parseInt(H.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:Z.map(H=>s.jsx("option",{value:H.id,children:H.name},H.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:H=>i(H.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(Me,{variant:"secondary",onClick:()=>J(),disabled:K,children:[s.jsx(Mr,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(Qn,{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(va,{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:H=>m(H.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"})]}),fe&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:H=>b(H.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:y,onChange:H=>x(H.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:v,onChange:H=>S(H.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(Me,{variant:"secondary",onClick:le,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Ir,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Me,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[s.jsx(oi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),M?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:we,title:"Select all visible profiles",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Me,{variant:"secondary",onClick:De,disabled:A.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${A.size} selected profiles`,children:[s.jsx(fn,{className:"w-4 h-4"}),"Delete (",A.size,")"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{N(!1),k(new Set)},children:[s.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Me,{variant:"secondary",onClick:()=>N(!0),disabled:!ne.length,title:"Enter selection mode for bulk delete",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select"]})]}),W?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):V?s.jsx(Et,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Yg,{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(Me,{variant:"secondary",onClick:()=>J(),children:[s.jsx(Mr,{className:"w-4 h-4"}),"Retry"]})]})}):ne.length>0?fe?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:ne.filter(H=>H.extruder_id===1).map(H=>s.jsx(Vj,{profile:H,onEdit:()=>o(H),onCopy:()=>d(H),selectionMode:M,isSelected:A.has(U(H)),onToggleSelect:()=>me(U(H)),note:Y(H)},U(H)))})]}),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:ne.filter(H=>H.extruder_id===0).map(H=>s.jsx(Vj,{profile:H,onEdit:()=>o(H),onCopy:()=>d(H),selectionMode:M,isSelected:A.has(U(H)),onToggleSelect:()=>me(U(H)),note:Y(H)},U(H)))})]})]}):s.jsx("div",{className:"space-y-1",children:ne.map(H=>s.jsx(Vj,{profile:H,onEdit:()=>o(H),onCopy:()=>d(H),selectionMode:M,isSelected:A.has(U(H)),onToggleSelect:()=>me(U(H)),note:Y(H)},U(H)))}):f||p!=="all"||y!=="all"?s.jsx(Et,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(va,{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(Et,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(rE,{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(Me,{onClick:()=>c(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:H,key:F}=te(a);return s.jsx(Gj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ie?.profiles||j?.profiles,isDualNozzle:fe,initialNote:H,initialNoteKey:F,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),J()},onSave:()=>{o(null),J()}})})(),l&&e&&s.jsx(Gj,{printerId:e,nozzleDiameter:r,existingProfiles:ie?.profiles||j?.profiles,isDualNozzle:fe,onSaveNote:B,onClose:()=>{c(!1),J()},onSave:()=>{c(!1),J()}}),u&&e&&s.jsx(Gj,{printerId:e,nozzleDiameter:r,existingProfiles:ie?.profiles||j?.profiles,isDualNozzle:fe,onSaveNote:B,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),J()},onSave:()=>{d(null),J()}}),C&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Et,{className:"w-full max-w-sm",children:s.jsxs(At,{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(fn,{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:A.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>D(!1),disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:ee,disabled:T,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[T?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function pI(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 py(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function QYe(t){const e=gi(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 JYe({onSuccess:t}){const{showToast:e}=qn(),[n,r]=w.useState("email"),[i,a]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState("global"),b=ht({mutationFn:()=>pe.cloudLogin(i,o,m),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):M.needs_verification?(e("Verification code sent to your email"),r("code")):e(M.message,"error")},onError:M=>e(M.message,"error")}),y=ht({mutationFn:()=>pe.cloudVerify(i,c),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):e(M.message,"error")},onError:M=>e(M.message,"error")}),x=ht({mutationFn:()=>pe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:M=>e(M.message,"error")}),v=M=>{M.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&x.mutate()},S=b.isPending||y.isPending||x.isPending;return s.jsx(Et,{className:"max-w-md mx-auto",children:s.jsxs(At,{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(JM,{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:v,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:M=>a(M.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:M=>l(M.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:m,onChange:M=>p(M.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:M=>u(M.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:M=>f(M.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(Me,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Me,{type:"submit",disabled:S,className:"flex-1",children:[S?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Wz,{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(of,{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(Wz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Lp({label:t,value:e,options:n,onChange:r}){const[i,a]=w.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(Zi,{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 eZe(){const[t,e]=w.useState(!1);w.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(hg,{className:"w-5 h-5"})}):null}function Wj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=pI(t.name),c=py(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(rl,{className:"w-4 h-4"})})]})}function xD(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(`
  8327. `)){const i=t.replace(/\\n/g,`
  8328. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8329. `);if(i.length>1)return`"""
  8330. `+i.map(a=>n+" "+a).join(`
  8331. `)+`
  8332. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8333. `+t.map(i=>n+" "+xD(i,e+1)).join(`,
  8334. `)+`
  8335. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8336. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+xD(o,e+1)).join(`,
  8337. `)+`
  8338. `+n+"}"}return String(t)}function tZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=qn(),o=un(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ut({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>pe.getCloudSettingDetail(t.setting_id)}),f=ht({mutationFn:()=>pe.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),m=py(t.setting_id),p=pI(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(Et,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(At,{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}),m&&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"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.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(Wt,{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(dt,{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:xD(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(Rn,{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(Me,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fn,{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(Me,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Me,{variant:"secondary",onClick:r,children:[s.jsx(rl,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(Ia,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{variant:"danger",onClick:()=>c(!0),children:s.jsx(fn,{className:"w-4 h-4"})})]})]})})]})})})}function Bie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function $ie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function nZe({onClose:t,onApply:e}){const{showToast:n}=qn(),[r,i]=w.useState(Bie),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,b]=w.useState("{}"),[y,x]=w.useState(null),[v,S]=w.useState(null),M=a==="all"?r:r.filter(O=>O.type===a),N=O=>{i(O),$ie(O)},A=O=>{const q=r.filter(j=>j.id!==O);N(q),S(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),m(O.description),b(JSON.stringify(O.settings,null,2)),x(null)},C=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(p),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:O}:j);N(q),c(null),n("Template updated")}catch(O){x(O.message)}},D=()=>{c(null),d(""),m(""),b("{}"),x(null)},T=O=>{const q=r.map(j=>j.id===O?{...j,showInModal:!j.showInModal}:j);N(q)},R={filament:{label:"Filament",icon:OD,color:"text-amber-400"},print:{label:"Process",icon:qd,color:"text-blue-400"},printer:{label:"Printer",icon:Br,color:"text-purple-400"}},U=v?r.find(O=>O.id===v):null;return w.useEffect(()=>{const O=q=>{q.key==="Escape"&&(v?S(null):l?D():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[U&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(Et,{className:"w-full max-w-md",children:s.jsxs(At,{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(Rn,{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:U.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>S(null),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>A(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(fn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Et,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(At,{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(T0,{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(Wt,{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(O=>s.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":R[O].label},O))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(T0,{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:M.map(O=>{const q=R[O.type],j=q.icon;return l===O.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:W=>d(W.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:W=>m(W.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:p,onChange:W=>{b(W.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 ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:C,disabled:!u.trim(),children:[s.jsx(ps,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},O.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(j,{className:`w-5 h-5 ${q.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:O.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),s.jsx("button",{onClick:()=>T(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?s.jsx(If,{className:"w-4 h-4"}):s.jsx(eE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(O),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:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(fn,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Hie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of p){if(y==="inherits"||y==="version")continue;const x=e[y],v=n[y],S=y in e,M=y in n;let N;!S&&M?N="added":S&&!M?N="removed":JSON.stringify(x)!==JSON.stringify(v)?N="changed":N="same",b.push({key:y,left:x,right:v,status:N})}return b.sort((y,x)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[x.status]?v[y.status]-v[x.status]:y.key.localeCompare(x.key)})},[e,n]),d=w.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(b=>b.status!=="same")),l){const b=l.toLowerCase();p=p.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return p},[u,a,l]),f=w.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),m=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const b=String(p);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return w.useEffect(()=>{const p=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(Et,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(At,{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(Zp,{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(Wt,{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(Qn,{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(xP,{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(dP,{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(rT,{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(va,{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:p=>c(p.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(rT,{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(p=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],y={added:s.jsx(Qn,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(xP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(dP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(rT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.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:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.right)})})]},p.key)})})]})})]})})})}function rZe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=qn(),i=un(),a=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[m,p]=w.useState(e?.base_id||""),[b,y]=w.useState(""),[x,v]=w.useState(e?.setting||{inherits:""}),[S,M]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[N,A]=w.useState(null),[k,C]=w.useState(""),[D,T]=w.useState(!1),[R,U]=w.useState(""),[O,q]=w.useState(!1),[j,W]=w.useState(Bie),[K,G]=w.useState(!1),[J,ie]=w.useState(""),[re,z]=w.useState(""),[V,Z]=w.useState(!0),[ne,he]=w.useState(null),[fe,le]=w.useState(!1),Ee=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),me=w.useMemo(()=>Ee.filter(oe=>py(oe.setting_id)),[Ee]),{data:we}=ut({queryKey:["cloudFields",c],queryFn:()=>pe.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:De}=ut({queryKey:["allPresetDetails",c,me.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let Ce=0;Ce<me.length;Ce+=5){const $e=me.slice(Ce,Ce+5);(await Promise.all($e.map(async se=>{try{const ze=await pe.getCloudSettingDetail(se.setting_id);return{id:se.setting_id,detail:ze}}catch{return null}}))).forEach(se=>{se&&(oe[se.id]=se.detail)})}return oe},enabled:me.length>0,staleTime:1e3*60*10}),{data:ee,isLoading:Qe}=ut({queryKey:["cloudSettingDetail",m],queryFn:()=>pe.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&M(JSON.stringify(x,null,2))},[x,o]);const B=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ye=>!py(ye.setting_id)).sort((ye,Ce)=>ye.name.localeCompare(Ce.name)),[n,c]);w.useEffect(()=>{if(!m)return;const oe=B.find(ye=>ye.setting_id===m);oe&&(y(oe.name),a||(v({inherits:oe.name}),M(JSON.stringify({inherits:oe.name},null,2))))},[m,B,a]);const te=w.useMemo(()=>{const oe=we?.fields||[],ye=new Set(oe.map(se=>se.key)),Ce=new Set,$e=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);De&&Object.values(De).forEach(se=>{se?.setting&&Object.keys(se.setting).forEach(ze=>{!ye.has(ze)&&!$e.has(ze)&&Ce.add(ze)})}),Object.keys(x).forEach(se=>{!ye.has(se)&&!$e.has(se)&&Ce.add(se)});const lt=Array.from(Ce).sort().map(se=>({key:se,label:se.replace(/_/g," ").replace(/\b\w/g,ze=>ze.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...lt]},[we,De,x]),Y=te.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),H=()=>{if(R.trim()){const oe=R.trim().toLowerCase().replace(/\s+/g,"_");F(oe,""),U(""),q(!1),r(`Field "${oe}" added`)}},F=(oe,ye)=>{v(Ce=>{const $e={...Ce};return ye===""||ye===void 0?delete $e[oe]:$e[oe]=ye,$e})},de=oe=>{v(ye=>({...ye,...oe.settings})),he(oe.name),r("Template applied")},Ae=()=>{if(!J.trim())return;const oe={...x};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const ye={id:Date.now().toString(),name:J.trim(),description:re.trim()||"Custom template",type:c,settings:oe,showInModal:V},Ce=[...j,ye];W(Ce),$ie(Ce),G(!1),ie(""),z(""),Z(!0),r("Template saved")},Le=w.useMemo(()=>j.filter(oe=>oe.type===c&&oe.showInModal),[c,j]),Se=oe=>{M(oe);try{const ye=JSON.parse(oe);v(ye),A(null)}catch(ye){A(ye.message)}},$=oe=>{oe.preventDefault(),T(!1);const ye=oe.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const Ce=new FileReader;Ce.onload=$e=>{try{const lt=$e.target?.result,se=JSON.parse(lt),ze=se.setting||se;v(ve=>({...ve,...ze})),M(JSON.stringify({...x,...ze},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Ce.readAsText(ye)}},L=ht({mutationFn:()=>{const oe={...x},ye=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[ye]=`"${d}"`;const Ce={type:c,name:d,base_id:m,setting:oe};return pe.createCloudSetting(Ce)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),X=ht({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return pe.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:oe=>r(oe.message,"error")}),xe=a?X:L,_e=ee?.setting?.inherits,ae=_e?B.find(oe=>oe.name===_e):void 0,{data:Te}=ut({queryKey:["cloudSettingDetail",ae?.setting_id],queryFn:()=>pe.getCloudSettingDetail(ae.setting_id),enabled:!!ae?.setting_id}),Pe=w.useMemo(()=>{const oe=Te?.setting||{},ye=ee?.setting||{},Ce=m&&De?.[m]?.setting?De[m].setting:{};return{...oe,...ye,...Ce}},[m,ee,Te,De]),Xe=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const ye=[...new Set(oe.map(Ce=>String(Ce)))];return ye.length===1?ye[0]:oe.join(", ")}return String(oe)},Je=oe=>{const ye=x[oe.key],Ce=Pe[oe.key],$e=Xe(Ce),lt=Qe?"Loading...":$e||"",se="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(oe.type==="boolean"){const ze=ye==="1"||ye===void 0&&Ce==="1";return s.jsx("button",{type:"button",onClick:()=>F(oe.key,ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${ze?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${ze?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?s.jsxs("select",{value:ye||"",onChange:ze=>F(oe.key,ze.target.value),className:se,children:[s.jsx("option",{value:"",children:lt}),oe.options?.map(ze=>s.jsx("option",{value:ze.value,children:ze.label},ze.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:oe.type==="number"?"number":"text",value:ye!==void 0?String(ye):"",onChange:ze=>F(oe.key,ze.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:lt,className:se}),oe.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Ze=w.useMemo(()=>ee?.setting?ee.setting:{},[ee]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:oe=>{oe.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:$,children:[fe&&m&&s.jsx(Hie,{onClose:()=>le(!1),leftPreset:Ze,rightPreset:x,leftLabel:`Base: ${b||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Et,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(At,{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:[m&&s.jsxs("button",{onClick:()=>le(!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(Zp,{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(Wt,{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(oi,{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:oe=>{u(oe.target.value),p("")},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:m,onChange:oe=>p(oe.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..."}),B.map(oe=>s.jsx("option",{value:oe.setting_id,children:oe.name},oe.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:oe=>f(oe.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(ws,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),Qe&&s.jsx(dt,{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(qz,{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(oE,{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(cK,{className:"w-4 h-4"}),"JSON",N&&s.jsx(Qi,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:m,setting:x},ye=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Ce=URL.createObjectURL(ye),$e=document.createElement("a");$e.href=Ce,$e.download=`${d||"preset"}.json`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Ce),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(Ir,{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(oi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const ye=oe.target.files?.[0];if(ye){const Ce=new FileReader;Ce.onload=$e=>{try{const lt=JSON.parse($e.target?.result),se=lt.setting||lt;v(ze=>({...ze,...se})),r("File imported")}catch{r("Invalid JSON","error")}},Ce.readAsText(ye)}}})]}),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(T0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(oe=>oe!=="inherits").length>0&&s.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(ps,{className:"w-3 h-3"}),"Save as template"]})]}),K&&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:J,onChange:oe=>ie(oe.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:re,onChange:oe=>z(oe.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(Me,{size:"sm",onClick:Ae,disabled:!J.trim(),children:[s.jsx(ps,{className:"w-3 h-3"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>Z(!V),className:`flex items-center gap-1.5 text-xs transition-colors ${V?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[V?s.jsx(If,{className:"w-3.5 h-3.5"}):s.jsx(eE,{className:"w-3.5 h-3.5"}),V?"Show in modals":"Hidden in modals"]})]})]}),ne&&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(ws,{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:ne})]}),s.jsx("button",{onClick:()=>he(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Wt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Le.map(oe=>s.jsxs("button",{onClick:()=>de(oe),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:oe.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Le.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:te.slice(0,10).map(oe=>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:oe.label}),s.jsx("div",{className:"w-48",children:Je(oe)})]},oe.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(([oe])=>oe!=="inherits").map(([oe,ye])=>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:[oe,": ",String(ye).slice(0,20),s.jsx("button",{onClick:()=>F(oe,void 0),className:"hover:text-white",children:s.jsx(Wt,{className:"w-3 h-3"})})]},oe))})]})]}),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:De?`${te.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(va,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:k,onChange:oe=>C(oe.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:[Y.filter(oe=>!(oe.key in x)).map(oe=>{const ye=Pe[oe.key],Ce=Xe(ye);return s.jsxs("div",{onClick:()=>{v($e=>({...$e,[oe.key]:Ce||""}))},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:oe.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ce&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ce,children:[Ce.slice(0,20),Ce.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(Qn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),Y.filter(oe=>!(oe.key in x)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,onChange:oe=>U(oe.target.value),onKeyDown:oe=>oe.key==="Enter"&&H(),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(Me,{size:"sm",onClick:H,disabled:!R.trim(),children:s.jsx(Qn,{className:"w-4 h-4"})}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{q(!1),U("")},children:s.jsx(Wt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>q(!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(Qn,{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(oe=>oe!=="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(([oe])=>oe!=="inherits").map(([oe,ye])=>{const Ce=te.find($e=>$e.key===oe);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:Ce?.label||oe}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),s.jsx("button",{onClick:()=>F(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Wt,{className:"w-4 h-4"})})]}),Ce?Je(Ce):s.jsx("input",{type:"text",value:String(ye),onChange:$e=>F(oe,$e.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"})]},oe)}),Object.keys(x).filter(oe=>oe!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(qz,{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(oe=>oe!=="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(ps,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[N&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Qi,{className:"w-4 h-4"}),N]}),s.jsx("textarea",{value:S,onChange:oe=>Se(oe.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 ${N?"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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>xe.mutate(),disabled:xe.isPending||!d.trim()||!a&&!m||!!N,className:"flex-1",children:[xe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(ps,{className:"w-4 h-4"}):s.jsx(Qn,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function iZe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=w.useState(""),[l,c]=w.useState("all"),[u,d]=w.useState("all"),[f,m]=w.useState("all"),[p,b]=w.useState("all"),[y,x]=w.useState("all"),[v,S]=w.useState("all"),[M,N]=w.useState(null),[A,k]=w.useState(!1),[C,D]=w.useState(!1),[T,R]=w.useState(null),[U,O]=w.useState(null),[q,j]=w.useState(null),[W,K]=w.useState(!1),[G,J]=w.useState([null,null]),[ie,re]=w.useState(!1),[z,V]=w.useState(null),Z=un(),ne=w.useMemo(()=>[...t.filament.map(Y=>({...Y,type:"filament"})),...t.printer.map(Y=>({...Y,type:"printer"})),...t.process.map(Y=>({...Y,type:"process"}))].map(Y=>({...Y,meta:pI(Y.name)})),[t]),he=w.useMemo(()=>{const te=new Set,Y=new Set,H=new Set;return ne.forEach(F=>{F.meta.nozzle&&te.add(F.meta.nozzle),F.meta.filamentType&&Y.add(F.meta.filamentType),F.meta.layerHeight&&H.add(F.meta.layerHeight)}),{printers:i.map(F=>({id:F.id.toString(),name:F.name})),nozzles:Array.from(te).sort((F,de)=>parseFloat(F)-parseFloat(de)),filaments:Array.from(Y).sort(),layerHeights:Array.from(H).sort((F,de)=>parseFloat(F)-parseFloat(de))}},[ne,i]),fe=w.useMemo(()=>f==="all"?null:i.find(Y=>Y.id.toString()===f)?.model||null,[f,i]),le=w.useMemo(()=>ne.filter(te=>l==="all"||te.type===l).filter(te=>{if(u==="all")return!0;const Y=py(te.setting_id);return u==="custom"?Y:!Y}).filter(te=>{if(f==="all"||!fe)return!0;const Y=te.meta.printer?.toLowerCase()||"",H=fe.toLowerCase();return Y.includes(H)||H.includes(Y)}).filter(te=>p==="all"||te.meta.nozzle===p).filter(te=>y==="all"||te.meta.filamentType===y).filter(te=>v==="all"||te.meta.layerHeight===v).filter(te=>a===""||te.name.toLowerCase().includes(a.toLowerCase())).sort((te,Y)=>te.name.localeCompare(Y.name)),[ne,l,u,f,fe,p,y,v,a]),Ee=te=>{if(W){const Y=G[0]?.setting_id===te.setting_id,H=G[1]?.setting_id===te.setting_id;if(Y)J([G[1],null]);else if(H)J([G[0],null]);else if(!G[0])J([te,null]);else if(G[1]){if(G[0].type!==te.type)return;J([G[0],te])}else{if(G[0].type!==te.type)return;J([G[0],te])}}else N(te)},me=te=>{if(G[0]?.setting_id===te.setting_id)return 0;if(G[1]?.setting_id===te.setting_id)return 1},we=async te=>{try{const Y=await pe.getCloudSettingDetail(te.setting_id),H=te.type==="process"?"print":te.type;R({type:H,name:te.name,base_id:Y.base_id||"GFSA00",setting:Y.setting||{}}),N(null)}catch(Y){console.error("Failed to fetch preset details for duplication:",Y)}},De=async te=>{try{Z.removeQueries({queryKey:["cloudSettingDetail",te.setting_id]});const Y=await pe.getCloudSettingDetail(te.setting_id),H=te.type==="process"?"print":te.type;O({type:H,name:te.name,base_id:Y.base_id||"GFSA00",setting:Y.setting||{},setting_id:te.setting_id}),N(null)}catch(Y){console.error("Failed to fetch preset details for editing:",Y)}},ee=()=>{c("all"),d("all"),m("all"),b("all"),x("all"),S("all"),o("")},Qe=l!=="all"||u!=="all"||f!=="all"||p!=="all"||y!=="all"||v!=="all"||a!=="",B=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(va,{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:te=>o(te.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(Me,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),J([null,null])):K(!0)},children:[s.jsx(Zp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(T0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Me,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(Mr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(Qn,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(nE,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(Lp,{label:"Type",value:l,options:[{value:"all",label:"All",count:B},{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:te=>c(te)}),s.jsx(Lp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:te=>d(te)}),he.printers.length>0&&s.jsx(Lp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...he.printers.map(te=>({value:te.id,label:te.name}))],onChange:m}),he.nozzles.length>0&&s.jsx(Lp,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...he.nozzles.map(te=>({value:te,label:te}))],onChange:b}),he.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(Lp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...he.filaments.map(te=>({value:te,label:te}))],onChange:x}),he.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(Lp,{label:"Layer",value:v,options:[{value:"all",label:"All"},...he.layerHeights.map(te=>({value:te,label:te}))],onChange:S}),Qe&&s.jsx("button",{onClick:ee,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&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(Zp,{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(dP,{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(Me,{size:"sm",onClick:async()=>{try{const[te,Y]=await Promise.all([pe.getCloudSettingDetail(G[0].setting_id),pe.getCloudSettingDetail(G[1].setting_id)]);V([te.setting||{},Y.setting||{}]),re(!0)}catch{}},children:[s.jsx(Zp,{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(Yn,{className:"w-3 h-3"}),"Last synced: ",QYe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",le.length," of ",B," 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)"})]})]}),le.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(al,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Qe&&s.jsx("button",{onClick:ee,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(OD,{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:["(",le.filter(te=>te.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[le.filter(te=>te.type==="filament").map(te=>s.jsx(Wj,{setting:te,onClick:()=>Ee(te),onDuplicate:()=>we(te),compareMode:W,isCompareSelected:me(te)!==void 0,compareIndex:me(te),compareDisabled:W&&!!G[0]&&G[0].type!==te.type},te.setting_id)),le.filter(te=>te.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(qd,{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:["(",le.filter(te=>te.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[le.filter(te=>te.type==="process").map(te=>s.jsx(Wj,{setting:te,onClick:()=>Ee(te),onDuplicate:()=>we(te),compareMode:W,isCompareSelected:me(te)!==void 0,compareIndex:me(te),compareDisabled:W&&!!G[0]&&G[0].type!==te.type},te.setting_id)),le.filter(te=>te.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(Br,{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:["(",le.filter(te=>te.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[le.filter(te=>te.type==="printer").map(te=>s.jsx(Wj,{setting:te,onClick:()=>Ee(te),onDuplicate:()=>we(te),compareMode:W,isCompareSelected:me(te)!==void 0,compareIndex:me(te),compareDisabled:W&&!!G[0]&&G[0].type!==te.type},te.setting_id)),le.filter(te=>te.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),M&&s.jsx(tZe,{setting:M,onClose:()=>N(null),onDeleted:()=>N(null),onDuplicate:()=>we(M),onEdit:()=>De(M)}),(A||T||U||q)&&s.jsx(rZe,{onClose:()=>{k(!1),R(null),O(null),j(null)},initialData:U||T||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),C&&s.jsx(nZe,{onClose:()=>D(!1),onApply:te=>{j({type:te.type,setting:te.settings}),D(!1)}}),ie&&z&&G[0]&&G[1]&&s.jsx(Hie,{onClose:()=>{re(!1),V(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function aZe(){const t=un(),{showToast:e}=qn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ut({queryKey:["cloudStatus"],queryFn:pe.getCloudStatus}),{data:c=[]}=ut({queryKey:["printers"],queryFn:pe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ut({queryKey:["cloudSettings"],queryFn:()=>pe.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=ht({mutationFn:pe.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(dt,{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(JM,{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(rE,{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(Me,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(gP,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(iZe,{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(Me,{onClick:()=>f(),children:"Retry"})]}):s.jsx(JYe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(ZYe,{}),s.jsx(eZe,{})]})}const Qb={Droplet:OD,Flame:Zde,Ruler:Cfe,Sparkles:T0,Square:ll,Cable:Wue,Wrench:Kd,Calendar:ti,Timer:Nd,Cog:Mde,Fan:uK,Zap:zf,Wind:EK,Thermometer:dE,Layers:al,Box:Fs,Target:_K,RefreshCw:Mr,Settings:uE,Filter:nE,CircleDot:dde};function w0(t){return t&&Qb[t]||Kd}function Ip(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 qj(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 sZe(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 oZe({item:t,onPerform:e,onToggle:n}){const r=w0(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 ${Ip(Math.abs(f),"days")}`:t.is_warning?`Due in ${Ip(f,"days")}`:`${Ip(f,"days")} left`}else return t.is_due?`Overdue by ${Ip(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Ip(t.hours_until_due,"hours")}`:`${Ip(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(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||sZe(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:m=>m.stopPropagation(),children:s.jsx(zr,{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(Rn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Yn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(ws,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Xn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(om,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function lZe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=w.useState(!0),[o,l]=w.useState(!1),[c,u]=w.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,b)=>p.is_due&&!b.is_due?-1:!p.is_due&&b.is_due?1:p.is_warning&&!b.is_warning?-1:!p.is_warning&&b.is_warning?1:p.maintenance_type_id-b.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),m=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(Et,{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(Rn,{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(Yn,{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(ws,{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(uu,{className:"w-4 h-4"}):s.jsx(Zi,{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(Nd,{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:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m(),p.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(Me,{size:"sm",onClick:m,children:"Save"}),s.jsx(Me,{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(Ff,{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 p=w0(f.maintenance_type_icon);return s.jsx(p,{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(At,{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(p=>s.jsx(oZe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function cZe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState("hours"),[b,y]=w.useState(!1),[x,v]=w.useState(""),[S,M]=w.useState("100"),[N,A]=w.useState("hours"),[k,C]=w.useState("Wrench"),[D,T]=w.useState(""),[R,U]=w.useState(new Set),[O,q]=w.useState(null),j=w.useMemo(()=>t?t.map(H=>({id:H.printer_id,name:H.printer_name})):[],[t]),W=H=>t?t.filter(F=>F.maintenance_items.some(de=>de.maintenance_type_id===H)).map(F=>({printerId:F.printer_id,printerName:F.printer_name,itemId:F.maintenance_items.find(de=>de.maintenance_type_id===H)?.id})):[],K=H=>{if(!t)return[];const F=new Set(W(H).map(de=>de.printerId));return j.filter(de=>!F.has(de.id))},[G,J]=w.useState(null),[ie,re]=w.useState(""),[z,V]=w.useState(""),[Z,ne]=w.useState("hours"),[he,fe]=w.useState("Wrench"),[le,Ee]=w.useState(""),me=H=>{J(H),re(H.name),V(H.default_interval_hours.toString()),ne(H.interval_type||"hours"),fe(H.icon||"Wrench"),Ee(H.wiki_url||"")},we=()=>{G&&ie.trim()&&parseFloat(z)>0&&(i(G.id,{name:ie.trim(),default_interval_hours:parseFloat(z),interval_type:Z,icon:he,wiki_url:le.trim()||null}),J(null))},De=(H,F,de)=>{const Ae=parseFloat(d);if(!isNaN(Ae)&&Ae>0){const Le=Math.abs(Ae-F)<.01?null:Ae;n(H,{custom_interval_hours:Le,custom_interval_type:m!==de?m:null})}u(null)},ee=H=>{H.preventDefault(),x.trim()&&parseFloat(S)>0&&R.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(S),interval_type:N,icon:k,wiki_url:D.trim()||null},Array.from(R)),v(""),M("100"),A("hours"),T(""),U(new Set),y(!1))},Qe=H=>{U(F=>{const de=new Set(F);return de.has(H)?de.delete(H):de.add(H),de})},B=t?.map(H=>({printerId:H.printer_id,printerName:H.printer_name,items:H.maintenance_items.sort((F,de)=>F.maintenance_type_id-de.maintenance_type_id)})).sort((H,F)=>H.printerName.localeCompare(F.printerName))||[],te=e.filter(H=>H.is_system),Y=e.filter(H=>!H.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(Me,{onClick:()=>y(!b),children:[s.jsx(Qn,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(Et,{className:"mb-6",children:s.jsx(At,{className:"py-4",children:s.jsxs("form",{onSubmit:ee,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:H=>v(H.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:N,onChange:H=>{A(H.target.value),H.target.value==="days"?M("30"):M("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 (",N==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:S,onChange:H=>M(H.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(Qb).map(H=>{const F=Qb[H];return s.jsx("button",{type:"button",onClick:()=>C(H),className:`p-2 rounded-lg transition-colors ${k===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(F,{className:"w-4 h-4"})},H)})})]})}),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:H=>T(H.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:j.map(H=>s.jsx("button",{type:"button",onClick:()=>Qe(H.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(H.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:H.name},H.id))}),R.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(Me,{type:"button",variant:"secondary",onClick:()=>{y(!1),U(new Set)},children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!x.trim()||R.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[te.map(H=>{const F=w0(H.icon),de=H.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(F,{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:H.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[de==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(Nd,{className:"w-3 h-3"}),qj(H.default_interval_hours,de)]})]})]})},H.id)}),Y.map(H=>{const F=w0(H.icon),de=H.interval_type||"hours";if(G?.id===H.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:ie,onChange:L=>re(L.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:Z,onChange:L=>ne(L.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:z,onChange:L=>V(L.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(Qb).map(L=>{const X=Qb[L];return s.jsx("button",{type:"button",onClick:()=>fe(L),className:`p-1.5 rounded transition-colors ${he===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(X,{className:"w-3.5 h-3.5"})},L)})}),s.jsx("input",{type:"url",value:le,onChange:L=>Ee(L.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(Me,{size:"sm",onClick:we,disabled:!ie.trim(),children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>J(null),children:"Cancel"})]})]})},H.id);const Le=W(H.id),Se=K(H.id),$=O===H.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(F,{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:H.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:[de==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(Nd,{className:"w-3 h-3"}),qj(H.default_interval_hours,de)]})]}),s.jsxs("button",{onClick:()=>q($?null:H.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Le.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:`${Le.length} printer(s) assigned - click to manage`,children:[s.jsx(Br,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Le.length}),s.jsx(Zi,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>me(H),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ff,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${H.name}"?`)&&a(H.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(fn,{className:"w-4 h-4"})})]}),$&&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:"}),Le.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:Le.map(L=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[L.printerName,s.jsx("button",{onClick:()=>L.itemId&&l(L.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},L.printerId))}),Se.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:"}),Se.map(L=>s.jsxs("button",{onClick:()=>o(L.id,H.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:["+ ",L.name]},L.id))]})]})]},H.id)})]})]}),B.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:B.map(H=>s.jsx(Et,{children:s.jsxs(At,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:H.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:H.items.map(F=>{const de=w0(F.maintenance_type_icon),Ae=e.find(X=>X.id===F.maintenance_type_id),Le=Ae?.default_interval_hours||F.interval_hours,Se=Ae?.interval_type||"hours",$=F.interval_type||"hours",L=c===F.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(de,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:F.maintenance_type_name}),L?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(Nd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:X=>p(X.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:X=>f(X.target.value),onKeyDown:X=>{X.key==="Enter"&&De(F.id,Le,Se),X.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(Me,{size:"sm",onClick:()=>De(F.id,Le,Se),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(F.id),f(F.interval_hours.toString()),p($)},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:[$==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(Nd,{className:"w-3 h-3"}),qj(F.interval_hours,$),s.jsx(Ff,{className:"w-3 h-3 text-bambu-gray"})]})]},F.id)})})]})},H.printerId))})]}),B.length===0&&s.jsx(Et,{children:s.jsxs(At,{className:"text-center py-12",children:[s.jsx(Yn,{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 uZe(){const t=un(),{showToast:e}=qn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ut({queryKey:["maintenanceOverview"],queryFn:pe.getMaintenanceOverview}),{data:o}=ut({queryKey:["maintenanceTypes"],queryFn:pe.getMaintenanceTypes}),l=ht({mutationFn:({id:M,notes:N})=>pe.performMaintenance(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),c=ht({mutationFn:({id:M,data:N})=>pe.updateMaintenanceItem(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=ht({mutationFn:({id:M,data:N})=>pe.updateMaintenanceType(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),d=ht({mutationFn:pe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),f=ht({mutationFn:({printerId:M,hours:N})=>pe.setPrinterHours(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=ht({mutationFn:({printerId:M,typeId:N})=>pe.assignMaintenanceType(M,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:M=>{e(M.message,"error")}}),p=ht({mutationFn:pe.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:M=>{e(M.message,"error")}}),b=M=>{l.mutate({id:M})},y=(M,N)=>{c.mutate({id:M,data:{enabled:N}})},x=(M,N)=>{f.mutate({printerId:M,hours:N})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((M,N)=>M+N.due_count,0)||0,S=i?.reduce((M,N)=>M+N.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:[v>0&&s.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&S>0&&" · ",S>0&&s.jsxs("span",{className:"text-amber-400",children:[S," due soon"]}),v===0&&S===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((M,N)=>{const A=M.due_count*10+M.warning_count,k=N.due_count*10+N.warning_count;return A!==k?k-A:M.printer_name.localeCompare(N.printer_name)}).map(M=>s.jsx(lZe,{overview:M,onPerform:b,onToggle:y,onSetHours:x},M.printer_id)):s.jsx(Et,{children:s.jsxs(At,{className:"text-center py-16",children:[s.jsx(Kd,{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(cZe,{overview:i,types:o||[],onUpdateInterval:(M,N)=>c.mutate({id:M,data:N}),onAddType:async(M,N)=>{const A=await pe.createMaintenanceType(M);for(const k of N)await pe.assignMaintenanceType(k,A.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(M,N)=>u.mutate({id:M,data:N}),onDeleteType:M=>d.mutate(M),onAssignType:(M,N)=>m.mutate({printerId:M,typeId:N}),onRemoveItem:M=>p.mutate(M)})]})}const uq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Vie({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||uq[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[b,y]=w.useState(t?.status||"active"),[x,v]=w.useState(t?.tags||""),[S,M]=w.useState(t?.due_date?.split("T")[0]||""),[N,A]=w.useState(t?.priority||"normal"),k=C=>{C.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:x.trim()||void 0,due_date:S||void 0,priority:N,...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:k,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:C=>a(C.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:C=>l(C.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:uq.map(C=>s.jsx("button",{type:"button",onClick:()=>u(C),className:`w-8 h-8 rounded-full transition-transform ${c===C?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:C}},C))})]}),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:C=>f(C.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:m,onChange:C=>p(C.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:C=>v(C.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:S,onChange:C=>M(C.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:N,onChange:C=>A(C.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:C=>y(C.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(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function dZe({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]=w.useState(!1),f=o?{icon:QM,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Xa,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Yn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:wa,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 m=t.archives.map(x=>x.filament_type).filter(Boolean).flatMap(x=>x.split(",").map(v=>v.trim())).filter(Boolean),p=[...new Set(m)],b=t.archives.map(x=>x.filament_color).filter(Boolean).flatMap(x=>x.split(",").map(v=>v.trim())).filter(x=>x.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(x)),y=[...new Set(b)];return p.length===0&&y.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[p.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)),y.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[y.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)),y.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:m=>m.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(Od,{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(Ff,{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(fn,{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(Xa,{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(Rn,{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(Yn,{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(m=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?s.jsx("img",{src:pe.getArchiveThumbnail(m.id),alt:m.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(Zl,{className:"w-6 h-6"})}),m.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Rn,{className:"w-4 h-4 text-white"})})]},m.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(al,{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(Zl,{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(Rn,{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(pP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Ks,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function hZe(){const t=ml(),e=un(),{showToast:n}=qn(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>pe.getProjects(l==="all"?void 0:l)}),p=ht({mutationFn:U=>pe.createProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:U=>{n(U.message,"error")}}),b=ht({mutationFn:({id:U,data:O})=>pe.updateProject(U,O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:U=>{n(U.message,"error")}}),y=ht({mutationFn:U=>pe.deleteProject(U),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{d(null),n(U.message,"error")}}),x=ht({mutationFn:U=>pe.importProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:U=>{n(U.message,"error")}}),v=w.useRef(null),S=async()=>{try{const U=await pe.getProjects(),O=await Promise.all(U.map(async K=>await pe.exportProjectJson(K.id))),q=new Blob([JSON.stringify(O,null,2)],{type:"application/json"}),j=URL.createObjectURL(q),W=document.createElement("a");W.href=j,W.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,W.click(),URL.revokeObjectURL(j),n("Projects exported (metadata only)","success")}catch(U){n(U.message,"error")}},M=()=>{v.current?.click()},N=async U=>{const O=U.target.files?.[0];if(O){try{if(O.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",O);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!W.ok){const K=await W.json();throw new Error(K.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await O.text(),W=JSON.parse(j),K=Array.isArray(W)?W:[W];for(const G of K)await x.mutateAsync(G);K.length>1&&n(`${K.length} projects imported`,"success")}}catch(q){n(`Import failed: ${q.message}`,"error")}U.target.value=""}},A=U=>{a?b.mutate({id:a.id,data:U}):p.mutate(U)},k=U=>{o(U),i(!0)},C=U=>{t(`/projects/${U.id}`)},D=U=>{d(U)},T=()=>{u!==null&&y.mutate(u)},R=f?.reduce((U,O)=>(U[O.status]=(U[O.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:v,type:"file",accept:".json,.zip",onChange:N,className:"hidden"}),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(wa,{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("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:M,title:"Import project",children:[s.jsx(oi,{className:"w-4 h-4 mr-2"}),"Import"]}),s.jsxs(Me,{variant:"secondary",onClick:S,title:"Export all projects",children:[s.jsx(Ir,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(Qn,{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:Yn},{key:"completed",label:"Completed",icon:QM},{key:"archived",label:"Archived",icon:Xa},{key:"all",label:"All",icon:wa}].map(({key:U,label:O,icon:q})=>s.jsxs("button",{onClick:()=>c(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(q,{className:"w-4 h-4"}),s.jsx("span",{children:O}),R[U]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===U?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:R[U]})]},U))}),m?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(dt,{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(wa,{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(Me,{onClick:()=>i(!0),children:[s.jsx(Qn,{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(U=>s.jsx(dZe,{project:U,onClick:()=>C(U),onEdit:()=>k(U),onDelete:()=>D(U.id)},U.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:T,onCancel:()=>d(null)}),r&&s.jsx(Vie,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:A,isLoading:p.isPending||b.isPending})]})}function fZe(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 mZe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function pZe({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 dq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(Et,{children:s.jsx(At,{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 gZe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Zl,{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(hs,{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:pe.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(Zl,{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(Ya,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Gn,{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 xZe({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(Rn,{className:"w-3 h-3"}),r]})}function bZe(t){return t?xg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Kj(t){if(!t)return null;const e=gi(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 yZe(){const{id:t}=SD(),e=ml(),n=un(),{showToast:r}=qn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:p}=ut({queryKey:["project",d],queryFn:()=>pe.getProject(d),enabled:d>0}),{data:b,isLoading:y}=ut({queryKey:["project-archives",d],queryFn:()=>pe.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:v}=ut({queryKey:["project-bom",d],queryFn:()=>pe.getProjectBOM(d),enabled:d>0}),{data:S,isLoading:M}=ut({queryKey:["project-timeline",d],queryFn:()=>pe.getProjectTimeline(d,20),enabled:d>0}),{data:N}=ut({queryKey:["settings"],queryFn:pe.getSettings}),{data:A}=ut({queryKey:["project-folders",d],queryFn:()=>pe.getLibraryFoldersByProject(d),enabled:d>0}),k=N?.currency||"$",C=N?.time_format||"system",D=ht({mutationFn:ye=>pe.updateProject(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:ye=>{r(ye.message,"error")}}),T=()=>{u(f?.notes||""),l(!0)},R=()=>{D.mutate({notes:c})},U=()=>{l(!1),u("")},[O,q]=w.useState(""),[j,W]=w.useState(1),[K,G]=w.useState(""),[J,ie]=w.useState(""),[re,z]=w.useState(""),[V,Z]=w.useState(!1),[ne,he]=w.useState(!1),[fe,le]=w.useState(null),[Ee,me]=w.useState(""),[we,De]=w.useState(1),[ee,Qe]=w.useState(""),[B,te]=w.useState(""),[Y,H]=w.useState(""),[F,de]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ae=ht({mutationFn:ye=>pe.createBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),W(1),G(""),ie(""),z(""),Z(!1),r("Part added","success")},onError:ye=>r(ye.message,"error")}),Le=ht({mutationFn:({itemId:ye,data:Ce})=>pe.updateBOMItem(d,ye,Ce),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),le(null)},onError:ye=>r(ye.message,"error")}),Se=ht({mutationFn:ye=>pe.deleteBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:ye=>r(ye.message,"error")}),$=ye=>{ye.preventDefault(),O.trim()&&Ae.mutate({name:O.trim(),quantity_needed:j,unit_price:K?parseFloat(K):void 0,sourcing_url:J.trim()||void 0,remarks:re.trim()||void 0})},L=ye=>{const Ce=ye.is_complete?0:ye.quantity_needed;Le.mutate({itemId:ye.id,data:{quantity_acquired:Ce}})},X=(ye,Ce)=>{de({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Ce}"?`,onConfirm:()=>{de($e=>({...$e,isOpen:!1})),Se.mutate(ye)}})},xe=ye=>{le(ye),me(ye.name),De(ye.quantity_needed),Qe(ye.unit_price?.toString()||""),te(ye.sourcing_url||""),H(ye.remarks||"")},_e=ye=>{ye.preventDefault(),!(!fe||!Ee.trim())&&Le.mutate({itemId:fe.id,data:{name:Ee.trim(),quantity_needed:we,unit_price:ee?parseFloat(ee):void 0,sourcing_url:B.trim()||void 0,remarks:Y.trim()||void 0}})},ae=()=>{le(null)},Te=async()=>{try{const ye=await fetch(`/api/v1/projects/${d}/export`);if(!ye.ok)throw new Error("Export failed");const Ce=await ye.blob(),$e=URL.createObjectURL(Ce),lt=document.createElement("a");lt.href=$e;const ze=ye.headers.get("Content-Disposition")?.match(/filename="(.+)"/);lt.download=ze?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,lt.click(),URL.revokeObjectURL($e),r("Project exported","success")}catch(ye){r(ye.message,"error")}},Pe=ht({mutationFn:()=>pe.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:ye=>r(ye.message,"error")}),Xe=ye=>bg(ye,C,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(m)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(p||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:p?`Error: ${p.message}`:"Project not found"}),s.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const Je=f.stats,Ze=Je?.progress_percent??0,oe=Je?.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(hs,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Ks,{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(sK,{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(pZe,{status:f.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:Te,title:"Export project",children:[s.jsx(Ir,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>a(!0),children:[s.jsx(Ff,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(Et,{children:s.jsxs(At,{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:[Je?.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(Ze,100)}%`,backgroundColor:Ze>=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:[Ze.toFixed(0),"% complete"]}),Je?.remaining_prints!=null&&Je.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Je.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:[Je?.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(oe,100)}%`,backgroundColor:oe>=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:[oe.toFixed(0),"% complete"]}),Je?.remaining_parts!=null&&Je.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Je.remaining_parts," remaining"]})]})]})]})}),Je&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Et,{children:s.jsx(At,{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(Zl,{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:[Je.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),Je.failed_prints>0&&s.jsxs("p",{className:"text-sm text-status-error",children:[Je.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[Je.completed_prints," parts printed"]})]})]})})}),s.jsx(dq,{icon:Yn,label:"Print Time",value:fZe(Je.total_print_time_hours),color:"text-yellow-400"}),s.jsx(dq,{icon:Br,label:"Filament Used",value:mZe(Je.total_filament_grams),color:"text-purple-400"})]}),Je&&(Je.estimated_cost>0||f.budget)&&s.jsx(Et,{children:s.jsxs(At,{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:[k,Je.estimated_cost.toFixed(2)]})]}),Je.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:[Je.total_energy_kwh.toFixed(2)," kWh",Je.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,Je.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:[k,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-Je.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-Je.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(Et,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(rhe,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(ye=>s.jsxs(hs,{to:`/projects/${ye.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:ye.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:ye.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ye.status==="completed"?"bg-status-ok/20 text-status-ok":ye.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ye.status})]}),ye.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[ye.progress_percent.toFixed(0),"%"]})]},ye.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(al,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(hs,{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(xZe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:bZe(f.due_date)}),Kj(f.due_date)&&s.jsxs("span",{className:`text-xs ${Kj(f.due_date).color}`,children:["(",Kj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(gg,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((ye,Ce)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ye.trim()},Ce))})]})]}),s.jsx(Et,{children:s.jsxs(At,{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(Wa,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:U,disabled:D.isPending,children:[s.jsx(Wt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Me,{size:"sm",onClick:R,disabled:D.isPending,children:[D.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(ps,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:T,children:[s.jsx(Ff,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(uD,{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(Et,{children:s.jsxs(At,{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(il,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(hs,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),A&&A.length>0?s.jsx("div",{className:"space-y-2",children:A.map(ye=>s.jsxs(hs,{to:`/files?folder=${ye.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(il,{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:ye.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[ye.file_count," file",ye.file_count!==1?"s":""]})]})]}),s.jsx(Ks,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ye.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(Et,{children:s.jsxs(At,{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(yK,{className:"w-5 h-5"}),"Bill of Materials",Je&&Je.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Je.bom_completed_items,"/",Je.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[x&&x.some(ye=>ye.is_complete)&&s.jsx("button",{onClick:()=>he(!ne),className:`text-xs px-2 py-1 rounded transition-colors ${ne?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ne?"Show all":"Hide done"}),!V&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(Qn,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),V&&s.jsxs("form",{onSubmit:$,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:O,onChange:ye=>q(ye.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:j,onChange:ye=>W(parseInt(ye.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:K,onChange:ye=>G(ye.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 (${k})`})]})]}),s.jsx("input",{type:"url",value:J,onChange:ye=>ie(ye.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:re,onChange:ye=>z(ye.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(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>Z(!1),children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!O.trim()||Ae.isPending,children:Ae.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x&&x.length>0?s.jsxs("div",{className:"space-y-2",children:[x.filter(ye=>!ne||!ye.is_complete).map(ye=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${ye.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:fe?.id===ye.id?s.jsxs("form",{onSubmit:_e,className:"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:Ee,onChange:Ce=>me(Ce.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",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:we,onChange:Ce=>De(parseInt(Ce.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:ee,onChange:Ce=>Qe(Ce.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 (${k})`})]})]}),s.jsx("input",{type:"url",value:B,onChange:Ce=>te(Ce.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:Y,onChange:Ce=>H(Ce.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(Me,{type:"button",variant:"secondary",size:"sm",onClick:ae,children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!Ee.trim()||Le.isPending,children:Le.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>L(ye),disabled:Le.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ye.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:ye.is_complete&&s.jsx(Gn,{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 ${ye.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ye.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ye.quantity_needed]})]}),ye.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(ye.unit_price*ye.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>xe(ye),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0",title:"Edit",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>X(ye.id,ye.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(fn,{className:"w-4 h-4"})})]})]}),ye.sourcing_url&&s.jsxs("a",{href:ye.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:Ce=>Ce.stopPropagation(),children:[s.jsx(zr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ye.sourcing_url).hostname.replace("www.","")}catch{return ye.sourcing_url}})()})]}),ye.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ye.remarks})]})]})},ye.id)),x.some(ye=>ye.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:[k,x.reduce((ye,Ce)=>ye+(Ce.unit_price||0)*Ce.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(Et,{children:s.jsxs(At,{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(Pw,{className:"w-5 h-5"}),"Activity Timeline"]})}),M?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?s.jsx("div",{className:"space-y-3",children:S.slice(0,10).map((ye,Ce)=>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 ${ye.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ye.event_type==="print_failed"?"bg-status-error/20 text-status-error":ye.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ye.event_type==="print_completed"&&s.jsx(Gn,{className:"w-4 h-4"}),ye.event_type==="print_failed"&&s.jsx(Ya,{className:"w-4 h-4"}),ye.event_type==="print_started"&&s.jsx(Br,{className:"w-4 h-4"}),ye.event_type==="queued"&&s.jsx(pP,{className:"w-4 h-4"}),ye.event_type==="project_created"&&s.jsx(Qn,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:ye.title}),ye.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ye.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:Xe(ye.timestamp)})]})]},Ce))}):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(Me,{variant:"secondary",size:"sm",onClick:()=>Pe.mutate(),disabled:Pe.isPending,children:[Pe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(rl,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),Je&&(Je.queued_prints>0||Je.in_progress_prints>0)&&s.jsx(Et,{children:s.jsxs(At,{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(pP,{className:"w-5 h-5"}),"Queue"]}),s.jsx(hs,{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:[Je.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[Je.in_progress_prints," printing"]}),Je.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[Je.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(Zl,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),y?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(gZe,{archives:b||[]})]}),i&&s.jsx(Vie,{project:{...f,archive_count:Je?.total_archives||0,total_items:Je?.total_items||0,completed_count:Je?.completed_prints||0,failed_count:Je?.failed_prints||0,queue_count:Je?.queued_prints||0,progress_percent:Je?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:ye=>D.mutate(ye),isLoading:D.isPending}),F.isOpen&&s.jsx(Un,{title:F.title,message:F.message,confirmText:"Delete",variant:"danger",onConfirm:F.onConfirm,onCancel:()=>de(ye=>({...ye,isOpen:!1}))})]})}function Vp(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 vZe(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 _Ze({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.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(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function wZe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[a,o]=w.useState(e),l=c=>{c.preventDefault(),a.trim()&&a.trim()!==e&&r(a.trim())};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:["Rename ",t==="file"?"File":"Folder"]})}),s.jsxs("form",{onSubmit:l,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:a,onChange:c=>o(c.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",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function SZe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const p of d)m.push({id:p.id,name:p.name,depth:f}),p.children.length>0&&m.push(...c(p.children,f+1));return m},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(il,{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(Me,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:()=>i(o),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function MZe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,a]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&a("archive")});const{data:c}=ut({queryKey:["projects"],queryFn:()=>pe.getProjects()}),{data:u}=ut({queryKey:["archives-for-link"],queryFn:()=>pe.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})},m=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(Vl,{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(Wt,{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(lK,{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(Xa,{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(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.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:p.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:p.name})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(vf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.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:[m&&s.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(zD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!o||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function EZe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[a,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!0),[f,m]=w.useState(!1),p=w.useRef(null),b=R=>{R.preventDefault(),o(!0)},y=R=>{R.preventDefault(),o(!1)},x=R=>{R.preventDefault(),o(!1);const U=Array.from(R.dataTransfer.files);S(U)},v=R=>{R.target.files&&S(Array.from(R.target.files))},S=R=>{const U=R.map(O=>({file:O,status:"pending",isZip:O.name.toLowerCase().endsWith(".zip")}));i(O=>[...O,...U])},M=R=>{i(U=>U.filter((O,q)=>q!==R))},N=r.some(R=>R.isZip&&R.status==="pending"),A=async()=>{if(r.length!==0){c(!0);for(let R=0;R<r.length;R++)if(r[R].status==="pending"){i(U=>U.map((O,q)=>q===R?{...O,status:"uploading"}:O));try{if(r[R].isZip){const U=await pe.extractZipFile(r[R].file,t,u,f);i(O=>O.map((q,j)=>j===R?{...q,status:U.errors.length>0&&U.extracted===0?"error":"success",extractedCount:U.extracted,error:U.errors.length>0?`${U.errors.length} files failed`:void 0}:q))}else await pe.uploadLibraryFile(r[R].file,t),i(U=>U.map((O,q)=>q===R?{...O,status:"success"}:O))}catch(U){i(O=>O.map((q,j)=>j===R?{...q,status:"error",error:U instanceof Error?U.message:"Upload failed"}:q))}}c(!1),n(),e()}},k=r.filter(R=>R.status==="pending").length,C=r.filter(R=>R.status==="success").length,D=r.filter(R=>R.status==="error").length,T=r.length>0&&k===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(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:b,onDragLeave:y,onDrop:x,onClick:()=>p.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(oi,{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("p",{className:"text-xs text-bambu-gray/70 mt-2",children:"All file types supported. ZIP files will be extracted."})]}),s.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:v}),N&&s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Xa,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:"ZIP files detected"}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:R=>d(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Preserve folder structure from ZIP"})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>m(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Create folder from ZIP filename"})]})]})]})}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((R,U)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[R.isZip?s.jsx(Xa,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(tE,{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:R.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(R.file.size/1024/1024).toFixed(2)," MB",R.isZip&&R.status==="pending"&&s.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),R.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",R.extractedCount," files extracted"]})]})]}),R.status==="pending"&&s.jsx("button",{onClick:()=>M(U),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Wt,{className:"w-4 h-4 text-bambu-gray"})}),R.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),R.status==="success"&&s.jsx(Gn,{className:"w-4 h-4 text-green-500"}),R.status==="error"&&s.jsx("span",{title:R.error,children:s.jsx(Ya,{className:"w-4 h-4 text-red-500"})})]},U))}),T&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",C," succeeded",D>0&&s.jsxs("span",{className:"text-red-400",children:[", ",D," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:T?"Close":"Cancel"}),!T&&s.jsx(Me,{onClick:A,disabled:k===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(oi,{className:"w-4 h-4 mr-2"}),"Upload ",k>0?`(${k})`:""]})})]})]})})}function Gie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0}){const[l,c]=w.useState(!0),[u,d]=w.useState(!1),f=t.children.length>0,m=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+o*12}px`},onClick:()=>n(t.id),children:[f?s.jsx("button",{onClick:p=>{p.stopPropagation(),c(!l)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ks,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(il,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",children:t.name}),m&&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(Vl,{className:"w-3 h-3"}),t.project_name?s.jsx(lK,{className:"w-3 h-3"}):s.jsx(Xa,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!m&&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(Vl,{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:()=>d(!u),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(Od,{className:"w-3.5 h-3.5 text-bambu-gray"})}),u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!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:()=>{a(t),d(!1)},children:[s.jsx(Ia,{className:"w-3.5 h-3.5"}),"Rename"]}),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),d(!1)},children:[s.jsx(Vl,{className:"w-3.5 h-3.5"}),m?"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),d(!1)},children:[s.jsx(fn,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),f&&l&&s.jsx("div",{children:t.children.map(p=>s.jsx(Gie,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},p.id))})]})}function bD(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function NZe({file:t,isSelected:e,onSelect:n,onDelete:r,onDownload:i,onAddToQueue:a,onPrint:o,onRename:l}){const[c,u]=w.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:pe.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(vf,{className:"w-12 h-12 text-bambu-gray/30"}),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:Vp(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Yn,{className:"w-3 h-3"}),vZe(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-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",onClick:d=>d.stopPropagation(),children:[s.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(Od,{className:"w-4 h-4 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 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[o&&bD(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:()=>{o(t),u(!1)},children:[s.jsx(Br,{className:"w-3.5 h-3.5"}),"Print"]}),a&&bD(t.filename)&&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:()=>{a(t.id),u(!1)},children:[s.jsx(Yn,{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),u(!1)},children:[s.jsx(Ir,{className:"w-3.5 h-3.5"}),"Download"]}),l&&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:()=>{l(t),u(!1)},children:[s.jsx(Ia,{className:"w-3.5 h-3.5"}),"Rename"]}),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(fn,{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-100 md:opacity-0 md:group-hover:opacity-100"}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function AZe(){const t=un(),{showToast:e}=qn(),[n]=$q(),r=n.get("folder"),i=r?parseInt(r,10):null,[a,o]=w.useState(i),[l,c]=w.useState([]),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,b]=w.useState(!1),[y,x]=w.useState(null),[v,S]=w.useState(null),[M,N]=w.useState(null),[A,k]=w.useState(null),[C,D]=w.useState(null),[T,R]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[U,O]=w.useState(""),[q,j]=w.useState("all"),[W,K]=w.useState("date"),[G,J]=w.useState("desc");w.useEffect(()=>{const ae=n.get("folder");if(ae){const Te=parseInt(ae,10);o(Te)}},[n]);const{data:ie}=ut({queryKey:["settings"],queryFn:()=>pe.getSettings()}),{data:re,isLoading:z}=ut({queryKey:["library-folders"],queryFn:()=>pe.getLibraryFolders()}),{data:V,isLoading:Z}=ut({queryKey:["library-files",a],queryFn:()=>pe.getLibraryFiles(a,a===null)}),{data:ne}=ut({queryKey:["library-stats"],queryFn:()=>pe.getLibraryStats()}),he=w.useMemo(()=>{if(!V)return[];const ae=new Set(V.map(Te=>Te.file_type));return Array.from(ae).sort()},[V]),fe=w.useMemo(()=>{if(!V)return[];let ae=[...V];if(U.trim()){const Te=U.toLowerCase();ae=ae.filter(Pe=>Pe.filename.toLowerCase().includes(Te)||Pe.print_name&&Pe.print_name.toLowerCase().includes(Te))}return q!=="all"&&(ae=ae.filter(Te=>Te.file_type===q)),ae.sort((Te,Pe)=>{let Xe=0;switch(W){case"name":Xe=(Te.print_name||Te.filename).localeCompare(Pe.print_name||Pe.filename);break;case"date":Xe=new Date(Te.created_at).getTime()-new Date(Pe.created_at).getTime();break;case"size":Xe=Te.file_size-Pe.file_size;break;case"type":Xe=Te.file_type.localeCompare(Pe.file_type);break;case"prints":Xe=Te.print_count-Pe.print_count;break}return G==="asc"?Xe:-Xe}),ae},[V,U,q,W,G]),le=w.useMemo(()=>{if(!ne||!ie)return!1;const ae=(ie.library_disk_warning_gb||5)*1024*1024*1024;return ne.disk_free_bytes<ae},[ne,ie]),Ee=ht({mutationFn:ae=>pe.createLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:ae=>e(ae.message,"error")}),me=ht({mutationFn:ae=>pe.deleteLibraryFolder(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===v?.id&&o(null),S(null),e("Folder deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),we=ht({mutationFn:ae=>pe.deleteLibraryFile(ae),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(ae=>ae.filter(Te=>Te!==v?.id)),S(null),e("File deleted","success")},onError:ae=>{S(null),e(ae.message,"error")}}),De=ht({mutationFn:ae=>pe.bulkDeleteLibrary(ae,[]),onSuccess:(ae,Te)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${Te.length} files`,"success"),c([]),S(null)},onError:ae=>{S(null),e(ae.message,"error")}}),ee=ht({mutationFn:({fileIds:ae,folderId:Te})=>pe.moveLibraryFiles(ae,Te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:ae=>e(ae.message,"error")}),Qe=ht({mutationFn:({id:ae,data:Te})=>pe.updateLibraryFolder(ae,Te),onSuccess:(ae,Te)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const Pe=Te.data.project_id===0&&Te.data.archive_id===0;e(Pe?"Folder unlinked":"Folder linked","success")},onError:ae=>e(ae.message,"error")}),B=ht({mutationFn:ae=>pe.addLibraryFilesToQueue(ae),onSuccess:ae=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),ae.added.length>0&&ae.errors.length===0?e(`Added ${ae.added.length} file${ae.added.length>1?"s":""} to queue`,"success"):ae.added.length>0&&ae.errors.length>0?e(`Added ${ae.added.length} file${ae.added.length>1?"s":""}, ${ae.errors.length} failed`,"success"):e(`Failed to add files: ${ae.errors[0]?.error||"Unknown error"}`,"error")},onError:ae=>e(ae.message,"error")}),te=ht({mutationFn:({id:ae,filename:Te})=>pe.updateLibraryFile(ae,{filename:Te}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),D(null),e("File renamed","success")},onError:ae=>{D(null),e(ae.message,"error")}}),Y=ht({mutationFn:({id:ae,name:Te})=>pe.updateLibraryFolder(ae,{name:Te}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),D(null),e("Folder renamed","success")},onError:ae=>{D(null),e(ae.message,"error")}}),H=w.useCallback(ae=>{const Te=ae.toLowerCase();return Te.endsWith(".gcode")||Te.includes(".gcode.")},[]),F=w.useMemo(()=>V?V.filter(ae=>l.includes(ae.id)&&H(ae.filename)):[],[V,l,H]),de=w.useCallback(ae=>{c(Te=>Te.includes(ae)?Te.filter(Pe=>Pe!==ae):[...Te,ae])},[]),Ae=w.useCallback(()=>{fe.length>0&&c(fe.map(ae=>ae.id))},[fe]),Le=w.useCallback(()=>{c([])},[]),Se=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},$=ae=>{window.open(pe.getLibraryFileDownloadUrl(ae),"_blank")},L=()=>{v&&(v.type==="file"?we.mutate(v.id):v.type==="folder"?me.mutate(v.id):v.type==="bulk"&&De.mutate(l))},X=me.isPending||we.isPending||De.isPending,xe=ae=>{R(ae),localStorage.setItem("library-view-mode",ae)},_e=z||Z;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(il,{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:()=>xe("grid"),className:`p-1.5 rounded transition-colors ${T==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(sE,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>xe("list"),className:`p-1.5 rounded transition-colors ${T==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(oE,{className:"w-4 h-4"})})]}),s.jsxs(Me,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(the,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Me,{onClick:()=>b(!0),children:[s.jsx(oi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),le&&ne&&ie&&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(Rn,{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 ",Vp(ne.disk_free_bytes)," free of ",Vp(ne.disk_total_bytes)," total. Threshold is set to ",ie.library_disk_warning_gb," GB in settings."]})]})]}),ne&&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(tE,{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:ne.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(il,{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:ne.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(iE,{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:Vp(ne.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 ${le?"text-amber-500":"text-white"}`,children:Vp(ne.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(vf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),re?.map(ae=>s.jsx(Gie,{folder:ae,selectedFolderId:a,onSelect:o,onDelete:Te=>S({type:"folder",id:Te}),onLink:x,onRename:Te=>D({type:"folder",id:Te.id,name:Te.name})},ae.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[V&&V.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(va,{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:U,onChange:ae=>O(ae.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(nE,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:q,onChange:ae=>j(ae.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"}),he.map(ae=>s.jsx("option",{value:ae,children:ae.toUpperCase()},ae))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:W,onChange:ae=>K(ae.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:()=>J(ae=>ae==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:G==="asc"?"Ascending":"Descending",children:G==="asc"?s.jsx(Rue,{className:"w-4 h-4 text-white"}):s.jsx(Aue,{className:"w-4 h-4 text-white"})})]}),(U||q!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[fe.length," of ",V.length," files"]})]}),fe.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===fe.length&&l.length>0?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Le,children:[s.jsx(ll,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ae,children:[s.jsx(ol,{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"}),F.length===1&&s.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>k(F[0]),children:[s.jsx(sl,{className:"w-4 h-4 mr-1"}),"Print"]}),F.length>0&&s.jsxs(Me,{variant:F.length===1?"secondary":"primary",size:"sm",onClick:()=>B.mutate(F.map(ae=>ae.id)),disabled:B.isPending,children:[s.jsx(Yn,{className:"w-4 h-4 mr-1"}),B.isPending?"Adding...":`Add to Queue${F.length<l.length?` (${F.length})`:""}`]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(cfe,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{l.length===1?S({type:"file",id:l[0]}):S({type:"bulk",id:0,count:l.length})},children:[s.jsx(fn,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Le,children:"Clear"})]})]}),_e?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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):V?.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(vf,{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(Me,{onClick:()=>b(!0),children:[s.jsx(Qn,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):fe.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(va,{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(Me,{variant:"secondary",onClick:()=>{O(""),j("all")},children:"Clear filters"})]}):T==="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:fe.map(ae=>s.jsx(NZe,{file:ae,isSelected:l.includes(ae.id),onSelect:de,onDelete:Te=>S({type:"file",id:Te}),onDownload:$,onAddToQueue:Te=>B.mutate([Te]),onPrint:N,onRename:Te=>D({type:"file",id:Te.id,name:Te.filename})},ae.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",{})]}),fe.map(ae=>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(ae.id)?"bg-bambu-green/10":""}`,onClick:()=>de(ae.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(ae.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(ae.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:ae.thumbnail_path?s.jsx("img",{src:pe.getLibraryFileThumbnailUrl(ae.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(vf,{className:"w-5 h-5 text-bambu-gray/50"})})}),ae.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:pe.getLibraryFileThumbnailUrl(ae.id),alt:ae.filename,className:"w-full h-full object-contain"})})})]}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-sm text-white truncate",children:ae.print_name||ae.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${ae.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":ae.file_type==="gcode"?"bg-blue-500/20 text-blue-400":ae.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ae.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Vp(ae.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:ae.print_count>0?`${ae.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:Te=>Te.stopPropagation(),children:[bD(ae.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>N(ae),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Br,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>B.mutate([ae.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:B.isPending,children:s.jsx(Yn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>$(ae.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx(Ir,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>D({type:"file",id:ae.id,name:ae.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S({type:"file",id:ae.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(fn,{className:"w-4 h-4"})})]})]},ae.id))]})})]})]}),u&&s.jsx(_Ze,{parentId:a,onClose:()=>d(!1),onSave:ae=>Ee.mutate(ae),isLoading:Ee.isPending}),f&&re&&s.jsx(SZe,{folders:re,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:ae=>ee.mutate({fileIds:l,folderId:ae}),isLoading:ee.isPending}),p&&s.jsx(EZe,{folderId:a,onClose:()=>b(!1),onUploadComplete:Se}),y&&s.jsx(MZe,{folder:y,onClose:()=>x(null),onLink:ae=>Qe.mutate({id:y.id,data:ae}),isLoading:Qe.isPending}),v&&s.jsx(Un,{title:v.type==="folder"?"Delete Folder":v.type==="bulk"?`Delete ${v.count} Files`:"Delete File",message:v.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":v.type==="bulk"?`Are you sure you want to delete ${v.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:X,loadingText:"Deleting...",onConfirm:L,onCancel:()=>S(null)}),M&&s.jsx(rh,{mode:"reprint",libraryFileId:M.id,archiveName:M.print_name||M.filename,onClose:()=>N(null),onSuccess:()=>{N(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(rh,{mode:"reprint",libraryFileId:A.id,archiveName:A.print_name||A.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),C&&s.jsx(wZe,{type:C.type,currentName:C.name,onClose:()=>D(null),onSave:ae=>{C.type==="file"?te.mutate({id:C.id,filename:ae}):Y.mutate({id:C.id,name:ae})},isLoading:te.isPending||Y.isPending})]})}const Xj=5,TZe=2e3,CZe=3e4,kZe=5e3;function jZe(){const{printerId:t}=SD(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,a]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,p]=w.useState(!1),[b,y]=w.useState(0),[x,v]=w.useState(!1),[S,M]=w.useState(0),[N,A]=w.useState(1),[k,C]=w.useState({x:0,y:0}),[D,T]=w.useState(!1),[R,U]=w.useState({x:0,y:0}),[O,q]=w.useState(null),[j,W]=w.useState(null),K=w.useRef(null),G=w.useRef(null),J=w.useRef(null),ie=w.useRef(null),re=w.useRef(null),{data:z}=ut({queryKey:["printer",e],queryFn:()=>pe.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const V=w.useRef(!1);w.useEffect(()=>{const X=`/api/v1/printers/${e}/camera/stop`;V.current=!1;const xe=()=>{e>0&&!V.current&&(V.current=!0,navigator.sendBeacon(X))},_e=()=>{xe()};window.addEventListener("beforeunload",_e);const ae=K.current;return()=>{window.removeEventListener("beforeunload",_e),ae&&(ae.src=""),xe()}},[e]),w.useEffect(()=>{if(o&&!d){const xe=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(xe)}},[n,o,c,d]),w.useEffect(()=>{const X=()=>{const xe=!!document.fullscreenElement;p(xe),A(1),C({x:0,y:0}),n==="stream"&&!d&&(K.current&&(K.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",X),()=>document.removeEventListener("fullscreenchange",X)},[n,d]),w.useEffect(()=>{let X;const xe=()=>{clearTimeout(X),X=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",xe),()=>{clearTimeout(X),window.removeEventListener("resize",xe)}},[]),w.useEffect(()=>()=>{J.current&&clearTimeout(J.current),ie.current&&clearInterval(ie.current),re.current&&clearInterval(re.current)},[]);const Z=w.useCallback(()=>{if(b>=Xj){v(!1),a(!0);return}const X=Math.min(TZe*Math.pow(2,b),CZe);v(!0),M(Math.ceil(X/1e3)),ie.current=setInterval(()=>{M(xe=>xe<=1?(ie.current&&clearInterval(ie.current),0):xe-1)},1e3),J.current=setTimeout(()=>{y(xe=>xe+1),v(!1),l(!0),a(!1),K.current&&(K.current.src=""),u(Date.now())},X)},[b]);w.useEffect(()=>{if(n!=="stream"||o||x||d){re.current&&(clearInterval(re.current),re.current=null);return}return re.current=setInterval(async()=>{try{const X=await fetch(`/api/v1/printers/${e}/camera/status`);if(X.ok){const xe=await X.json();(xe.stalled||!xe.active&&!i)&&(console.log(`Stream issue detected: stalled=${xe.stalled}, active=${xe.active}, reconnecting...`),re.current&&(clearInterval(re.current),re.current=null),l(!1),Z())}}catch{}},kZe),()=>{re.current&&(clearInterval(re.current),re.current=null)}},[n,o,i,x,d,e,Z]);const ne=()=>{l(!1),n==="stream"&&b<Xj?Z():a(!0)},he=()=>{if(l(!1),a(!1),y(0),v(!1),J.current&&clearTimeout(J.current),ie.current&&clearInterval(ie.current),K.current&&!localStorage.getItem("cameraWindowState")){const X=K.current,xe=X.naturalWidth,_e=X.naturalHeight;if(xe>0&&_e>0){const Pe=window.outerWidth-window.innerWidth,Xe=window.outerHeight-window.innerHeight,Je=xe+16+Pe,Ze=_e+45+16+Xe;try{window.resizeTo(Je,Ze)}catch{}}}},fe=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},le=X=>{n===X||d||(f(!0),l(!0),a(!1),y(0),v(!1),A(1),C({x:0,y:0}),J.current&&clearTimeout(J.current),ie.current&&clearInterval(ie.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{r(X),u(Date.now()),f(!1)},100))},Ee=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),J.current&&clearTimeout(J.current),ie.current&&clearInterval(ie.current),K.current&&(K.current.src=""),n==="stream"&&fe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},me=()=>{G.current&&(document.fullscreenElement?document.exitFullscreen():G.current.requestFullscreen())},we=()=>{A(X=>Math.min(X+.5,4))},De=()=>{A(X=>{const xe=Math.max(X-.5,1);return xe===1&&C({x:0,y:0}),xe})},ee=X=>{X.preventDefault(),X.deltaY<0?we():De()},Qe=X=>{N>1&&(X.preventDefault(),T(!0),U({x:X.clientX-k.x,y:X.clientY-k.y}))},B=w.useCallback(()=>{if(!G.current)return{x:300,y:200};const X=G.current.getBoundingClientRect(),xe=X.width*(N-1)/2,_e=X.height*(N-1)/2;return{x:Math.max(50,xe),y:Math.max(50,_e)}},[N]),te=X=>{if(D&&N>1){const xe=X.clientX-R.x,_e=X.clientY-R.y,ae=B();C({x:Math.max(-ae.x,Math.min(ae.x,xe)),y:Math.max(-ae.y,Math.min(ae.y,_e))})}},Y=()=>{T(!1)},H=X=>{if(X.length<2)return 0;const xe=X[0].clientX-X[1].clientX,_e=X[0].clientY-X[1].clientY;return Math.sqrt(xe*xe+_e*_e)},F=X=>X.length<2?{x:X[0].clientX,y:X[0].clientY}:{x:(X[0].clientX+X[1].clientX)/2,y:(X[0].clientY+X[1].clientY)/2},de=X=>{X.touches.length===2?(X.preventDefault(),q(H(X.touches)),W(F(X.touches))):X.touches.length===1&&N>1&&(X.preventDefault(),T(!0),U({x:X.touches[0].clientX-k.x,y:X.touches[0].clientY-k.y}))},Ae=X=>{if(X.touches.length===2&&O!==null){X.preventDefault();const xe=H(X.touches),_e=xe/O;A(Te=>{const Pe=Math.max(1,Math.min(4,Te*_e));return Pe===1&&C({x:0,y:0}),Pe}),q(xe);const ae=F(X.touches);if(j){const Te=B();C(Pe=>({x:Math.max(-Te.x,Math.min(Te.x,Pe.x+(ae.x-j.x))),y:Math.max(-Te.y,Math.min(Te.y,Pe.y+(ae.y-j.y)))}))}W(ae)}else if(X.touches.length===1&&D&&N>1){X.preventDefault();const xe=X.touches[0].clientX-R.x,_e=X.touches[0].clientY-R.y,ae=B();C({x:Math.max(-ae.x,Math.min(ae.x,xe)),y:Math.max(-ae.y,Math.min(ae.y,_e))})}},Le=X=>{X.touches.length<2&&(q(null),W(null)),X.touches.length===0&&T(!1)},Se=()=>{A(1),C({x:0,y:0})},$=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,L=o||d||x;return e?s.jsxs("div",{ref:G,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(fg,{className:"w-4 h-4"}),z?.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:()=>le("stream"),disabled:L,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:()=>le("snapshot"),disabled:L,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:Ee,disabled:L,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(Mr,{className:`w-4 h-4 text-bambu-gray ${L?"animate-spin":""}`})}),s.jsx("button",{onClick:me,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(gK,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Zhe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:ee,onMouseMove:te,onMouseUp:Y,onMouseLeave:Y,onTouchStart:de,onTouchMove:Ae,onTouchEnd:Le,style:{touchAction:"none"},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(Mr,{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(Yg,{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 ",S,"s... (attempt ",b+1,"/",Xj,")"]}),s.jsx("button",{onClick:Ee,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(Rn,{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:Ee,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:K,src:$,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${N}) translate(${k.x/N}px, ${k.y/N}px)`,cursor:N>1?D?"grabbing":"grab":"default"},onError:$?ne:void 0,onLoad:$?he:void 0,onMouseDown:Qe,draggable:!1},c),s.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[s.jsx("button",{onClick:De,disabled:N<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(HD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:Se,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(N*100),"%"]}),s.jsx("button",{onClick:we,disabled:N>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx($D,{className:"w-4 h-4 text-white"})})]})]})})]}):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 PZe(){const{id:t}=SD(),{mode:e}=sh(),{data:n,isLoading:r,error:i}=ut({queryKey:["external-link",t],queryFn:()=>pe.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(dt,{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(Rn,{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"})}const hq=["DEBUG","INFO","WARNING","ERROR"],Yj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},RZe={DEBUG:ZM,INFO:Yl,WARNING:Rn,ERROR:Qi};function DZe(){const t=un(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[a,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),p=w.useRef(null),{data:b,isLoading:y,refetch:x}=ut({queryKey:["application-logs",l,a],queryFn:()=>Jp.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const v=ht({mutationFn:()=>Jp.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&b?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[b?.entries,e]);const S=C=>{i(D=>{const T=new Set(D);return T.has(C)?T.delete(C):T.add(C),T})},M=C=>{const D=C.split(" ");return D.length>=2?D[1]:C},N=w.useMemo(()=>b?.entries??[],[b?.entries]),A=w.useMemo(()=>[...N].reverse(),[N]),k=({level:C})=>{const D=RZe[C]||Yl;return s.jsx(D,{className:`w-3.5 h-3.5 ${Yj[C]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(ZM,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${b?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(uu,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Zi,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[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 flex-wrap",children:[f?s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[s.jsx(ll,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!0),x()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[s.jsx(sl,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||N.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[s.jsx(fn,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>x(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:s.jsx(Mr,{className:`w-4 h-4 ${y?"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:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[b?.filtered_count??0,"/",b?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(va,{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 message or logger name...",value:a,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Wt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),hq.map((C,D)=>s.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===hq.length-1?"rounded-r":""} ${l===C?`${Yj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:N.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:A.map((C,D)=>{const T=r.has(D),R=C.message.includes(`
  8339. `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${T?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&S(D),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:M(C.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(k,{level:C.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Yj[C.level]||"text-white/80"} ${!T&&R?"truncate":""}`,children:T?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
  8340. `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:T?s.jsx(uu,{className:"w-3.5 h-3.5"}):s.jsx(Zi,{className:"w-3.5 h-3.5"})})]})},D)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?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"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function OZe(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 Xr({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 fq({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 hd({title:t,icon:e,children:n}){return s.jsxs(Et,{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 LZe(){const{t}=Gg(),e=un(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ut({queryKey:["systemInfo"],queryFn:pe.getSystemInfo,refetchInterval:3e4}),{data:m}=ut({queryKey:["debugLogging"],queryFn:Jp.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ut({queryKey:["settings"],queryFn:pe.getSettings}),{data:b}=ut({queryKey:["library-stats"],queryFn:pe.getLibraryStats}),y=p?.time_format||"system",x=async()=>{l(!0);try{const N=await Jp.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],N)}catch(N){console.error("Failed to toggle debug logging:",N)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await Jp.downloadSupportBundle()}catch(N){r(N instanceof Error?N.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(dt,{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 S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",M=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(Mr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(hd,{title:t("system.application","Application"),icon:qh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Xr,{icon:qh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(Xr,{icon:Yn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(Xr,{icon:qh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(hd,{title:t("support.title","Support & Troubleshooting"),icon:vhe,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 ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(ZM,{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:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.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 ${m?.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(dt,{className:"w-4 h-4 animate-spin"}),m?.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(Ir,{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:v,disabled:i||!m?.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:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(dt,{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}),!m?.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.jsx(DZe,{})]})}),s.jsxs(hd,{title:t("system.database","Database"),icon:mg,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(Xr,{icon:Xa,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(Xr,{icon:QM,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(Xr,{icon:Ya,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(Xr,{icon:dt,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(Xr,{icon:Br,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(Xr,{icon:ID,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(Xr,{icon:wa,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(Xr,{icon:Hs,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(Xr,{icon:Yn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(Xr,{icon:Xa,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(hd,{title:t("system.connectedPrinters","Connected Printers"),icon:Br,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(N=>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:N.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:N.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${N.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":N.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:N.state})]})]},N.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(hd,{title:t("system.storage","Storage"),icon:iE,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(fq,{percent:c.storage.disk_percent_used,color:S}),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(Xr,{icon:Xa,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(Xr,{icon:mg,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(Xr,{icon:il,label:t("system.fileManagerStorage","File Manager"),value:OZe(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(hd,{title:t("system.memory","Memory"),icon:Jhe,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(fq,{percent:c.memory.percent_used,color:M}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(hd,{title:t("system.cpu","CPU"),icon:f_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Xr,{icon:f_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(Xr,{icon:f_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(hd,{title:t("system.systemDetails","System Details"),icon:qh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Xr,{icon:qh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(Xr,{icon:f_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(Xr,{icon:qh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(Xr,{icon:Yn,label:t("system.bootTime","Boot Time"),value:bg(c.system.boot_time,y)})]})})]})}function IZe(){const t=ml(),{login:e}=oh(),{showToast:n}=qn(),{mode:r}=sh(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=ht({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:d=>{n(d.message||"Login failed","error")}}),u=d=>{if(d.preventDefault(),!i||!o){n("Please enter username and password","error");return}c.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Login"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:u,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:d=>a(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:d=>l(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your password",autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:c.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:c.isPending?"Logging in...":"Sign in"})})]})]})})}function FZe(){const t=ml(),{showToast:e}=qn(),{mode:n}=sh(),{refreshAuth:r}=oh(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=ht({mutationFn:()=>pe.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async b=>{await r(),b.auth_enabled?b.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:b=>{e(b.message,"error")}}),p=b=>{if(b.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:i,onChange:b=>a(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),i&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Yl,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Admin Account"}),s.jsx("p",{children:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user."})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-username",type:"text",value:o,onChange:b=>l(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username (optional)",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-password",type:"password",value:c,onChange:b=>u(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),s.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:b=>f(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?"Setting up...":"Complete Setup"})})]})]})})}function UZe(){const t=ml(),{user:e}=oh(),{showToast:n}=qn(),r=un(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState({username:"",password:"",role:"user"});w.useEffect(()=>{const A=k=>{k.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[i]);const{data:m=[],isLoading:p}=ut({queryKey:["users"],queryFn:()=>pe.getUsers()}),b=ht({mutationFn:A=>pe.createUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:A=>{n(A.message,"error")}}),y=ht({mutationFn:({id:A,data:k})=>pe.updateUser(A,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:A=>{n(A.message,"error")}}),x=ht({mutationFn:A=>pe.deleteUser(A),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:A=>{n(A.message,"error")}}),v=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}b.mutate(d)},S=A=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,y.mutate({id:A,data:k})},M=A=>{u(A)},N=A=>{l(A.id),f({username:A.username,password:"",role:A.role})};return e?.role!=="admin"?s.jsx("div",{className:"p-6",children:s.jsx(Et,{children:s.jsx(At,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(yP,{className:"w-5 h-5"}),s.jsx("p",{className:"text-white",children:"You do not have permission to access this page."})]})})})}):s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>t("/settings?tab=users"),className:"p-2 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Back to Settings",children:s.jsx(sK,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(lf,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),s.jsxs(Me,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(Qn,{className:"w-4 h-4"}),"Create User"]})]}),p?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(Et,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-bambu-dark-tertiary",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Username"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Role"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Status"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:m.map(A=>s.jsxs("tr",{className:"hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:o===A.id?s.jsx("input",{type:"text",value:d.username,onChange:k=>f({...d,username:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green"}):A.username}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===A.id?s.jsxs("select",{value:d.role,onChange:k=>f({...d,role:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]}):s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${A.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:A.role})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${A.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:A.is_active?"Active":"Inactive"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===A.id?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",onClick:()=>S(A.id),disabled:y.isPending,children:[y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ps,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>N(A),children:[s.jsx(lE,{className:"w-4 h-4"}),"Edit"]}),A.id!==e?.id&&s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>M(A.id),children:[s.jsx(fn,{className:"w-4 h-4"}),"Delete"]})]})})]},A.id))})]})})}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsxs(Et,{className:"w-full max-w-md",onClick:A=>A.stopPropagation(),children:[s.jsx(wr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(lf,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Wt,{className:"w-5 h-5"})})]})}),s.jsxs(At,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),s.jsx("input",{type:"text",value:d.username,onChange:A=>f({...d,username:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{type:"password",value:d.password,onChange:A=>f({...d,password:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter password",autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Role"}),s.jsxs("select",{value:d.role,onChange:A=>f({...d,role:A.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Me,{onClick:v,disabled:b.isPending||!d.username||!d.password,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Qn,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(Un,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{x.mutate(c),u(null)},onCancel:()=>u(null)})]})}function zZe(){const t=w.useRef(null),e=w.useRef(null),n=un(),[r,i]=w.useState(!1),a=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const M=u.current.shift();M?requestAnimationFrame(()=>{f.current(M),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const M=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(M);let A=null;N.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),A=window.setInterval(()=>{N.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:"ping"}))},3e4)},N.onmessage=k=>{try{const C=JSON.parse(k.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?f.current(C):(u.current.push(C),m())}catch{}},N.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),A&&(clearInterval(A),A=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},N.onerror=k=>{console.error("[WebSocket] Error",k),N.close()},t.current=N},[m]),b=w.useCallback((S,M)=>{const N=l.current.get(S)||{};l.current.set(S,{...N,...M}),c.current||(c.current=window.setTimeout(()=>{const A=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{A.forEach((k,C)=>{n.setQueryData(["printerStatus",C],D=>{const T={...D,...k};return T.wifi_signal==null&&D?.wifi_signal!=null&&(T.wifi_signal=D.wifi_signal),T})})})},100))},[n]),y=w.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const M=Array.from(a.current);a.current.clear(),o.current=null;let N=0;M.forEach(A=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[A]})})},N),N+=500})},3e3)},[n]),x=w.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&b(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break}},[n,y,b]);w.useEffect(()=>{f.current=x},[x]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=w.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const BZe=new hue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function $Ze({children:t}){return zZe(),s.jsx(s.Fragment,{children:t})}function HZe({children:t}){const{authEnabled:e,loading:n,user:r}=oh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function VZe({children:t}){const{authEnabled:e,loading:n,user:r}=oh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(Aw,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function GZe({children:t}){const{authEnabled:e,loading:n}=oh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Aw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function WZe(){return s.jsx(Ime,{children:s.jsx(Yme,{children:s.jsx(fue,{client:BZe,children:s.jsx($me,{children:s.jsx(Pce,{children:s.jsxs(oce,{children:[s.jsx(zi,{path:"/setup",element:s.jsx(GZe,{children:s.jsx(FZe,{})})}),s.jsx(zi,{path:"/login",element:s.jsx(IZe,{})}),s.jsx(zi,{path:"/camera/:printerId",element:s.jsx(jZe,{})}),s.jsxs(zi,{element:s.jsx(HZe,{children:s.jsx($Ze,{children:s.jsx(Wme,{})})}),children:[s.jsx(zi,{index:!0,element:s.jsx(YPe,{})}),s.jsx(zi,{path:"archives",element:s.jsx(NKe,{})}),s.jsx(zi,{path:"queue",element:s.jsx(uYe,{})}),s.jsx(zi,{path:"stats",element:s.jsx(MYe,{})}),s.jsx(zi,{path:"profiles",element:s.jsx(aZe,{})}),s.jsx(zi,{path:"maintenance",element:s.jsx(uZe,{})}),s.jsx(zi,{path:"projects",element:s.jsx(hZe,{})}),s.jsx(zi,{path:"projects/:id",element:s.jsx(yZe,{})}),s.jsx(zi,{path:"files",element:s.jsx(AZe,{})}),s.jsx(zi,{path:"settings",element:s.jsx(VZe,{children:s.jsx(KYe,{})})}),s.jsx(zi,{path:"users",element:s.jsx(UZe,{})}),s.jsx(zi,{path:"system",element:s.jsx(LZe,{})}),s.jsx(zi,{path:"external/:id",element:s.jsx(PZe,{})})]})]})})})})})})}soe.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(WZe,{})}));