index-BHvBWY5n.js 2.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596
  1. function ane(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 s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).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 Nb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Js(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var AA={exports:{}},Ng={};var Z4;function sne(){if(Z4)return Ng;Z4=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var o in i)o!=="key"&&(a[o]=i[o])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return Ng.Fragment=e,Ng.jsx=n,Ng.jsxs=n,Ng}var Q4;function one(){return Q4||(Q4=1,AA.exports=sne()),AA.exports}var h=one(),TA={exports:{}},Kt={};var J4;function lne(){if(J4)return Kt;J4=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"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function m($){return $===null||typeof $!="object"?null:($=g&&$[g]||$["@@iterator"],typeof $=="function"?$:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function x($,X,ae){this.props=$,this.context=X,this.refs=b,this.updater=ae||y}x.prototype.isReactComponent={},x.prototype.setState=function($,X){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,X,"setState")},x.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function M(){}M.prototype=x.prototype;function w($,X,ae){this.props=$,this.context=X,this.refs=b,this.updater=ae||y}var A=w.prototype=new M;A.constructor=w,v(A,x.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function R(){}var N={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function C($,X,ae){var ce=ae.ref;return{$$typeof:t,type:$,key:X,ref:ce!==void 0?ce:null,props:ae}}function k($,X){return C($.type,X,$.props)}function U($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function I($){var X={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(ae){return X[ae]})}var H=/\/+/g;function O($,X){return typeof $=="object"&&$!==null&&$.key!=null?I(""+$.key):X.toString(36)}function B($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(R,R):($.status="pending",$.then(function(X){$.status==="pending"&&($.status="fulfilled",$.value=X)},function(X){$.status==="pending"&&($.status="rejected",$.reason=X)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function V($,X,ae,ce,xe){var te=typeof $;(te==="undefined"||te==="boolean")&&($=null);var ve=!1;if($===null)ve=!0;else switch(te){case"bigint":case"string":case"number":ve=!0;break;case"object":switch($.$$typeof){case t:case e:ve=!0;break;case u:return ve=$._init,V(ve($._payload),X,ae,ce,xe)}}if(ve)return xe=xe($),ve=ce===""?"."+O($,0):ce,T(xe)?(ae="",ve!=null&&(ae=ve.replace(H,"$&/")+"/"),V(xe,X,ae,"",function(me){return me})):xe!=null&&(U(xe)&&(xe=k(xe,ae+(xe.key==null||$&&$.key===xe.key?"":(""+xe.key).replace(H,"$&/")+"/")+ve)),X.push(xe)),1;ve=0;var De=ce===""?".":ce+":";if(T($))for(var he=0;he<$.length;he++)ce=$[he],te=De+O(ce,he),ve+=V(ce,X,ae,te,xe);else if(he=m($),typeof he=="function")for($=he.call($),he=0;!(ce=$.next()).done;)ce=ce.value,te=De+O(ce,he++),ve+=V(ce,X,ae,te,xe);else if(te==="object"){if(typeof $.then=="function")return V(B($),X,ae,ce,xe);throw X=String($),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return ve}function G($,X,ae){if($==null)return $;var ce=[],xe=0;return V($,ce,"","",function(te){return X.call(ae,te,xe++)}),ce}function K($){if($._status===-1){var X=$._result;X=X(),X.then(function(ae){($._status===0||$._status===-1)&&($._status=1,$._result=ae)},function(ae){($._status===0||$._status===-1)&&($._status=2,$._result=ae)}),$._status===-1&&($._status=0,$._result=X)}if($._status===1)return $._result.default;throw $._result}var Y=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},oe={map:G,forEach:function($,X,ae){G($,function(){X.apply(this,arguments)},ae)},count:function($){var X=0;return G($,function(){X++}),X},toArray:function($){return G($,function(X){return X})||[]},only:function($){if(!U($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return Kt.Activity=f,Kt.Children=oe,Kt.Component=x,Kt.Fragment=n,Kt.Profiler=i,Kt.PureComponent=w,Kt.StrictMode=r,Kt.Suspense=l,Kt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Kt.__COMPILER_RUNTIME={__proto__:null,c:function($){return N.H.useMemoCache($)}},Kt.cache=function($){return function(){return $.apply(null,arguments)}},Kt.cacheSignal=function(){return null},Kt.cloneElement=function($,X,ae){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var ce=v({},$.props),xe=$.key;if(X!=null)for(te in X.key!==void 0&&(xe=""+X.key),X)!j.call(X,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&X.ref===void 0||(ce[te]=X[te]);var te=arguments.length-2;if(te===1)ce.children=ae;else if(1<te){for(var ve=Array(te),De=0;De<te;De++)ve[De]=arguments[De+2];ce.children=ve}return C($.type,xe,ce)},Kt.createContext=function($){return $={$$typeof:s,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:a,_context:$},$},Kt.createElement=function($,X,ae){var ce,xe={},te=null;if(X!=null)for(ce in X.key!==void 0&&(te=""+X.key),X)j.call(X,ce)&&ce!=="key"&&ce!=="__self"&&ce!=="__source"&&(xe[ce]=X[ce]);var ve=arguments.length-2;if(ve===1)xe.children=ae;else if(1<ve){for(var De=Array(ve),he=0;he<ve;he++)De[he]=arguments[he+2];xe.children=De}if($&&$.defaultProps)for(ce in ve=$.defaultProps,ve)xe[ce]===void 0&&(xe[ce]=ve[ce]);return C($,te,xe)},Kt.createRef=function(){return{current:null}},Kt.forwardRef=function($){return{$$typeof:o,render:$}},Kt.isValidElement=U,Kt.lazy=function($){return{$$typeof:u,_payload:{_status:-1,_result:$},_init:K}},Kt.memo=function($,X){return{$$typeof:c,type:$,compare:X===void 0?null:X}},Kt.startTransition=function($){var X=N.T,ae={};N.T=ae;try{var ce=$(),xe=N.S;xe!==null&&xe(ae,ce),typeof ce=="object"&&ce!==null&&typeof ce.then=="function"&&ce.then(R,Y)}catch(te){Y(te)}finally{X!==null&&ae.types!==null&&(X.types=ae.types),N.T=X}},Kt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Kt.use=function($){return N.H.use($)},Kt.useActionState=function($,X,ae){return N.H.useActionState($,X,ae)},Kt.useCallback=function($,X){return N.H.useCallback($,X)},Kt.useContext=function($){return N.H.useContext($)},Kt.useDebugValue=function(){},Kt.useDeferredValue=function($,X){return N.H.useDeferredValue($,X)},Kt.useEffect=function($,X){return N.H.useEffect($,X)},Kt.useEffectEvent=function($){return N.H.useEffectEvent($)},Kt.useId=function(){return N.H.useId()},Kt.useImperativeHandle=function($,X,ae){return N.H.useImperativeHandle($,X,ae)},Kt.useInsertionEffect=function($,X){return N.H.useInsertionEffect($,X)},Kt.useLayoutEffect=function($,X){return N.H.useLayoutEffect($,X)},Kt.useMemo=function($,X){return N.H.useMemo($,X)},Kt.useOptimistic=function($,X){return N.H.useOptimistic($,X)},Kt.useReducer=function($,X,ae){return N.H.useReducer($,X,ae)},Kt.useRef=function($){return N.H.useRef($)},Kt.useState=function($){return N.H.useState($)},Kt.useSyncExternalStore=function($,X,ae){return N.H.useSyncExternalStore($,X,ae)},Kt.useTransition=function(){return N.H.useTransition()},Kt.version="19.2.0",Kt}var eU;function xm(){return eU||(eU=1,TA.exports=lne()),TA.exports}var E=xm();const ur=Js(E),cne=ane({__proto__:null,default:ur},[E]);var CA={exports:{}},Rg={},NA={exports:{}},RA={};var tU;function une(){return tU||(tU=1,(function(t){function e(V,G){var K=V.length;V.push(G);e:for(;0<K;){var Y=K-1>>>1,oe=V[Y];if(0<i(oe,G))V[Y]=G,V[K]=oe,K=Y;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var G=V[0],K=V.pop();if(K!==G){V[0]=K;e:for(var Y=0,oe=V.length,$=oe>>>1;Y<$;){var X=2*(Y+1)-1,ae=V[X],ce=X+1,xe=V[ce];if(0>i(ae,K))ce<oe&&0>i(xe,ae)?(V[Y]=xe,V[ce]=K,Y=ce):(V[Y]=ae,V[X]=K,Y=X);else if(ce<oe&&0>i(xe,K))V[Y]=xe,V[ce]=K,Y=ce;else break e}}return G}function i(V,G){var K=V.sortIndex-G.sortIndex;return K!==0?K:V.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 s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var l=[],c=[],u=1,f=null,g=3,m=!1,y=!1,v=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(V){for(var G=n(c);G!==null;){if(G.callback===null)r(c);else if(G.startTime<=V)r(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=n(c)}}function T(V){if(v=!1,A(V),!y)if(n(l)!==null)y=!0,R||(R=!0,I());else{var G=n(c);G!==null&&B(T,G.startTime-V)}}var R=!1,N=-1,j=5,C=-1;function k(){return b?!0:!(t.unstable_now()-C<j)}function U(){if(b=!1,R){var V=t.unstable_now();C=V;var G=!0;try{e:{y=!1,v&&(v=!1,M(N),N=-1),m=!0;var K=g;try{t:{for(A(V),f=n(l);f!==null&&!(f.expirationTime>V&&k());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,g=f.priorityLevel;var oe=Y(f.expirationTime<=V);if(V=t.unstable_now(),typeof oe=="function"){f.callback=oe,A(V),G=!0;break t}f===n(l)&&r(l),A(V)}else r(l);f=n(l)}if(f!==null)G=!0;else{var $=n(c);$!==null&&B(T,$.startTime-V),G=!1}}break e}finally{f=null,g=K,m=!1}G=void 0}}finally{G?I():R=!1}}}var I;if(typeof w=="function")I=function(){w(U)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,O=H.port2;H.port1.onmessage=U,I=function(){O.postMessage(null)}}else I=function(){x(U,0)};function B(V,G){N=x(function(){V(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(V){V.callback=null},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(V){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var K=g;g=G;try{return V()}finally{g=K}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(V,G){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var K=g;g=V;try{return G()}finally{g=K}},t.unstable_scheduleCallback=function(V,G,K){var Y=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?Y+K:Y):K=Y,V){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=K+oe,V={id:u++,callback:G,priorityLevel:V,startTime:K,expirationTime:oe,sortIndex:-1},K>Y?(V.sortIndex=K,e(c,V),n(l)===null&&V===n(c)&&(v?(M(N),N=-1):v=!0,B(T,K-Y))):(V.sortIndex=oe,e(l,V),y||m||(y=!0,R||(R=!0,I()))),V},t.unstable_shouldYield=k,t.unstable_wrapCallback=function(V){var G=g;return function(){var K=g;g=G;try{return V.apply(this,arguments)}finally{g=K}}}})(RA)),RA}var nU;function dne(){return nU||(nU=1,NA.exports=une()),NA.exports}var PA={exports:{}},Xi={};var rU;function fne(){if(rU)return Xi;rU=1;var t=xm();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)c+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var 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(l,c,u){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:l,containerInfo:c,implementation:u}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return Xi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Xi.createPortal=function(l,c){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return a(l,c,null,u)},Xi.flushSync=function(l){var c=s.T,u=r.p;try{if(s.T=null,r.p=2,l)return l()}finally{s.T=c,r.p=u,r.d.f()}},Xi.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,r.d.C(l,c))},Xi.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},Xi.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var u=c.as,f=o(u,c.crossOrigin),g=typeof c.integrity=="string"?c.integrity:void 0,m=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;u==="style"?r.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):u==="script"&&r.d.X(l,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Xi.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var u=o(c.as,c.crossOrigin);r.d.M(l,{crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&r.d.M(l)},Xi.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var u=c.as,f=o(u,c.crossOrigin);r.d.L(l,u,{crossOrigin:f,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},Xi.preloadModule=function(l,c){if(typeof l=="string")if(c){var u=o(c.as,c.crossOrigin);r.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else r.d.m(l)},Xi.requestFormReset=function(l){r.d.r(l)},Xi.unstable_batchedUpdates=function(l,c){return l(c)},Xi.useFormState=function(l,c,u){return s.H.useFormState(l,c,u)},Xi.useFormStatus=function(){return s.H.useHostTransitionStatus()},Xi.version="19.2.0",Xi}var iU;function bG(){if(iU)return PA.exports;iU=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(),PA.exports=fne(),PA.exports}var aU;function hne(){if(aU)return Rg;aU=1;var t=dne(),e=xm(),n=bG();function r(d){var p="https://react.dev/errors/"+d;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+d+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function a(d){var p=d,_=d;if(d.alternate)for(;p.return;)p=p.return;else{d=p;do p=d,(p.flags&4098)!==0&&(_=p.return),d=p.return;while(d)}return p.tag===3?_:null}function s(d){if(d.tag===13){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function o(d){if(d.tag===31){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function l(d){if(a(d)!==d)throw Error(r(188))}function c(d){var p=d.alternate;if(!p){if(p=a(d),p===null)throw Error(r(188));return p!==d?null:d}for(var _=d,S=p;;){var P=_.return;if(P===null)break;var D=P.alternate;if(D===null){if(S=P.return,S!==null){_=S;continue}break}if(P.child===D.child){for(D=P.child;D;){if(D===_)return l(P),d;if(D===S)return l(P),p;D=D.sibling}throw Error(r(188))}if(_.return!==S.return)_=P,S=D;else{for(var W=!1,re=P.child;re;){if(re===_){W=!0,_=P,S=D;break}if(re===S){W=!0,S=P,_=D;break}re=re.sibling}if(!W){for(re=D.child;re;){if(re===_){W=!0,_=D,S=P;break}if(re===S){W=!0,S=D,_=P;break}re=re.sibling}if(!W)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?d:p}function u(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d;for(d=d.child;d!==null;){if(p=u(d),p!==null)return p;d=d.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),w=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function I(d){return d===null||typeof d!="object"?null:(d=U&&d[U]||d["@@iterator"],typeof d=="function"?d:null)}var H=Symbol.for("react.client.reference");function O(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===H?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case v:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList";case C:return"Activity"}if(typeof d=="object")switch(d.$$typeof){case y:return"Portal";case w:return d.displayName||"Context";case M:return(d._context.displayName||"Context")+".Consumer";case A:var p=d.render;return d=d.displayName,d||(d=p.displayName||p.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case N:return p=d.displayName||null,p!==null?p:O(d.type)||"Memo";case j:p=d._payload,d=d._init;try{return O(d(p))}catch{}}return null}var B=Array.isArray,V=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,K={pending:!1,data:null,method:null,action:null},Y=[],oe=-1;function $(d){return{current:d}}function X(d){0>oe||(d.current=Y[oe],Y[oe]=null,oe--)}function ae(d,p){oe++,Y[oe]=d.current,d.current=p}var ce=$(null),xe=$(null),te=$(null),ve=$(null);function De(d,p){switch(ae(te,p),ae(xe,d),ae(ce,null),p.nodeType){case 9:case 11:d=(d=p.documentElement)&&(d=d.namespaceURI)?y4(d):0;break;default:if(d=p.tagName,p=p.namespaceURI)p=y4(p),d=_4(p,d);else switch(d){case"svg":d=1;break;case"math":d=2;break;default:d=0}}X(ce),ae(ce,d)}function he(){X(ce),X(xe),X(te)}function me(d){d.memoizedState!==null&&ae(ve,d);var p=ce.current,_=_4(p,d.type);p!==_&&(ae(xe,d),ae(ce,_))}function we(d){xe.current===d&&(X(ce),X(xe)),ve.current===d&&(X(ve),Eg._currentValue=K)}var se,st;function z(d){if(se===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);se=p&&p[1]||"",st=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+se+d+st}var q=!1;function ie(d,p){if(!d||q)return"";q=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var lt=function(){throw Error()};if(Object.defineProperty(lt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(lt,[])}catch(Ye){var Ve=Ye}Reflect.construct(d,[],lt)}else{try{lt.call()}catch(Ye){Ve=Ye}d.call(lt.prototype)}}else{try{throw Error()}catch(Ye){Ve=Ye}(lt=d())&&typeof lt.catch=="function"&&lt.catch(function(){})}}catch(Ye){if(Ye&&Ve&&typeof Ye.stack=="string")return[Ye.stack,Ve.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var D=S.DetermineComponentFrameRoot(),W=D[0],re=D[1];if(W&&re){var Se=W.split(`
  4. `),Be=re.split(`
  5. `);for(P=S=0;S<Se.length&&!Se[S].includes("DetermineComponentFrameRoot");)S++;for(;P<Be.length&&!Be[P].includes("DetermineComponentFrameRoot");)P++;if(S===Se.length||P===Be.length)for(S=Se.length-1,P=Be.length-1;1<=S&&0<=P&&Se[S]!==Be[P];)P--;for(;1<=S&&0<=P;S--,P--)if(Se[S]!==Be[P]){if(S!==1||P!==1)do if(S--,P--,0>P||Se[S]!==Be[P]){var et=`
  6. `+Se[S].replace(" at new "," at ");return d.displayName&&et.includes("<anonymous>")&&(et=et.replace("<anonymous>",d.displayName)),et}while(1<=S&&0<=P);break}}}finally{q=!1,Error.prepareStackTrace=_}return(_=d?d.displayName||d.name:"")?z(_):""}function Q(d,p){switch(d.tag){case 26:case 27:case 5:return z(d.type);case 16:return z("Lazy");case 13:return d.child!==p&&p!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return ie(d.type,!1);case 11:return ie(d.type.render,!1);case 1:return ie(d.type,!0);case 31:return z("Activity");default:return""}}function ee(d){try{var p="",_=null;do p+=Q(d,_),_=d,d=d.return;while(d);return p}catch(S){return`
  7. Error generating stack: `+S.message+`
  8. `+S.stack}}var le=Object.prototype.hasOwnProperty,Re=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,ne=t.unstable_shouldYield,F=t.unstable_requestPaint,L=t.unstable_now,Z=t.unstable_getCurrentPriorityLevel,ge=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,pe=t.unstable_NormalPriority,Ze=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,Xe=t.log,ot=t.unstable_setDisableYieldValue,je=null,ke=null;function pt(d){if(typeof Xe=="function"&&ot(d),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(je,d)}catch{}}var rt=Math.clz32?Math.clz32:de,nt=Math.log,dt=Math.LN2;function de(d){return d>>>=0,d===0?32:31-(nt(d)/dt|0)|0}var it=256,fe=262144,Le=4194304;function Ee(d){var p=d&42;if(p!==0)return p;switch(d&-d){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return d&261888;case 262144:case 524288:case 1048576:case 2097152:return d&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return d&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return d}}function be(d,p,_){var S=d.pendingLanes;if(S===0)return 0;var P=0,D=d.suspendedLanes,W=d.pingedLanes;d=d.warmLanes;var re=S&134217727;return re!==0?(S=re&~D,S!==0?P=Ee(S):(W&=re,W!==0?P=Ee(W):_||(_=re&~d,_!==0&&(P=Ee(_))))):(re=S&~D,re!==0?P=Ee(re):W!==0?P=Ee(W):_||(_=S&~d,_!==0&&(P=Ee(_)))),P===0?0:p!==0&&p!==P&&(p&D)===0&&(D=P&-P,_=p&-p,D>=_||D===32&&(_&4194048)!==0)?p:P}function He(d,p){return(d.pendingLanes&~(d.suspendedLanes&~d.pingedLanes)&p)===0}function ut(d,p){switch(d){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _t(){var d=Le;return Le<<=1,(Le&62914560)===0&&(Le=4194304),d}function Rt(d){for(var p=[],_=0;31>_;_++)p.push(d);return p}function ln(d,p){d.pendingLanes|=p,p!==268435456&&(d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0)}function Dt(d,p,_,S,P,D){var W=d.pendingLanes;d.pendingLanes=_,d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0,d.expiredLanes&=_,d.entangledLanes&=_,d.errorRecoveryDisabledLanes&=_,d.shellSuspendCounter=0;var re=d.entanglements,Se=d.expirationTimes,Be=d.hiddenUpdates;for(_=W&~_;0<_;){var et=31-rt(_),lt=1<<et;re[et]=0,Se[et]=-1;var Ve=Be[et];if(Ve!==null)for(Be[et]=null,et=0;et<Ve.length;et++){var Ye=Ve[et];Ye!==null&&(Ye.lane&=-536870913)}_&=~lt}S!==0&&Rn(d,S,0),D!==0&&P===0&&d.tag!==0&&(d.suspendedLanes|=D&~(W&~p))}function Rn(d,p,_){d.pendingLanes|=p,d.suspendedLanes&=~p;var S=31-rt(p);d.entangledLanes|=p,d.entanglements[S]=d.entanglements[S]|1073741824|_&261930}function qn(d,p){var _=d.entangledLanes|=p;for(d=d.entanglements;_;){var S=31-rt(_),P=1<<S;P&p|d[S]&p&&(d[S]|=p),_&=~P}}function pi(d,p){var _=p&-p;return _=(_&42)!==0?1:Zr(_),(_&(d.suspendedLanes|p))!==0?0:_}function Zr(d){switch(d){case 2:d=1;break;case 8:d=4;break;case 32:d=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:d=128;break;case 268435456:d=134217728;break;default:d=0}return d}function mi(d){return d&=-d,2<d?8<d?(d&134217727)!==0?32:268435456:8:2}function Pi(){var d=G.p;return d!==0?d:(d=window.event,d===void 0?32:V4(d.type))}function qi(d,p){var _=G.p;try{return G.p=d,p()}finally{G.p=_}}var Lr=Math.random().toString(36).slice(2),hr="__reactFiber$"+Lr,Ar="__reactProps$"+Lr,no="__reactContainer$"+Lr,Oc="__reactEvents$"+Lr,ue="__reactListeners$"+Lr,Ue="__reactHandles$"+Lr,qe="__reactResources$"+Lr,Ke="__reactMarker$"+Lr;function We(d){delete d[hr],delete d[Ar],delete d[Oc],delete d[ue],delete d[Ue]}function St(d){var p=d[hr];if(p)return p;for(var _=d.parentNode;_;){if(p=_[no]||_[hr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(d=C4(d);d!==null;){if(_=d[hr])return _;d=C4(d)}return p}d=_,_=d.parentNode}return null}function J(d){if(d=d[hr]||d[no]){var p=d.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return d}return null}function _e(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d.stateNode;throw Error(r(33))}function Ne(d){var p=d[qe];return p||(p=d[qe]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Ce(d){d[Ke]=!0}var Me=new Set,Qe={};function ft(d,p){vt(d,p),vt(d+"Capture",p)}function vt(d,p){for(Qe[d]=p,d=0;d<p.length;d++)Me.add(p[d])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Pt={},Mt={};function mt(d){return le.call(Mt,d)?!0:le.call(Pt,d)?!1:xt.test(d)?Mt[d]=!0:(Pt[d]=!0,!1)}function Gt(d,p,_){if(mt(p))if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":d.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){d.removeAttribute(p);return}}d.setAttribute(p,""+_)}}function Lt(d,p,_){if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(p);return}d.setAttribute(p,""+_)}}function en(d,p,_,S){if(S===null)d.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(_);return}d.setAttributeNS(p,_,""+S)}}function un(d){switch(typeof d){case"bigint":case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function gn(d){var p=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ot(d,p,_){var S=Object.getOwnPropertyDescriptor(d.constructor.prototype,p);if(!d.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var P=S.get,D=S.set;return Object.defineProperty(d,p,{configurable:!0,get:function(){return P.call(this)},set:function(W){_=""+W,D.call(this,W)}}),Object.defineProperty(d,p,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(W){_=""+W},stopTracking:function(){d._valueTracker=null,delete d[p]}}}}function Xt(d){if(!d._valueTracker){var p=gn(d)?"checked":"value";d._valueTracker=Ot(d,p,""+d[p])}}function Zt(d){if(!d)return!1;var p=d._valueTracker;if(!p)return!0;var _=p.getValue(),S="";return d&&(S=gn(d)?d.checked?"true":"false":d.value),d=S,d!==_?(p.setValue(d),!0):!1}function br(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}var Tr=/[\n"\\]/g;function Nn(d){return d.replace(Tr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function ro(d,p,_,S,P,D,W,re){d.name="",W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"?d.type=W:d.removeAttribute("type"),p!=null?W==="number"?(p===0&&d.value===""||d.value!=p)&&(d.value=""+un(p)):d.value!==""+un(p)&&(d.value=""+un(p)):W!=="submit"&&W!=="reset"||d.removeAttribute("value"),p!=null?gi(d,W,un(p)):_!=null?gi(d,W,un(_)):S!=null&&d.removeAttribute("value"),P==null&&D!=null&&(d.defaultChecked=!!D),P!=null&&(d.checked=P&&typeof P!="function"&&typeof P!="symbol"),re!=null&&typeof re!="function"&&typeof re!="symbol"&&typeof re!="boolean"?d.name=""+un(re):d.removeAttribute("name")}function Pn(d,p,_,S,P,D,W,re){if(D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(d.type=D),p!=null||_!=null){if(!(D!=="submit"&&D!=="reset"||p!=null)){Xt(d);return}_=_!=null?""+un(_):"",p=p!=null?""+un(p):_,re||p===d.value||(d.value=p),d.defaultValue=p}S=S??P,S=typeof S!="function"&&typeof S!="symbol"&&!!S,d.checked=re?d.checked:!!S,d.defaultChecked=!!S,W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"&&(d.name=W),Xt(d)}function gi(d,p,_){p==="number"&&br(d.ownerDocument)===d||d.defaultValue===""+_||(d.defaultValue=""+_)}function Qr(d,p,_,S){if(d=d.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<d.length;_++)P=p.hasOwnProperty("$"+d[_].value),d[_].selected!==P&&(d[_].selected=P),P&&S&&(d[_].defaultSelected=!0)}else{for(_=""+un(_),p=null,P=0;P<d.length;P++){if(d[P].value===_){d[P].selected=!0,S&&(d[P].defaultSelected=!0);return}p!==null||d[P].disabled||(p=d[P])}p!==null&&(p.selected=!0)}}function xi(d,p,_){if(p!=null&&(p=""+un(p),p!==d.value&&(d.value=p),_==null)){d.defaultValue!==p&&(d.defaultValue=p);return}d.defaultValue=_!=null?""+un(_):""}function ki(d,p,_,S){if(p==null){if(S!=null){if(_!=null)throw Error(r(92));if(B(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),p=_}_=un(p),d.defaultValue=_,S=d.textContent,S===_&&S!==""&&S!==null&&(d.value=S),Xt(d)}function No(d,p){if(p){var _=d.firstChild;if(_&&_===d.lastChild&&_.nodeType===3){_.nodeValue=p;return}}d.textContent=p}var fl=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 xL(d,p,_){var S=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?d.setProperty(p,""):p==="float"?d.cssFloat="":d[p]="":S?d.setProperty(p,_):typeof _!="number"||_===0||fl.has(p)?p==="float"?d.cssFloat=_:d[p]=(""+_).trim():d[p]=_+"px"}function vL(d,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(d=d.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?d.setProperty(S,""):S==="float"?d.cssFloat="":d[S]="");for(var P in p)S=p[P],p.hasOwnProperty(P)&&_[P]!==S&&xL(d,P,S)}else for(var D in p)p.hasOwnProperty(D)&&xL(d,D,p[D])}function SM(d){if(d.indexOf("-")===-1)return!1;switch(d){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var tee=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),nee=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yv(d){return nee.test(""+d)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":d}function hl(){}var wM=null;function MM(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var Qf=null,Jf=null;function bL(d){var p=J(d);if(p&&(d=p.stateNode)){var _=d[Ar]||null;e:switch(d=p.stateNode,p.type){case"input":if(ro(d,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=d;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Nn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var S=_[p];if(S!==d&&S.form===d.form){var P=S[Ar]||null;if(!P)throw Error(r(90));ro(S,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)S=_[p],S.form===d.form&&Zt(S)}break e;case"textarea":xi(d,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&Qr(d,!!_.multiple,p,!1)}}}var EM=!1;function yL(d,p,_){if(EM)return d(p,_);EM=!0;try{var S=d(p);return S}finally{if(EM=!1,(Qf!==null||Jf!==null)&&(ob(),Qf&&(p=Qf,d=Jf,Jf=Qf=null,bL(p),d)))for(p=0;p<d.length;p++)bL(d[p])}}function Hm(d,p){var _=d.stateNode;if(_===null)return null;var S=_[Ar]||null;if(S===null)return null;_=S[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(d=d.type,S=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!S;break e;default:d=!1}if(d)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var pl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),AM=!1;if(pl)try{var $m={};Object.defineProperty($m,"passive",{get:function(){AM=!0}}),window.addEventListener("test",$m,$m),window.removeEventListener("test",$m,$m)}catch{AM=!1}var Lc=null,TM=null,_v=null;function _L(){if(_v)return _v;var d,p=TM,_=p.length,S,P="value"in Lc?Lc.value:Lc.textContent,D=P.length;for(d=0;d<_&&p[d]===P[d];d++);var W=_-d;for(S=1;S<=W&&p[_-S]===P[D-S];S++);return _v=P.slice(d,1<S?1-S:void 0)}function Sv(d){var p=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&p===13&&(d=13)):d=p,d===10&&(d=13),32<=d||d===13?d:0}function wv(){return!0}function SL(){return!1}function Ta(d){function p(_,S,P,D,W){this._reactName=_,this._targetInst=P,this.type=S,this.nativeEvent=D,this.target=W,this.currentTarget=null;for(var re in d)d.hasOwnProperty(re)&&(_=d[re],this[re]=_?_(D):D[re]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?wv:SL,this.isPropagationStopped=SL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=wv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=wv)},persist:function(){},isPersistent:wv}),p}var md={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Mv=Ta(md),Vm=f({},md,{view:0,detail:0}),ree=Ta(Vm),CM,NM,Gm,Ev=f({},Vm,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:PM,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==Gm&&(Gm&&d.type==="mousemove"?(CM=d.screenX-Gm.screenX,NM=d.screenY-Gm.screenY):NM=CM=0,Gm=d),CM)},movementY:function(d){return"movementY"in d?d.movementY:NM}}),wL=Ta(Ev),iee=f({},Ev,{dataTransfer:0}),aee=Ta(iee),see=f({},Vm,{relatedTarget:0}),RM=Ta(see),oee=f({},md,{animationName:0,elapsedTime:0,pseudoElement:0}),lee=Ta(oee),cee=f({},md,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),uee=Ta(cee),dee=f({},md,{data:0}),ML=Ta(dee),fee={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hee={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},pee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mee(d){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(d):(d=pee[d])?!!p[d]:!1}function PM(){return mee}var gee=f({},Vm,{key:function(d){if(d.key){var p=fee[d.key]||d.key;if(p!=="Unidentified")return p}return d.type==="keypress"?(d=Sv(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?hee[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:PM,charCode:function(d){return d.type==="keypress"?Sv(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?Sv(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),xee=Ta(gee),vee=f({},Ev,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),EL=Ta(vee),bee=f({},Vm,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:PM}),yee=Ta(bee),_ee=f({},md,{propertyName:0,elapsedTime:0,pseudoElement:0}),See=Ta(_ee),wee=f({},Ev,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),Mee=Ta(wee),Eee=f({},md,{newState:0,oldState:0}),Aee=Ta(Eee),Tee=[9,13,27,32],kM=pl&&"CompositionEvent"in window,Wm=null;pl&&"documentMode"in document&&(Wm=document.documentMode);var Cee=pl&&"TextEvent"in window&&!Wm,AL=pl&&(!kM||Wm&&8<Wm&&11>=Wm),TL=" ",CL=!1;function NL(d,p){switch(d){case"keyup":return Tee.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function RL(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var eh=!1;function Nee(d,p){switch(d){case"compositionend":return RL(p);case"keypress":return p.which!==32?null:(CL=!0,TL);case"textInput":return d=p.data,d===TL&&CL?null:d;default:return null}}function Ree(d,p){if(eh)return d==="compositionend"||!kM&&NL(d,p)?(d=_L(),_v=TM=Lc=null,eh=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return AL&&p.locale!=="ko"?null:p.data;default:return null}}var Pee={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function PL(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p==="input"?!!Pee[d.type]:p==="textarea"}function kL(d,p,_,S){Qf?Jf?Jf.push(S):Jf=[S]:Qf=S,p=pb(p,"onChange"),0<p.length&&(_=new Mv("onChange","change",null,_,S),d.push({event:_,listeners:p}))}var qm=null,Xm=null;function kee(d){p4(d,0)}function Av(d){var p=_e(d);if(Zt(p))return d}function DL(d,p){if(d==="change")return p}var OL=!1;if(pl){var DM;if(pl){var OM="oninput"in document;if(!OM){var LL=document.createElement("div");LL.setAttribute("oninput","return;"),OM=typeof LL.oninput=="function"}DM=OM}else DM=!1;OL=DM&&(!document.documentMode||9<document.documentMode)}function IL(){qm&&(qm.detachEvent("onpropertychange",jL),Xm=qm=null)}function jL(d){if(d.propertyName==="value"&&Av(Xm)){var p=[];kL(p,Xm,d,MM(d)),yL(kee,p)}}function Dee(d,p,_){d==="focusin"?(IL(),qm=p,Xm=_,qm.attachEvent("onpropertychange",jL)):d==="focusout"&&IL()}function Oee(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return Av(Xm)}function Lee(d,p){if(d==="click")return Av(p)}function Iee(d,p){if(d==="input"||d==="change")return Av(p)}function jee(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var Xa=typeof Object.is=="function"?Object.is:jee;function Km(d,p){if(Xa(d,p))return!0;if(typeof d!="object"||d===null||typeof p!="object"||p===null)return!1;var _=Object.keys(d),S=Object.keys(p);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var P=_[S];if(!le.call(p,P)||!Xa(d[P],p[P]))return!1}return!0}function UL(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function FL(d,p){var _=UL(d);d=0;for(var S;_;){if(_.nodeType===3){if(S=d+_.textContent.length,d<=p&&S>=p)return{node:_,offset:p-d};d=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=UL(_)}}function zL(d,p){return d&&p?d===p?!0:d&&d.nodeType===3?!1:p&&p.nodeType===3?zL(d,p.parentNode):"contains"in d?d.contains(p):d.compareDocumentPosition?!!(d.compareDocumentPosition(p)&16):!1:!1}function BL(d){d=d!=null&&d.ownerDocument!=null&&d.ownerDocument.defaultView!=null?d.ownerDocument.defaultView:window;for(var p=br(d.document);p instanceof d.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)d=p.contentWindow;else break;p=br(d.document)}return p}function LM(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p&&(p==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||p==="textarea"||d.contentEditable==="true")}var Uee=pl&&"documentMode"in document&&11>=document.documentMode,th=null,IM=null,Ym=null,jM=!1;function HL(d,p,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;jM||th==null||th!==br(S)||(S=th,"selectionStart"in S&&LM(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),Ym&&Km(Ym,S)||(Ym=S,S=pb(IM,"onSelect"),0<S.length&&(p=new Mv("onSelect","select",null,p,_),d.push({event:p,listeners:S}),p.target=th)))}function gd(d,p){var _={};return _[d.toLowerCase()]=p.toLowerCase(),_["Webkit"+d]="webkit"+p,_["Moz"+d]="moz"+p,_}var nh={animationend:gd("Animation","AnimationEnd"),animationiteration:gd("Animation","AnimationIteration"),animationstart:gd("Animation","AnimationStart"),transitionrun:gd("Transition","TransitionRun"),transitionstart:gd("Transition","TransitionStart"),transitioncancel:gd("Transition","TransitionCancel"),transitionend:gd("Transition","TransitionEnd")},UM={},$L={};pl&&($L=document.createElement("div").style,"AnimationEvent"in window||(delete nh.animationend.animation,delete nh.animationiteration.animation,delete nh.animationstart.animation),"TransitionEvent"in window||delete nh.transitionend.transition);function xd(d){if(UM[d])return UM[d];if(!nh[d])return d;var p=nh[d],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in $L)return UM[d]=p[_];return d}var VL=xd("animationend"),GL=xd("animationiteration"),WL=xd("animationstart"),Fee=xd("transitionrun"),zee=xd("transitionstart"),Bee=xd("transitioncancel"),qL=xd("transitionend"),XL=new Map,FM="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(" ");FM.push("scrollEnd");function io(d,p){XL.set(d,p),ft(p,[d])}var Tv=typeof reportError=="function"?reportError:function(d){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof d=="object"&&d!==null&&typeof d.message=="string"?String(d.message):String(d),error:d});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",d);return}console.error(d)},vs=[],rh=0,zM=0;function Cv(){for(var d=rh,p=zM=rh=0;p<d;){var _=vs[p];vs[p++]=null;var S=vs[p];vs[p++]=null;var P=vs[p];vs[p++]=null;var D=vs[p];if(vs[p++]=null,S!==null&&P!==null){var W=S.pending;W===null?P.next=P:(P.next=W.next,W.next=P),S.pending=P}D!==0&&KL(_,P,D)}}function Nv(d,p,_,S){vs[rh++]=d,vs[rh++]=p,vs[rh++]=_,vs[rh++]=S,zM|=S,d.lanes|=S,d=d.alternate,d!==null&&(d.lanes|=S)}function BM(d,p,_,S){return Nv(d,p,_,S),Rv(d)}function vd(d,p){return Nv(d,null,null,p),Rv(d)}function KL(d,p,_){d.lanes|=_;var S=d.alternate;S!==null&&(S.lanes|=_);for(var P=!1,D=d.return;D!==null;)D.childLanes|=_,S=D.alternate,S!==null&&(S.childLanes|=_),D.tag===22&&(d=D.stateNode,d===null||d._visibility&1||(P=!0)),d=D,D=D.return;return d.tag===3?(D=d.stateNode,P&&p!==null&&(P=31-rt(_),d=D.hiddenUpdates,S=d[P],S===null?d[P]=[p]:S.push(p),p.lane=_|536870912),D):null}function Rv(d){if(50<vg)throw vg=0,YE=null,Error(r(185));for(var p=d.return;p!==null;)d=p,p=d.return;return d.tag===3?d.stateNode:null}var ih={};function Hee(d,p,_,S){this.tag=d,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=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ka(d,p,_,S){return new Hee(d,p,_,S)}function HM(d){return d=d.prototype,!(!d||!d.isReactComponent)}function ml(d,p){var _=d.alternate;return _===null?(_=Ka(d.tag,p,d.key,d.mode),_.elementType=d.elementType,_.type=d.type,_.stateNode=d.stateNode,_.alternate=d,d.alternate=_):(_.pendingProps=p,_.type=d.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=d.flags&65011712,_.childLanes=d.childLanes,_.lanes=d.lanes,_.child=d.child,_.memoizedProps=d.memoizedProps,_.memoizedState=d.memoizedState,_.updateQueue=d.updateQueue,p=d.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=d.sibling,_.index=d.index,_.ref=d.ref,_.refCleanup=d.refCleanup,_}function YL(d,p){d.flags&=65011714;var _=d.alternate;return _===null?(d.childLanes=0,d.lanes=p,d.child=null,d.subtreeFlags=0,d.memoizedProps=null,d.memoizedState=null,d.updateQueue=null,d.dependencies=null,d.stateNode=null):(d.childLanes=_.childLanes,d.lanes=_.lanes,d.child=_.child,d.subtreeFlags=0,d.deletions=null,d.memoizedProps=_.memoizedProps,d.memoizedState=_.memoizedState,d.updateQueue=_.updateQueue,d.type=_.type,p=_.dependencies,d.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),d}function Pv(d,p,_,S,P,D){var W=0;if(S=d,typeof d=="function")HM(d)&&(W=1);else if(typeof d=="string")W=qte(d,_,ce.current)?26:d==="html"||d==="head"||d==="body"?27:5;else e:switch(d){case C:return d=Ka(31,_,p,P),d.elementType=C,d.lanes=D,d;case v:return bd(_.children,P,D,p);case b:W=8,P|=24;break;case x:return d=Ka(12,_,p,P|2),d.elementType=x,d.lanes=D,d;case T:return d=Ka(13,_,p,P),d.elementType=T,d.lanes=D,d;case R:return d=Ka(19,_,p,P),d.elementType=R,d.lanes=D,d;default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case w:W=10;break e;case M:W=9;break e;case A:W=11;break e;case N:W=14;break e;case j:W=16,S=null;break e}W=29,_=Error(r(130,d===null?"null":typeof d,"")),S=null}return p=Ka(W,_,p,P),p.elementType=d,p.type=S,p.lanes=D,p}function bd(d,p,_,S){return d=Ka(7,d,S,p),d.lanes=_,d}function $M(d,p,_){return d=Ka(6,d,null,p),d.lanes=_,d}function ZL(d){var p=Ka(18,null,null,0);return p.stateNode=d,p}function VM(d,p,_){return p=Ka(4,d.children!==null?d.children:[],d.key,p),p.lanes=_,p.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},p}var QL=new WeakMap;function bs(d,p){if(typeof d=="object"&&d!==null){var _=QL.get(d);return _!==void 0?_:(p={value:d,source:p,stack:ee(p)},QL.set(d,p),p)}return{value:d,source:p,stack:ee(p)}}var ah=[],sh=0,kv=null,Zm=0,ys=[],_s=0,Ic=null,Ro=1,Po="";function gl(d,p){ah[sh++]=Zm,ah[sh++]=kv,kv=d,Zm=p}function JL(d,p,_){ys[_s++]=Ro,ys[_s++]=Po,ys[_s++]=Ic,Ic=d;var S=Ro;d=Po;var P=32-rt(S)-1;S&=~(1<<P),_+=1;var D=32-rt(p)+P;if(30<D){var W=P-P%5;D=(S&(1<<W)-1).toString(32),S>>=W,P-=W,Ro=1<<32-rt(p)+P|_<<P|S,Po=D+d}else Ro=1<<D|_<<P|S,Po=d}function GM(d){d.return!==null&&(gl(d,1),JL(d,1,0))}function WM(d){for(;d===kv;)kv=ah[--sh],ah[sh]=null,Zm=ah[--sh],ah[sh]=null;for(;d===Ic;)Ic=ys[--_s],ys[_s]=null,Po=ys[--_s],ys[_s]=null,Ro=ys[--_s],ys[_s]=null}function eI(d,p){ys[_s++]=Ro,ys[_s++]=Po,ys[_s++]=Ic,Ro=p.id,Po=p.overflow,Ic=d}var Di=null,tr=null,yn=!1,jc=null,Ss=!1,qM=Error(r(519));function Uc(d){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qm(bs(p,d)),qM}function tI(d){var p=d.stateNode,_=d.type,S=d.memoizedProps;switch(p[hr]=d,p[Ar]=S,_){case"dialog":hn("cancel",p),hn("close",p);break;case"iframe":case"object":case"embed":hn("load",p);break;case"video":case"audio":for(_=0;_<yg.length;_++)hn(yg[_],p);break;case"source":hn("error",p);break;case"img":case"image":case"link":hn("error",p),hn("load",p);break;case"details":hn("toggle",p);break;case"input":hn("invalid",p),Pn(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":hn("invalid",p);break;case"textarea":hn("invalid",p),ki(p,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||S.suppressHydrationWarning===!0||v4(p.textContent,_)?(S.popover!=null&&(hn("beforetoggle",p),hn("toggle",p)),S.onScroll!=null&&hn("scroll",p),S.onScrollEnd!=null&&hn("scrollend",p),S.onClick!=null&&(p.onclick=hl),p=!0):p=!1,p||Uc(d,!0)}function nI(d){for(Di=d.return;Di;)switch(Di.tag){case 5:case 31:case 13:Ss=!1;return;case 27:case 3:Ss=!0;return;default:Di=Di.return}}function oh(d){if(d!==Di)return!1;if(!yn)return nI(d),yn=!0,!1;var p=d.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=d.type,_=!(_!=="form"&&_!=="button")||dA(d.type,d.memoizedProps)),_=!_),_&&tr&&Uc(d),nI(d),p===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=T4(d)}else if(p===31){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=T4(d)}else p===27?(p=tr,Qc(d.type)?(d=gA,gA=null,tr=d):tr=p):tr=Di?Ms(d.stateNode.nextSibling):null;return!0}function yd(){tr=Di=null,yn=!1}function XM(){var d=jc;return d!==null&&(Pa===null?Pa=d:Pa.push.apply(Pa,d),jc=null),d}function Qm(d){jc===null?jc=[d]:jc.push(d)}var KM=$(null),_d=null,xl=null;function Fc(d,p,_){ae(KM,p._currentValue),p._currentValue=_}function vl(d){d._currentValue=KM.current,X(KM)}function YM(d,p,_){for(;d!==null;){var S=d.alternate;if((d.childLanes&p)!==p?(d.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),d===_)break;d=d.return}}function ZM(d,p,_,S){var P=d.child;for(P!==null&&(P.return=d);P!==null;){var D=P.dependencies;if(D!==null){var W=P.child;D=D.firstContext;e:for(;D!==null;){var re=D;D=P;for(var Se=0;Se<p.length;Se++)if(re.context===p[Se]){D.lanes|=_,re=D.alternate,re!==null&&(re.lanes|=_),YM(D.return,_,d),S||(W=null);break e}D=re.next}}else if(P.tag===18){if(W=P.return,W===null)throw Error(r(341));W.lanes|=_,D=W.alternate,D!==null&&(D.lanes|=_),YM(W,_,d),W=null}else W=P.child;if(W!==null)W.return=P;else for(W=P;W!==null;){if(W===d){W=null;break}if(P=W.sibling,P!==null){P.return=W.return,W=P;break}W=W.return}P=W}}function lh(d,p,_,S){d=null;for(var P=p,D=!1;P!==null;){if(!D){if((P.flags&524288)!==0)D=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var W=P.alternate;if(W===null)throw Error(r(387));if(W=W.memoizedProps,W!==null){var re=P.type;Xa(P.pendingProps.value,W.value)||(d!==null?d.push(re):d=[re])}}else if(P===ve.current){if(W=P.alternate,W===null)throw Error(r(387));W.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(d!==null?d.push(Eg):d=[Eg])}P=P.return}d!==null&&ZM(p,d,_,S),p.flags|=262144}function Dv(d){for(d=d.firstContext;d!==null;){if(!Xa(d.context._currentValue,d.memoizedValue))return!0;d=d.next}return!1}function Sd(d){_d=d,xl=null,d=d.dependencies,d!==null&&(d.firstContext=null)}function Oi(d){return rI(_d,d)}function Ov(d,p){return _d===null&&Sd(d),rI(d,p)}function rI(d,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},xl===null){if(d===null)throw Error(r(308));xl=p,d.dependencies={lanes:0,firstContext:p},d.flags|=524288}else xl=xl.next=p;return _}var $ee=typeof AbortController<"u"?AbortController:function(){var d=[],p=this.signal={aborted:!1,addEventListener:function(_,S){d.push(S)}};this.abort=function(){p.aborted=!0,d.forEach(function(_){return _()})}},Vee=t.unstable_scheduleCallback,Gee=t.unstable_NormalPriority,Ir={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function QM(){return{controller:new $ee,data:new Map,refCount:0}}function Jm(d){d.refCount--,d.refCount===0&&Vee(Gee,function(){d.controller.abort()})}var eg=null,JM=0,ch=0,uh=null;function Wee(d,p){if(eg===null){var _=eg=[];JM=0,ch=nA(),uh={status:"pending",value:void 0,then:function(S){_.push(S)}}}return JM++,p.then(iI,iI),p}function iI(){if(--JM===0&&eg!==null){uh!==null&&(uh.status="fulfilled");var d=eg;eg=null,ch=0,uh=null;for(var p=0;p<d.length;p++)(0,d[p])()}}function qee(d,p){var _=[],S={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return d.then(function(){S.status="fulfilled",S.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(S.status="rejected",S.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),S}var aI=V.S;V.S=function(d,p){Hj=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&Wee(d,p),aI!==null&&aI(d,p)};var wd=$(null);function eE(){var d=wd.current;return d!==null?d:Xn.pooledCache}function Lv(d,p){p===null?ae(wd,wd.current):ae(wd,p.pool)}function sI(){var d=eE();return d===null?null:{parent:Ir._currentValue,pool:d}}var dh=Error(r(460)),tE=Error(r(474)),Iv=Error(r(542)),jv={then:function(){}};function oI(d){return d=d.status,d==="fulfilled"||d==="rejected"}function lI(d,p,_){switch(_=d[_],_===void 0?d.push(p):_!==p&&(p.then(hl,hl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,uI(d),d;default:if(typeof p.status=="string")p.then(hl,hl);else{if(d=Xn,d!==null&&100<d.shellSuspendCounter)throw Error(r(482));d=p,d.status="pending",d.then(function(S){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=S}},function(S){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=S}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,uI(d),d}throw Ed=p,dh}}function Md(d){try{var p=d._init;return p(d._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ed=_,dh):_}}var Ed=null;function cI(){if(Ed===null)throw Error(r(459));var d=Ed;return Ed=null,d}function uI(d){if(d===dh||d===Iv)throw Error(r(483))}var fh=null,tg=0;function Uv(d){var p=tg;return tg+=1,fh===null&&(fh=[]),lI(fh,d,p)}function ng(d,p){p=p.props.ref,d.ref=p!==void 0?p:null}function Fv(d,p){throw p.$$typeof===g?Error(r(525)):(d=Object.prototype.toString.call(p),Error(r(31,d==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":d)))}function dI(d){function p(Oe,Ae){if(d){var ze=Oe.deletions;ze===null?(Oe.deletions=[Ae],Oe.flags|=16):ze.push(Ae)}}function _(Oe,Ae){if(!d)return null;for(;Ae!==null;)p(Oe,Ae),Ae=Ae.sibling;return null}function S(Oe){for(var Ae=new Map;Oe!==null;)Oe.key!==null?Ae.set(Oe.key,Oe):Ae.set(Oe.index,Oe),Oe=Oe.sibling;return Ae}function P(Oe,Ae){return Oe=ml(Oe,Ae),Oe.index=0,Oe.sibling=null,Oe}function D(Oe,Ae,ze){return Oe.index=ze,d?(ze=Oe.alternate,ze!==null?(ze=ze.index,ze<Ae?(Oe.flags|=67108866,Ae):ze):(Oe.flags|=67108866,Ae)):(Oe.flags|=1048576,Ae)}function W(Oe){return d&&Oe.alternate===null&&(Oe.flags|=67108866),Oe}function re(Oe,Ae,ze,at){return Ae===null||Ae.tag!==6?(Ae=$M(ze,Oe.mode,at),Ae.return=Oe,Ae):(Ae=P(Ae,ze),Ae.return=Oe,Ae)}function Se(Oe,Ae,ze,at){var It=ze.type;return It===v?et(Oe,Ae,ze.props.children,at,ze.key):Ae!==null&&(Ae.elementType===It||typeof It=="object"&&It!==null&&It.$$typeof===j&&Md(It)===Ae.type)?(Ae=P(Ae,ze.props),ng(Ae,ze),Ae.return=Oe,Ae):(Ae=Pv(ze.type,ze.key,ze.props,null,Oe.mode,at),ng(Ae,ze),Ae.return=Oe,Ae)}function Be(Oe,Ae,ze,at){return Ae===null||Ae.tag!==4||Ae.stateNode.containerInfo!==ze.containerInfo||Ae.stateNode.implementation!==ze.implementation?(Ae=VM(ze,Oe.mode,at),Ae.return=Oe,Ae):(Ae=P(Ae,ze.children||[]),Ae.return=Oe,Ae)}function et(Oe,Ae,ze,at,It){return Ae===null||Ae.tag!==7?(Ae=bd(ze,Oe.mode,at,It),Ae.return=Oe,Ae):(Ae=P(Ae,ze),Ae.return=Oe,Ae)}function lt(Oe,Ae,ze){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number"||typeof Ae=="bigint")return Ae=$M(""+Ae,Oe.mode,ze),Ae.return=Oe,Ae;if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case m:return ze=Pv(Ae.type,Ae.key,Ae.props,null,Oe.mode,ze),ng(ze,Ae),ze.return=Oe,ze;case y:return Ae=VM(Ae,Oe.mode,ze),Ae.return=Oe,Ae;case j:return Ae=Md(Ae),lt(Oe,Ae,ze)}if(B(Ae)||I(Ae))return Ae=bd(Ae,Oe.mode,ze,null),Ae.return=Oe,Ae;if(typeof Ae.then=="function")return lt(Oe,Uv(Ae),ze);if(Ae.$$typeof===w)return lt(Oe,Ov(Oe,Ae),ze);Fv(Oe,Ae)}return null}function Ve(Oe,Ae,ze,at){var It=Ae!==null?Ae.key:null;if(typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint")return It!==null?null:re(Oe,Ae,""+ze,at);if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case m:return ze.key===It?Se(Oe,Ae,ze,at):null;case y:return ze.key===It?Be(Oe,Ae,ze,at):null;case j:return ze=Md(ze),Ve(Oe,Ae,ze,at)}if(B(ze)||I(ze))return It!==null?null:et(Oe,Ae,ze,at,null);if(typeof ze.then=="function")return Ve(Oe,Ae,Uv(ze),at);if(ze.$$typeof===w)return Ve(Oe,Ae,Ov(Oe,ze),at);Fv(Oe,ze)}return null}function Ye(Oe,Ae,ze,at,It){if(typeof at=="string"&&at!==""||typeof at=="number"||typeof at=="bigint")return Oe=Oe.get(ze)||null,re(Ae,Oe,""+at,It);if(typeof at=="object"&&at!==null){switch(at.$$typeof){case m:return Oe=Oe.get(at.key===null?ze:at.key)||null,Se(Ae,Oe,at,It);case y:return Oe=Oe.get(at.key===null?ze:at.key)||null,Be(Ae,Oe,at,It);case j:return at=Md(at),Ye(Oe,Ae,ze,at,It)}if(B(at)||I(at))return Oe=Oe.get(ze)||null,et(Ae,Oe,at,It,null);if(typeof at.then=="function")return Ye(Oe,Ae,ze,Uv(at),It);if(at.$$typeof===w)return Ye(Oe,Ae,ze,Ov(Ae,at),It);Fv(Ae,at)}return null}function Nt(Oe,Ae,ze,at){for(var It=null,wn=null,kt=Ae,Jt=Ae=0,vn=null;kt!==null&&Jt<ze.length;Jt++){kt.index>Jt?(vn=kt,kt=null):vn=kt.sibling;var Mn=Ve(Oe,kt,ze[Jt],at);if(Mn===null){kt===null&&(kt=vn);break}d&&kt&&Mn.alternate===null&&p(Oe,kt),Ae=D(Mn,Ae,Jt),wn===null?It=Mn:wn.sibling=Mn,wn=Mn,kt=vn}if(Jt===ze.length)return _(Oe,kt),yn&&gl(Oe,Jt),It;if(kt===null){for(;Jt<ze.length;Jt++)kt=lt(Oe,ze[Jt],at),kt!==null&&(Ae=D(kt,Ae,Jt),wn===null?It=kt:wn.sibling=kt,wn=kt);return yn&&gl(Oe,Jt),It}for(kt=S(kt);Jt<ze.length;Jt++)vn=Ye(kt,Oe,Jt,ze[Jt],at),vn!==null&&(d&&vn.alternate!==null&&kt.delete(vn.key===null?Jt:vn.key),Ae=D(vn,Ae,Jt),wn===null?It=vn:wn.sibling=vn,wn=vn);return d&&kt.forEach(function(ru){return p(Oe,ru)}),yn&&gl(Oe,Jt),It}function Ht(Oe,Ae,ze,at){if(ze==null)throw Error(r(151));for(var It=null,wn=null,kt=Ae,Jt=Ae=0,vn=null,Mn=ze.next();kt!==null&&!Mn.done;Jt++,Mn=ze.next()){kt.index>Jt?(vn=kt,kt=null):vn=kt.sibling;var ru=Ve(Oe,kt,Mn.value,at);if(ru===null){kt===null&&(kt=vn);break}d&&kt&&ru.alternate===null&&p(Oe,kt),Ae=D(ru,Ae,Jt),wn===null?It=ru:wn.sibling=ru,wn=ru,kt=vn}if(Mn.done)return _(Oe,kt),yn&&gl(Oe,Jt),It;if(kt===null){for(;!Mn.done;Jt++,Mn=ze.next())Mn=lt(Oe,Mn.value,at),Mn!==null&&(Ae=D(Mn,Ae,Jt),wn===null?It=Mn:wn.sibling=Mn,wn=Mn);return yn&&gl(Oe,Jt),It}for(kt=S(kt);!Mn.done;Jt++,Mn=ze.next())Mn=Ye(kt,Oe,Jt,Mn.value,at),Mn!==null&&(d&&Mn.alternate!==null&&kt.delete(Mn.key===null?Jt:Mn.key),Ae=D(Mn,Ae,Jt),wn===null?It=Mn:wn.sibling=Mn,wn=Mn);return d&&kt.forEach(function(ine){return p(Oe,ine)}),yn&&gl(Oe,Jt),It}function Fn(Oe,Ae,ze,at){if(typeof ze=="object"&&ze!==null&&ze.type===v&&ze.key===null&&(ze=ze.props.children),typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case m:e:{for(var It=ze.key;Ae!==null;){if(Ae.key===It){if(It=ze.type,It===v){if(Ae.tag===7){_(Oe,Ae.sibling),at=P(Ae,ze.props.children),at.return=Oe,Oe=at;break e}}else if(Ae.elementType===It||typeof It=="object"&&It!==null&&It.$$typeof===j&&Md(It)===Ae.type){_(Oe,Ae.sibling),at=P(Ae,ze.props),ng(at,ze),at.return=Oe,Oe=at;break e}_(Oe,Ae);break}else p(Oe,Ae);Ae=Ae.sibling}ze.type===v?(at=bd(ze.props.children,Oe.mode,at,ze.key),at.return=Oe,Oe=at):(at=Pv(ze.type,ze.key,ze.props,null,Oe.mode,at),ng(at,ze),at.return=Oe,Oe=at)}return W(Oe);case y:e:{for(It=ze.key;Ae!==null;){if(Ae.key===It)if(Ae.tag===4&&Ae.stateNode.containerInfo===ze.containerInfo&&Ae.stateNode.implementation===ze.implementation){_(Oe,Ae.sibling),at=P(Ae,ze.children||[]),at.return=Oe,Oe=at;break e}else{_(Oe,Ae);break}else p(Oe,Ae);Ae=Ae.sibling}at=VM(ze,Oe.mode,at),at.return=Oe,Oe=at}return W(Oe);case j:return ze=Md(ze),Fn(Oe,Ae,ze,at)}if(B(ze))return Nt(Oe,Ae,ze,at);if(I(ze)){if(It=I(ze),typeof It!="function")throw Error(r(150));return ze=It.call(ze),Ht(Oe,Ae,ze,at)}if(typeof ze.then=="function")return Fn(Oe,Ae,Uv(ze),at);if(ze.$$typeof===w)return Fn(Oe,Ae,Ov(Oe,ze),at);Fv(Oe,ze)}return typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint"?(ze=""+ze,Ae!==null&&Ae.tag===6?(_(Oe,Ae.sibling),at=P(Ae,ze),at.return=Oe,Oe=at):(_(Oe,Ae),at=$M(ze,Oe.mode,at),at.return=Oe,Oe=at),W(Oe)):_(Oe,Ae)}return function(Oe,Ae,ze,at){try{tg=0;var It=Fn(Oe,Ae,ze,at);return fh=null,It}catch(kt){if(kt===dh||kt===Iv)throw kt;var wn=Ka(29,kt,null,Oe.mode);return wn.lanes=at,wn.return=Oe,wn}finally{}}}var Ad=dI(!0),fI=dI(!1),zc=!1;function nE(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rE(d,p){d=d.updateQueue,p.updateQueue===d&&(p.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,callbacks:null})}function Bc(d){return{lane:d,tag:0,payload:null,callback:null,next:null}}function Hc(d,p,_){var S=d.updateQueue;if(S===null)return null;if(S=S.shared,(Cn&2)!==0){var P=S.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),S.pending=p,p=Rv(d),KL(d,null,_),p}return Nv(d,S,p,_),Rv(d)}function rg(d,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}function iE(d,p){var _=d.updateQueue,S=d.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var P=null,D=null;if(_=_.firstBaseUpdate,_!==null){do{var W={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};D===null?P=D=W:D=D.next=W,_=_.next}while(_!==null);D===null?P=D=p:D=D.next=p}else P=D=p;_={baseState:S.baseState,firstBaseUpdate:P,lastBaseUpdate:D,shared:S.shared,callbacks:S.callbacks},d.updateQueue=_;return}d=_.lastBaseUpdate,d===null?_.firstBaseUpdate=p:d.next=p,_.lastBaseUpdate=p}var aE=!1;function ig(){if(aE){var d=uh;if(d!==null)throw d}}function ag(d,p,_,S){aE=!1;var P=d.updateQueue;zc=!1;var D=P.firstBaseUpdate,W=P.lastBaseUpdate,re=P.shared.pending;if(re!==null){P.shared.pending=null;var Se=re,Be=Se.next;Se.next=null,W===null?D=Be:W.next=Be,W=Se;var et=d.alternate;et!==null&&(et=et.updateQueue,re=et.lastBaseUpdate,re!==W&&(re===null?et.firstBaseUpdate=Be:re.next=Be,et.lastBaseUpdate=Se))}if(D!==null){var lt=P.baseState;W=0,et=Be=Se=null,re=D;do{var Ve=re.lane&-536870913,Ye=Ve!==re.lane;if(Ye?(xn&Ve)===Ve:(S&Ve)===Ve){Ve!==0&&Ve===ch&&(aE=!0),et!==null&&(et=et.next={lane:0,tag:re.tag,payload:re.payload,callback:null,next:null});e:{var Nt=d,Ht=re;Ve=p;var Fn=_;switch(Ht.tag){case 1:if(Nt=Ht.payload,typeof Nt=="function"){lt=Nt.call(Fn,lt,Ve);break e}lt=Nt;break e;case 3:Nt.flags=Nt.flags&-65537|128;case 0:if(Nt=Ht.payload,Ve=typeof Nt=="function"?Nt.call(Fn,lt,Ve):Nt,Ve==null)break e;lt=f({},lt,Ve);break e;case 2:zc=!0}}Ve=re.callback,Ve!==null&&(d.flags|=64,Ye&&(d.flags|=8192),Ye=P.callbacks,Ye===null?P.callbacks=[Ve]:Ye.push(Ve))}else Ye={lane:Ve,tag:re.tag,payload:re.payload,callback:re.callback,next:null},et===null?(Be=et=Ye,Se=lt):et=et.next=Ye,W|=Ve;if(re=re.next,re===null){if(re=P.shared.pending,re===null)break;Ye=re,re=Ye.next,Ye.next=null,P.lastBaseUpdate=Ye,P.shared.pending=null}}while(!0);et===null&&(Se=lt),P.baseState=Se,P.firstBaseUpdate=Be,P.lastBaseUpdate=et,D===null&&(P.shared.lanes=0),qc|=W,d.lanes=W,d.memoizedState=lt}}function hI(d,p){if(typeof d!="function")throw Error(r(191,d));d.call(p)}function pI(d,p){var _=d.callbacks;if(_!==null)for(d.callbacks=null,d=0;d<_.length;d++)hI(_[d],p)}var hh=$(null),zv=$(0);function mI(d,p){d=Tl,ae(zv,d),ae(hh,p),Tl=d|p.baseLanes}function sE(){ae(zv,Tl),ae(hh,hh.current)}function oE(){Tl=zv.current,X(hh),X(zv)}var Ya=$(null),ws=null;function $c(d){var p=d.alternate;ae(Cr,Cr.current&1),ae(Ya,d),ws===null&&(p===null||hh.current!==null||p.memoizedState!==null)&&(ws=d)}function lE(d){ae(Cr,Cr.current),ae(Ya,d),ws===null&&(ws=d)}function gI(d){d.tag===22?(ae(Cr,Cr.current),ae(Ya,d),ws===null&&(ws=d)):Vc()}function Vc(){ae(Cr,Cr.current),ae(Ya,Ya.current)}function Za(d){X(Ya),ws===d&&(ws=null),X(Cr)}var Cr=$(0);function Bv(d){for(var p=d;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||pA(_)||mA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var bl=0,Qt=null,jn=null,jr=null,Hv=!1,ph=!1,Td=!1,$v=0,sg=0,mh=null,Xee=0;function yr(){throw Error(r(321))}function cE(d,p){if(p===null)return!1;for(var _=0;_<p.length&&_<d.length;_++)if(!Xa(d[_],p[_]))return!1;return!0}function uE(d,p,_,S,P,D){return bl=D,Qt=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,V.H=d===null||d.memoizedState===null?JI:EE,Td=!1,D=_(S,P),Td=!1,ph&&(D=vI(p,_,S,P)),xI(d),D}function xI(d){V.H=cg;var p=jn!==null&&jn.next!==null;if(bl=0,jr=jn=Qt=null,Hv=!1,sg=0,mh=null,p)throw Error(r(300));d===null||Ur||(d=d.dependencies,d!==null&&Dv(d)&&(Ur=!0))}function vI(d,p,_,S){Qt=d;var P=0;do{if(ph&&(mh=null),sg=0,ph=!1,25<=P)throw Error(r(301));if(P+=1,jr=jn=null,d.updateQueue!=null){var D=d.updateQueue;D.lastEffect=null,D.events=null,D.stores=null,D.memoCache!=null&&(D.memoCache.index=0)}V.H=ej,D=p(_,S)}while(ph);return D}function Kee(){var d=V.H,p=d.useState()[0];return p=typeof p.then=="function"?og(p):p,d=d.useState()[0],(jn!==null?jn.memoizedState:null)!==d&&(Qt.flags|=1024),p}function dE(){var d=$v!==0;return $v=0,d}function fE(d,p,_){p.updateQueue=d.updateQueue,p.flags&=-2053,d.lanes&=~_}function hE(d){if(Hv){for(d=d.memoizedState;d!==null;){var p=d.queue;p!==null&&(p.pending=null),d=d.next}Hv=!1}bl=0,jr=jn=Qt=null,ph=!1,sg=$v=0,mh=null}function ua(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jr===null?Qt.memoizedState=jr=d:jr=jr.next=d,jr}function Nr(){if(jn===null){var d=Qt.alternate;d=d!==null?d.memoizedState:null}else d=jn.next;var p=jr===null?Qt.memoizedState:jr.next;if(p!==null)jr=p,jn=d;else{if(d===null)throw Qt.alternate===null?Error(r(467)):Error(r(310));jn=d,d={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},jr===null?Qt.memoizedState=jr=d:jr=jr.next=d}return jr}function Vv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function og(d){var p=sg;return sg+=1,mh===null&&(mh=[]),d=lI(mh,d,p),p=Qt,(jr===null?p.memoizedState:jr.next)===null&&(p=p.alternate,V.H=p===null||p.memoizedState===null?JI:EE),d}function Gv(d){if(d!==null&&typeof d=="object"){if(typeof d.then=="function")return og(d);if(d.$$typeof===w)return Oi(d)}throw Error(r(438,String(d)))}function pE(d){var p=null,_=Qt.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var S=Qt.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Vv(),Qt.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(d),S=0;S<d;S++)_[S]=k;return p.index++,_}function yl(d,p){return typeof p=="function"?p(d):p}function Wv(d){var p=Nr();return mE(p,jn,d)}function mE(d,p,_){var S=d.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var P=d.baseQueue,D=S.pending;if(D!==null){if(P!==null){var W=P.next;P.next=D.next,D.next=W}p.baseQueue=P=D,S.pending=null}if(D=d.baseState,P===null)d.memoizedState=D;else{p=P.next;var re=W=null,Se=null,Be=p,et=!1;do{var lt=Be.lane&-536870913;if(lt!==Be.lane?(xn&lt)===lt:(bl&lt)===lt){var Ve=Be.revertLane;if(Ve===0)Se!==null&&(Se=Se.next={lane:0,revertLane:0,gesture:null,action:Be.action,hasEagerState:Be.hasEagerState,eagerState:Be.eagerState,next:null}),lt===ch&&(et=!0);else if((bl&Ve)===Ve){Be=Be.next,Ve===ch&&(et=!0);continue}else lt={lane:0,revertLane:Be.revertLane,gesture:null,action:Be.action,hasEagerState:Be.hasEagerState,eagerState:Be.eagerState,next:null},Se===null?(re=Se=lt,W=D):Se=Se.next=lt,Qt.lanes|=Ve,qc|=Ve;lt=Be.action,Td&&_(D,lt),D=Be.hasEagerState?Be.eagerState:_(D,lt)}else Ve={lane:lt,revertLane:Be.revertLane,gesture:Be.gesture,action:Be.action,hasEagerState:Be.hasEagerState,eagerState:Be.eagerState,next:null},Se===null?(re=Se=Ve,W=D):Se=Se.next=Ve,Qt.lanes|=lt,qc|=lt;Be=Be.next}while(Be!==null&&Be!==p);if(Se===null?W=D:Se.next=re,!Xa(D,d.memoizedState)&&(Ur=!0,et&&(_=uh,_!==null)))throw _;d.memoizedState=D,d.baseState=W,d.baseQueue=Se,S.lastRenderedState=D}return P===null&&(S.lanes=0),[d.memoizedState,S.dispatch]}function gE(d){var p=Nr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=d;var S=_.dispatch,P=_.pending,D=p.memoizedState;if(P!==null){_.pending=null;var W=P=P.next;do D=d(D,W.action),W=W.next;while(W!==P);Xa(D,p.memoizedState)||(Ur=!0),p.memoizedState=D,p.baseQueue===null&&(p.baseState=D),_.lastRenderedState=D}return[D,S]}function bI(d,p,_){var S=Qt,P=Nr(),D=yn;if(D){if(_===void 0)throw Error(r(407));_=_()}else _=p();var W=!Xa((jn||P).memoizedState,_);if(W&&(P.memoizedState=_,Ur=!0),P=P.queue,bE(SI.bind(null,S,P,d),[d]),P.getSnapshot!==p||W||jr!==null&&jr.memoizedState.tag&1){if(S.flags|=2048,gh(9,{destroy:void 0},_I.bind(null,S,P,_,p),null),Xn===null)throw Error(r(349));D||(bl&127)!==0||yI(S,p,_)}return _}function yI(d,p,_){d.flags|=16384,d={getSnapshot:p,value:_},p=Qt.updateQueue,p===null?(p=Vv(),Qt.updateQueue=p,p.stores=[d]):(_=p.stores,_===null?p.stores=[d]:_.push(d))}function _I(d,p,_,S){p.value=_,p.getSnapshot=S,wI(p)&&MI(d)}function SI(d,p,_){return _(function(){wI(p)&&MI(d)})}function wI(d){var p=d.getSnapshot;d=d.value;try{var _=p();return!Xa(d,_)}catch{return!0}}function MI(d){var p=vd(d,2);p!==null&&ka(p,d,2)}function xE(d){var p=ua();if(typeof d=="function"){var _=d;if(d=_(),Td){pt(!0);try{_()}finally{pt(!1)}}}return p.memoizedState=p.baseState=d,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yl,lastRenderedState:d},p}function EI(d,p,_,S){return d.baseState=_,mE(d,jn,typeof S=="function"?S:yl)}function Yee(d,p,_,S,P){if(Kv(d))throw Error(r(485));if(d=p.action,d!==null){var D={payload:P,action:d,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(W){D.listeners.push(W)}};V.T!==null?_(!0):D.isTransition=!1,S(D),_=p.pending,_===null?(D.next=p.pending=D,AI(p,D)):(D.next=_.next,p.pending=_.next=D)}}function AI(d,p){var _=p.action,S=p.payload,P=d.state;if(p.isTransition){var D=V.T,W={};V.T=W;try{var re=_(P,S),Se=V.S;Se!==null&&Se(W,re),TI(d,p,re)}catch(Be){vE(d,p,Be)}finally{D!==null&&W.types!==null&&(D.types=W.types),V.T=D}}else try{D=_(P,S),TI(d,p,D)}catch(Be){vE(d,p,Be)}}function TI(d,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){CI(d,p,S)},function(S){return vE(d,p,S)}):CI(d,p,_)}function CI(d,p,_){p.status="fulfilled",p.value=_,NI(p),d.state=_,p=d.pending,p!==null&&(_=p.next,_===p?d.pending=null:(_=_.next,p.next=_,AI(d,_)))}function vE(d,p,_){var S=d.pending;if(d.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=_,NI(p),p=p.next;while(p!==S)}d.action=null}function NI(d){d=d.listeners;for(var p=0;p<d.length;p++)(0,d[p])()}function RI(d,p){return p}function PI(d,p){if(yn){var _=Xn.formState;if(_!==null){e:{var S=Qt;if(yn){if(tr){t:{for(var P=tr,D=Ss;P.nodeType!==8;){if(!D){P=null;break t}if(P=Ms(P.nextSibling),P===null){P=null;break t}}D=P.data,P=D==="F!"||D==="F"?P:null}if(P){tr=Ms(P.nextSibling),S=P.data==="F!";break e}}Uc(S)}S=!1}S&&(p=_[0])}}return _=ua(),_.memoizedState=_.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:RI,lastRenderedState:p},_.queue=S,_=YI.bind(null,Qt,S),S.dispatch=_,S=xE(!1),D=ME.bind(null,Qt,!1,S.queue),S=ua(),P={state:p,dispatch:null,action:d,pending:null},S.queue=P,_=Yee.bind(null,Qt,P,D,_),P.dispatch=_,S.memoizedState=d,[p,_,!1]}function kI(d){var p=Nr();return DI(p,jn,d)}function DI(d,p,_){if(p=mE(d,p,RI)[0],d=Wv(yl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=og(p)}catch(W){throw W===dh?Iv:W}else S=p;p=Nr();var P=p.queue,D=P.dispatch;return _!==p.memoizedState&&(Qt.flags|=2048,gh(9,{destroy:void 0},Zee.bind(null,P,_),null)),[S,D,d]}function Zee(d,p){d.action=p}function OI(d){var p=Nr(),_=jn;if(_!==null)return DI(p,_,d);Nr(),p=p.memoizedState,_=Nr();var S=_.queue.dispatch;return _.memoizedState=d,[p,S,!1]}function gh(d,p,_,S){return d={tag:d,create:_,deps:S,inst:p,next:null},p=Qt.updateQueue,p===null&&(p=Vv(),Qt.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=d.next=d:(S=_.next,_.next=d,d.next=S,p.lastEffect=d),d}function LI(){return Nr().memoizedState}function qv(d,p,_,S){var P=ua();Qt.flags|=d,P.memoizedState=gh(1|p,{destroy:void 0},_,S===void 0?null:S)}function Xv(d,p,_,S){var P=Nr();S=S===void 0?null:S;var D=P.memoizedState.inst;jn!==null&&S!==null&&cE(S,jn.memoizedState.deps)?P.memoizedState=gh(p,D,_,S):(Qt.flags|=d,P.memoizedState=gh(1|p,D,_,S))}function II(d,p){qv(8390656,8,d,p)}function bE(d,p){Xv(2048,8,d,p)}function Qee(d){Qt.flags|=4;var p=Qt.updateQueue;if(p===null)p=Vv(),Qt.updateQueue=p,p.events=[d];else{var _=p.events;_===null?p.events=[d]:_.push(d)}}function jI(d){var p=Nr().memoizedState;return Qee({ref:p,nextImpl:d}),function(){if((Cn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function UI(d,p){return Xv(4,2,d,p)}function FI(d,p){return Xv(4,4,d,p)}function zI(d,p){if(typeof p=="function"){d=d();var _=p(d);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return d=d(),p.current=d,function(){p.current=null}}function BI(d,p,_){_=_!=null?_.concat([d]):null,Xv(4,4,zI.bind(null,p,d),_)}function yE(){}function HI(d,p){var _=Nr();p=p===void 0?null:p;var S=_.memoizedState;return p!==null&&cE(p,S[1])?S[0]:(_.memoizedState=[d,p],d)}function $I(d,p){var _=Nr();p=p===void 0?null:p;var S=_.memoizedState;if(p!==null&&cE(p,S[1]))return S[0];if(S=d(),Td){pt(!0);try{d()}finally{pt(!1)}}return _.memoizedState=[S,p],S}function _E(d,p,_){return _===void 0||(bl&1073741824)!==0&&(xn&261930)===0?d.memoizedState=p:(d.memoizedState=_,d=Vj(),Qt.lanes|=d,qc|=d,_)}function VI(d,p,_,S){return Xa(_,p)?_:hh.current!==null?(d=_E(d,_,S),Xa(d,p)||(Ur=!0),d):(bl&42)===0||(bl&1073741824)!==0&&(xn&261930)===0?(Ur=!0,d.memoizedState=_):(d=Vj(),Qt.lanes|=d,qc|=d,p)}function GI(d,p,_,S,P){var D=G.p;G.p=D!==0&&8>D?D:8;var W=V.T,re={};V.T=re,ME(d,!1,p,_);try{var Se=P(),Be=V.S;if(Be!==null&&Be(re,Se),Se!==null&&typeof Se=="object"&&typeof Se.then=="function"){var et=qee(Se,S);lg(d,p,et,es(d))}else lg(d,p,S,es(d))}catch(lt){lg(d,p,{then:function(){},status:"rejected",reason:lt},es())}finally{G.p=D,W!==null&&re.types!==null&&(W.types=re.types),V.T=W}}function Jee(){}function SE(d,p,_,S){if(d.tag!==5)throw Error(r(476));var P=WI(d).queue;GI(d,P,p,K,_===null?Jee:function(){return qI(d),_(S)})}function WI(d){var p=d.memoizedState;if(p!==null)return p;p={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yl,lastRenderedState:K},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:yl,lastRenderedState:_},next:null},d.memoizedState=p,d=d.alternate,d!==null&&(d.memoizedState=p),p}function qI(d){var p=WI(d);p.next===null&&(p=d.alternate.memoizedState),lg(d,p.next.queue,{},es())}function wE(){return Oi(Eg)}function XI(){return Nr().memoizedState}function KI(){return Nr().memoizedState}function ete(d){for(var p=d.return;p!==null;){switch(p.tag){case 24:case 3:var _=es();d=Bc(_);var S=Hc(p,d,_);S!==null&&(ka(S,p,_),rg(S,p,_)),p={cache:QM()},d.payload=p;return}p=p.return}}function tte(d,p,_){var S=es();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Kv(d)?ZI(p,_):(_=BM(d,p,_,S),_!==null&&(ka(_,d,S),QI(_,p,S)))}function YI(d,p,_){var S=es();lg(d,p,_,S)}function lg(d,p,_,S){var P={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Kv(d))ZI(p,P);else{var D=d.alternate;if(d.lanes===0&&(D===null||D.lanes===0)&&(D=p.lastRenderedReducer,D!==null))try{var W=p.lastRenderedState,re=D(W,_);if(P.hasEagerState=!0,P.eagerState=re,Xa(re,W))return Nv(d,p,P,0),Xn===null&&Cv(),!1}catch{}finally{}if(_=BM(d,p,P,S),_!==null)return ka(_,d,S),QI(_,p,S),!0}return!1}function ME(d,p,_,S){if(S={lane:2,revertLane:nA(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Kv(d)){if(p)throw Error(r(479))}else p=BM(d,_,S,2),p!==null&&ka(p,d,2)}function Kv(d){var p=d.alternate;return d===Qt||p!==null&&p===Qt}function ZI(d,p){ph=Hv=!0;var _=d.pending;_===null?p.next=p:(p.next=_.next,_.next=p),d.pending=p}function QI(d,p,_){if((_&4194048)!==0){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}var cg={readContext:Oi,use:Gv,useCallback:yr,useContext:yr,useEffect:yr,useImperativeHandle:yr,useLayoutEffect:yr,useInsertionEffect:yr,useMemo:yr,useReducer:yr,useRef:yr,useState:yr,useDebugValue:yr,useDeferredValue:yr,useTransition:yr,useSyncExternalStore:yr,useId:yr,useHostTransitionStatus:yr,useFormState:yr,useActionState:yr,useOptimistic:yr,useMemoCache:yr,useCacheRefresh:yr};cg.useEffectEvent=yr;var JI={readContext:Oi,use:Gv,useCallback:function(d,p){return ua().memoizedState=[d,p===void 0?null:p],d},useContext:Oi,useEffect:II,useImperativeHandle:function(d,p,_){_=_!=null?_.concat([d]):null,qv(4194308,4,zI.bind(null,p,d),_)},useLayoutEffect:function(d,p){return qv(4194308,4,d,p)},useInsertionEffect:function(d,p){qv(4,2,d,p)},useMemo:function(d,p){var _=ua();p=p===void 0?null:p;var S=d();if(Td){pt(!0);try{d()}finally{pt(!1)}}return _.memoizedState=[S,p],S},useReducer:function(d,p,_){var S=ua();if(_!==void 0){var P=_(p);if(Td){pt(!0);try{_(p)}finally{pt(!1)}}}else P=p;return S.memoizedState=S.baseState=P,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:P},S.queue=d,d=d.dispatch=tte.bind(null,Qt,d),[S.memoizedState,d]},useRef:function(d){var p=ua();return d={current:d},p.memoizedState=d},useState:function(d){d=xE(d);var p=d.queue,_=YI.bind(null,Qt,p);return p.dispatch=_,[d.memoizedState,_]},useDebugValue:yE,useDeferredValue:function(d,p){var _=ua();return _E(_,d,p)},useTransition:function(){var d=xE(!1);return d=GI.bind(null,Qt,d.queue,!0,!1),ua().memoizedState=d,[!1,d]},useSyncExternalStore:function(d,p,_){var S=Qt,P=ua();if(yn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Xn===null)throw Error(r(349));(xn&127)!==0||yI(S,p,_)}P.memoizedState=_;var D={value:_,getSnapshot:p};return P.queue=D,II(SI.bind(null,S,D,d),[d]),S.flags|=2048,gh(9,{destroy:void 0},_I.bind(null,S,D,_,p),null),_},useId:function(){var d=ua(),p=Xn.identifierPrefix;if(yn){var _=Po,S=Ro;_=(S&~(1<<32-rt(S)-1)).toString(32)+_,p="_"+p+"R_"+_,_=$v++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=Xee++,p="_"+p+"r_"+_.toString(32)+"_";return d.memoizedState=p},useHostTransitionStatus:wE,useFormState:PI,useActionState:PI,useOptimistic:function(d){var p=ua();p.memoizedState=p.baseState=d;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=ME.bind(null,Qt,!0,_),_.dispatch=p,[d,p]},useMemoCache:pE,useCacheRefresh:function(){return ua().memoizedState=ete.bind(null,Qt)},useEffectEvent:function(d){var p=ua(),_={impl:d};return p.memoizedState=_,function(){if((Cn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},EE={readContext:Oi,use:Gv,useCallback:HI,useContext:Oi,useEffect:bE,useImperativeHandle:BI,useInsertionEffect:UI,useLayoutEffect:FI,useMemo:$I,useReducer:Wv,useRef:LI,useState:function(){return Wv(yl)},useDebugValue:yE,useDeferredValue:function(d,p){var _=Nr();return VI(_,jn.memoizedState,d,p)},useTransition:function(){var d=Wv(yl)[0],p=Nr().memoizedState;return[typeof d=="boolean"?d:og(d),p]},useSyncExternalStore:bI,useId:XI,useHostTransitionStatus:wE,useFormState:kI,useActionState:kI,useOptimistic:function(d,p){var _=Nr();return EI(_,jn,d,p)},useMemoCache:pE,useCacheRefresh:KI};EE.useEffectEvent=jI;var ej={readContext:Oi,use:Gv,useCallback:HI,useContext:Oi,useEffect:bE,useImperativeHandle:BI,useInsertionEffect:UI,useLayoutEffect:FI,useMemo:$I,useReducer:gE,useRef:LI,useState:function(){return gE(yl)},useDebugValue:yE,useDeferredValue:function(d,p){var _=Nr();return jn===null?_E(_,d,p):VI(_,jn.memoizedState,d,p)},useTransition:function(){var d=gE(yl)[0],p=Nr().memoizedState;return[typeof d=="boolean"?d:og(d),p]},useSyncExternalStore:bI,useId:XI,useHostTransitionStatus:wE,useFormState:OI,useActionState:OI,useOptimistic:function(d,p){var _=Nr();return jn!==null?EI(_,jn,d,p):(_.baseState=d,[d,_.queue.dispatch])},useMemoCache:pE,useCacheRefresh:KI};ej.useEffectEvent=jI;function AE(d,p,_,S){p=d.memoizedState,_=_(S,p),_=_==null?p:f({},p,_),d.memoizedState=_,d.lanes===0&&(d.updateQueue.baseState=_)}var TE={enqueueSetState:function(d,p,_){d=d._reactInternals;var S=es(),P=Bc(S);P.payload=p,_!=null&&(P.callback=_),p=Hc(d,P,S),p!==null&&(ka(p,d,S),rg(p,d,S))},enqueueReplaceState:function(d,p,_){d=d._reactInternals;var S=es(),P=Bc(S);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Hc(d,P,S),p!==null&&(ka(p,d,S),rg(p,d,S))},enqueueForceUpdate:function(d,p){d=d._reactInternals;var _=es(),S=Bc(_);S.tag=2,p!=null&&(S.callback=p),p=Hc(d,S,_),p!==null&&(ka(p,d,_),rg(p,d,_))}};function tj(d,p,_,S,P,D,W){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(S,D,W):p.prototype&&p.prototype.isPureReactComponent?!Km(_,S)||!Km(P,D):!0}function nj(d,p,_,S){d=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,S),p.state!==d&&TE.enqueueReplaceState(p,p.state,null)}function Cd(d,p){var _=p;if("ref"in p){_={};for(var S in p)S!=="ref"&&(_[S]=p[S])}if(d=d.defaultProps){_===p&&(_=f({},_));for(var P in d)_[P]===void 0&&(_[P]=d[P])}return _}function rj(d){Tv(d)}function ij(d){console.error(d)}function aj(d){Tv(d)}function Yv(d,p){try{var _=d.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function sj(d,p,_){try{var S=d.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function CE(d,p,_){return _=Bc(_),_.tag=3,_.payload={element:null},_.callback=function(){Yv(d,p)},_}function oj(d){return d=Bc(d),d.tag=3,d}function lj(d,p,_,S){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var D=S.value;d.payload=function(){return P(D)},d.callback=function(){sj(p,_,S)}}var W=_.stateNode;W!==null&&typeof W.componentDidCatch=="function"&&(d.callback=function(){sj(p,_,S),typeof P!="function"&&(Xc===null?Xc=new Set([this]):Xc.add(this));var re=S.stack;this.componentDidCatch(S.value,{componentStack:re!==null?re:""})})}function nte(d,p,_,S,P){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=_.alternate,p!==null&&lh(p,_,P,!0),_=Ya.current,_!==null){switch(_.tag){case 31:case 13:return ws===null?lb():_.alternate===null&&_r===0&&(_r=3),_.flags&=-257,_.flags|=65536,_.lanes=P,S===jv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([S]):p.add(S),JE(d,S,P)),!1;case 22:return _.flags|=65536,S===jv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([S]):_.add(S)),JE(d,S,P)),!1}throw Error(r(435,_.tag))}return JE(d,S,P),lb(),!1}if(yn)return p=Ya.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,S!==qM&&(d=Error(r(422),{cause:S}),Qm(bs(d,_)))):(S!==qM&&(p=Error(r(423),{cause:S}),Qm(bs(p,_))),d=d.current.alternate,d.flags|=65536,P&=-P,d.lanes|=P,S=bs(S,_),P=CE(d.stateNode,S,P),iE(d,P),_r!==4&&(_r=2)),!1;var D=Error(r(520),{cause:S});if(D=bs(D,_),xg===null?xg=[D]:xg.push(D),_r!==4&&(_r=2),p===null)return!0;S=bs(S,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,d=P&-P,_.lanes|=d,d=CE(_.stateNode,S,d),iE(_,d),!1;case 1:if(p=_.type,D=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(Xc===null||!Xc.has(D))))return _.flags|=65536,P&=-P,_.lanes|=P,P=oj(P),lj(P,d,_,S),iE(_,P),!1}_=_.return}while(_!==null);return!1}var NE=Error(r(461)),Ur=!1;function Li(d,p,_,S){p.child=d===null?fI(p,null,_,S):Ad(p,d.child,_,S)}function cj(d,p,_,S,P){_=_.render;var D=p.ref;if("ref"in S){var W={};for(var re in S)re!=="ref"&&(W[re]=S[re])}else W=S;return Sd(p),S=uE(d,p,_,W,D,P),re=dE(),d!==null&&!Ur?(fE(d,p,P),_l(d,p,P)):(yn&&re&&GM(p),p.flags|=1,Li(d,p,S,P),p.child)}function uj(d,p,_,S,P){if(d===null){var D=_.type;return typeof D=="function"&&!HM(D)&&D.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=D,dj(d,p,D,S,P)):(d=Pv(_.type,null,S,p,p.mode,P),d.ref=p.ref,d.return=p,p.child=d)}if(D=d.child,!jE(d,P)){var W=D.memoizedProps;if(_=_.compare,_=_!==null?_:Km,_(W,S)&&d.ref===p.ref)return _l(d,p,P)}return p.flags|=1,d=ml(D,S),d.ref=p.ref,d.return=p,p.child=d}function dj(d,p,_,S,P){if(d!==null){var D=d.memoizedProps;if(Km(D,S)&&d.ref===p.ref)if(Ur=!1,p.pendingProps=S=D,jE(d,P))(d.flags&131072)!==0&&(Ur=!0);else return p.lanes=d.lanes,_l(d,p,P)}return RE(d,p,_,S,P)}function fj(d,p,_,S){var P=S.children,D=d!==null?d.memoizedState:null;if(d===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(D=D!==null?D.baseLanes|_:_,d!==null){for(S=p.child=d.child,P=0;S!==null;)P=P|S.lanes|S.childLanes,S=S.sibling;S=P&~D}else S=0,p.child=null;return hj(d,p,D,_,S)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},d!==null&&Lv(p,D!==null?D.cachePool:null),D!==null?mI(p,D):sE(),gI(p);else return S=p.lanes=536870912,hj(d,p,D!==null?D.baseLanes|_:_,_,S)}else D!==null?(Lv(p,D.cachePool),mI(p,D),Vc(),p.memoizedState=null):(d!==null&&Lv(p,null),sE(),Vc());return Li(d,p,P,_),p.child}function ug(d,p){return d!==null&&d.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function hj(d,p,_,S,P){var D=eE();return D=D===null?null:{parent:Ir._currentValue,pool:D},p.memoizedState={baseLanes:_,cachePool:D},d!==null&&Lv(p,null),sE(),gI(p),d!==null&&lh(d,p,S,!0),p.childLanes=P,null}function Zv(d,p){return p=Jv({mode:p.mode,children:p.children},d.mode),p.ref=d.ref,d.child=p,p.return=d,p}function pj(d,p,_){return Ad(p,d.child,null,_),d=Zv(p,p.pendingProps),d.flags|=2,Za(p),p.memoizedState=null,d}function rte(d,p,_){var S=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,d===null){if(yn){if(S.mode==="hidden")return d=Zv(p,S),p.lanes=536870912,ug(null,d);if(lE(p),(d=tr)?(d=A4(d,Ss),d=d!==null&&d.data==="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Ro,overflow:Po}:null,retryLane:536870912,hydrationErrors:null},_=ZL(d),_.return=p,p.child=_,Di=p,tr=null)):d=null,d===null)throw Uc(p);return p.lanes=536870912,null}return Zv(p,S)}var D=d.memoizedState;if(D!==null){var W=D.dehydrated;if(lE(p),P)if(p.flags&256)p.flags&=-257,p=pj(d,p,_);else if(p.memoizedState!==null)p.child=d.child,p.flags|=128,p=null;else throw Error(r(558));else if(Ur||lh(d,p,_,!1),P=(_&d.childLanes)!==0,Ur||P){if(S=Xn,S!==null&&(W=pi(S,_),W!==0&&W!==D.retryLane))throw D.retryLane=W,vd(d,W),ka(S,d,W),NE;lb(),p=pj(d,p,_)}else d=D.treeContext,tr=Ms(W.nextSibling),Di=p,yn=!0,jc=null,Ss=!1,d!==null&&eI(p,d),p=Zv(p,S),p.flags|=4096;return p}return d=ml(d.child,{mode:S.mode,children:S.children}),d.ref=p.ref,p.child=d,d.return=p,d}function Qv(d,p){var _=p.ref;if(_===null)d!==null&&d.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(d===null||d.ref!==_)&&(p.flags|=4194816)}}function RE(d,p,_,S,P){return Sd(p),_=uE(d,p,_,S,void 0,P),S=dE(),d!==null&&!Ur?(fE(d,p,P),_l(d,p,P)):(yn&&S&&GM(p),p.flags|=1,Li(d,p,_,P),p.child)}function mj(d,p,_,S,P,D){return Sd(p),p.updateQueue=null,_=vI(p,S,_,P),xI(d),S=dE(),d!==null&&!Ur?(fE(d,p,D),_l(d,p,D)):(yn&&S&&GM(p),p.flags|=1,Li(d,p,_,D),p.child)}function gj(d,p,_,S,P){if(Sd(p),p.stateNode===null){var D=ih,W=_.contextType;typeof W=="object"&&W!==null&&(D=Oi(W)),D=new _(S,D),p.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=TE,p.stateNode=D,D._reactInternals=p,D=p.stateNode,D.props=S,D.state=p.memoizedState,D.refs={},nE(p),W=_.contextType,D.context=typeof W=="object"&&W!==null?Oi(W):ih,D.state=p.memoizedState,W=_.getDerivedStateFromProps,typeof W=="function"&&(AE(p,_,W,S),D.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(W=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),W!==D.state&&TE.enqueueReplaceState(D,D.state,null),ag(p,S,D,P),ig(),D.state=p.memoizedState),typeof D.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(d===null){D=p.stateNode;var re=p.memoizedProps,Se=Cd(_,re);D.props=Se;var Be=D.context,et=_.contextType;W=ih,typeof et=="object"&&et!==null&&(W=Oi(et));var lt=_.getDerivedStateFromProps;et=typeof lt=="function"||typeof D.getSnapshotBeforeUpdate=="function",re=p.pendingProps!==re,et||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(re||Be!==W)&&nj(p,D,S,W),zc=!1;var Ve=p.memoizedState;D.state=Ve,ag(p,S,D,P),ig(),Be=p.memoizedState,re||Ve!==Be||zc?(typeof lt=="function"&&(AE(p,_,lt,S),Be=p.memoizedState),(Se=zc||tj(p,_,Se,S,Ve,Be,W))?(et||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(p.flags|=4194308)):(typeof D.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=Be),D.props=S,D.state=Be,D.context=W,S=Se):(typeof D.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{D=p.stateNode,rE(d,p),W=p.memoizedProps,et=Cd(_,W),D.props=et,lt=p.pendingProps,Ve=D.context,Be=_.contextType,Se=ih,typeof Be=="object"&&Be!==null&&(Se=Oi(Be)),re=_.getDerivedStateFromProps,(Be=typeof re=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(W!==lt||Ve!==Se)&&nj(p,D,S,Se),zc=!1,Ve=p.memoizedState,D.state=Ve,ag(p,S,D,P),ig();var Ye=p.memoizedState;W!==lt||Ve!==Ye||zc||d!==null&&d.dependencies!==null&&Dv(d.dependencies)?(typeof re=="function"&&(AE(p,_,re,S),Ye=p.memoizedState),(et=zc||tj(p,_,et,S,Ve,Ye,Se)||d!==null&&d.dependencies!==null&&Dv(d.dependencies))?(Be||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(S,Ye,Se),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(S,Ye,Se)),typeof D.componentDidUpdate=="function"&&(p.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof D.componentDidUpdate!="function"||W===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||W===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=Ye),D.props=S,D.state=Ye,D.context=Se,S=et):(typeof D.componentDidUpdate!="function"||W===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||W===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=1024),S=!1)}return D=S,Qv(d,p),S=(p.flags&128)!==0,D||S?(D=p.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:D.render(),p.flags|=1,d!==null&&S?(p.child=Ad(p,d.child,null,P),p.child=Ad(p,null,_,P)):Li(d,p,_,P),p.memoizedState=D.state,d=p.child):d=_l(d,p,P),d}function xj(d,p,_,S){return yd(),p.flags|=256,Li(d,p,_,S),p.child}var PE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function kE(d){return{baseLanes:d,cachePool:sI()}}function DE(d,p,_){return d=d!==null?d.childLanes&~_:0,p&&(d|=Ja),d}function vj(d,p,_){var S=p.pendingProps,P=!1,D=(p.flags&128)!==0,W;if((W=D)||(W=d!==null&&d.memoizedState===null?!1:(Cr.current&2)!==0),W&&(P=!0,p.flags&=-129),W=(p.flags&32)!==0,p.flags&=-33,d===null){if(yn){if(P?$c(p):Vc(),(d=tr)?(d=A4(d,Ss),d=d!==null&&d.data!=="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Ro,overflow:Po}:null,retryLane:536870912,hydrationErrors:null},_=ZL(d),_.return=p,p.child=_,Di=p,tr=null)):d=null,d===null)throw Uc(p);return mA(d)?p.lanes=32:p.lanes=536870912,null}var re=S.children;return S=S.fallback,P?(Vc(),P=p.mode,re=Jv({mode:"hidden",children:re},P),S=bd(S,P,_,null),re.return=p,S.return=p,re.sibling=S,p.child=re,S=p.child,S.memoizedState=kE(_),S.childLanes=DE(d,W,_),p.memoizedState=PE,ug(null,S)):($c(p),OE(p,re))}var Se=d.memoizedState;if(Se!==null&&(re=Se.dehydrated,re!==null)){if(D)p.flags&256?($c(p),p.flags&=-257,p=LE(d,p,_)):p.memoizedState!==null?(Vc(),p.child=d.child,p.flags|=128,p=null):(Vc(),re=S.fallback,P=p.mode,S=Jv({mode:"visible",children:S.children},P),re=bd(re,P,_,null),re.flags|=2,S.return=p,re.return=p,S.sibling=re,p.child=S,Ad(p,d.child,null,_),S=p.child,S.memoizedState=kE(_),S.childLanes=DE(d,W,_),p.memoizedState=PE,p=ug(null,S));else if($c(p),mA(re)){if(W=re.nextSibling&&re.nextSibling.dataset,W)var Be=W.dgst;W=Be,S=Error(r(419)),S.stack="",S.digest=W,Qm({value:S,source:null,stack:null}),p=LE(d,p,_)}else if(Ur||lh(d,p,_,!1),W=(_&d.childLanes)!==0,Ur||W){if(W=Xn,W!==null&&(S=pi(W,_),S!==0&&S!==Se.retryLane))throw Se.retryLane=S,vd(d,S),ka(W,d,S),NE;pA(re)||lb(),p=LE(d,p,_)}else pA(re)?(p.flags|=192,p.child=d.child,p=null):(d=Se.treeContext,tr=Ms(re.nextSibling),Di=p,yn=!0,jc=null,Ss=!1,d!==null&&eI(p,d),p=OE(p,S.children),p.flags|=4096);return p}return P?(Vc(),re=S.fallback,P=p.mode,Se=d.child,Be=Se.sibling,S=ml(Se,{mode:"hidden",children:S.children}),S.subtreeFlags=Se.subtreeFlags&65011712,Be!==null?re=ml(Be,re):(re=bd(re,P,_,null),re.flags|=2),re.return=p,S.return=p,S.sibling=re,p.child=S,ug(null,S),S=p.child,re=d.child.memoizedState,re===null?re=kE(_):(P=re.cachePool,P!==null?(Se=Ir._currentValue,P=P.parent!==Se?{parent:Se,pool:Se}:P):P=sI(),re={baseLanes:re.baseLanes|_,cachePool:P}),S.memoizedState=re,S.childLanes=DE(d,W,_),p.memoizedState=PE,ug(d.child,S)):($c(p),_=d.child,d=_.sibling,_=ml(_,{mode:"visible",children:S.children}),_.return=p,_.sibling=null,d!==null&&(W=p.deletions,W===null?(p.deletions=[d],p.flags|=16):W.push(d)),p.child=_,p.memoizedState=null,_)}function OE(d,p){return p=Jv({mode:"visible",children:p},d.mode),p.return=d,d.child=p}function Jv(d,p){return d=Ka(22,d,null,p),d.lanes=0,d}function LE(d,p,_){return Ad(p,d.child,null,_),d=OE(p,p.pendingProps.children),d.flags|=2,p.memoizedState=null,d}function bj(d,p,_){d.lanes|=p;var S=d.alternate;S!==null&&(S.lanes|=p),YM(d.return,p,_)}function IE(d,p,_,S,P,D){var W=d.memoizedState;W===null?d.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:P,treeForkCount:D}:(W.isBackwards=p,W.rendering=null,W.renderingStartTime=0,W.last=S,W.tail=_,W.tailMode=P,W.treeForkCount=D)}function yj(d,p,_){var S=p.pendingProps,P=S.revealOrder,D=S.tail;S=S.children;var W=Cr.current,re=(W&2)!==0;if(re?(W=W&1|2,p.flags|=128):W&=1,ae(Cr,W),Li(d,p,S,_),S=yn?Zm:0,!re&&d!==null&&(d.flags&128)!==0)e:for(d=p.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&bj(d,_,p);else if(d.tag===19)bj(d,_,p);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===p)break e;for(;d.sibling===null;){if(d.return===null||d.return===p)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}switch(P){case"forwards":for(_=p.child,P=null;_!==null;)d=_.alternate,d!==null&&Bv(d)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),IE(p,!1,P,_,D,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(d=P.alternate,d!==null&&Bv(d)===null){p.child=P;break}d=P.sibling,P.sibling=_,_=P,P=d}IE(p,!0,_,null,D,S);break;case"together":IE(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function _l(d,p,_){if(d!==null&&(p.dependencies=d.dependencies),qc|=p.lanes,(_&p.childLanes)===0)if(d!==null){if(lh(d,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(d!==null&&p.child!==d.child)throw Error(r(153));if(p.child!==null){for(d=p.child,_=ml(d,d.pendingProps),p.child=_,_.return=p;d.sibling!==null;)d=d.sibling,_=_.sibling=ml(d,d.pendingProps),_.return=p;_.sibling=null}return p.child}function jE(d,p){return(d.lanes&p)!==0?!0:(d=d.dependencies,!!(d!==null&&Dv(d)))}function ite(d,p,_){switch(p.tag){case 3:De(p,p.stateNode.containerInfo),Fc(p,Ir,d.memoizedState.cache),yd();break;case 27:case 5:me(p);break;case 4:De(p,p.stateNode.containerInfo);break;case 10:Fc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,lE(p),null;break;case 13:var S=p.memoizedState;if(S!==null)return S.dehydrated!==null?($c(p),p.flags|=128,null):(_&p.child.childLanes)!==0?vj(d,p,_):($c(p),d=_l(d,p,_),d!==null?d.sibling:null);$c(p);break;case 19:var P=(d.flags&128)!==0;if(S=(_&p.childLanes)!==0,S||(lh(d,p,_,!1),S=(_&p.childLanes)!==0),P){if(S)return yj(d,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ae(Cr,Cr.current),S)break;return null;case 22:return p.lanes=0,fj(d,p,_,p.pendingProps);case 24:Fc(p,Ir,d.memoizedState.cache)}return _l(d,p,_)}function _j(d,p,_){if(d!==null)if(d.memoizedProps!==p.pendingProps)Ur=!0;else{if(!jE(d,_)&&(p.flags&128)===0)return Ur=!1,ite(d,p,_);Ur=(d.flags&131072)!==0}else Ur=!1,yn&&(p.flags&1048576)!==0&&JL(p,Zm,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(d=Md(p.elementType),p.type=d,typeof d=="function")HM(d)?(S=Cd(d,S),p.tag=1,p=gj(null,p,d,S,_)):(p.tag=0,p=RE(null,p,d,S,_));else{if(d!=null){var P=d.$$typeof;if(P===A){p.tag=11,p=cj(null,p,d,S,_);break e}else if(P===N){p.tag=14,p=uj(null,p,d,S,_);break e}}throw p=O(d)||d,Error(r(306,p,""))}}return p;case 0:return RE(d,p,p.type,p.pendingProps,_);case 1:return S=p.type,P=Cd(S,p.pendingProps),gj(d,p,S,P,_);case 3:e:{if(De(p,p.stateNode.containerInfo),d===null)throw Error(r(387));S=p.pendingProps;var D=p.memoizedState;P=D.element,rE(d,p),ag(p,S,null,_);var W=p.memoizedState;if(S=W.cache,Fc(p,Ir,S),S!==D.cache&&ZM(p,[Ir],_,!0),ig(),S=W.element,D.isDehydrated)if(D={element:S,isDehydrated:!1,cache:W.cache},p.updateQueue.baseState=D,p.memoizedState=D,p.flags&256){p=xj(d,p,S,_);break e}else if(S!==P){P=bs(Error(r(424)),p),Qm(P),p=xj(d,p,S,_);break e}else{switch(d=p.stateNode.containerInfo,d.nodeType){case 9:d=d.body;break;default:d=d.nodeName==="HTML"?d.ownerDocument.body:d}for(tr=Ms(d.firstChild),Di=p,yn=!0,jc=null,Ss=!0,_=fI(p,null,S,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(yd(),S===P){p=_l(d,p,_);break e}Li(d,p,S,_)}p=p.child}return p;case 26:return Qv(d,p),d===null?(_=k4(p.type,null,p.pendingProps,null))?p.memoizedState=_:yn||(_=p.type,d=p.pendingProps,S=mb(te.current).createElement(_),S[hr]=p,S[Ar]=d,Ii(S,_,d),Ce(S),p.stateNode=S):p.memoizedState=k4(p.type,d.memoizedProps,p.pendingProps,d.memoizedState),null;case 27:return me(p),d===null&&yn&&(S=p.stateNode=N4(p.type,p.pendingProps,te.current),Di=p,Ss=!0,P=tr,Qc(p.type)?(gA=P,tr=Ms(S.firstChild)):tr=P),Li(d,p,p.pendingProps.children,_),Qv(d,p),d===null&&(p.flags|=4194304),p.child;case 5:return d===null&&yn&&((P=S=tr)&&(S=Ote(S,p.type,p.pendingProps,Ss),S!==null?(p.stateNode=S,Di=p,tr=Ms(S.firstChild),Ss=!1,P=!0):P=!1),P||Uc(p)),me(p),P=p.type,D=p.pendingProps,W=d!==null?d.memoizedProps:null,S=D.children,dA(P,D)?S=null:W!==null&&dA(P,W)&&(p.flags|=32),p.memoizedState!==null&&(P=uE(d,p,Kee,null,null,_),Eg._currentValue=P),Qv(d,p),Li(d,p,S,_),p.child;case 6:return d===null&&yn&&((d=_=tr)&&(_=Lte(_,p.pendingProps,Ss),_!==null?(p.stateNode=_,Di=p,tr=null,d=!0):d=!1),d||Uc(p)),null;case 13:return vj(d,p,_);case 4:return De(p,p.stateNode.containerInfo),S=p.pendingProps,d===null?p.child=Ad(p,null,S,_):Li(d,p,S,_),p.child;case 11:return cj(d,p,p.type,p.pendingProps,_);case 7:return Li(d,p,p.pendingProps,_),p.child;case 8:return Li(d,p,p.pendingProps.children,_),p.child;case 12:return Li(d,p,p.pendingProps.children,_),p.child;case 10:return S=p.pendingProps,Fc(p,p.type,S.value),Li(d,p,S.children,_),p.child;case 9:return P=p.type._context,S=p.pendingProps.children,Sd(p),P=Oi(P),S=S(P),p.flags|=1,Li(d,p,S,_),p.child;case 14:return uj(d,p,p.type,p.pendingProps,_);case 15:return dj(d,p,p.type,p.pendingProps,_);case 19:return yj(d,p,_);case 31:return rte(d,p,_);case 22:return fj(d,p,_,p.pendingProps);case 24:return Sd(p),S=Oi(Ir),d===null?(P=eE(),P===null&&(P=Xn,D=QM(),P.pooledCache=D,D.refCount++,D!==null&&(P.pooledCacheLanes|=_),P=D),p.memoizedState={parent:S,cache:P},nE(p),Fc(p,Ir,P)):((d.lanes&_)!==0&&(rE(d,p),ag(p,null,null,_),ig()),P=d.memoizedState,D=p.memoizedState,P.parent!==S?(P={parent:S,cache:S},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),Fc(p,Ir,S)):(S=D.cache,Fc(p,Ir,S),S!==P.cache&&ZM(p,[Ir],_,!0))),Li(d,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Sl(d){d.flags|=4}function UE(d,p,_,S,P){if((p=(d.mode&32)!==0)&&(p=!1),p){if(d.flags|=16777216,(P&335544128)===P)if(d.stateNode.complete)d.flags|=8192;else if(Xj())d.flags|=8192;else throw Ed=jv,tE}else d.flags&=-16777217}function Sj(d,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)d.flags&=-16777217;else if(d.flags|=16777216,!j4(p))if(Xj())d.flags|=8192;else throw Ed=jv,tE}function eb(d,p){p!==null&&(d.flags|=4),d.flags&16384&&(p=d.tag!==22?_t():536870912,d.lanes|=p,yh|=p)}function dg(d,p){if(!yn)switch(d.tailMode){case"hidden":p=d.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?d.tail=null:_.sibling=null;break;case"collapsed":_=d.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?p||d.tail===null?d.tail=null:d.tail.sibling=null:S.sibling=null}}function nr(d){var p=d.alternate!==null&&d.alternate.child===d.child,_=0,S=0;if(p)for(var P=d.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags&65011712,S|=P.flags&65011712,P.return=d,P=P.sibling;else for(P=d.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags,S|=P.flags,P.return=d,P=P.sibling;return d.subtreeFlags|=S,d.childLanes=_,p}function ate(d,p,_){var S=p.pendingProps;switch(WM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nr(p),null;case 1:return nr(p),null;case 3:return _=p.stateNode,S=null,d!==null&&(S=d.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),vl(Ir),he(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(d===null||d.child===null)&&(oh(p)?Sl(p):d===null||d.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,XM())),nr(p),null;case 26:var P=p.type,D=p.memoizedState;return d===null?(Sl(p),D!==null?(nr(p),Sj(p,D)):(nr(p),UE(p,P,null,S,_))):D?D!==d.memoizedState?(Sl(p),nr(p),Sj(p,D)):(nr(p),p.flags&=-16777217):(d=d.memoizedProps,d!==S&&Sl(p),nr(p),UE(p,P,d,S,_)),null;case 27:if(we(p),_=te.current,P=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&Sl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}d=ce.current,oh(p)?tI(p):(d=N4(P,S,_),p.stateNode=d,Sl(p))}return nr(p),null;case 5:if(we(p),P=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&Sl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}if(D=ce.current,oh(p))tI(p);else{var W=mb(te.current);switch(D){case 1:D=W.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:D=W.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":D=W.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":D=W.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":D=W.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof S.is=="string"?W.createElement("select",{is:S.is}):W.createElement("select"),S.multiple?D.multiple=!0:S.size&&(D.size=S.size);break;default:D=typeof S.is=="string"?W.createElement(P,{is:S.is}):W.createElement(P)}}D[hr]=p,D[Ar]=S;e:for(W=p.child;W!==null;){if(W.tag===5||W.tag===6)D.appendChild(W.stateNode);else if(W.tag!==4&&W.tag!==27&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===p)break e;for(;W.sibling===null;){if(W.return===null||W.return===p)break e;W=W.return}W.sibling.return=W.return,W=W.sibling}p.stateNode=D;e:switch(Ii(D,P,S),P){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&Sl(p)}}return nr(p),UE(p,p.type,d===null?null:d.memoizedProps,p.pendingProps,_),null;case 6:if(d&&p.stateNode!=null)d.memoizedProps!==S&&Sl(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(r(166));if(d=te.current,oh(p)){if(d=p.stateNode,_=p.memoizedProps,S=null,P=Di,P!==null)switch(P.tag){case 27:case 5:S=P.memoizedProps}d[hr]=p,d=!!(d.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||v4(d.nodeValue,_)),d||Uc(p,!0)}else d=mb(d).createTextNode(S),d[hr]=p,p.stateNode=d}return nr(p),null;case 31:if(_=p.memoizedState,d===null||d.memoizedState!==null){if(S=oh(p),_!==null){if(d===null){if(!S)throw Error(r(318));if(d=p.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(557));d[hr]=p}else yd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),d=!1}else _=XM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=_),d=!0;if(!d)return p.flags&256?(Za(p),p):(Za(p),null);if((p.flags&128)!==0)throw Error(r(558))}return nr(p),null;case 13:if(S=p.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(P=oh(p),S!==null&&S.dehydrated!==null){if(d===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[hr]=p}else yd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),P=!1}else P=XM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(Za(p),p):(Za(p),null)}return Za(p),(p.flags&128)!==0?(p.lanes=_,p):(_=S!==null,d=d!==null&&d.memoizedState!==null,_&&(S=p.child,P=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(P=S.alternate.memoizedState.cachePool.pool),D=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(D=S.memoizedState.cachePool.pool),D!==P&&(S.flags|=2048)),_!==d&&_&&(p.child.flags|=8192),eb(p,p.updateQueue),nr(p),null);case 4:return he(),d===null&&sA(p.stateNode.containerInfo),nr(p),null;case 10:return vl(p.type),nr(p),null;case 19:if(X(Cr),S=p.memoizedState,S===null)return nr(p),null;if(P=(p.flags&128)!==0,D=S.rendering,D===null)if(P)dg(S,!1);else{if(_r!==0||d!==null&&(d.flags&128)!==0)for(d=p.child;d!==null;){if(D=Bv(d),D!==null){for(p.flags|=128,dg(S,!1),d=D.updateQueue,p.updateQueue=d,eb(p,d),p.subtreeFlags=0,d=_,_=p.child;_!==null;)YL(_,d),_=_.sibling;return ae(Cr,Cr.current&1|2),yn&&gl(p,S.treeForkCount),p.child}d=d.sibling}S.tail!==null&&L()>ab&&(p.flags|=128,P=!0,dg(S,!1),p.lanes=4194304)}else{if(!P)if(d=Bv(D),d!==null){if(p.flags|=128,P=!0,d=d.updateQueue,p.updateQueue=d,eb(p,d),dg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!D.alternate&&!yn)return nr(p),null}else 2*L()-S.renderingStartTime>ab&&_!==536870912&&(p.flags|=128,P=!0,dg(S,!1),p.lanes=4194304);S.isBackwards?(D.sibling=p.child,p.child=D):(d=S.last,d!==null?d.sibling=D:p.child=D,S.last=D)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=L(),d.sibling=null,_=Cr.current,ae(Cr,P?_&1|2:_&1),yn&&gl(p,S.treeForkCount),d):(nr(p),null);case 22:case 23:return Za(p),oE(),S=p.memoizedState!==null,d!==null?d.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(_&536870912)!==0&&(p.flags&128)===0&&(nr(p),p.subtreeFlags&6&&(p.flags|=8192)):nr(p),_=p.updateQueue,_!==null&&eb(p,_.retryQueue),_=null,d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==_&&(p.flags|=2048),d!==null&&X(wd),null;case 24:return _=null,d!==null&&(_=d.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),vl(Ir),nr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function ste(d,p){switch(WM(p),p.tag){case 1:return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 3:return vl(Ir),he(),d=p.flags,(d&65536)!==0&&(d&128)===0?(p.flags=d&-65537|128,p):null;case 26:case 27:case 5:return we(p),null;case 31:if(p.memoizedState!==null){if(Za(p),p.alternate===null)throw Error(r(340));yd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 13:if(Za(p),d=p.memoizedState,d!==null&&d.dehydrated!==null){if(p.alternate===null)throw Error(r(340));yd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 19:return X(Cr),null;case 4:return he(),null;case 10:return vl(p.type),null;case 22:case 23:return Za(p),oE(),d!==null&&X(wd),d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 24:return vl(Ir),null;case 25:return null;default:return null}}function wj(d,p){switch(WM(p),p.tag){case 3:vl(Ir),he();break;case 26:case 27:case 5:we(p);break;case 4:he();break;case 31:p.memoizedState!==null&&Za(p);break;case 13:Za(p);break;case 19:X(Cr);break;case 10:vl(p.type);break;case 22:case 23:Za(p),oE(),d!==null&&X(wd);break;case 24:vl(Ir)}}function fg(d,p){try{var _=p.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var P=S.next;_=P;do{if((_.tag&d)===d){S=void 0;var D=_.create,W=_.inst;S=D(),W.destroy=S}_=_.next}while(_!==P)}}catch(re){Dn(p,p.return,re)}}function Gc(d,p,_){try{var S=p.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var D=P.next;S=D;do{if((S.tag&d)===d){var W=S.inst,re=W.destroy;if(re!==void 0){W.destroy=void 0,P=p;var Se=_,Be=re;try{Be()}catch(et){Dn(P,Se,et)}}}S=S.next}while(S!==D)}}catch(et){Dn(p,p.return,et)}}function Mj(d){var p=d.updateQueue;if(p!==null){var _=d.stateNode;try{pI(p,_)}catch(S){Dn(d,d.return,S)}}}function Ej(d,p,_){_.props=Cd(d.type,d.memoizedProps),_.state=d.memoizedState;try{_.componentWillUnmount()}catch(S){Dn(d,p,S)}}function hg(d,p){try{var _=d.ref;if(_!==null){switch(d.tag){case 26:case 27:case 5:var S=d.stateNode;break;case 30:S=d.stateNode;break;default:S=d.stateNode}typeof _=="function"?d.refCleanup=_(S):_.current=S}}catch(P){Dn(d,p,P)}}function ko(d,p){var _=d.ref,S=d.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(P){Dn(d,p,P)}finally{d.refCleanup=null,d=d.alternate,d!=null&&(d.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Dn(d,p,P)}else _.current=null}function Aj(d){var p=d.type,_=d.memoizedProps,S=d.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&S.focus();break e;case"img":_.src?S.src=_.src:_.srcSet&&(S.srcset=_.srcSet)}}catch(P){Dn(d,d.return,P)}}function FE(d,p,_){try{var S=d.stateNode;Cte(S,d.type,_,p),S[Ar]=p}catch(P){Dn(d,d.return,P)}}function Tj(d){return d.tag===5||d.tag===3||d.tag===26||d.tag===27&&Qc(d.type)||d.tag===4}function zE(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||Tj(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.tag===27&&Qc(d.type)||d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function BE(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(d,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(d),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=hl));else if(S!==4&&(S===27&&Qc(d.type)&&(_=d.stateNode,p=null),d=d.child,d!==null))for(BE(d,p,_),d=d.sibling;d!==null;)BE(d,p,_),d=d.sibling}function tb(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?_.insertBefore(d,p):_.appendChild(d);else if(S!==4&&(S===27&&Qc(d.type)&&(_=d.stateNode),d=d.child,d!==null))for(tb(d,p,_),d=d.sibling;d!==null;)tb(d,p,_),d=d.sibling}function Cj(d){var p=d.stateNode,_=d.memoizedProps;try{for(var S=d.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Ii(p,S,_),p[hr]=d,p[Ar]=_}catch(D){Dn(d,d.return,D)}}var wl=!1,Fr=!1,HE=!1,Nj=typeof WeakSet=="function"?WeakSet:Set,vi=null;function ote(d,p){if(d=d.containerInfo,cA=Sb,d=BL(d),LM(d)){if("selectionStart"in d)var _={start:d.selectionStart,end:d.selectionEnd};else e:{_=(_=d.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var P=S.anchorOffset,D=S.focusNode;S=S.focusOffset;try{_.nodeType,D.nodeType}catch{_=null;break e}var W=0,re=-1,Se=-1,Be=0,et=0,lt=d,Ve=null;t:for(;;){for(var Ye;lt!==_||P!==0&&lt.nodeType!==3||(re=W+P),lt!==D||S!==0&&lt.nodeType!==3||(Se=W+S),lt.nodeType===3&&(W+=lt.nodeValue.length),(Ye=lt.firstChild)!==null;)Ve=lt,lt=Ye;for(;;){if(lt===d)break t;if(Ve===_&&++Be===P&&(re=W),Ve===D&&++et===S&&(Se=W),(Ye=lt.nextSibling)!==null)break;lt=Ve,Ve=lt.parentNode}lt=Ye}_=re===-1||Se===-1?null:{start:re,end:Se}}else _=null}_=_||{start:0,end:0}}else _=null;for(uA={focusedElem:d,selectionRange:_},Sb=!1,vi=p;vi!==null;)if(p=vi,d=p.child,(p.subtreeFlags&1028)!==0&&d!==null)d.return=p,vi=d;else for(;vi!==null;){switch(p=vi,D=p.alternate,d=p.flags,p.tag){case 0:if((d&4)!==0&&(d=p.updateQueue,d=d!==null?d.events:null,d!==null))for(_=0;_<d.length;_++)P=d[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((d&1024)!==0&&D!==null){d=void 0,_=p,P=D.memoizedProps,D=D.memoizedState,S=_.stateNode;try{var Nt=Cd(_.type,P);d=S.getSnapshotBeforeUpdate(Nt,D),S.__reactInternalSnapshotBeforeUpdate=d}catch(Ht){Dn(_,_.return,Ht)}}break;case 3:if((d&1024)!==0){if(d=p.stateNode.containerInfo,_=d.nodeType,_===9)hA(d);else if(_===1)switch(d.nodeName){case"HEAD":case"HTML":case"BODY":hA(d);break;default:d.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((d&1024)!==0)throw Error(r(163))}if(d=p.sibling,d!==null){d.return=p.return,vi=d;break}vi=p.return}}function Rj(d,p,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:El(d,_),S&4&&fg(5,_);break;case 1:if(El(d,_),S&4)if(d=_.stateNode,p===null)try{d.componentDidMount()}catch(W){Dn(_,_.return,W)}else{var P=Cd(_.type,p.memoizedProps);p=p.memoizedState;try{d.componentDidUpdate(P,p,d.__reactInternalSnapshotBeforeUpdate)}catch(W){Dn(_,_.return,W)}}S&64&&Mj(_),S&512&&hg(_,_.return);break;case 3:if(El(d,_),S&64&&(d=_.updateQueue,d!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{pI(d,p)}catch(W){Dn(_,_.return,W)}}break;case 27:p===null&&S&4&&Cj(_);case 26:case 5:El(d,_),p===null&&S&4&&Aj(_),S&512&&hg(_,_.return);break;case 12:El(d,_);break;case 31:El(d,_),S&4&&Dj(d,_);break;case 13:El(d,_),S&4&&Oj(d,_),S&64&&(d=_.memoizedState,d!==null&&(d=d.dehydrated,d!==null&&(_=gte.bind(null,_),Ite(d,_))));break;case 22:if(S=_.memoizedState!==null||wl,!S){p=p!==null&&p.memoizedState!==null||Fr,P=wl;var D=Fr;wl=S,(Fr=p)&&!D?Al(d,_,(_.subtreeFlags&8772)!==0):El(d,_),wl=P,Fr=D}break;case 30:break;default:El(d,_)}}function Pj(d){var p=d.alternate;p!==null&&(d.alternate=null,Pj(p)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(p=d.stateNode,p!==null&&We(p)),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}var lr=null,Ca=!1;function Ml(d,p,_){for(_=_.child;_!==null;)kj(d,p,_),_=_.sibling}function kj(d,p,_){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(je,_)}catch{}switch(_.tag){case 26:Fr||ko(_,p),Ml(d,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Fr||ko(_,p);var S=lr,P=Ca;Qc(_.type)&&(lr=_.stateNode,Ca=!1),Ml(d,p,_),Sg(_.stateNode),lr=S,Ca=P;break;case 5:Fr||ko(_,p);case 6:if(S=lr,P=Ca,lr=null,Ml(d,p,_),lr=S,Ca=P,lr!==null)if(Ca)try{(lr.nodeType===9?lr.body:lr.nodeName==="HTML"?lr.ownerDocument.body:lr).removeChild(_.stateNode)}catch(D){Dn(_,p,D)}else try{lr.removeChild(_.stateNode)}catch(D){Dn(_,p,D)}break;case 18:lr!==null&&(Ca?(d=lr,M4(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,_.stateNode),Ch(d)):M4(lr,_.stateNode));break;case 4:S=lr,P=Ca,lr=_.stateNode.containerInfo,Ca=!0,Ml(d,p,_),lr=S,Ca=P;break;case 0:case 11:case 14:case 15:Gc(2,_,p),Fr||Gc(4,_,p),Ml(d,p,_);break;case 1:Fr||(ko(_,p),S=_.stateNode,typeof S.componentWillUnmount=="function"&&Ej(_,p,S)),Ml(d,p,_);break;case 21:Ml(d,p,_);break;case 22:Fr=(S=Fr)||_.memoizedState!==null,Ml(d,p,_),Fr=S;break;default:Ml(d,p,_)}}function Dj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null))){d=d.dehydrated;try{Ch(d)}catch(_){Dn(p,p.return,_)}}}function Oj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null&&(d=d.dehydrated,d!==null))))try{Ch(d)}catch(_){Dn(p,p.return,_)}}function lte(d){switch(d.tag){case 31:case 13:case 19:var p=d.stateNode;return p===null&&(p=d.stateNode=new Nj),p;case 22:return d=d.stateNode,p=d._retryCache,p===null&&(p=d._retryCache=new Nj),p;default:throw Error(r(435,d.tag))}}function nb(d,p){var _=lte(d);p.forEach(function(S){if(!_.has(S)){_.add(S);var P=xte.bind(null,d,S);S.then(P,P)}})}function Na(d,p){var _=p.deletions;if(_!==null)for(var S=0;S<_.length;S++){var P=_[S],D=d,W=p,re=W;e:for(;re!==null;){switch(re.tag){case 27:if(Qc(re.type)){lr=re.stateNode,Ca=!1;break e}break;case 5:lr=re.stateNode,Ca=!1;break e;case 3:case 4:lr=re.stateNode.containerInfo,Ca=!0;break e}re=re.return}if(lr===null)throw Error(r(160));kj(D,W,P),lr=null,Ca=!1,D=P.alternate,D!==null&&(D.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)Lj(p,d),p=p.sibling}var ao=null;function Lj(d,p){var _=d.alternate,S=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:Na(p,d),Ra(d),S&4&&(Gc(3,d,d.return),fg(3,d),Gc(5,d,d.return));break;case 1:Na(p,d),Ra(d),S&512&&(Fr||_===null||ko(_,_.return)),S&64&&wl&&(d=d.updateQueue,d!==null&&(S=d.callbacks,S!==null&&(_=d.shared.hiddenCallbacks,d.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var P=ao;if(Na(p,d),Ra(d),S&512&&(Fr||_===null||ko(_,_.return)),S&4){var D=_!==null?_.memoizedState:null;if(S=d.memoizedState,_===null)if(S===null)if(d.stateNode===null){e:{S=d.type,_=d.memoizedProps,P=P.ownerDocument||P;t:switch(S){case"title":D=P.getElementsByTagName("title")[0],(!D||D[Ke]||D[hr]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=P.createElement(S),P.head.insertBefore(D,P.querySelector("head > title"))),Ii(D,S,_),D[hr]=d,Ce(D),S=D;break e;case"link":var W=L4("link","href",P).get(S+(_.href||""));if(W){for(var re=0;re<W.length;re++)if(D=W[re],D.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&D.getAttribute("rel")===(_.rel==null?null:_.rel)&&D.getAttribute("title")===(_.title==null?null:_.title)&&D.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){W.splice(re,1);break t}}D=P.createElement(S),Ii(D,S,_),P.head.appendChild(D);break;case"meta":if(W=L4("meta","content",P).get(S+(_.content||""))){for(re=0;re<W.length;re++)if(D=W[re],D.getAttribute("content")===(_.content==null?null:""+_.content)&&D.getAttribute("name")===(_.name==null?null:_.name)&&D.getAttribute("property")===(_.property==null?null:_.property)&&D.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&D.getAttribute("charset")===(_.charSet==null?null:_.charSet)){W.splice(re,1);break t}}D=P.createElement(S),Ii(D,S,_),P.head.appendChild(D);break;default:throw Error(r(468,S))}D[hr]=d,Ce(D),S=D}d.stateNode=S}else I4(P,d.type,d.stateNode);else d.stateNode=O4(P,S,d.memoizedProps);else D!==S?(D===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):D.count--,S===null?I4(P,d.type,d.stateNode):O4(P,S,d.memoizedProps)):S===null&&d.stateNode!==null&&FE(d,d.memoizedProps,_.memoizedProps)}break;case 27:Na(p,d),Ra(d),S&512&&(Fr||_===null||ko(_,_.return)),_!==null&&S&4&&FE(d,d.memoizedProps,_.memoizedProps);break;case 5:if(Na(p,d),Ra(d),S&512&&(Fr||_===null||ko(_,_.return)),d.flags&32){P=d.stateNode;try{No(P,"")}catch(Nt){Dn(d,d.return,Nt)}}S&4&&d.stateNode!=null&&(P=d.memoizedProps,FE(d,P,_!==null?_.memoizedProps:P)),S&1024&&(HE=!0);break;case 6:if(Na(p,d),Ra(d),S&4){if(d.stateNode===null)throw Error(r(162));S=d.memoizedProps,_=d.stateNode;try{_.nodeValue=S}catch(Nt){Dn(d,d.return,Nt)}}break;case 3:if(vb=null,P=ao,ao=gb(p.containerInfo),Na(p,d),ao=P,Ra(d),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Ch(p.containerInfo)}catch(Nt){Dn(d,d.return,Nt)}HE&&(HE=!1,Ij(d));break;case 4:S=ao,ao=gb(d.stateNode.containerInfo),Na(p,d),Ra(d),ao=S;break;case 12:Na(p,d),Ra(d);break;case 31:Na(p,d),Ra(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,nb(d,S)));break;case 13:Na(p,d),Ra(d),d.child.flags&8192&&d.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(ib=L()),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,nb(d,S)));break;case 22:P=d.memoizedState!==null;var Se=_!==null&&_.memoizedState!==null,Be=wl,et=Fr;if(wl=Be||P,Fr=et||Se,Na(p,d),Fr=et,wl=Be,Ra(d),S&8192)e:for(p=d.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Se||wl||Fr||Nd(d)),_=null,p=d;;){if(p.tag===5||p.tag===26){if(_===null){Se=_=p;try{if(D=Se.stateNode,P)W=D.style,typeof W.setProperty=="function"?W.setProperty("display","none","important"):W.display="none";else{re=Se.stateNode;var lt=Se.memoizedProps.style,Ve=lt!=null&&lt.hasOwnProperty("display")?lt.display:null;re.style.display=Ve==null||typeof Ve=="boolean"?"":(""+Ve).trim()}}catch(Nt){Dn(Se,Se.return,Nt)}}}else if(p.tag===6){if(_===null){Se=p;try{Se.stateNode.nodeValue=P?"":Se.memoizedProps}catch(Nt){Dn(Se,Se.return,Nt)}}}else if(p.tag===18){if(_===null){Se=p;try{var Ye=Se.stateNode;P?E4(Ye,!0):E4(Se.stateNode,!1)}catch(Nt){Dn(Se,Se.return,Nt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===d)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break e;for(;p.sibling===null;){if(p.return===null||p.return===d)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=d.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,nb(d,_))));break;case 19:Na(p,d),Ra(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,nb(d,S)));break;case 30:break;case 21:break;default:Na(p,d),Ra(d)}}function Ra(d){var p=d.flags;if(p&2){try{for(var _,S=d.return;S!==null;){if(Tj(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,D=zE(d);tb(d,D,P);break;case 5:var W=_.stateNode;_.flags&32&&(No(W,""),_.flags&=-33);var re=zE(d);tb(d,re,W);break;case 3:case 4:var Se=_.stateNode.containerInfo,Be=zE(d);BE(d,Be,Se);break;default:throw Error(r(161))}}catch(et){Dn(d,d.return,et)}d.flags&=-3}p&4096&&(d.flags&=-4097)}function Ij(d){if(d.subtreeFlags&1024)for(d=d.child;d!==null;){var p=d;Ij(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),d=d.sibling}}function El(d,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)Rj(d,p.alternate,p),p=p.sibling}function Nd(d){for(d=d.child;d!==null;){var p=d;switch(p.tag){case 0:case 11:case 14:case 15:Gc(4,p,p.return),Nd(p);break;case 1:ko(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&Ej(p,p.return,_),Nd(p);break;case 27:Sg(p.stateNode);case 26:case 5:ko(p,p.return),Nd(p);break;case 22:p.memoizedState===null&&Nd(p);break;case 30:Nd(p);break;default:Nd(p)}d=d.sibling}}function Al(d,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,P=d,D=p,W=D.flags;switch(D.tag){case 0:case 11:case 15:Al(P,D,_),fg(4,D);break;case 1:if(Al(P,D,_),S=D,P=S.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Be){Dn(S,S.return,Be)}if(S=D,P=S.updateQueue,P!==null){var re=S.stateNode;try{var Se=P.shared.hiddenCallbacks;if(Se!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Se.length;P++)hI(Se[P],re)}catch(Be){Dn(S,S.return,Be)}}_&&W&64&&Mj(D),hg(D,D.return);break;case 27:Cj(D);case 26:case 5:Al(P,D,_),_&&S===null&&W&4&&Aj(D),hg(D,D.return);break;case 12:Al(P,D,_);break;case 31:Al(P,D,_),_&&W&4&&Dj(P,D);break;case 13:Al(P,D,_),_&&W&4&&Oj(P,D);break;case 22:D.memoizedState===null&&Al(P,D,_),hg(D,D.return);break;case 30:break;default:Al(P,D,_)}p=p.sibling}}function $E(d,p){var _=null;d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),d=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(d=p.memoizedState.cachePool.pool),d!==_&&(d!=null&&d.refCount++,_!=null&&Jm(_))}function VE(d,p){d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&Jm(d))}function so(d,p,_,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)jj(d,p,_,S),p=p.sibling}function jj(d,p,_,S){var P=p.flags;switch(p.tag){case 0:case 11:case 15:so(d,p,_,S),P&2048&&fg(9,p);break;case 1:so(d,p,_,S);break;case 3:so(d,p,_,S),P&2048&&(d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&Jm(d)));break;case 12:if(P&2048){so(d,p,_,S),d=p.stateNode;try{var D=p.memoizedProps,W=D.id,re=D.onPostCommit;typeof re=="function"&&re(W,p.alternate===null?"mount":"update",d.passiveEffectDuration,-0)}catch(Se){Dn(p,p.return,Se)}}else so(d,p,_,S);break;case 31:so(d,p,_,S);break;case 13:so(d,p,_,S);break;case 23:break;case 22:D=p.stateNode,W=p.alternate,p.memoizedState!==null?D._visibility&2?so(d,p,_,S):pg(d,p):D._visibility&2?so(d,p,_,S):(D._visibility|=2,xh(d,p,_,S,(p.subtreeFlags&10256)!==0||!1)),P&2048&&$E(W,p);break;case 24:so(d,p,_,S),P&2048&&VE(p.alternate,p);break;default:so(d,p,_,S)}}function xh(d,p,_,S,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var D=d,W=p,re=_,Se=S,Be=W.flags;switch(W.tag){case 0:case 11:case 15:xh(D,W,re,Se,P),fg(8,W);break;case 23:break;case 22:var et=W.stateNode;W.memoizedState!==null?et._visibility&2?xh(D,W,re,Se,P):pg(D,W):(et._visibility|=2,xh(D,W,re,Se,P)),P&&Be&2048&&$E(W.alternate,W);break;case 24:xh(D,W,re,Se,P),P&&Be&2048&&VE(W.alternate,W);break;default:xh(D,W,re,Se,P)}p=p.sibling}}function pg(d,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=d,S=p,P=S.flags;switch(S.tag){case 22:pg(_,S),P&2048&&$E(S.alternate,S);break;case 24:pg(_,S),P&2048&&VE(S.alternate,S);break;default:pg(_,S)}p=p.sibling}}var mg=8192;function vh(d,p,_){if(d.subtreeFlags&mg)for(d=d.child;d!==null;)Uj(d,p,_),d=d.sibling}function Uj(d,p,_){switch(d.tag){case 26:vh(d,p,_),d.flags&mg&&d.memoizedState!==null&&Xte(_,ao,d.memoizedState,d.memoizedProps);break;case 5:vh(d,p,_);break;case 3:case 4:var S=ao;ao=gb(d.stateNode.containerInfo),vh(d,p,_),ao=S;break;case 22:d.memoizedState===null&&(S=d.alternate,S!==null&&S.memoizedState!==null?(S=mg,mg=16777216,vh(d,p,_),mg=S):vh(d,p,_));break;default:vh(d,p,_)}}function Fj(d){var p=d.alternate;if(p!==null&&(d=p.child,d!==null)){p.child=null;do p=d.sibling,d.sibling=null,d=p;while(d!==null)}}function gg(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];vi=S,Bj(S,d)}Fj(d)}if(d.subtreeFlags&10256)for(d=d.child;d!==null;)zj(d),d=d.sibling}function zj(d){switch(d.tag){case 0:case 11:case 15:gg(d),d.flags&2048&&Gc(9,d,d.return);break;case 3:gg(d);break;case 12:gg(d);break;case 22:var p=d.stateNode;d.memoizedState!==null&&p._visibility&2&&(d.return===null||d.return.tag!==13)?(p._visibility&=-3,rb(d)):gg(d);break;default:gg(d)}}function rb(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];vi=S,Bj(S,d)}Fj(d)}for(d=d.child;d!==null;){switch(p=d,p.tag){case 0:case 11:case 15:Gc(8,p,p.return),rb(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,rb(p));break;default:rb(p)}d=d.sibling}}function Bj(d,p){for(;vi!==null;){var _=vi;switch(_.tag){case 0:case 11:case 15:Gc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:Jm(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,vi=S;else e:for(_=d;vi!==null;){S=vi;var P=S.sibling,D=S.return;if(Pj(S),S===_){vi=null;break e}if(P!==null){P.return=D,vi=P;break e}vi=D}}}var cte={getCacheForType:function(d){var p=Oi(Ir),_=p.data.get(d);return _===void 0&&(_=d(),p.data.set(d,_)),_},cacheSignal:function(){return Oi(Ir).controller.signal}},ute=typeof WeakMap=="function"?WeakMap:Map,Cn=0,Xn=null,fn=null,xn=0,kn=0,Qa=null,Wc=!1,bh=!1,GE=!1,Tl=0,_r=0,qc=0,Rd=0,WE=0,Ja=0,yh=0,xg=null,Pa=null,qE=!1,ib=0,Hj=0,ab=1/0,sb=null,Xc=null,Jr=0,Kc=null,_h=null,Cl=0,XE=0,KE=null,$j=null,vg=0,YE=null;function es(){return(Cn&2)!==0&&xn!==0?xn&-xn:V.T!==null?nA():Pi()}function Vj(){if(Ja===0)if((xn&536870912)===0||yn){var d=fe;fe<<=1,(fe&3932160)===0&&(fe=262144),Ja=d}else Ja=536870912;return d=Ya.current,d!==null&&(d.flags|=32),Ja}function ka(d,p,_){(d===Xn&&(kn===2||kn===9)||d.cancelPendingCommit!==null)&&(Sh(d,0),Yc(d,xn,Ja,!1)),ln(d,_),((Cn&2)===0||d!==Xn)&&(d===Xn&&((Cn&2)===0&&(Rd|=_),_r===4&&Yc(d,xn,Ja,!1)),Do(d))}function Gj(d,p,_){if((Cn&6)!==0)throw Error(r(327));var S=!_&&(p&127)===0&&(p&d.expiredLanes)===0||He(d,p),P=S?hte(d,p):QE(d,p,!0),D=S;do{if(P===0){bh&&!S&&Yc(d,p,0,!1);break}else{if(_=d.current.alternate,D&&!dte(_)){P=QE(d,p,!1),D=!1;continue}if(P===2){if(D=p,d.errorRecoveryDisabledLanes&D)var W=0;else W=d.pendingLanes&-536870913,W=W!==0?W:W&536870912?536870912:0;if(W!==0){p=W;e:{var re=d;P=xg;var Se=re.current.memoizedState.isDehydrated;if(Se&&(Sh(re,W).flags|=256),W=QE(re,W,!1),W!==2){if(GE&&!Se){re.errorRecoveryDisabledLanes|=D,Rd|=D,P=4;break e}D=Pa,Pa=P,D!==null&&(Pa===null?Pa=D:Pa.push.apply(Pa,D))}P=W}if(D=!1,P!==2)continue}}if(P===1){Sh(d,0),Yc(d,p,0,!0);break}e:{switch(S=d,D=P,D){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:Yc(S,p,Ja,!Wc);break e;case 2:Pa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=ib+300-L(),10<P)){if(Yc(S,p,Ja,!Wc),be(S,0,!0)!==0)break e;Cl=p,S.timeoutHandle=S4(Wj.bind(null,S,_,Pa,sb,qE,p,Ja,Rd,yh,Wc,D,"Throttled",-0,0),P);break e}Wj(S,_,Pa,sb,qE,p,Ja,Rd,yh,Wc,D,null,-0,0)}}break}while(!0);Do(d)}function Wj(d,p,_,S,P,D,W,re,Se,Be,et,lt,Ve,Ye){if(d.timeoutHandle=-1,lt=p.subtreeFlags,lt&8192||(lt&16785408)===16785408){lt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:hl},Uj(p,D,lt);var Nt=(D&62914560)===D?ib-L():(D&4194048)===D?Hj-L():0;if(Nt=Kte(lt,Nt),Nt!==null){Cl=D,d.cancelPendingCommit=Nt(e4.bind(null,d,p,D,_,S,P,W,re,Se,et,lt,null,Ve,Ye)),Yc(d,D,W,!Be);return}}e4(d,p,D,_,S,P,W,re,Se)}function dte(d){for(var p=d;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var P=_[S],D=P.getSnapshot;P=P.value;try{if(!Xa(D(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Yc(d,p,_,S){p&=~WE,p&=~Rd,d.suspendedLanes|=p,d.pingedLanes&=~p,S&&(d.warmLanes|=p),S=d.expirationTimes;for(var P=p;0<P;){var D=31-rt(P),W=1<<D;S[D]=-1,P&=~W}_!==0&&Rn(d,_,p)}function ob(){return(Cn&6)===0?(bg(0),!1):!0}function ZE(){if(fn!==null){if(kn===0)var d=fn.return;else d=fn,xl=_d=null,hE(d),fh=null,tg=0,d=fn;for(;d!==null;)wj(d.alternate,d),d=d.return;fn=null}}function Sh(d,p){var _=d.timeoutHandle;_!==-1&&(d.timeoutHandle=-1,Pte(_)),_=d.cancelPendingCommit,_!==null&&(d.cancelPendingCommit=null,_()),Cl=0,ZE(),Xn=d,fn=_=ml(d.current,null),xn=p,kn=0,Qa=null,Wc=!1,bh=He(d,p),GE=!1,yh=Ja=WE=Rd=qc=_r=0,Pa=xg=null,qE=!1,(p&8)!==0&&(p|=p&32);var S=d.entangledLanes;if(S!==0)for(d=d.entanglements,S&=p;0<S;){var P=31-rt(S),D=1<<P;p|=d[P],S&=~D}return Tl=p,Cv(),_}function qj(d,p){Qt=null,V.H=cg,p===dh||p===Iv?(p=cI(),kn=3):p===tE?(p=cI(),kn=4):kn=p===NE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,Qa=p,fn===null&&(_r=1,Yv(d,bs(p,d.current)))}function Xj(){var d=Ya.current;return d===null?!0:(xn&4194048)===xn?ws===null:(xn&62914560)===xn||(xn&536870912)!==0?d===ws:!1}function Kj(){var d=V.H;return V.H=cg,d===null?cg:d}function Yj(){var d=V.A;return V.A=cte,d}function lb(){_r=4,Wc||(xn&4194048)!==xn&&Ya.current!==null||(bh=!0),(qc&134217727)===0&&(Rd&134217727)===0||Xn===null||Yc(Xn,xn,Ja,!1)}function QE(d,p,_){var S=Cn;Cn|=2;var P=Kj(),D=Yj();(Xn!==d||xn!==p)&&(sb=null,Sh(d,p)),p=!1;var W=_r;e:do try{if(kn!==0&&fn!==null){var re=fn,Se=Qa;switch(kn){case 8:ZE(),W=6;break e;case 3:case 2:case 9:case 6:Ya.current===null&&(p=!0);var Be=kn;if(kn=0,Qa=null,wh(d,re,Se,Be),_&&bh){W=0;break e}break;default:Be=kn,kn=0,Qa=null,wh(d,re,Se,Be)}}fte(),W=_r;break}catch(et){qj(d,et)}while(!0);return p&&d.shellSuspendCounter++,xl=_d=null,Cn=S,V.H=P,V.A=D,fn===null&&(Xn=null,xn=0,Cv()),W}function fte(){for(;fn!==null;)Zj(fn)}function hte(d,p){var _=Cn;Cn|=2;var S=Kj(),P=Yj();Xn!==d||xn!==p?(sb=null,ab=L()+500,Sh(d,p)):bh=He(d,p);e:do try{if(kn!==0&&fn!==null){p=fn;var D=Qa;t:switch(kn){case 1:kn=0,Qa=null,wh(d,p,D,1);break;case 2:case 9:if(oI(D)){kn=0,Qa=null,Qj(p);break}p=function(){kn!==2&&kn!==9||Xn!==d||(kn=7),Do(d)},D.then(p,p);break e;case 3:kn=7;break e;case 4:kn=5;break e;case 7:oI(D)?(kn=0,Qa=null,Qj(p)):(kn=0,Qa=null,wh(d,p,D,7));break;case 5:var W=null;switch(fn.tag){case 26:W=fn.memoizedState;case 5:case 27:var re=fn;if(W?j4(W):re.stateNode.complete){kn=0,Qa=null;var Se=re.sibling;if(Se!==null)fn=Se;else{var Be=re.return;Be!==null?(fn=Be,cb(Be)):fn=null}break t}}kn=0,Qa=null,wh(d,p,D,5);break;case 6:kn=0,Qa=null,wh(d,p,D,6);break;case 8:ZE(),_r=6;break e;default:throw Error(r(462))}}pte();break}catch(et){qj(d,et)}while(!0);return xl=_d=null,V.H=S,V.A=P,Cn=_,fn!==null?0:(Xn=null,xn=0,Cv(),_r)}function pte(){for(;fn!==null&&!ne();)Zj(fn)}function Zj(d){var p=_j(d.alternate,d,Tl);d.memoizedProps=d.pendingProps,p===null?cb(d):fn=p}function Qj(d){var p=d,_=p.alternate;switch(p.tag){case 15:case 0:p=mj(_,p,p.pendingProps,p.type,void 0,xn);break;case 11:p=mj(_,p,p.pendingProps,p.type.render,p.ref,xn);break;case 5:hE(p);default:wj(_,p),p=fn=YL(p,Tl),p=_j(_,p,Tl)}d.memoizedProps=d.pendingProps,p===null?cb(d):fn=p}function wh(d,p,_,S){xl=_d=null,hE(p),fh=null,tg=0;var P=p.return;try{if(nte(d,P,p,_,xn)){_r=1,Yv(d,bs(_,d.current)),fn=null;return}}catch(D){if(P!==null)throw fn=P,D;_r=1,Yv(d,bs(_,d.current)),fn=null;return}p.flags&32768?(yn||S===1?d=!0:bh||(xn&536870912)!==0?d=!1:(Wc=d=!0,(S===2||S===9||S===3||S===6)&&(S=Ya.current,S!==null&&S.tag===13&&(S.flags|=16384))),Jj(p,d)):cb(p)}function cb(d){var p=d;do{if((p.flags&32768)!==0){Jj(p,Wc);return}d=p.return;var _=ate(p.alternate,p,Tl);if(_!==null){fn=_;return}if(p=p.sibling,p!==null){fn=p;return}fn=p=d}while(p!==null);_r===0&&(_r=5)}function Jj(d,p){do{var _=ste(d.alternate,d);if(_!==null){_.flags&=32767,fn=_;return}if(_=d.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(d=d.sibling,d!==null)){fn=d;return}fn=d=_}while(d!==null);_r=6,fn=null}function e4(d,p,_,S,P,D,W,re,Se){d.cancelPendingCommit=null;do ub();while(Jr!==0);if((Cn&6)!==0)throw Error(r(327));if(p!==null){if(p===d.current)throw Error(r(177));if(D=p.lanes|p.childLanes,D|=zM,Dt(d,_,D,W,re,Se),d===Xn&&(fn=Xn=null,xn=0),_h=p,Kc=d,Cl=_,XE=D,KE=P,$j=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(d.callbackNode=null,d.callbackPriority=0,vte(pe,function(){return a4(),null})):(d.callbackNode=null,d.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=V.T,V.T=null,P=G.p,G.p=2,W=Cn,Cn|=4;try{ote(d,p,_)}finally{Cn=W,G.p=P,V.T=S}}Jr=1,t4(),n4(),r4()}}function t4(){if(Jr===1){Jr=0;var d=Kc,p=_h,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=V.T,V.T=null;var S=G.p;G.p=2;var P=Cn;Cn|=4;try{Lj(p,d);var D=uA,W=BL(d.containerInfo),re=D.focusedElem,Se=D.selectionRange;if(W!==re&&re&&re.ownerDocument&&zL(re.ownerDocument.documentElement,re)){if(Se!==null&&LM(re)){var Be=Se.start,et=Se.end;if(et===void 0&&(et=Be),"selectionStart"in re)re.selectionStart=Be,re.selectionEnd=Math.min(et,re.value.length);else{var lt=re.ownerDocument||document,Ve=lt&&lt.defaultView||window;if(Ve.getSelection){var Ye=Ve.getSelection(),Nt=re.textContent.length,Ht=Math.min(Se.start,Nt),Fn=Se.end===void 0?Ht:Math.min(Se.end,Nt);!Ye.extend&&Ht>Fn&&(W=Fn,Fn=Ht,Ht=W);var Oe=FL(re,Ht),Ae=FL(re,Fn);if(Oe&&Ae&&(Ye.rangeCount!==1||Ye.anchorNode!==Oe.node||Ye.anchorOffset!==Oe.offset||Ye.focusNode!==Ae.node||Ye.focusOffset!==Ae.offset)){var ze=lt.createRange();ze.setStart(Oe.node,Oe.offset),Ye.removeAllRanges(),Ht>Fn?(Ye.addRange(ze),Ye.extend(Ae.node,Ae.offset)):(ze.setEnd(Ae.node,Ae.offset),Ye.addRange(ze))}}}}for(lt=[],Ye=re;Ye=Ye.parentNode;)Ye.nodeType===1&&lt.push({element:Ye,left:Ye.scrollLeft,top:Ye.scrollTop});for(typeof re.focus=="function"&&re.focus(),re=0;re<lt.length;re++){var at=lt[re];at.element.scrollLeft=at.left,at.element.scrollTop=at.top}}Sb=!!cA,uA=cA=null}finally{Cn=P,G.p=S,V.T=_}}d.current=p,Jr=2}}function n4(){if(Jr===2){Jr=0;var d=Kc,p=_h,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=V.T,V.T=null;var S=G.p;G.p=2;var P=Cn;Cn|=4;try{Rj(d,p.alternate,p)}finally{Cn=P,G.p=S,V.T=_}}Jr=3}}function r4(){if(Jr===4||Jr===3){Jr=0,F();var d=Kc,p=_h,_=Cl,S=$j;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?Jr=5:(Jr=0,_h=Kc=null,i4(d,d.pendingLanes));var P=d.pendingLanes;if(P===0&&(Xc=null),mi(_),p=p.stateNode,ke&&typeof ke.onCommitFiberRoot=="function")try{ke.onCommitFiberRoot(je,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=V.T,P=G.p,G.p=2,V.T=null;try{for(var D=d.onRecoverableError,W=0;W<S.length;W++){var re=S[W];D(re.value,{componentStack:re.stack})}}finally{V.T=p,G.p=P}}(Cl&3)!==0&&ub(),Do(d),P=d.pendingLanes,(_&261930)!==0&&(P&42)!==0?d===YE?vg++:(vg=0,YE=d):vg=0,bg(0)}}function i4(d,p){(d.pooledCacheLanes&=p)===0&&(p=d.pooledCache,p!=null&&(d.pooledCache=null,Jm(p)))}function ub(){return t4(),n4(),r4(),a4()}function a4(){if(Jr!==5)return!1;var d=Kc,p=XE;XE=0;var _=mi(Cl),S=V.T,P=G.p;try{G.p=32>_?32:_,V.T=null,_=KE,KE=null;var D=Kc,W=Cl;if(Jr=0,_h=Kc=null,Cl=0,(Cn&6)!==0)throw Error(r(331));var re=Cn;if(Cn|=4,zj(D.current),jj(D,D.current,W,_),Cn=re,bg(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(je,D)}catch{}return!0}finally{G.p=P,V.T=S,i4(d,p)}}function s4(d,p,_){p=bs(_,p),p=CE(d.stateNode,p,2),d=Hc(d,p,2),d!==null&&(ln(d,2),Do(d))}function Dn(d,p,_){if(d.tag===3)s4(d,d,_);else for(;p!==null;){if(p.tag===3){s4(p,d,_);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(Xc===null||!Xc.has(S))){d=bs(_,d),_=oj(2),S=Hc(p,_,2),S!==null&&(lj(_,S,p,d),ln(S,2),Do(S));break}}p=p.return}}function JE(d,p,_){var S=d.pingCache;if(S===null){S=d.pingCache=new ute;var P=new Set;S.set(p,P)}else P=S.get(p),P===void 0&&(P=new Set,S.set(p,P));P.has(_)||(GE=!0,P.add(_),d=mte.bind(null,d,p,_),p.then(d,d))}function mte(d,p,_){var S=d.pingCache;S!==null&&S.delete(p),d.pingedLanes|=d.suspendedLanes&_,d.warmLanes&=~_,Xn===d&&(xn&_)===_&&(_r===4||_r===3&&(xn&62914560)===xn&&300>L()-ib?(Cn&2)===0&&Sh(d,0):WE|=_,yh===xn&&(yh=0)),Do(d)}function o4(d,p){p===0&&(p=_t()),d=vd(d,p),d!==null&&(ln(d,p),Do(d))}function gte(d){var p=d.memoizedState,_=0;p!==null&&(_=p.retryLane),o4(d,_)}function xte(d,p){var _=0;switch(d.tag){case 31:case 13:var S=d.stateNode,P=d.memoizedState;P!==null&&(_=P.retryLane);break;case 19:S=d.stateNode;break;case 22:S=d.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(p),o4(d,_)}function vte(d,p){return Re(d,p)}var db=null,Mh=null,eA=!1,fb=!1,tA=!1,Zc=0;function Do(d){d!==Mh&&d.next===null&&(Mh===null?db=Mh=d:Mh=Mh.next=d),fb=!0,eA||(eA=!0,yte())}function bg(d,p){if(!tA&&fb){tA=!0;do for(var _=!1,S=db;S!==null;){if(d!==0){var P=S.pendingLanes;if(P===0)var D=0;else{var W=S.suspendedLanes,re=S.pingedLanes;D=(1<<31-rt(42|d)+1)-1,D&=P&~(W&~re),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(_=!0,d4(S,D))}else D=xn,D=be(S,S===Xn?D:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(D&3)===0||He(S,D)||(_=!0,d4(S,D));S=S.next}while(_);tA=!1}}function bte(){l4()}function l4(){fb=eA=!1;var d=0;Zc!==0&&Rte()&&(d=Zc);for(var p=L(),_=null,S=db;S!==null;){var P=S.next,D=c4(S,p);D===0?(S.next=null,_===null?db=P:_.next=P,P===null&&(Mh=_)):(_=S,(d!==0||(D&3)!==0)&&(fb=!0)),S=P}Jr!==0&&Jr!==5||bg(d),Zc!==0&&(Zc=0)}function c4(d,p){for(var _=d.suspendedLanes,S=d.pingedLanes,P=d.expirationTimes,D=d.pendingLanes&-62914561;0<D;){var W=31-rt(D),re=1<<W,Se=P[W];Se===-1?((re&_)===0||(re&S)!==0)&&(P[W]=ut(re,p)):Se<=p&&(d.expiredLanes|=re),D&=~re}if(p=Xn,_=xn,_=be(d,d===p?_:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S=d.callbackNode,_===0||d===p&&(kn===2||kn===9)||d.cancelPendingCommit!==null)return S!==null&&S!==null&&Pe(S),d.callbackNode=null,d.callbackPriority=0;if((_&3)===0||He(d,_)){if(p=_&-_,p===d.callbackPriority)return p;switch(S!==null&&Pe(S),mi(_)){case 2:case 8:_=ye;break;case 32:_=pe;break;case 268435456:_=Ie;break;default:_=pe}return S=u4.bind(null,d),_=Re(_,S),d.callbackPriority=p,d.callbackNode=_,p}return S!==null&&S!==null&&Pe(S),d.callbackPriority=2,d.callbackNode=null,2}function u4(d,p){if(Jr!==0&&Jr!==5)return d.callbackNode=null,d.callbackPriority=0,null;var _=d.callbackNode;if(ub()&&d.callbackNode!==_)return null;var S=xn;return S=be(d,d===Xn?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S===0?null:(Gj(d,S,p),c4(d,L()),d.callbackNode!=null&&d.callbackNode===_?u4.bind(null,d):null)}function d4(d,p){if(ub())return null;Gj(d,p,!0)}function yte(){kte(function(){(Cn&6)!==0?Re(ge,bte):l4()})}function nA(){if(Zc===0){var d=ch;d===0&&(d=it,it<<=1,(it&261888)===0&&(it=256)),Zc=d}return Zc}function f4(d){return d==null||typeof d=="symbol"||typeof d=="boolean"?null:typeof d=="function"?d:yv(""+d)}function h4(d,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,d.id&&_.setAttribute("form",d.id),p.parentNode.insertBefore(_,p),d=new FormData(d),_.parentNode.removeChild(_),d}function _te(d,p,_,S,P){if(p==="submit"&&_&&_.stateNode===P){var D=f4((P[Ar]||null).action),W=S.submitter;W&&(p=(p=W[Ar]||null)?f4(p.formAction):W.getAttribute("formAction"),p!==null&&(D=p,W=null));var re=new Mv("action","action",null,S,P);d.push({event:re,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Zc!==0){var Se=W?h4(P,W):new FormData(P);SE(_,{pending:!0,data:Se,method:P.method,action:D},null,Se)}}else typeof D=="function"&&(re.preventDefault(),Se=W?h4(P,W):new FormData(P),SE(_,{pending:!0,data:Se,method:P.method,action:D},D,Se))},currentTarget:P}]})}}for(var rA=0;rA<FM.length;rA++){var iA=FM[rA],Ste=iA.toLowerCase(),wte=iA[0].toUpperCase()+iA.slice(1);io(Ste,"on"+wte)}io(VL,"onAnimationEnd"),io(GL,"onAnimationIteration"),io(WL,"onAnimationStart"),io("dblclick","onDoubleClick"),io("focusin","onFocus"),io("focusout","onBlur"),io(Fee,"onTransitionRun"),io(zee,"onTransitionStart"),io(Bee,"onTransitionCancel"),io(qL,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var yg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Mte=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yg));function p4(d,p){p=(p&4)!==0;for(var _=0;_<d.length;_++){var S=d[_],P=S.event;S=S.listeners;e:{var D=void 0;if(p)for(var W=S.length-1;0<=W;W--){var re=S[W],Se=re.instance,Be=re.currentTarget;if(re=re.listener,Se!==D&&P.isPropagationStopped())break e;D=re,P.currentTarget=Be;try{D(P)}catch(et){Tv(et)}P.currentTarget=null,D=Se}else for(W=0;W<S.length;W++){if(re=S[W],Se=re.instance,Be=re.currentTarget,re=re.listener,Se!==D&&P.isPropagationStopped())break e;D=re,P.currentTarget=Be;try{D(P)}catch(et){Tv(et)}P.currentTarget=null,D=Se}}}}function hn(d,p){var _=p[Oc];_===void 0&&(_=p[Oc]=new Set);var S=d+"__bubble";_.has(S)||(m4(p,d,2,!1),_.add(S))}function aA(d,p,_){var S=0;p&&(S|=4),m4(_,d,S,p)}var hb="_reactListening"+Math.random().toString(36).slice(2);function sA(d){if(!d[hb]){d[hb]=!0,Me.forEach(function(_){_!=="selectionchange"&&(Mte.has(_)||aA(_,!1,d),aA(_,!0,d))});var p=d.nodeType===9?d:d.ownerDocument;p===null||p[hb]||(p[hb]=!0,aA("selectionchange",!1,p))}}function m4(d,p,_,S){switch(V4(p)){case 2:var P=Qte;break;case 8:P=Jte;break;default:P=_A}_=P.bind(null,p,_,d),P=void 0,!AM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),S?P!==void 0?d.addEventListener(p,_,{capture:!0,passive:P}):d.addEventListener(p,_,!0):P!==void 0?d.addEventListener(p,_,{passive:P}):d.addEventListener(p,_,!1)}function oA(d,p,_,S,P){var D=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var W=S.tag;if(W===3||W===4){var re=S.stateNode.containerInfo;if(re===P)break;if(W===4)for(W=S.return;W!==null;){var Se=W.tag;if((Se===3||Se===4)&&W.stateNode.containerInfo===P)return;W=W.return}for(;re!==null;){if(W=St(re),W===null)return;if(Se=W.tag,Se===5||Se===6||Se===26||Se===27){S=D=W;continue e}re=re.parentNode}}S=S.return}yL(function(){var Be=D,et=MM(_),lt=[];e:{var Ve=XL.get(d);if(Ve!==void 0){var Ye=Mv,Nt=d;switch(d){case"keypress":if(Sv(_)===0)break e;case"keydown":case"keyup":Ye=xee;break;case"focusin":Nt="focus",Ye=RM;break;case"focusout":Nt="blur",Ye=RM;break;case"beforeblur":case"afterblur":Ye=RM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ye=wL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ye=aee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ye=yee;break;case VL:case GL:case WL:Ye=lee;break;case qL:Ye=See;break;case"scroll":case"scrollend":Ye=ree;break;case"wheel":Ye=Mee;break;case"copy":case"cut":case"paste":Ye=uee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ye=EL;break;case"toggle":case"beforetoggle":Ye=Aee}var Ht=(p&4)!==0,Fn=!Ht&&(d==="scroll"||d==="scrollend"),Oe=Ht?Ve!==null?Ve+"Capture":null:Ve;Ht=[];for(var Ae=Be,ze;Ae!==null;){var at=Ae;if(ze=at.stateNode,at=at.tag,at!==5&&at!==26&&at!==27||ze===null||Oe===null||(at=Hm(Ae,Oe),at!=null&&Ht.push(_g(Ae,at,ze))),Fn)break;Ae=Ae.return}0<Ht.length&&(Ve=new Ye(Ve,Nt,null,_,et),lt.push({event:Ve,listeners:Ht}))}}if((p&7)===0){e:{if(Ve=d==="mouseover"||d==="pointerover",Ye=d==="mouseout"||d==="pointerout",Ve&&_!==wM&&(Nt=_.relatedTarget||_.fromElement)&&(St(Nt)||Nt[no]))break e;if((Ye||Ve)&&(Ve=et.window===et?et:(Ve=et.ownerDocument)?Ve.defaultView||Ve.parentWindow:window,Ye?(Nt=_.relatedTarget||_.toElement,Ye=Be,Nt=Nt?St(Nt):null,Nt!==null&&(Fn=a(Nt),Ht=Nt.tag,Nt!==Fn||Ht!==5&&Ht!==27&&Ht!==6)&&(Nt=null)):(Ye=null,Nt=Be),Ye!==Nt)){if(Ht=wL,at="onMouseLeave",Oe="onMouseEnter",Ae="mouse",(d==="pointerout"||d==="pointerover")&&(Ht=EL,at="onPointerLeave",Oe="onPointerEnter",Ae="pointer"),Fn=Ye==null?Ve:_e(Ye),ze=Nt==null?Ve:_e(Nt),Ve=new Ht(at,Ae+"leave",Ye,_,et),Ve.target=Fn,Ve.relatedTarget=ze,at=null,St(et)===Be&&(Ht=new Ht(Oe,Ae+"enter",Nt,_,et),Ht.target=ze,Ht.relatedTarget=Fn,at=Ht),Fn=at,Ye&&Nt)t:{for(Ht=Ete,Oe=Ye,Ae=Nt,ze=0,at=Oe;at;at=Ht(at))ze++;at=0;for(var It=Ae;It;It=Ht(It))at++;for(;0<ze-at;)Oe=Ht(Oe),ze--;for(;0<at-ze;)Ae=Ht(Ae),at--;for(;ze--;){if(Oe===Ae||Ae!==null&&Oe===Ae.alternate){Ht=Oe;break t}Oe=Ht(Oe),Ae=Ht(Ae)}Ht=null}else Ht=null;Ye!==null&&g4(lt,Ve,Ye,Ht,!1),Nt!==null&&Fn!==null&&g4(lt,Fn,Nt,Ht,!0)}}e:{if(Ve=Be?_e(Be):window,Ye=Ve.nodeName&&Ve.nodeName.toLowerCase(),Ye==="select"||Ye==="input"&&Ve.type==="file")var wn=DL;else if(PL(Ve))if(OL)wn=Iee;else{wn=Oee;var kt=Dee}else Ye=Ve.nodeName,!Ye||Ye.toLowerCase()!=="input"||Ve.type!=="checkbox"&&Ve.type!=="radio"?Be&&SM(Be.elementType)&&(wn=DL):wn=Lee;if(wn&&(wn=wn(d,Be))){kL(lt,wn,_,et);break e}kt&&kt(d,Ve,Be),d==="focusout"&&Be&&Ve.type==="number"&&Be.memoizedProps.value!=null&&gi(Ve,"number",Ve.value)}switch(kt=Be?_e(Be):window,d){case"focusin":(PL(kt)||kt.contentEditable==="true")&&(th=kt,IM=Be,Ym=null);break;case"focusout":Ym=IM=th=null;break;case"mousedown":jM=!0;break;case"contextmenu":case"mouseup":case"dragend":jM=!1,HL(lt,_,et);break;case"selectionchange":if(Uee)break;case"keydown":case"keyup":HL(lt,_,et)}var Jt;if(kM)e:{switch(d){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else eh?NL(d,_)&&(vn="onCompositionEnd"):d==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(AL&&_.locale!=="ko"&&(eh||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&eh&&(Jt=_L()):(Lc=et,TM="value"in Lc?Lc.value:Lc.textContent,eh=!0)),kt=pb(Be,vn),0<kt.length&&(vn=new ML(vn,d,null,_,et),lt.push({event:vn,listeners:kt}),Jt?vn.data=Jt:(Jt=RL(_),Jt!==null&&(vn.data=Jt)))),(Jt=Cee?Nee(d,_):Ree(d,_))&&(vn=pb(Be,"onBeforeInput"),0<vn.length&&(kt=new ML("onBeforeInput","beforeinput",null,_,et),lt.push({event:kt,listeners:vn}),kt.data=Jt)),_te(lt,d,Be,_,et)}p4(lt,p)})}function _g(d,p,_){return{instance:d,listener:p,currentTarget:_}}function pb(d,p){for(var _=p+"Capture",S=[];d!==null;){var P=d,D=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||D===null||(P=Hm(d,_),P!=null&&S.unshift(_g(d,P,D)),P=Hm(d,p),P!=null&&S.push(_g(d,P,D))),d.tag===3)return S;d=d.return}return[]}function Ete(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5&&d.tag!==27);return d||null}function g4(d,p,_,S,P){for(var D=p._reactName,W=[];_!==null&&_!==S;){var re=_,Se=re.alternate,Be=re.stateNode;if(re=re.tag,Se!==null&&Se===S)break;re!==5&&re!==26&&re!==27||Be===null||(Se=Be,P?(Be=Hm(_,D),Be!=null&&W.unshift(_g(_,Be,Se))):P||(Be=Hm(_,D),Be!=null&&W.push(_g(_,Be,Se)))),_=_.return}W.length!==0&&d.push({event:p,listeners:W})}var Ate=/\r\n?/g,Tte=/\u0000|\uFFFD/g;function x4(d){return(typeof d=="string"?d:""+d).replace(Ate,`
  9. `).replace(Tte,"")}function v4(d,p){return p=x4(p),x4(d)===p}function Un(d,p,_,S,P,D){switch(_){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||No(d,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&No(d,""+S);break;case"className":Lt(d,"class",S);break;case"tabIndex":Lt(d,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Lt(d,_,S);break;case"style":vL(d,S,D);break;case"data":if(p!=="object"){Lt(d,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||_!=="href")){d.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=yv(""+S),d.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){d.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 D=="function"&&(_==="formAction"?(p!=="input"&&Un(d,p,"name",P.name,P,null),Un(d,p,"formEncType",P.formEncType,P,null),Un(d,p,"formMethod",P.formMethod,P,null),Un(d,p,"formTarget",P.formTarget,P,null)):(Un(d,p,"encType",P.encType,P,null),Un(d,p,"method",P.method,P,null),Un(d,p,"target",P.target,P,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=yv(""+S),d.setAttribute(_,S);break;case"onClick":S!=null&&(d.onclick=hl);break;case"onScroll":S!=null&&hn("scroll",d);break;case"onScrollEnd":S!=null&&hn("scrollend",d);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));d.innerHTML=_}}break;case"multiple":d.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":d.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){d.removeAttribute("xlink:href");break}_=yv(""+S),d.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":S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,""+S):d.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":S&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,""):d.removeAttribute(_);break;case"capture":case"download":S===!0?d.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,S):d.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?d.setAttribute(_,S):d.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?d.removeAttribute(_):d.setAttribute(_,S);break;case"popover":hn("beforetoggle",d),hn("toggle",d),Gt(d,"popover",S);break;case"xlinkActuate":en(d,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":en(d,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":en(d,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":en(d,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":en(d,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":en(d,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":en(d,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":en(d,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":en(d,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Gt(d,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=tee.get(_)||_,Gt(d,_,S))}}function lA(d,p,_,S,P,D){switch(_){case"style":vL(d,S,D);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));d.innerHTML=_}}break;case"children":typeof S=="string"?No(d,S):(typeof S=="number"||typeof S=="bigint")&&No(d,""+S);break;case"onScroll":S!=null&&hn("scroll",d);break;case"onScrollEnd":S!=null&&hn("scrollend",d);break;case"onClick":S!=null&&(d.onclick=hl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qe.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),D=d[Ar]||null,D=D!=null?D[_]:null,typeof D=="function"&&d.removeEventListener(p,D,P),typeof S=="function")){typeof D!="function"&&D!==null&&(_ in d?d[_]=null:d.hasAttribute(_)&&d.removeAttribute(_)),d.addEventListener(p,S,P);break e}_ in d?d[_]=S:S===!0?d.setAttribute(_,""):Gt(d,_,S)}}}function Ii(d,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":hn("error",d),hn("load",d);var S=!1,P=!1,D;for(D in _)if(_.hasOwnProperty(D)){var W=_[D];if(W!=null)switch(D){case"src":S=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,D,W,_,null)}}P&&Un(d,p,"srcSet",_.srcSet,_,null),S&&Un(d,p,"src",_.src,_,null);return;case"input":hn("invalid",d);var re=D=W=P=null,Se=null,Be=null;for(S in _)if(_.hasOwnProperty(S)){var et=_[S];if(et!=null)switch(S){case"name":P=et;break;case"type":W=et;break;case"checked":Se=et;break;case"defaultChecked":Be=et;break;case"value":D=et;break;case"defaultValue":re=et;break;case"children":case"dangerouslySetInnerHTML":if(et!=null)throw Error(r(137,p));break;default:Un(d,p,S,et,_,null)}}Pn(d,D,re,Se,Be,W,P,!1);return;case"select":hn("invalid",d),S=W=D=null;for(P in _)if(_.hasOwnProperty(P)&&(re=_[P],re!=null))switch(P){case"value":D=re;break;case"defaultValue":W=re;break;case"multiple":S=re;default:Un(d,p,P,re,_,null)}p=D,_=W,d.multiple=!!S,p!=null?Qr(d,!!S,p,!1):_!=null&&Qr(d,!!S,_,!0);return;case"textarea":hn("invalid",d),D=P=S=null;for(W in _)if(_.hasOwnProperty(W)&&(re=_[W],re!=null))switch(W){case"value":S=re;break;case"defaultValue":P=re;break;case"children":D=re;break;case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(91));break;default:Un(d,p,W,re,_,null)}ki(d,S,P,D);return;case"option":for(Se in _)if(_.hasOwnProperty(Se)&&(S=_[Se],S!=null))switch(Se){case"selected":d.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Un(d,p,Se,S,_,null)}return;case"dialog":hn("beforetoggle",d),hn("toggle",d),hn("cancel",d),hn("close",d);break;case"iframe":case"object":hn("load",d);break;case"video":case"audio":for(S=0;S<yg.length;S++)hn(yg[S],d);break;case"image":hn("error",d),hn("load",d);break;case"details":hn("toggle",d);break;case"embed":case"source":case"link":hn("error",d),hn("load",d);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Be in _)if(_.hasOwnProperty(Be)&&(S=_[Be],S!=null))switch(Be){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,Be,S,_,null)}return;default:if(SM(p)){for(et in _)_.hasOwnProperty(et)&&(S=_[et],S!==void 0&&lA(d,p,et,S,_,void 0));return}}for(re in _)_.hasOwnProperty(re)&&(S=_[re],S!=null&&Un(d,p,re,S,_,null))}function Cte(d,p,_,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,D=null,W=null,re=null,Se=null,Be=null,et=null;for(Ye in _){var lt=_[Ye];if(_.hasOwnProperty(Ye)&&lt!=null)switch(Ye){case"checked":break;case"value":break;case"defaultValue":Se=lt;default:S.hasOwnProperty(Ye)||Un(d,p,Ye,null,S,lt)}}for(var Ve in S){var Ye=S[Ve];if(lt=_[Ve],S.hasOwnProperty(Ve)&&(Ye!=null||lt!=null))switch(Ve){case"type":D=Ye;break;case"name":P=Ye;break;case"checked":Be=Ye;break;case"defaultChecked":et=Ye;break;case"value":W=Ye;break;case"defaultValue":re=Ye;break;case"children":case"dangerouslySetInnerHTML":if(Ye!=null)throw Error(r(137,p));break;default:Ye!==lt&&Un(d,p,Ve,Ye,S,lt)}}ro(d,W,re,Se,Be,et,D,P);return;case"select":Ye=W=re=Ve=null;for(D in _)if(Se=_[D],_.hasOwnProperty(D)&&Se!=null)switch(D){case"value":break;case"multiple":Ye=Se;default:S.hasOwnProperty(D)||Un(d,p,D,null,S,Se)}for(P in S)if(D=S[P],Se=_[P],S.hasOwnProperty(P)&&(D!=null||Se!=null))switch(P){case"value":Ve=D;break;case"defaultValue":re=D;break;case"multiple":W=D;default:D!==Se&&Un(d,p,P,D,S,Se)}p=re,_=W,S=Ye,Ve!=null?Qr(d,!!_,Ve,!1):!!S!=!!_&&(p!=null?Qr(d,!!_,p,!0):Qr(d,!!_,_?[]:"",!1));return;case"textarea":Ye=Ve=null;for(re in _)if(P=_[re],_.hasOwnProperty(re)&&P!=null&&!S.hasOwnProperty(re))switch(re){case"value":break;case"children":break;default:Un(d,p,re,null,S,P)}for(W in S)if(P=S[W],D=_[W],S.hasOwnProperty(W)&&(P!=null||D!=null))switch(W){case"value":Ve=P;break;case"defaultValue":Ye=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==D&&Un(d,p,W,P,S,D)}xi(d,Ve,Ye);return;case"option":for(var Nt in _)if(Ve=_[Nt],_.hasOwnProperty(Nt)&&Ve!=null&&!S.hasOwnProperty(Nt))switch(Nt){case"selected":d.selected=!1;break;default:Un(d,p,Nt,null,S,Ve)}for(Se in S)if(Ve=S[Se],Ye=_[Se],S.hasOwnProperty(Se)&&Ve!==Ye&&(Ve!=null||Ye!=null))switch(Se){case"selected":d.selected=Ve&&typeof Ve!="function"&&typeof Ve!="symbol";break;default:Un(d,p,Se,Ve,S,Ye)}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 Ht in _)Ve=_[Ht],_.hasOwnProperty(Ht)&&Ve!=null&&!S.hasOwnProperty(Ht)&&Un(d,p,Ht,null,S,Ve);for(Be in S)if(Ve=S[Be],Ye=_[Be],S.hasOwnProperty(Be)&&Ve!==Ye&&(Ve!=null||Ye!=null))switch(Be){case"children":case"dangerouslySetInnerHTML":if(Ve!=null)throw Error(r(137,p));break;default:Un(d,p,Be,Ve,S,Ye)}return;default:if(SM(p)){for(var Fn in _)Ve=_[Fn],_.hasOwnProperty(Fn)&&Ve!==void 0&&!S.hasOwnProperty(Fn)&&lA(d,p,Fn,void 0,S,Ve);for(et in S)Ve=S[et],Ye=_[et],!S.hasOwnProperty(et)||Ve===Ye||Ve===void 0&&Ye===void 0||lA(d,p,et,Ve,S,Ye);return}}for(var Oe in _)Ve=_[Oe],_.hasOwnProperty(Oe)&&Ve!=null&&!S.hasOwnProperty(Oe)&&Un(d,p,Oe,null,S,Ve);for(lt in S)Ve=S[lt],Ye=_[lt],!S.hasOwnProperty(lt)||Ve===Ye||Ve==null&&Ye==null||Un(d,p,lt,Ve,S,Ye)}function b4(d){switch(d){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Nte(){if(typeof performance.getEntriesByType=="function"){for(var d=0,p=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var P=_[S],D=P.transferSize,W=P.initiatorType,re=P.duration;if(D&&re&&b4(W)){for(W=0,re=P.responseEnd,S+=1;S<_.length;S++){var Se=_[S],Be=Se.startTime;if(Be>re)break;var et=Se.transferSize,lt=Se.initiatorType;et&&b4(lt)&&(Se=Se.responseEnd,W+=et*(Se<re?1:(re-Be)/(Se-Be)))}if(--S,p+=8*(D+W)/(P.duration/1e3),d++,10<d)break}}if(0<d)return p/d/1e6}return navigator.connection&&(d=navigator.connection.downlink,typeof d=="number")?d:5}var cA=null,uA=null;function mb(d){return d.nodeType===9?d:d.ownerDocument}function y4(d){switch(d){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function _4(d,p){if(d===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return d===1&&p==="foreignObject"?0:d}function dA(d,p){return d==="textarea"||d==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var fA=null;function Rte(){var d=window.event;return d&&d.type==="popstate"?d===fA?!1:(fA=d,!0):(fA=null,!1)}var S4=typeof setTimeout=="function"?setTimeout:void 0,Pte=typeof clearTimeout=="function"?clearTimeout:void 0,w4=typeof Promise=="function"?Promise:void 0,kte=typeof queueMicrotask=="function"?queueMicrotask:typeof w4<"u"?function(d){return w4.resolve(null).then(d).catch(Dte)}:S4;function Dte(d){setTimeout(function(){throw d})}function Qc(d){return d==="head"}function M4(d,p){var _=p,S=0;do{var P=_.nextSibling;if(d.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(S===0){d.removeChild(P),Ch(p);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Sg(d.ownerDocument.documentElement);else if(_==="head"){_=d.ownerDocument.head,Sg(_);for(var D=_.firstChild;D;){var W=D.nextSibling,re=D.nodeName;D[Ke]||re==="SCRIPT"||re==="STYLE"||re==="LINK"&&D.rel.toLowerCase()==="stylesheet"||_.removeChild(D),D=W}}else _==="body"&&Sg(d.ownerDocument.body);_=P}while(_);Ch(p)}function E4(d,p){var _=d;d=0;do{var S=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(d===0)break;d--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||d++;_=S}while(_)}function hA(d){var p=d.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":hA(_),We(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}d.removeChild(_)}}function Ote(d,p,_,S){for(;d.nodeType===1;){var P=_;if(d.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(d.nodeName!=="INPUT"||d.type!=="hidden"))break}else if(S){if(!d[Ke])switch(p){case"meta":if(!d.hasAttribute("itemprop"))break;return d;case"link":if(D=d.getAttribute("rel"),D==="stylesheet"&&d.hasAttribute("data-precedence"))break;if(D!==P.rel||d.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||d.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||d.getAttribute("title")!==(P.title==null?null:P.title))break;return d;case"style":if(d.hasAttribute("data-precedence"))break;return d;case"script":if(D=d.getAttribute("src"),(D!==(P.src==null?null:P.src)||d.getAttribute("type")!==(P.type==null?null:P.type)||d.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&D&&d.hasAttribute("async")&&!d.hasAttribute("itemprop"))break;return d;default:return d}}else if(p==="input"&&d.type==="hidden"){var D=P.name==null?null:""+P.name;if(P.type==="hidden"&&d.getAttribute("name")===D)return d}else return d;if(d=Ms(d.nextSibling),d===null)break}return null}function Lte(d,p,_){if(p==="")return null;for(;d.nodeType!==3;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!_||(d=Ms(d.nextSibling),d===null))return null;return d}function A4(d,p){for(;d.nodeType!==8;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!p||(d=Ms(d.nextSibling),d===null))return null;return d}function pA(d){return d.data==="$?"||d.data==="$~"}function mA(d){return d.data==="$!"||d.data==="$?"&&d.ownerDocument.readyState!=="loading"}function Ite(d,p){var _=d.ownerDocument;if(d.data==="$~")d._reactRetry=p;else if(d.data!=="$?"||_.readyState!=="loading")p();else{var S=function(){p(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),d._reactRetry=S}}function Ms(d){for(;d!=null;d=d.nextSibling){var p=d.nodeType;if(p===1||p===3)break;if(p===8){if(p=d.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return d}var gA=null;function T4(d){d=d.nextSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="/$"||_==="/&"){if(p===0)return Ms(d.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}d=d.nextSibling}return null}function C4(d){d=d.previousSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return d;p--}else _!=="/$"&&_!=="/&"||p++}d=d.previousSibling}return null}function N4(d,p,_){switch(p=mb(_),d){case"html":if(d=p.documentElement,!d)throw Error(r(452));return d;case"head":if(d=p.head,!d)throw Error(r(453));return d;case"body":if(d=p.body,!d)throw Error(r(454));return d;default:throw Error(r(451))}}function Sg(d){for(var p=d.attributes;p.length;)d.removeAttributeNode(p[0]);We(d)}var Es=new Map,R4=new Set;function gb(d){return typeof d.getRootNode=="function"?d.getRootNode():d.nodeType===9?d:d.ownerDocument}var Nl=G.d;G.d={f:jte,r:Ute,D:Fte,C:zte,L:Bte,m:Hte,X:Vte,S:$te,M:Gte};function jte(){var d=Nl.f(),p=ob();return d||p}function Ute(d){var p=J(d);p!==null&&p.tag===5&&p.type==="form"?qI(p):Nl.r(d)}var Eh=typeof document>"u"?null:document;function P4(d,p,_){var S=Eh;if(S&&typeof p=="string"&&p){var P=Nn(p);P='link[rel="'+d+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),R4.has(P)||(R4.add(P),d={rel:d,crossOrigin:_,href:p},S.querySelector(P)===null&&(p=S.createElement("link"),Ii(p,"link",d),Ce(p),S.head.appendChild(p)))}}function Fte(d){Nl.D(d),P4("dns-prefetch",d,null)}function zte(d,p){Nl.C(d,p),P4("preconnect",d,p)}function Bte(d,p,_){Nl.L(d,p,_);var S=Eh;if(S&&d&&p){var P='link[rel="preload"][as="'+Nn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Nn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Nn(_.imageSizes)+'"]')):P+='[href="'+Nn(d)+'"]';var D=P;switch(p){case"style":D=Ah(d);break;case"script":D=Th(d)}Es.has(D)||(d=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:d,as:p},_),Es.set(D,d),S.querySelector(P)!==null||p==="style"&&S.querySelector(wg(D))||p==="script"&&S.querySelector(Mg(D))||(p=S.createElement("link"),Ii(p,"link",d),Ce(p),S.head.appendChild(p)))}}function Hte(d,p){Nl.m(d,p);var _=Eh;if(_&&d){var S=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Nn(S)+'"][href="'+Nn(d)+'"]',D=P;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=Th(d)}if(!Es.has(D)&&(d=f({rel:"modulepreload",href:d},p),Es.set(D,d),_.querySelector(P)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Mg(D)))return}S=_.createElement("link"),Ii(S,"link",d),Ce(S),_.head.appendChild(S)}}}function $te(d,p,_){Nl.S(d,p,_);var S=Eh;if(S&&d){var P=Ne(S).hoistableStyles,D=Ah(d);p=p||"default";var W=P.get(D);if(!W){var re={loading:0,preload:null};if(W=S.querySelector(wg(D)))re.loading=5;else{d=f({rel:"stylesheet",href:d,"data-precedence":p},_),(_=Es.get(D))&&xA(d,_);var Se=W=S.createElement("link");Ce(Se),Ii(Se,"link",d),Se._p=new Promise(function(Be,et){Se.onload=Be,Se.onerror=et}),Se.addEventListener("load",function(){re.loading|=1}),Se.addEventListener("error",function(){re.loading|=2}),re.loading|=4,xb(W,p,S)}W={type:"stylesheet",instance:W,count:1,state:re},P.set(D,W)}}}function Vte(d,p){Nl.X(d,p);var _=Eh;if(_&&d){var S=Ne(_).hoistableScripts,P=Th(d),D=S.get(P);D||(D=_.querySelector(Mg(P)),D||(d=f({src:d,async:!0},p),(p=Es.get(P))&&vA(d,p),D=_.createElement("script"),Ce(D),Ii(D,"link",d),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function Gte(d,p){Nl.M(d,p);var _=Eh;if(_&&d){var S=Ne(_).hoistableScripts,P=Th(d),D=S.get(P);D||(D=_.querySelector(Mg(P)),D||(d=f({src:d,async:!0,type:"module"},p),(p=Es.get(P))&&vA(d,p),D=_.createElement("script"),Ce(D),Ii(D,"link",d),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function k4(d,p,_,S){var P=(P=te.current)?gb(P):null;if(!P)throw Error(r(446));switch(d){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Ah(_.href),_=Ne(P).hoistableStyles,S=_.get(p),S||(S={type:"style",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){d=Ah(_.href);var D=Ne(P).hoistableStyles,W=D.get(d);if(W||(P=P.ownerDocument||P,W={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(d,W),(D=P.querySelector(wg(d)))&&!D._p&&(W.instance=D,W.state.loading=5),Es.has(d)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Es.set(d,_),D||Wte(P,d,_,W.state))),p&&S===null)throw Error(r(528,""));return W}if(p&&S!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Th(_),_=Ne(P).hoistableScripts,S=_.get(p),S||(S={type:"script",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,d))}}function Ah(d){return'href="'+Nn(d)+'"'}function wg(d){return'link[rel="stylesheet"]['+d+"]"}function D4(d){return f({},d,{"data-precedence":d.precedence,precedence:null})}function Wte(d,p,_,S){d.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=d.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),Ii(p,"link",_),Ce(p),d.head.appendChild(p))}function Th(d){return'[src="'+Nn(d)+'"]'}function Mg(d){return"script[async]"+d}function O4(d,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var S=d.querySelector('style[data-href~="'+Nn(_.href)+'"]');if(S)return p.instance=S,Ce(S),S;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(d.ownerDocument||d).createElement("style"),Ce(S),Ii(S,"style",P),xb(S,_.precedence,d),p.instance=S;case"stylesheet":P=Ah(_.href);var D=d.querySelector(wg(P));if(D)return p.state.loading|=4,p.instance=D,Ce(D),D;S=D4(_),(P=Es.get(P))&&xA(S,P),D=(d.ownerDocument||d).createElement("link"),Ce(D);var W=D;return W._p=new Promise(function(re,Se){W.onload=re,W.onerror=Se}),Ii(D,"link",S),p.state.loading|=4,xb(D,_.precedence,d),p.instance=D;case"script":return D=Th(_.src),(P=d.querySelector(Mg(D)))?(p.instance=P,Ce(P),P):(S=_,(P=Es.get(D))&&(S=f({},_),vA(S,P)),d=d.ownerDocument||d,P=d.createElement("script"),Ce(P),Ii(P,"link",S),d.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(S=p.instance,p.state.loading|=4,xb(S,_.precedence,d));return p.instance}function xb(d,p,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=S.length?S[S.length-1]:null,D=P,W=0;W<S.length;W++){var re=S[W];if(re.dataset.precedence===p)D=re;else if(D!==P)break}D?D.parentNode.insertBefore(d,D.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(d,p.firstChild))}function xA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.title==null&&(d.title=p.title)}function vA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.integrity==null&&(d.integrity=p.integrity)}var vb=null;function L4(d,p,_){if(vb===null){var S=new Map,P=vb=new Map;P.set(_,S)}else P=vb,S=P.get(_),S||(S=new Map,P.set(_,S));if(S.has(d))return S;for(S.set(d,null),_=_.getElementsByTagName(d),P=0;P<_.length;P++){var D=_[P];if(!(D[Ke]||D[hr]||d==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var W=D.getAttribute(p)||"";W=d+W;var re=S.get(W);re?re.push(D):S.set(W,[D])}}return S}function I4(d,p,_){d=d.ownerDocument||d,d.head.insertBefore(_,p==="title"?d.querySelector("head > title"):null)}function qte(d,p,_){if(_===1||p.itemProp!=null)return!1;switch(d){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return d=p.disabled,typeof p.precedence=="string"&&d==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function j4(d){return!(d.type==="stylesheet"&&(d.state.loading&3)===0)}function Xte(d,p,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Ah(S.href),D=p.querySelector(wg(P));if(D){p=D._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(d.count++,d=bb.bind(d),p.then(d,d)),_.state.loading|=4,_.instance=D,Ce(D);return}D=p.ownerDocument||p,S=D4(S),(P=Es.get(P))&&xA(S,P),D=D.createElement("link"),Ce(D);var W=D;W._p=new Promise(function(re,Se){W.onload=re,W.onerror=Se}),Ii(D,"link",S),_.instance=D}d.stylesheets===null&&(d.stylesheets=new Map),d.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(d.count++,_=bb.bind(d),p.addEventListener("load",_),p.addEventListener("error",_))}}var bA=0;function Kte(d,p){return d.stylesheets&&d.count===0&&_b(d,d.stylesheets),0<d.count||0<d.imgCount?function(_){var S=setTimeout(function(){if(d.stylesheets&&_b(d,d.stylesheets),d.unsuspend){var D=d.unsuspend;d.unsuspend=null,D()}},6e4+p);0<d.imgBytes&&bA===0&&(bA=62500*Nte());var P=setTimeout(function(){if(d.waitingForImages=!1,d.count===0&&(d.stylesheets&&_b(d,d.stylesheets),d.unsuspend)){var D=d.unsuspend;d.unsuspend=null,D()}},(d.imgBytes>bA?50:800)+p);return d.unsuspend=_,function(){d.unsuspend=null,clearTimeout(S),clearTimeout(P)}}:null}function bb(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_b(this,this.stylesheets);else if(this.unsuspend){var d=this.unsuspend;this.unsuspend=null,d()}}}var yb=null;function _b(d,p){d.stylesheets=null,d.unsuspend!==null&&(d.count++,yb=new Map,p.forEach(Yte,d),yb=null,bb.call(d))}function Yte(d,p){if(!(p.state.loading&4)){var _=yb.get(d);if(_)var S=_.get(null);else{_=new Map,yb.set(d,_);for(var P=d.querySelectorAll("link[data-precedence],style[data-precedence]"),D=0;D<P.length;D++){var W=P[D];(W.nodeName==="LINK"||W.getAttribute("media")!=="not all")&&(_.set(W.dataset.precedence,W),S=W)}S&&_.set(null,S)}P=p.instance,W=P.getAttribute("data-precedence"),D=_.get(W)||S,D===S&&_.set(null,P),_.set(W,P),this.count++,S=bb.bind(this),P.addEventListener("load",S),P.addEventListener("error",S),D?D.parentNode.insertBefore(P,D.nextSibling):(d=d.nodeType===9?d.head:d,d.insertBefore(P,d.firstChild)),p.state.loading|=4}}var Eg={$$typeof:w,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function Zte(d,p,_,S,P,D,W,re,Se){this.tag=1,this.containerInfo=d,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Rt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rt(0),this.hiddenUpdates=Rt(null),this.identifierPrefix=S,this.onUncaughtError=P,this.onCaughtError=D,this.onRecoverableError=W,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Se,this.incompleteTransitions=new Map}function U4(d,p,_,S,P,D,W,re,Se,Be,et,lt){return d=new Zte(d,p,_,W,Se,Be,et,lt,re),p=1,D===!0&&(p|=24),D=Ka(3,null,null,p),d.current=D,D.stateNode=d,p=QM(),p.refCount++,d.pooledCache=p,p.refCount++,D.memoizedState={element:S,isDehydrated:_,cache:p},nE(D),d}function F4(d){return d?(d=ih,d):ih}function z4(d,p,_,S,P,D){P=F4(P),S.context===null?S.context=P:S.pendingContext=P,S=Bc(p),S.payload={element:_},D=D===void 0?null:D,D!==null&&(S.callback=D),_=Hc(d,S,p),_!==null&&(ka(_,d,p),rg(_,d,p))}function B4(d,p){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var _=d.retryLane;d.retryLane=_!==0&&_<p?_:p}}function yA(d,p){B4(d,p),(d=d.alternate)&&B4(d,p)}function H4(d){if(d.tag===13||d.tag===31){var p=vd(d,67108864);p!==null&&ka(p,d,67108864),yA(d,67108864)}}function $4(d){if(d.tag===13||d.tag===31){var p=es();p=Zr(p);var _=vd(d,p);_!==null&&ka(_,d,p),yA(d,p)}}var Sb=!0;function Qte(d,p,_,S){var P=V.T;V.T=null;var D=G.p;try{G.p=2,_A(d,p,_,S)}finally{G.p=D,V.T=P}}function Jte(d,p,_,S){var P=V.T;V.T=null;var D=G.p;try{G.p=8,_A(d,p,_,S)}finally{G.p=D,V.T=P}}function _A(d,p,_,S){if(Sb){var P=SA(S);if(P===null)oA(d,p,S,wb,_),G4(d,S);else if(tne(P,d,p,_,S))S.stopPropagation();else if(G4(d,S),p&4&&-1<ene.indexOf(d)){for(;P!==null;){var D=J(P);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var W=Ee(D.pendingLanes);if(W!==0){var re=D;for(re.pendingLanes|=2,re.entangledLanes|=2;W;){var Se=1<<31-rt(W);re.entanglements[1]|=Se,W&=~Se}Do(D),(Cn&6)===0&&(ab=L()+500,bg(0))}}break;case 31:case 13:re=vd(D,2),re!==null&&ka(re,D,2),ob(),yA(D,2)}if(D=SA(S),D===null&&oA(d,p,S,wb,_),D===P)break;P=D}P!==null&&S.stopPropagation()}else oA(d,p,S,null,_)}}function SA(d){return d=MM(d),wA(d)}var wb=null;function wA(d){if(wb=null,d=St(d),d!==null){var p=a(d);if(p===null)d=null;else{var _=p.tag;if(_===13){if(d=s(p),d!==null)return d;d=null}else if(_===31){if(d=o(p),d!==null)return d;d=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;d=null}else p!==d&&(d=null)}}return wb=d,null}function V4(d){switch(d){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Z()){case ge:return 2;case ye:return 8;case pe:case Ze:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var MA=!1,Jc=null,eu=null,tu=null,Ag=new Map,Tg=new Map,nu=[],ene="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function G4(d,p){switch(d){case"focusin":case"focusout":Jc=null;break;case"dragenter":case"dragleave":eu=null;break;case"mouseover":case"mouseout":tu=null;break;case"pointerover":case"pointerout":Ag.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Tg.delete(p.pointerId)}}function Cg(d,p,_,S,P,D){return d===null||d.nativeEvent!==D?(d={blockedOn:p,domEventName:_,eventSystemFlags:S,nativeEvent:D,targetContainers:[P]},p!==null&&(p=J(p),p!==null&&H4(p)),d):(d.eventSystemFlags|=S,p=d.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),d)}function tne(d,p,_,S,P){switch(p){case"focusin":return Jc=Cg(Jc,d,p,_,S,P),!0;case"dragenter":return eu=Cg(eu,d,p,_,S,P),!0;case"mouseover":return tu=Cg(tu,d,p,_,S,P),!0;case"pointerover":var D=P.pointerId;return Ag.set(D,Cg(Ag.get(D)||null,d,p,_,S,P)),!0;case"gotpointercapture":return D=P.pointerId,Tg.set(D,Cg(Tg.get(D)||null,d,p,_,S,P)),!0}return!1}function W4(d){var p=St(d.target);if(p!==null){var _=a(p);if(_!==null){if(p=_.tag,p===13){if(p=s(_),p!==null){d.blockedOn=p,qi(d.priority,function(){$4(_)});return}}else if(p===31){if(p=o(_),p!==null){d.blockedOn=p,qi(d.priority,function(){$4(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){d.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}d.blockedOn=null}function Mb(d){if(d.blockedOn!==null)return!1;for(var p=d.targetContainers;0<p.length;){var _=SA(d.nativeEvent);if(_===null){_=d.nativeEvent;var S=new _.constructor(_.type,_);wM=S,_.target.dispatchEvent(S),wM=null}else return p=J(_),p!==null&&H4(p),d.blockedOn=_,!1;p.shift()}return!0}function q4(d,p,_){Mb(d)&&_.delete(p)}function nne(){MA=!1,Jc!==null&&Mb(Jc)&&(Jc=null),eu!==null&&Mb(eu)&&(eu=null),tu!==null&&Mb(tu)&&(tu=null),Ag.forEach(q4),Tg.forEach(q4)}function Eb(d,p){d.blockedOn===p&&(d.blockedOn=null,MA||(MA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,nne)))}var Ab=null;function X4(d){Ab!==d&&(Ab=d,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ab===d&&(Ab=null);for(var p=0;p<d.length;p+=3){var _=d[p],S=d[p+1],P=d[p+2];if(typeof S!="function"){if(wA(S||_)===null)continue;break}var D=J(_);D!==null&&(d.splice(p,3),p-=3,SE(D,{pending:!0,data:P,method:_.method,action:S},S,P))}}))}function Ch(d){function p(Se){return Eb(Se,d)}Jc!==null&&Eb(Jc,d),eu!==null&&Eb(eu,d),tu!==null&&Eb(tu,d),Ag.forEach(p),Tg.forEach(p);for(var _=0;_<nu.length;_++){var S=nu[_];S.blockedOn===d&&(S.blockedOn=null)}for(;0<nu.length&&(_=nu[0],_.blockedOn===null);)W4(_),_.blockedOn===null&&nu.shift();if(_=(d.ownerDocument||d).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var P=_[S],D=_[S+1],W=P[Ar]||null;if(typeof D=="function")W||X4(_);else if(W){var re=null;if(D&&D.hasAttribute("formAction")){if(P=D,W=D[Ar]||null)re=W.formAction;else if(wA(P)!==null)continue}else re=W.action;typeof re=="function"?_[S+1]=re:(_.splice(S,3),S-=3),X4(_)}}}function K4(){function d(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(W){return P=W})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var D=navigation.currentEntry;D&&D.url!=null&&navigation.navigate(D.url,{state:D.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,P=null;return navigation.addEventListener("navigate",d),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",d),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function EA(d){this._internalRoot=d}Tb.prototype.render=EA.prototype.render=function(d){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,S=es();z4(_,S,d,p,null,null)},Tb.prototype.unmount=EA.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var p=d.containerInfo;z4(d.current,2,null,d,null,null),ob(),p[no]=null}};function Tb(d){this._internalRoot=d}Tb.prototype.unstable_scheduleHydration=function(d){if(d){var p=Pi();d={blockedOn:null,target:d,priority:p};for(var _=0;_<nu.length&&p!==0&&p<nu[_].priority;_++);nu.splice(_,0,d),_===0&&W4(d)}};var Y4=e.version;if(Y4!=="19.2.0")throw Error(r(527,Y4,"19.2.0"));G.findDOMNode=function(d){var p=d._reactInternals;if(p===void 0)throw typeof d.render=="function"?Error(r(188)):(d=Object.keys(d).join(","),Error(r(268,d)));return d=c(p),d=d!==null?u(d):null,d=d===null?null:d.stateNode,d};var rne={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cb.isDisabled&&Cb.supportsFiber)try{je=Cb.inject(rne),ke=Cb}catch{}}return Rg.createRoot=function(d,p){if(!i(d))throw Error(r(299));var _=!1,S="",P=rj,D=ij,W=aj;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(D=p.onCaughtError),p.onRecoverableError!==void 0&&(W=p.onRecoverableError)),p=U4(d,1,!1,null,null,_,S,null,P,D,W,K4),d[no]=p.current,sA(d),new EA(p)},Rg.hydrateRoot=function(d,p,_){if(!i(d))throw Error(r(299));var S=!1,P="",D=rj,W=ij,re=aj,Se=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(D=_.onUncaughtError),_.onCaughtError!==void 0&&(W=_.onCaughtError),_.onRecoverableError!==void 0&&(re=_.onRecoverableError),_.formState!==void 0&&(Se=_.formState)),p=U4(d,1,!0,p,_??null,S,P,Se,D,W,re,K4),p.context=F4(null),_=p.current,S=es(),S=Zr(S),P=Bc(S),P.callback=null,Hc(_,P,S),_=S,p.current.lanes=_,ln(p,_),Do(p),d[no]=p.current,sA(d),new Tb(p)},Rg.version="19.2.0",Rg}var sU;function pne(){if(sU)return CA.exports;sU=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(),CA.exports=hne(),CA.exports}var mne=pne();const $t=t=>typeof t=="string",Pg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},oU=t=>t==null?"":""+t,gne=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},xne=/###/g,lU=t=>t&&t.indexOf("###")>-1?t.replace(xne,"."):t,cU=t=>!t||$t(t),mx=(t,e,n)=>{const r=$t(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(cU(t))return{};const a=lU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return cU(t)?{}:{obj:t,k:lU(r[i])}},uU=(t,e,n)=>{const{obj:r,k:i}=mx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=mx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=mx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},vne=(t,e,n,r)=>{const{obj:i,k:a}=mx(t,e,Object);i[a]=i[a]||[],i[a].push(n)},j_=(t,e)=>{const{obj:n,k:r}=mx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},bne=(t,e,n)=>{const r=j_(t,n);return r!==void 0?r:j_(e,n)},yG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?$t(t[r])||t[r]instanceof String||$t(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):yG(t[r],e[r],n):t[r]=e[r]);return t},Nh=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var yne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const _ne=t=>$t(t)?t.replace(/[&<>"'\/]/g,e=>yne[e]):t;class Sne{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const 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 wne=[" ",",","?","!",";"],Mne=new Sne(20),Ene=(t,e,n)=>{e=e||"",n=n||"";const r=wne.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Mne.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!i.test(t);if(!a){const s=t.indexOf(n);s>0&&!i.test(t.substring(0,s))&&(a=!0)}return a},_N=(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 s,o="";for(let l=a;l<r.length;++l)if(l!==a&&(o+=n),o+=r[l],s=i[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&l<r.length-1)continue;a+=l-a+1;break}i=s}return i},Fx=t=>t?.replace("_","-"),Ane={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class U_{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Ane,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:($t(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new U_(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new U_(this.logger,e)}}var Vo=new U_;let qS=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 s=0;s<a;s++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i.apply(i,[e,...n])})}};class dU extends qS{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,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):$t(r)&&a?o.push(...r.split(a)):o.push(r)));const l=j_(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!s||!$t(r)?l:_N(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),uU(this.data,o,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)($t(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,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let l=j_(this.data,o)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?yG(l,r,a):l={...l,...r},uU(this.data,o,l),s.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var _G={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const SG=Symbol("i18next/PATH_KEY");function Tne(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===SG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function SN(t,e){const{[SG]:n}=t(Tne());return n.join(e?.keySeparator??".")}const fU={},kA=t=>!$t(t)&&typeof t!="boolean"&&typeof t!="number";class F_ extends qS{constructor(e,n={}){super(),gne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Vo.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const 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 s=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Ene(e,r,i);if(s&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:$t(a)?[a]:a};const c=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),e=c.join(i)}return{key:e,namespaces:$t(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=SN(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${c}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${u}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let y=m?.res;const v=m?.usedKey||o,b=m?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!$t(i.count),T=F_.hasDefaultValue(i),R=A?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",j=A&&!i.ordinal&&i.count===0,C=j&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${R}`]||i[`defaultValue${N}`]||i.defaultValue;let k=y;w&&!y&&T&&(k=C);const U=kA(k),I=Object.prototype.toString.apply(k);if(w&&k&&U&&x.indexOf(I)<0&&!($t(M)&&Array.isArray(k))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const H=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,k,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(m.res=H,m.usedParams=this.getUsedParamsDetails(i),m):H}if(s){const H=Array.isArray(k),O=H?[]:{},B=H?b:v;for(const V in k)if(Object.prototype.hasOwnProperty.call(k,V)){const G=`${B}${s}${V}`;T&&!y?O[V]=this.translate(G,{...i,defaultValue:kA(C)?C[V]:void 0,joinArrays:!1,ns:l}):O[V]=this.translate(G,{...i,joinArrays:!1,ns:l}),O[V]===G&&(O[V]=k[V])}y=O}}else if(w&&$t(M)&&Array.isArray(y))y=y.join(M),y&&(y=this.extendTranslation(y,e,i,r));else{let H=!1,O=!1;!this.isValidLookup(y)&&T&&(H=!0,y=C),this.isValidLookup(y)||(O=!0,y=o);const V=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&O?void 0:y,G=T&&C!==y&&this.options.updateMissing;if(O||H||G){if(this.logger.log(G?"updateKey":"missingKey",f,c,o,G?C:y),s){const $=this.resolve(o,{...i,keySeparator:!1});$&&$.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 K=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let $=0;$<Y.length;$++)K.push(Y[$]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(i.lng||this.language):K.push(i.lng||this.language);const oe=($,X,ae)=>{const ce=T&&ae!==y?ae:V;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,X,ce,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing($,c,X,ce,G,i),this.emit("missingKey",$,c,X,y)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?K.forEach($=>{const X=this.pluralResolver.getSuffixes($,i);j&&i[`defaultValue${this.options.pluralSeparator}zero`]&&X.indexOf(`${this.options.pluralSeparator}zero`)<0&&X.push(`${this.options.pluralSeparator}zero`),X.forEach(ae=>{oe([$],o+ae,i[`defaultValue${ae}`]||C)})}):oe(K,o,C))}y=this.extendTranslation(y,e,i,m,r),O&&y===o&&this.options.appendNamespaceToMissingKey&&(y=`${c}${u}${o}`),(O||H)&&this.options.parseMissingKeyHandler&&(y=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${o}`:o,H?y:void 0,i))}return a?(m.res=y,m.usedParams=this.getUsedParamsDetails(i),m):y}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 l=$t(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const f=e.match(this.interpolator.nestingRegexp);c=f&&f.length}let u=r.replace&&!$t(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),l){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;c<g&&(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 s=r.postProcess||this.options.postProcess,o=$t(s)?[s]:s;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=_G.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,o;return $t(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(l,n),u=c.key;i=u;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!$t(n.count),m=g&&!n.ordinal&&n.count===0,y=n.context!==void 0&&($t(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(o=b,!fU[`${v[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(fU[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(x=>{if(this.isValidLookup(r))return;s=x;const M=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,u,x,b,n);else{let A;g&&(A=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,R=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(R)===0&&M.push(u+A.replace(R,this.options.pluralSeparator)),M.push(u+A),m&&M.push(u+T)),y){const N=`${u}${this.options.contextSeparator||"_"}${n.context}`;M.push(N),g&&(n.ordinal&&A.indexOf(R)===0&&M.push(N+A.replace(R,this.options.pluralSeparator)),M.push(N+A),m&&M.push(N+T))}}let w;for(;w=M.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(x,b,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:o}}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&&!$t(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 hU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Vo.create("languageUtils")}getScriptPartFromCode(e){if(e=Fx(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=Fx(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if($t(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(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),$t(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=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return $t(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))):$t(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const pU={zero:0,one:1,two:2,few:3,many:4,other:5},mU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Cne{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Vo.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=Fx(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 s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),mU;if(!e.match(/-|_/))return mU;const l=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(l,n)}return this.pluralRulesCache[a]=s,s}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)=>pU[i]-pU[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 gU=(t,e,n,r=".",i=!0)=>{let a=bne(t,e,n);return!a&&i&&$t(n)&&(a=_N(t,n,r),a===void 0&&(a=_N(e,n,r))),a},DA=t=>t.replace(/\$/g,"$$$$");class Nne{constructor(e={}){this.logger=Vo.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:_ne,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Nh(a):s||"{{",this.suffix=o?Nh(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=g?Nh(g):m||Nh("$t("),this.nestingSuffix=y?Nh(y):v||Nh(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=x||1e3,this.alwaysFormat=M!==void 0?M:!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,s,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=m=>{if(m.indexOf(this.formatSeparator)<0){const x=gU(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:m}):x}const y=m.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(gU(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>DA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?DA(this.escape(m)):DA(m)}].forEach(m=>{for(o=0;a=m.regex.exec(e);){const y=a[1].trim();if(s=c(y),s===void 0)if(typeof u=="function"){const b=u(e,a,i);s=$t(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,y))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),s="";else!$t(s)&&!this.useRawValueToEscape&&(s=oU(s));const v=m.safeValue(s);if(e=e.replace(a[0],v),f?(m.regex.lastIndex+=s.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const o=(l,c)=>{const u=this.nestingOptionsSeparator;if(l.indexOf(u)<0)return l;const f=l.split(new RegExp(`${u}[ ]*{`));let g=`{${f[1]}`;l=f[0],g=this.interpolate(g,s);const m=g.match(/'/g),y=g.match(/"/g);((m?.length??0)%2===0&&!y||y.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),c&&(s={...c,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,v),`${l}${u}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];s={...r},s=s.replace&&!$t(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),a=n(o.call(this,i[1].trim(),s),s),a&&i[0]===e&&!$t(a))return a;$t(a)||(a=oU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),l.length&&(a=l.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const Rne=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(s=>{if(s){const[o,...l]=s.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();n[u]||(n[u]=c),c==="false"&&(n[u]=!1),c==="true"&&(n[u]=!0),isNaN(c)||(n[u]=parseInt(c,10))}})}return{formatName:e,formatOptions:n}},xU=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 s=r+JSON.stringify(a);let o=e[s];return o||(o=t(Fx(r),i),e[s]=o),o(n)}},Pne=t=>(e,n,r)=>t(Fx(n),r)(e);class kne{constructor(e={}){this.logger=Vo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?xU:Pne;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return o=>s.format(o)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return o=>s.format(o)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return o=>s.format(o)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return o=>s.format(o,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=xU(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(o=>o.indexOf(")")>-1)){const o=a.findIndex(l=>l.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,l)=>{const{formatName:c,formatOptions:u}=Rne(l);if(this.formats[c]){let f=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[c](o,m,{...u,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const Dne=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class One extends qS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Vo.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={},s={},o={},l={};return e.forEach(c=>{let u=!0;n.forEach(f=>{const g=`${c}|${f}`;!r.reload&&this.store.hasResourceBundle(c,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,u=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),l[f]===void 0&&(l[f]=!0)))}),u||(o[c]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(l=>{vne(l.loaded,[a],s),Dne(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const u=l.loaded[c];u.length&&u.forEach(f=>{o[c][f]===void 0&&(o[c][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const o=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,s)},a);return}s(c,u)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const c=l(e,n);c&&typeof c.then=="function"?c.then(u=>o(null,u)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();$t(e)&&(e=this.languageUtils.toResolveHierarchy(e)),$t(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}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,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,o),this.loaded(e,s,o)})}saveMissing(e,n,r,i,a,s={},o=()=>{}){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 l={...s,isUpdate:a},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(e,n,r,i,l):u=c(e,n,r,i),u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}else c(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const vU=()=>({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]),$t(t[1])&&(e.defaultValue=t[1]),$t(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}),bU=t=>($t(t.ns)&&(t.ns=[t.ns]),$t(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),$t(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),Rb=()=>{},Lne=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class gx extends qS{constructor(e={},n){if(super(),this.options=bU(e),this.services={},this.logger=Vo,this.modules={external:[]},Lne(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&($t(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=vU();this.options={...r,...this.options,...bU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?Vo.init(i(this.modules.logger),this.options):Vo.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=kne;const u=new hU(this.options);this.store=new dU(this.options.resources,this.options);const f=this.services;f.logger=Vo,f.resourceStore=this.store,f.languageUtils=u,f.pluralResolver=new Cne(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==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"),c&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(c),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Nne(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new One(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...y)=>{this.emit(m,...y)}),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 F_(this.services,this.options),this.translator.on("*",(m,...y)=>{this.emit(m,...y)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Rb),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...u)=>this.store[c](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...u)=>(this.store[c](...u),this)});const o=Pg(),l=()=>{const c=(u,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(u,f)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=Rb){let r=n;const i=$t(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=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&a.indexOf(c)<0&&a.push(c)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=Pg();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=Rb),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&_G.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Pg();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,r.resolve((...c)=>this.t(...c)),n&&n(o,(...c)=>this.t(...c))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=$t(o)?o:o&&o[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes($t(o)?[o]:o);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,u=>{a(u,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...o)=>{let l;typeof s!="object"?l=this.options.overloadTranslationOptionHandler([a,s].concat(o)):l={...s},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||i.keyPrefix);const c=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(a)?u=a.map(f=>(typeof f=="function"&&(f=SN(f,{...this.options,...s})),`${l.keyPrefix}${c}${f}`)):(typeof a=="function"&&(a=SN(a,{...this.options,...s})),u=l.keyPrefix?`${l.keyPrefix}${c}${a}`:a),this.t(u,l)};return $t(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 s=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=Pg();return this.options.ns?($t(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=Pg();$t(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=i.concat(a),this.loadResources(s=>{r.resolve(),n&&n(s)}),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 hU(vU());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 gx(e,n);return r.createInstance=gx.createInstance,r}cloneInstance(e={},n=Rb){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new gx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const o=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((u,f)=>(u[f]={...l[c][f]},u),l[c]),l),{});a.store=new dU(o,i),a.services.resourceStore=a.store}return a.translator=new F_(a.services,i),a.translator.on("*",(o,...l)=>{a.emit(o,...l)}),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 Aa=gx.createInstance();Aa.createInstance;Aa.dir;Aa.init;Aa.loadResources;Aa.reloadResources;Aa.use;Aa.changeLanguage;Aa.getFixedT;Aa.t;Aa.exists;Aa.setDefaultNamespace;Aa.hasLoadedNamespace;Aa.loadNamespaces;Aa.loadLanguages;const Ine=(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);wf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},yU={},wG=(t,e,n,r)=>{wf(n)&&yU[n]||(wf(n)&&(yU[n]=new Date),Ine(t,e,n,r))},MG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},wN=(t,e,n)=>{t.loadNamespaces(e,MG(t,n))},_U=(t,e,n,r)=>{if(wf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return wN(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,MG(t,r))},jne=(t,e,n={})=>!e.languages||!e.languages.length?(wG(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}}),wf=t=>typeof t=="string",Une=t=>typeof t=="object"&&t!==null,Fne=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,zne={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Bne=t=>zne[t],Hne=t=>t.replace(Fne,Bne);let MN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Hne};const $ne=(t={})=>{MN={...MN,...t}},Vne=()=>MN;let EG;const Gne=t=>{EG=t},Wne=()=>EG,qne={type:"3rdParty",init(t){$ne(t.options.react),Gne(t)}},Xne=E.createContext();class Kne{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var OA={exports:{}},LA={};var SU;function Yne(){if(SU)return LA;SU=1;var t=xm();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,g){var m=g(),y=r({inst:{value:m,getSnapshot:g}}),v=y[0].inst,b=y[1];return a(function(){v.value=m,v.getSnapshot=g,l(v)&&b({inst:v})},[f,m,g]),i(function(){return l(v)&&b({inst:v}),f(function(){l(v)&&b({inst:v})})},[f]),s(m),m}function l(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!n(f,m)}catch{return!0}}function c(f,g){return g()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return LA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,LA}var wU;function AG(){return wU||(wU=1,OA.exports=Yne()),OA.exports}var RP=AG();const Zne=(t,e)=>wf(e)?e:Une(e)&&wf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Qne={t:Zne,ready:!1},Jne=()=>()=>{},PP=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(Xne)||{},a=n||r||Wne();a&&!a.reportNamespaces&&(a.reportNamespaces=new Kne),a||wG(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=E.useMemo(()=>({...Vne(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:l}=s,c=i||a?.options?.defaultNS,u=wf(c)?[c]:c||["translation"],f=E.useMemo(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=E.useRef(0),m=E.useCallback(C=>{if(!a)return Jne;const{bindI18n:k,bindI18nStore:U}=s,I=()=>{g.current+=1,C()};return k&&a.on(k,I),U&&a.store.on(U,I),()=>{k&&k.split(" ").forEach(H=>a.off(H,I)),U&&U.split(" ").forEach(H=>a.store.off(H,I))}},[a,s]),y=E.useRef(),v=E.useCallback(()=>{if(!a)return Qne;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(B=>jne(B,a,s)),k=e.lng||a.language,U=g.current,I=y.current;if(I&&I.ready===C&&I.lng===k&&I.keyPrefix===l&&I.revision===U)return I;const O={t:a.getFixedT(k,s.nsMode==="fallback"?f:f[0],l),ready:C,lng:k,keyPrefix:l,revision:U};return y.current=O,O},[a,f,l,s,e.lng]),[b,x]=E.useState(0),{t:M,ready:w}=RP.useSyncExternalStore(m,v,v);E.useEffect(()=>{if(a&&!w&&!o){const C=()=>x(k=>k+1);e.lng?_U(a,e.lng,f,C):wN(a,f,C)}},[a,e.lng,f,w,o,b]);const A=a||{},T=E.useRef(null),R=E.useRef(),N=C=>{const k=Object.getOwnPropertyDescriptors(C);k.__original&&delete k.__original;const U=Object.create(Object.getPrototypeOf(C),k);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},j=E.useMemo(()=>{const C=A,k=C?.language;let U=C;C&&(T.current&&T.current.__original===C?R.current!==k?(U=N(C),T.current=U,R.current=k):U=T.current:(U=N(C),T.current=U,R.current=k));const I=[M,U,w];return I.t=M,I.i18n=U,I.ready=w,I},[M,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&o&&!w)throw new Promise(C=>{const k=()=>C();e.lng?_U(a,e.lng,f,k):wN(a,f,k)});return j},{slice:ere,forEach:tre}=[];function nre(t){return tre.call(ere.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function rre(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 MU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,ire=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 s=r.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(r.domain){if(!MU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!MU.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},EU={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=ire(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 are={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return EU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&EU.create(n,t,r,i,a)}},sre={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 s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},ore={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 s=a.split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(r=s[o].substring(l+1))}}if(r)return r;if(!r&&n>-1){const s=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Rh=null;const AU=()=>{if(Rh!==null)return Rh;try{if(Rh=typeof window<"u"&&window.localStorage!==null,!Rh)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Rh=!1}return Rh};var lre={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&AU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&AU()&&window.localStorage.setItem(n,t)}};let Ph=null;const TU=()=>{if(Ph!==null)return Ph;try{if(Ph=typeof window<"u"&&window.sessionStorage!==null,!Ph)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ph=!1}return Ph};var cre={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&TU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&TU()&&window.sessionStorage.setItem(n,t)}},ure={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}},dre={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}},fre={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}},hre={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 TG=!1;try{document.cookie,TG=!0}catch{}const CG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];TG||CG.splice(1,1);const pre=()=>({order:CG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class NG{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=nre(n,this.options||{},pre()),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(are),this.addDetector(sre),this.addDetector(lre),this.addDetector(cre),this.addDetector(ure),this.addDetector(dre),this.addDetector(fre),this.addDetector(hre),this.addDetector(ore)}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&&!rre(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)}))}}NG.type="languageDetector";const mre={nav:{printers:"Printers",control:"Control",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",settings:"Settings",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},gre={nav:{printers:"Drucker",control:"Steuerung",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",settings:"Einstellungen",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},xre={en:{translation:mre},de:{translation:gre}};Aa.use(NG).use(qne).init({resources:xre,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const CU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var NU="popstate";function vre(t={}){function e(r,i){let{pathname:a,search:s,hash:o}=r.location;return EN("",{pathname:a,search:s,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:zx(i)}return yre(e,n,null,t)}function mr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ks(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function bre(){return Math.random().toString(36).substring(2,10)}function RU(t,e){return{usr:t.state,key:t.key,idx:e}}function EN(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?vm(e):e,state:n,key:e&&e.key||r||bre()}}function zx({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function vm(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function yre(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,o="POP",l=null,c=u();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function u(){return(s.state||{idx:null}).idx}function f(){o="POP";let b=u(),x=b==null?null:b-c;c=b,l&&l({action:o,location:v.location,delta:x})}function g(b,x){o="PUSH";let M=EN(v.location,b,x);c=u()+1;let w=RU(M,c),A=v.createHref(M);try{s.pushState(w,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&l&&l({action:o,location:v.location,delta:1})}function m(b,x){o="REPLACE";let M=EN(v.location,b,x);c=u();let w=RU(M,c),A=v.createHref(M);s.replaceState(w,"",A),a&&l&&l({action:o,location:v.location,delta:0})}function y(b){return _re(b)}let v={get action(){return o},get location(){return t(i,s)},listen(b){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(NU,f),l=b,()=>{i.removeEventListener(NU,f),l=null}},createHref(b){return e(i,b)},createURL:y,encodeLocation(b){let x=y(b);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:g,replace:m,go(b){return s.go(b)}};return v}function _re(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),mr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:zx(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function RG(t,e,n="/"){return Sre(t,e,n,!1)}function Sre(t,e,n,r){let i=typeof e=="string"?vm(e):e,a=pc(i.pathname||"/",n);if(a==null)return null;let s=PG(t);wre(s);let o=null;for(let l=0;o==null&&l<s.length;++l){let c=Ore(a);o=kre(s[l],c,r)}return o}function PG(t,e=[],n=[],r="",i=!1){let a=(s,o,l=i,c)=>{let u={relativePath:c===void 0?s.path||"":c,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&l)return;mr(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let f=sc([r,u.relativePath]),g=n.concat(u);s.children&&s.children.length>0&&(mr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),PG(s.children,e,g,f,l)),!(s.path==null&&!s.index)&&e.push({path:f,score:Rre(f,s.index),routesMeta:g})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let l of kG(s.path))a(s,o,!0,l)}),e}function kG(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 s=kG(r.join("/")),o=[];return o.push(...s.map(l=>l===""?a:[a,l].join("/"))),i&&o.push(...s),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function wre(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Pre(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Mre=/^:[\w-]+$/,Ere=3,Are=2,Tre=1,Cre=10,Nre=-2,PU=t=>t==="*";function Rre(t,e){let n=t.split("/"),r=n.length;return n.some(PU)&&(r+=Nre),e&&(r+=Are),n.filter(i=>!PU(i)).reduce((i,a)=>i+(Mre.test(a)?Ere:a===""?Tre:Cre),r)}function Pre(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 kre(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let o=0;o<r.length;++o){let l=r[o],c=o===r.length-1,u=a==="/"?e:e.slice(a.length)||"/",f=z_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),g=l.route;if(!f&&c&&n&&!r[r.length-1].route.index&&(f=z_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:sc([a,f.pathname]),pathnameBase:Fre(sc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=sc([a,f.pathnameBase]))}return s}function z_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Dre(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((c,{paramName:u,isOptional:f},g)=>{if(u==="*"){let y=o[g]||"";s=a.slice(0,a.length-y.length).replace(/(.)\/+$/,"$1")}const m=o[g];return f&&!m?c[u]=void 0:c[u]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:s,pattern:t}}function Dre(t,e=!1,n=!0){Ks(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,(s,o,l)=>(r.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).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 Ore(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ks(!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 pc(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 Lre=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ire=t=>Lre.test(t);function jre(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?vm(t):t,a;if(n)if(Ire(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Ks(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=kU(n.substring(1),"/"):a=kU(n,e)}else a=e;return{pathname:a,search:zre(r),hash:Bre(i)}}function kU(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 IA(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 Ure(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function DG(t){let e=Ure(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function OG(t,e,n,r=!1){let i;typeof t=="string"?i=vm(t):(i={...t},mr(!i.pathname||!i.pathname.includes("?"),IA("?","pathname","search",i)),mr(!i.pathname||!i.pathname.includes("#"),IA("#","pathname","hash",i)),mr(!i.search||!i.search.includes("#"),IA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,o;if(s==null)o=n;else{let f=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let l=jre(i,o),c=s&&s!=="/"&&s.endsWith("/"),u=(a||s===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var sc=t=>t.join("/").replace(/\/\/+/g,"/"),Fre=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),zre=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Bre=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Hre(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var LG=["POST","PUT","PATCH","DELETE"];new Set(LG);var $re=["GET",...LG];new Set($re);var bm=E.createContext(null);bm.displayName="DataRouter";var XS=E.createContext(null);XS.displayName="DataRouterState";E.createContext(!1);var IG=E.createContext({isTransitioning:!1});IG.displayName="ViewTransition";var Vre=E.createContext(new Map);Vre.displayName="Fetchers";var Gre=E.createContext(null);Gre.displayName="Await";var cl=E.createContext(null);cl.displayName="Navigation";var k0=E.createContext(null);k0.displayName="Location";var ul=E.createContext({outlet:null,matches:[],isDataRoute:!1});ul.displayName="Route";var kP=E.createContext(null);kP.displayName="RouteError";function Wre(t,{relative:e}={}){mr(D0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(cl),{hash:i,pathname:a,search:s}=O0(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:sc([n,a])),r.createHref({pathname:o,search:s,hash:i})}function D0(){return E.useContext(k0)!=null}function Ec(){return mr(D0(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(k0).location}var jG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function UG(t){E.useContext(cl).static||E.useLayoutEffect(t)}function KS(){let{isDataRoute:t}=E.useContext(ul);return t?oie():qre()}function qre(){mr(D0(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(bm),{basename:e,navigator:n}=E.useContext(cl),{matches:r}=E.useContext(ul),{pathname:i}=Ec(),a=JSON.stringify(DG(r)),s=E.useRef(!1);return UG(()=>{s.current=!0}),E.useCallback((l,c={})=>{if(Ks(s.current,jG),!s.current)return;if(typeof l=="number"){n.go(l);return}let u=OG(l,JSON.parse(a),i,c.relative==="path");t==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:sc([e,u.pathname])),(c.replace?n.replace:n.push)(u,c.state,c)},[e,n,a,i,t])}var Xre=E.createContext(null);function Kre(t){let e=E.useContext(ul).outlet;return E.useMemo(()=>e&&E.createElement(Xre.Provider,{value:t},e),[e,t])}function O0(t,{relative:e}={}){let{matches:n}=E.useContext(ul),{pathname:r}=Ec(),i=JSON.stringify(DG(n));return E.useMemo(()=>OG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Yre(t,e){return FG(t,e)}function FG(t,e,n,r,i){mr(D0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=E.useContext(cl),{matches:s}=E.useContext(ul),o=s[s.length-1],l=o?o.params:{},c=o?o.pathname:"/",u=o?o.pathnameBase:"/",f=o&&o.route;{let M=f&&f.path||"";zG(c,!f||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let g=Ec(),m;if(e){let M=typeof e=="string"?vm(e):e;mr(u==="/"||M.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=g;let y=m.pathname||"/",v=y;if(u!=="/"){let M=u.replace(/^\//,"").split("/");v="/"+y.replace(/^\//,"").split("/").slice(M.length).join("/")}let b=RG(t,{pathname:v});Ks(f||b!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Ks(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=tie(b&&b.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:sc([u,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?u:sc([u,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,r,i);return e&&x?E.createElement(k0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function Zre(){let t=sie(),e=Hre(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},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:a},"ErrorBoundary")," or"," ",E.createElement("code",{style:a},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,s)}var Qre=E.createElement(Zre,null),Jre=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?E.createElement(ul.Provider,{value:this.props.routeContext},E.createElement(kP.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function eie({routeContext:t,match:e,children:n}){let r=E.useContext(bm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(ul.Provider,{value:t},n)}function tie(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,s=n?.errors;if(s!=null){let u=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);mr(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=u),f.route.id){let{loaderData:g,errors:m}=n,y=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||y){o=!0,l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}let c=n&&r?(u,f)=>{r(u,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((u,f,g)=>{let m,y=!1,v=null,b=null;n&&(m=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||Qre,o&&(l<0&&g===0?(zG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,b=null):l===g&&(y=!0,b=f.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,g+1)),M=()=>{let w;return m?w=v:y?w=b:f.route.Component?w=E.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=u,E.createElement(eie,{match:f,routeContext:{outlet:u,matches:x,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?E.createElement(Jre,{location:n.location,revalidation:n.revalidation,component:v,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function DP(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nie(t){let e=E.useContext(bm);return mr(e,DP(t)),e}function rie(t){let e=E.useContext(XS);return mr(e,DP(t)),e}function iie(t){let e=E.useContext(ul);return mr(e,DP(t)),e}function OP(t){let e=iie(t),n=e.matches[e.matches.length-1];return mr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function aie(){return OP("useRouteId")}function sie(){let t=E.useContext(kP),e=rie("useRouteError"),n=OP("useRouteError");return t!==void 0?t:e.errors?.[n]}function oie(){let{router:t}=nie("useNavigate"),e=OP("useNavigate"),n=E.useRef(!1);return UG(()=>{n.current=!0}),E.useCallback(async(i,a={})=>{Ks(n.current,jG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var DU={};function zG(t,e,n){!e&&!DU[t]&&(DU[t]=!0,Ks(!1,n))}E.memo(lie);function lie({routes:t,future:e,state:n,unstable_onError:r}){return FG(t,void 0,n,r,e)}function cie(t){return Kre(t.context)}function jo(t){mr(!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 uie({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){mr(!D0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=vm(n));let{pathname:l="/",search:c="",hash:u="",state:f=null,key:g="default"}=n,m=E.useMemo(()=>{let y=pc(l,s);return y==null?null:{location:{pathname:y,search:c,hash:u,state:f,key:g},navigationType:r}},[s,l,c,u,f,g,r]);return Ks(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:E.createElement(cl.Provider,{value:o},E.createElement(k0.Provider,{children:e,value:m}))}function die({children:t,location:e}){return Yre(AN(t),e)}function AN(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let a=[...e,i];if(r.type===E.Fragment){n.push.apply(n,AN(r.props.children,a));return}mr(r.type===jo,`[${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>`),mr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={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&&(s.children=AN(r.props.children,a)),n.push(s)}),n}var f_="get",h_="application/x-www-form-urlencoded";function YS(t){return t!=null&&typeof t.tagName=="string"}function fie(t){return YS(t)&&t.tagName.toLowerCase()==="button"}function hie(t){return YS(t)&&t.tagName.toLowerCase()==="form"}function pie(t){return YS(t)&&t.tagName.toLowerCase()==="input"}function mie(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function gie(t,e){return t.button===0&&(!e||e==="_self")&&!mie(t)}function TN(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 xie(t,e){let n=TN(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var Pb=null;function vie(){if(Pb===null)try{new FormData(document.createElement("form"),0),Pb=!1}catch{Pb=!0}return Pb}var bie=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function jA(t){return t!=null&&!bie.has(t)?(Ks(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${h_}"`),null):t}function yie(t,e){let n,r,i,a,s;if(hie(t)){let o=t.getAttribute("action");r=o?pc(o,e):null,n=t.getAttribute("method")||f_,i=jA(t.getAttribute("enctype"))||h_,a=new FormData(t)}else if(fie(t)||pie(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=t.getAttribute("formaction")||o.getAttribute("action");if(r=l?pc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||f_,i=jA(t.getAttribute("formenctype"))||jA(o.getAttribute("enctype"))||h_,a=new FormData(o,t),!vie()){let{name:c,type:u,value:f}=t;if(u==="image"){let g=c?`${c}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else c&&a.append(c,f)}}else{if(YS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=f_,r=null,i=h_,s=t}return a&&i==="text/plain"&&(s=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function LP(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _ie(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&pc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Sie(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 wie(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 Mie(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await Sie(a,n);return s.links?s.links():[]}return[]}));return Cie(r.flat(1).filter(wie).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function OU(t,e,n,r,i,a){let s=(l,c)=>n[c]?l.route.id!==n[c].route.id:!0,o=(l,c)=>n[c].pathname!==l.pathname||n[c].route.path?.endsWith("*")&&n[c].params["*"]!==l.params["*"];return a==="assets"?e.filter((l,c)=>s(l,c)||o(l,c)):a==="data"?e.filter((l,c)=>{let u=r.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Eie(t,e,{includeHydrateFallback:n}={}){return Aie(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 Aie(t){return[...new Set(t)]}function Tie(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Cie(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Tie(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function BG(){let t=E.useContext(bm);return LP(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Nie(){let t=E.useContext(XS);return LP(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var IP=E.createContext(void 0);IP.displayName="FrameworkContext";function HG(){let t=E.useContext(IP);return LP(t,"You must render this element inside a <HydratedRouter> element"),t}function Rie(t,e){let n=E.useContext(IP),[r,i]=E.useState(!1),[a,s]=E.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:f}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let v=x=>{x.forEach(M=>{s(M.isIntersecting)})},b=new IntersectionObserver(v,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[t]),E.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let m=()=>{i(!0)},y=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:kg(o,m),onBlur:kg(l,y),onMouseEnter:kg(c,m),onMouseLeave:kg(u,y),onTouchStart:kg(f,m)}]:[!1,g,{}]}function kg(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Pie({page:t,...e}){let{router:n}=BG(),r=E.useMemo(()=>RG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(Die,{page:t,matches:r,...e}):null}function kie(t){let{manifest:e,routeModules:n}=HG(),[r,i]=E.useState([]);return E.useEffect(()=>{let a=!1;return Mie(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Die({page:t,matches:e,...n}){let r=Ec(),{manifest:i,routeModules:a}=HG(),{basename:s}=BG(),{loaderData:o,matches:l}=Nie(),c=E.useMemo(()=>OU(t,e,l,i,r,"data"),[t,e,l,i,r]),u=E.useMemo(()=>OU(t,e,l,i,r,"assets"),[t,e,l,i,r]),f=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,v=!1;if(e.forEach(x=>{let M=i.routes[x.route.id];!M||!M.hasLoader||(!c.some(w=>w.route.id===x.route.id)&&x.route.id in o&&a[x.route.id]?.shouldRevalidate||M.hasClientLoader?v=!0:y.add(x.route.id))}),y.size===0)return[];let b=_ie(t,s,"data");return v&&y.size>0&&b.searchParams.set("_routes",e.filter(x=>y.has(x.route.id)).map(x=>x.route.id).join(",")),[b.pathname+b.search]},[s,o,r,i,c,e,t,a]),g=E.useMemo(()=>Eie(u,i),[u,i]),m=kie(u);return E.createElement(E.Fragment,null,f.map(y=>E.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),g.map(y=>E.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),m.map(({key:y,link:v})=>E.createElement("link",{key:y,nonce:n.nonce,...v})))}function Oie(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var $G=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{$G&&(window.__reactRouterVersion="7.9.6")}catch{}function Lie({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=vre({window:n,v5Compat:!0}));let i=r.current,[a,s]=E.useState({action:i.action,location:i.location}),o=E.useCallback(l=>{E.startTransition(()=>s(l))},[s]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(uie,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var VG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ZS=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:o,target:l,to:c,preventScrollReset:u,viewTransition:f,...g},m){let{basename:y}=E.useContext(cl),v=typeof c=="string"&&VG.test(c),b,x=!1;if(typeof c=="string"&&v&&(b=c,$G))try{let C=new URL(window.location.href),k=c.startsWith("//")?new URL(C.protocol+c):new URL(c),U=pc(k.pathname,y);k.origin===C.origin&&U!=null?c=U+k.search+k.hash:x=!0}catch{Ks(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=Wre(c,{relative:i}),[w,A,T]=Rie(r,g),R=Uie(c,{replace:s,state:o,target:l,preventScrollReset:u,relative:i,viewTransition:f});function N(C){e&&e(C),C.defaultPrevented||R(C)}let j=E.createElement("a",{...g,...T,href:b||M,onClick:x||a?e:N,ref:Oie(m,A),target:l,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?E.createElement(E.Fragment,null,j,E.createElement(Pie,{page:M})):j});ZS.displayName="Link";var GG=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:o,children:l,...c},u){let f=O0(s,{relative:c.relative}),g=Ec(),m=E.useContext(XS),{navigator:y,basename:v}=E.useContext(cl),b=m!=null&&Vie(f)&&o===!0,x=y.encodeLocation?y.encodeLocation(f).pathname:f.pathname,M=g.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&v&&(w=pc(w,v)||w);const A=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let T=M===x||!i&&M.startsWith(x)&&M.charAt(A)==="/",R=w!=null&&(w===x||!i&&w.startsWith(x)&&w.charAt(x.length)==="/"),N={isActive:T,isPending:R,isTransitioning:b},j=T?e:void 0,C;typeof r=="function"?C=r(N):C=[r,T?"active":null,R?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let k=typeof a=="function"?a(N):a;return E.createElement(ZS,{...c,"aria-current":j,className:C,ref:u,style:k,to:s,viewTransition:o},typeof l=="function"?l(N):l)});GG.displayName="NavLink";var Iie=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=f_,action:o,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:f,...g},m)=>{let y=Hie(),v=$ie(o,{relative:c}),b=s.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&VG.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;y(A||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:c,preventScrollReset:u,viewTransition:f})};return E.createElement("form",{ref:m,method:b,action:v,onSubmit:r?l:M,...g,"data-discover":!x&&t==="render"?"true":void 0})});Iie.displayName="Form";function jie(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function WG(t){let e=E.useContext(bm);return mr(e,jie(t)),e}function Uie(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let o=KS(),l=Ec(),c=O0(t,{relative:a});return E.useCallback(u=>{if(gie(u,e)){u.preventDefault();let f=n!==void 0?n:zx(l)===zx(c);o(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[l,o,c,n,r,e,t,i,a,s])}function Fie(t){Ks(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=E.useRef(TN(t)),n=E.useRef(!1),r=Ec(),i=E.useMemo(()=>xie(r.search,n.current?null:e.current),[r.search]),a=KS(),s=E.useCallback((o,l)=>{const c=TN(typeof o=="function"?o(new URLSearchParams(i)):o);n.current=!0,a("?"+c,l)},[a,i]);return[i,s]}var zie=0,Bie=()=>`__${String(++zie)}__`;function Hie(){let{router:t}=WG("useSubmit"),{basename:e}=E.useContext(cl),n=aie();return E.useCallback(async(r,i={})=>{let{action:a,method:s,encType:o,formData:l,body:c}=yie(r,e);if(i.navigate===!1){let u=i.fetcherKey||Bie();await t.fetch(u,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function $ie(t,{relative:e}={}){let{basename:n}=E.useContext(cl),r=E.useContext(ul);mr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...O0(t||".",{relative:e})},s=Ec();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),l=o.getAll("index");if(l.some(u=>u==="")){o.delete("index"),l.filter(f=>f).forEach(f=>o.append("index",f));let u=o.toString();a.search=u?`?${u}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:sc([n,a.pathname])),zx(a)}function Vie(t,{relative:e}={}){let n=E.useContext(IG);mr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=WG("useViewTransitionState"),i=O0(t,{relative:e});if(!n.isTransitioning)return!1;let a=pc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=pc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return z_(i.pathname,s)!=null||z_(i.pathname,a)!=null}var Jl=bG();const Gie=Js(Jl);var ym=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(){}},Wie={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},qie=class{#e=Wie;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},ef=new qie;function Xie(t){setTimeout(t,0)}var Mf=typeof window>"u"||"Deno"in globalThis;function pa(){}function Kie(t,e){return typeof t=="function"?t(e):t}function CN(t){return typeof t=="number"&&t>=0&&t!==1/0}function qG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Fu(t,e){return typeof t=="function"?t(e):t}function Os(t,e){return typeof t=="function"?t(e):t}function LU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:o}=t;if(s){if(r){if(e.queryHash!==jP(s,e.options))return!1}else if(!Bx(e.queryKey,s))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function IU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Ef(e.options.mutationKey)!==Ef(a))return!1}else if(!Bx(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function jP(t,e){return(e?.queryKeyHashFn||Ef)(t)}function Ef(t){return JSON.stringify(t,(e,n)=>NN(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Bx(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Bx(t[n],e[n])):!1}var Yie=Object.prototype.hasOwnProperty;function XG(t,e){if(t===e)return t;const n=jU(t)&&jU(e);if(!n&&!(NN(t)&&NN(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let l=0;for(let c=0;c<s;c++){const u=n?c:a[c],f=t[u],g=e[u];if(f===g){o[u]=f,(n?c<i:Yie.call(t,u))&&l++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[u]=g;continue}const m=XG(f,g);o[u]=m,m===f&&l++}return i===s&&l===i?t:o}function B_(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 jU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function NN(t){if(!UU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!UU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function UU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Zie(t){return new Promise(e=>{ef.setTimeout(e,t)})}function RN(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?XG(t,e):e}function Qie(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Jie(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var UP=Symbol();function KG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===UP?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function YG(t,e){return typeof t=="function"?t(...e):!!t}var eae=class extends ym{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Mf&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},FP=new eae;function PN(){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 tae=Xie;function nae(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=tae;const a=o=>{e?t.push(o):i(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;e++;try{l=o()}finally{e--,e||s()}return l},batchCalls:o=>(...l)=>{a(()=>{o(...l)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var ri=nae(),rae=class extends ym{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Mf&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},H_=new rae;function iae(t){return Math.min(1e3*2**t,3e4)}function ZG(t){return(t??"online")==="online"?H_.isOnline():!0}var kN=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function QG(t){let e=!1,n=0,r;const i=PN(),a=()=>i.status!=="pending",s=v=>{if(!a()){const b=new kN(v);g(b),t.onCancel?.(b)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>FP.isFocused()&&(t.networkMode==="always"||H_.isOnline())&&t.canRun(),u=()=>ZG(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},m=()=>new Promise(v=>{r=b=>{(a()||c())&&v(b)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),y=()=>{if(a())return;let v;const b=n===0?t.initialPromise:void 0;try{v=b??t.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(f).catch(x=>{if(a())return;const M=t.retry??(Mf?0:3),w=t.retryDelay??iae,A=typeof w=="function"?w(n,x):w,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!T){g(x);return}n++,t.onFail?.(n,x),Zie(A).then(()=>c()?void 0:m()).then(()=>{e?g(x):y()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?y():m().then(y),i)}}var JG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),CN(this.gcTime)&&(this.#e=ef.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Mf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ef.clearTimeout(this.#e),this.#e=void 0)}},aae=class extends JG{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=zU(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=zU(this.options);e.data!==void 0&&(this.setState(FU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=RN(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(pa).catch(pa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Os(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===UP||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Fu(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:!qG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=KG(this.options,e),c=(()=>{const u={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=QG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof kN&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof kN){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...e9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...FU(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),ri.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function e9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ZG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function FU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function zU(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 sae=class extends ym{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=PN(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),BU(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return DN(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return DN(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Os(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!B_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&HU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Os(this.options.enabled,this.#t)!==Os(e.enabled,this.#t)||Fu(this.options.staleTime,this.#t)!==Fu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Os(this.options.enabled,this.#t)!==Os(e.enabled,this.#t)||i!==this.#l)&&this.#v(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return lae(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#S();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(pa)),e}#g(){this.#y();const t=Fu(this.options.staleTime,this.#t);if(Mf||this.#i.isStale||!CN(t))return;const n=qG(this.#i.dataUpdatedAt,t)+1;this.#c=ef.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#_(),this.#l=t,!(Mf||Os(this.options.enabled,this.#t)===!1||!CN(this.#l)||this.#l===0)&&(this.#u=ef.setInterval(()=>{(this.options.refetchIntervalInBackground||FP.isFocused())&&this.#d()},this.#l))}#b(){this.#g(),this.#v(this.#x())}#y(){this.#c&&(ef.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(ef.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,s=this.#s,l=t!==n?t.state:this.#n,{state:c}=t;let u={...c},f=!1,g;if(e._optimisticResults){const j=this.hasListeners(),C=!j&&BU(t,e),k=j&&HU(t,n,e,r);(C||k)&&(u={...u,...e9(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:v}=u;g=u.data;let b=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let j;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(j=i.data,b=!0):j=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,j!==void 0&&(v="success",g=RN(i?.data,j,e),f=!0)}if(e.select&&g!==void 0&&!b)if(i&&g===a?.data&&e.select===this.#m)g=this.#f;else try{this.#m=e.select,g=e.select(g),g=RN(i?.data,g,e),this.#f=g,this.#a=null}catch(j){this.#a=j}this.#a&&(m=this.#a,g=this.#f,y=Date.now(),v="error");const x=u.fetchStatus==="fetching",M=v==="pending",w=v==="error",A=M&&x,T=g!==void 0,N={status:v,fetchStatus:u.fetchStatus,isPending:M,isSuccess:v==="success",isError:w,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!T,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:zP(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Os(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=U=>{N.status==="error"?U.reject(N.error):N.data!==void 0&&U.resolve(N.data)},C=()=>{const U=this.#o=N.promise=PN();j(U)},k=this.#o;switch(k.status){case"pending":t.queryHash===n.queryHash&&j(k);break;case"fulfilled":(N.status==="error"||N.data!==k.value)&&C();break;case"rejected":(N.status!=="error"||N.error!==k.reason)&&C();break}}return N}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#h=this.#t),B_(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.#p.size)return!0;const a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const o=s;return this.#i[o]!==t[o]&&a.has(o)})};this.#w({listeners:n()})}#S(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#w(t){ri.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function oae(t,e){return Os(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function BU(t,e){return oae(t,e)||t.state.data!==void 0&&DN(t,e,e.refetchOnMount)}function DN(t,e,n){if(Os(e.enabled,t)!==!1&&Fu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&zP(t,e)}return!1}function HU(t,e,n,r){return(t!==e||Os(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&zP(t,n)}function zP(t,e){return Os(e.enabled,t)!==!1&&t.isStaleByTime(Fu(e.staleTime,t))}function lae(t,e){return!B_(t.getCurrentResult(),e)}function $U(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let u=!1;const f=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(e.signal.aborted?u=!0:e.signal.addEventListener("abort",()=>{u=!0}),e.signal)})},g=KG(e.options,e.fetchOptions),m=async(y,v,b)=>{if(u)return Promise.reject();if(v==null&&y.pages.length)return Promise.resolve(y);const M=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:v,direction:b?"backward":"forward",meta:e.options.meta};return f(R),R})(),w=await g(M),{maxPages:A}=e.options,T=b?Jie:Qie;return{pages:T(y.pages,w,A),pageParams:T(y.pageParams,v,A)}};if(i&&a.length){const y=i==="backward",v=y?cae:VU,b={pages:a,pageParams:s},x=v(r,b);o=await m(b,x,y)}else{const y=t??a.length;do{const v=l===0?s[0]??r.initialPageParam:VU(r,o);if(l>0&&v==null)break;o=await m(o,v),l++}while(l<y)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=c}}}function VU(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 cae(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var uae=class extends JG{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||t9(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=QG({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#r({type:"failed",failureCount:a,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#r({type:"pending",context:s,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),ri.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function t9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var dae=class extends ym{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new uae({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=kb(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=kb(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=kb(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=kb(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ri.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>IU(e,n))}findAll(t={}){return this.getAll().filter(e=>IU(t,e))}notify(t){ri.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ri.batch(()=>Promise.all(t.map(e=>e.continue().catch(pa))))}};function kb(t){return t.options.scope?.id}var fae=class extends ym{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),B_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Ef(n.mutationKey)!==Ef(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??t9();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){ri.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},hae=class extends ym{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??jP(r,e);let a=this.get(i);return a||(a=new aae({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ri.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>LU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>LU(t,n)):e}notify(t){ri.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ri.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ri.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},pae=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new hae,this.#t=t.mutationCache||new dae,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=FP.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=H_.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Fu(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,s=Kie(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return ri.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;ri.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return ri.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ri.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(pa).catch(pa)}invalidateQueries(t,e={}){return ri.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=ri.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(pa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(pa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Fu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pa).catch(pa)}fetchInfiniteQuery(t){return t.behavior=$U(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pa).catch(pa)}ensureInfiniteQueryData(t){return t.behavior=$U(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return H_.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Ef(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{Bx(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Ef(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{Bx(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=jP(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===UP&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},n9=E.createContext(void 0),In=t=>{const e=E.useContext(n9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},mae=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),h.jsx(n9.Provider,{value:t,children:e})),r9=E.createContext(!1),gae=()=>E.useContext(r9);r9.Provider;function xae(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var vae=E.createContext(xae()),bae=()=>E.useContext(vae),yae=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},_ae=t=>{E.useEffect(()=>{t.clearReset()},[t])},Sae=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||YG(n,[t.error,r])),wae=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))}},Mae=(t,e)=>t.isLoading&&t.isFetching&&!e,Eae=(t,e)=>t?.suspense&&e.isPending,GU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Aae(t,e,n){const r=gae(),i=bae(),a=In(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",wae(s),yae(s,i),_ae(i);const o=!a.getQueryCache().get(s.queryHash),[l]=E.useState(()=>new e(a,s)),c=l.getOptimisticResult(s),u=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(f=>{const g=u?l.subscribe(ri.batchCalls(f)):pa;return l.updateResult(),g},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),E.useEffect(()=>{l.setOptions(s)},[s,l]),Eae(s,c))throw GU(s,l,i);if(Sae({result:c,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!Mf&&Mae(c,r)&&(o?GU(s,l,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(pa).finally(()=>{l.updateResult()}),s.notifyOnChangeProps?c:l.trackResult(c)}function Ut(t,e){return Aae(t,sae)}function yt(t,e){const n=In(),[r]=E.useState(()=>new fae(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(s=>r.subscribe(ri.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((s,o)=>{r.mutate(s,o).catch(pa)},[r]);if(i.error&&YG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Tae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),WU=t=>{const e=Cae(t);return e.charAt(0).toUpperCase()+e.slice(1)},i9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Nae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Rae={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 Pae=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...o},l)=>E.createElement("svg",{ref:l,...Rae,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:i9("lucide",i),...!a&&!Nae(o)&&{"aria-hidden":"true"},...o},[...s.map(([c,u])=>E.createElement(c,u)),...Array.isArray(a)?a:[a]]));const tt=(t,e)=>{const n=E.forwardRef(({className:r,...i},a)=>E.createElement(Pae,{ref:a,iconNode:e,className:i9(`lucide-${Tae(WU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=WU(t),n};const kae=[["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"}]],Dae=tt("archive",kae);const Oae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Lae=tt("arrow-down",Oae);const Iae=[["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"}]],jae=tt("arrow-up-down",Iae);const Uae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Fae=tt("arrow-up",Uae);const zae=[["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"}]],ON=tt("bell",zae);const Bae=[["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"}]],Hae=tt("bold",Bae);const $ae=[["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"}]],Hx=tt("box",$ae);const Vae=[["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"}]],Gae=tt("cable",Vae);const Wae=[["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"}]],qae=tt("calendar-days",Wae);const Xae=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Zo=tt("calendar",Xae);const Kae=[["path",{d:"M14.564 14.558a3 3 0 1 1-4.122-4.121",key:"1rnrzw"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175",key:"1x3arw"}],["path",{d:"M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344",key:"1i84u0"}]],Yae=tt("camera-off",Kae);const Zae=[["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"}]],$_=tt("camera",Zae);const Qae=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Jae=tt("chart-column",Qae);const ese=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Hp=tt("check",ese);const tse=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Gf=tt("chevron-down",tse);const nse=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wf=tt("chevron-right",nse);const rse=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Af=tt("chevron-left",rse);const ise=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],QS=tt("chevron-up",ise);const ase=[["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"}]],od=tt("circle-alert",ase);const sse=[["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"}]],qU=tt("circle-arrow-up",sse);const ose=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ld=tt("circle-check-big",ose);const lse=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],cse=tt("circle-stop",lse);const use=[["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"}]],L0=tt("circle-x",use);const dse=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ba=tt("clock",dse);const fse=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],BP=tt("cloud",fse);const hse=[["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"}]],pse=tt("code-xml",hse);const mse=[["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"}]],LN=tt("copy",mse);const gse=[["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"}]],XU=tt("database",gse);const xse=[["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"}]],KU=tt("dollar-sign",xse);const vse=[["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"}]],Ku=tt("download",vse);const bse=[["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"}]],a9=tt("droplet",bse);const yse=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],_se=tt("ellipsis-vertical",yse);const Sse=[["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"}]],Qo=tt("external-link",Sse);const wse=[["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"}]],Mse=tt("eye-off",wse);const Ese=[["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"}]],YU=tt("eye",Ese);const Ase=[["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"}]],Tse=tt("file-box",Ase);const Cse=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"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"}]],ZU=tt("file-code",Cse);const Nse=[["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"}]],Rse=tt("file-exclamation-point",Nse);const Pse=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Sp=tt("file-text",Pse);const kse=[["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"}]],s9=tt("file",kse);const Dse=[["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"}]],Np=tt("film",Dse);const Ose=[["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"}]],o9=tt("flame",Ose);const Lse=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Ise=tt("folder-open",Lse);const jse=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Use=tt("folder",jse);const Fse=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],zse=tt("funnel",Fse);const Bse=[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]],Hse=tt("gamepad-2",Bse);const $se=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],HP=tt("gauge",$se);const Vse=[["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"}]],QU=tt("github",Vse);const Gse=[["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"}]],V_=tt("globe",Gse);const Wse=[["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"}]],$P=tt("grip-vertical",Wse);const qse=[["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"}]],l9=tt("hard-drive",qse);const Xse=[["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"}]],JS=tt("image",Xse);const Kse=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],c9=tt("info",Kse);const Yse=[["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"}]],Zse=tt("italic",Yse);const Qse=[["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"}]],Jse=tt("key",Qse);const eoe=[["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"}]],IN=tt("keyboard",eoe);const toe=[["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"}]],u9=tt("layers",toe);const noe=[["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"}]],roe=tt("layout-grid",noe);const ioe=[["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"}]],aoe=tt("link-2-off",ioe);const soe=[["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"}]],ooe=tt("link-2",soe);const loe=[["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"}]],coe=tt("link",loe);const uoe=[["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"}]],doe=tt("list-ordered",uoe);const foe=[["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"}]],d9=tt("list",foe);const hoe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ft=tt("loader-circle",hoe);const poe=[["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"}]],JU=tt("log-in",poe);const moe=[["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"}]],goe=tt("log-out",moe);const xoe=[["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"}]],f9=tt("maximize-2",xoe);const voe=[["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"}]],boe=tt("minimize-2",voe);const yoe=[["path",{d:"M5 12h14",key:"1ays0h"}]],_oe=tt("minus",yoe);const Soe=[["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"}]],G_=tt("moon",Soe);const woe=[["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"}]],W_=tt("package",woe);const Moe=[["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"}]],h9=tt("pause",Moe);const Eoe=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],VP=tt("pen-line",Eoe);const Aoe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],p9=tt("pen",Aoe);const Toe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],eF=tt("pencil",Toe);const Coe=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ew=tt("play",Coe);const Noe=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],jN=tt("plug",Noe);const Roe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Jo=tt("plus",Roe);const Poe=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],m9=tt("power-off",Poe);const koe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],tw=tt("power",koe);const Doe=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],mc=tt("printer",Doe);const Ooe=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Loe=tt("qr-code",Ooe);const Ioe=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],el=tt("refresh-cw",Ioe);const joe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],nw=tt("rotate-ccw",joe);const Uoe=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Foe=tt("rotate-cw",Uoe);const zoe=[["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"}]],Boe=tt("ruler",zoe);const Hoe=[["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"}]],I0=tt("save",Hoe);const $oe=[["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"}]],Voe=tt("scan-search",$oe);const Goe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],q_=tt("search",Goe);const Woe=[["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"}]],g9=tt("send",Woe);const qoe=[["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"}]],GP=tt("settings-2",qoe);const Xoe=[["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"}]],Koe=tt("settings",Xoe);const Yoe=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],Zoe=tt("skip-back",Yoe);const Qoe=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],x9=tt("skip-forward",Qoe);const Joe=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ele=tt("sparkles",Joe);const tle=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],X_=tt("square-check-big",tle);const nle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],$p=tt("square",nle);const rle=[["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"}]],$x=tt("star",rle);const ile=[["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"}]],ale=tt("sticky-note",ile);const sle=[["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"}]],tF=tt("sun",sle);const ole=[["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"}]],Vx=tt("tag",ole);const lle=[["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"}]],cle=tt("target",lle);const ule=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],dle=tt("terminal",ule);const fle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],hle=tt("text-align-center",fle);const ple=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],mle=tt("text-align-end",ple);const gle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],xle=tt("text-align-start",gle);const vle=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],p_=tt("thermometer",vle);const ble=[["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"}]],aa=tt("trash-2",ble);const yle=[["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"}]],ya=tt("triangle-alert",yle);const _le=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Sle=tt("underline",_le);const wle=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Mle=tt("unlink",wle);const Ele=[["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"}]],Gx=tt("upload",Ele);const Ale=[["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"}]],nF=tt("user",Ale);const Tle=[["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"}]],Cle=tt("video",Tle);const Nle=[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]],Rle=tt("webcam",Nle);const Ple=[["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"}]],Vp=tt("wifi-off",Ple);const kle=[["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"}]],WP=tt("wifi",kle);const Dle=[["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"}]],Ole=tt("wind",Dle);const Lle=[["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"}]],Gp=tt("wrench",Lle);const Ile=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],mn=tt("x",Ile);const jle=[["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"}]],Ule=tt("zoom-in",jle);const Fle=[["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"}]],v9=tt("zap",Fle);const zle=[["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"}]],Ble=tt("zoom-out",zle),b9=E.createContext(void 0);function Hle({children:t}){const[e,n]=E.useState(()=>{const a=localStorage.getItem("theme");return a||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});E.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(a=>a==="dark"?"light":"dark")},i=a=>{n(a)};return h.jsx(b9.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function $le(){const t=E.useContext(b9);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Yt({children:t,className:e="",onClick:n,onContextMenu:r}){return h.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Xl({children:t,className:e=""}){return h.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function on({children:t,className:e=""}){return h.jsx("div",{className:`p-6 ${e}`,children:t})}function Vle(t,e){return[{category:"Navigation",items:t?t.map((r,i)=>({keys:[String(i+1)],description:`Go to ${e(r.labelKey)}`})):[{keys:["1"],description:"Go to Printers"},{keys:["2"],description:"Go to Archives"},{keys:["3"],description:"Go to Queue"},{keys:["4"],description:"Go to Statistics"},{keys:["5"],description:"Go to Cloud Profiles"},{keys:["6"],description:"Go to Settings"}]},{category:"Archives",items:[{keys:["/"],description:"Focus search"},{keys:["U"],description:"Open upload modal"},{keys:["Esc"],description:"Clear selection / blur input"},{keys:["Right-click"],description:"Context menu on cards"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function rF({children:t}){return h.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function Gle({onClose:t,navItems:e}){const{t:n}=PP(),r=Vle(e,n);return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:h.jsx(Yt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:h.jsxs(on,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(IN,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),h.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:r.map(i=>h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:i.category}),h.jsx("div",{className:"space-y-2",children:i.items.map(a=>h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-white text-sm",children:a.description}),h.jsx("div",{className:"flex gap-1",children:a.keys.map(s=>h.jsx(rF,{children:s},s))})]},a.description))})]},i.category))}),h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:h.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",h.jsx(rF,{children:"Esc"})," or click outside to close"]})})]})})})}const Rr="/api/v1";async function Je(t,e={}){const n=await fetch(`${Rr}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.json()}function Wx(t){return"requires_confirmation"in t&&t.requires_confirmation===!0}const Fe={getPrinters:()=>Je("/printers/"),getPrinter:t=>Je(`/printers/${t}`),createPrinter:t=>Je("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Je(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>Je(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>Je(`/printers/${t}/status`),connectPrinter:t=>Je(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Je(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>Je(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Je(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Je(`/printers/${t}/logging`),clearMQTTLogs:t=>Je(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Je(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Rr}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Je(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Je(`/printers/${t}/storage`),getArchives:(t,e=50,n=0)=>{const r=new URLSearchParams;return t&&r.set("printer_id",String(t)),r.set("limit",String(e)),r.set("offset",String(n)),Je(`/archives/?${r}`)},getArchive:t=>Je(`/archives/${t}`),updateArchive:(t,e)=>Je(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Je(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Je(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Je("/archives/stats"),getArchiveDuplicates:t=>Je(`/archives/${t}/duplicates`),backfillContentHashes:()=>Je("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Rr}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Rr}/archives/${t}/download`,getArchiveGcode:t=>`${Rr}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Rr}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>Je(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Je(`/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(`${Rr}/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()},getArchivePhotoUrl:(t,e)=>`${Rr}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Rr}/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)=>Je(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Rr}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Rr}/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(`${Rr}/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=>Je(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Rr}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Je(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Je(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Je(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Rr}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Rr}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>Je(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Rr}/archives/upload?printer_id=${e}`:`${Rr}/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?`${Rr}/archives/upload-bulk?printer_id=${e}`:`${Rr}/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:()=>Je("/settings/"),updateSettings:t=>Je("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>Je("/settings/reset",{method:"POST"}),checkFfmpeg:()=>Je("/settings/check-ffmpeg"),getCloudStatus:()=>Je("/cloud/status"),cloudLogin:(t,e,n="global")=>Je("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Je("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Je("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Je("/cloud/logout",{method:"POST"}),getCloudSettings:(t="01.09.00.00")=>Je(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Je(`/cloud/settings/${t}`),getCloudDevices:()=>Je("/cloud/devices"),getSmartPlugs:()=>Je("/smart-plugs/"),getSmartPlug:t=>Je(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Je(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Je("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Je(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Je(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Je(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Je(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Je("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Je(`/queue/?${n}`)},getQueueItem:t=>Je(`/queue/${t}`),addToQueue:t=>Je("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Je(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Je(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Je("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Je(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Je(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Je(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Je(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Je(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),getSlotPresets:t=>Je(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Je(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Je(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Je(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Je("/filaments/"),getFilament:t=>Je(`/filaments/${t}`),getFilamentsByType:t=>Je(`/filaments/by-type/${t}`),getNotificationProviders:()=>Je("/notifications/"),getNotificationProvider:t=>Je(`/notifications/${t}`),createNotificationProvider:t=>Je("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Je(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Je(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Je(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Je("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),getSpoolmanStatus:()=>Je("/spoolman/status"),connectSpoolman:()=>Je("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Je("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Je(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Je("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Je("/spoolman/spools"),getSpoolmanFilaments:()=>Je("/spoolman/filaments"),getVersion:()=>Je("/updates/version"),checkForUpdates:()=>Je("/updates/check"),applyUpdate:()=>Je("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Je("/updates/status"),getMaintenanceTypes:()=>Je("/maintenance/types"),createMaintenanceType:t=>Je("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Je(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Je(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Je("/maintenance/overview"),getPrinterMaintenance:t=>Je(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Je(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Je(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Je(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Je("/maintenance/summary"),setPrinterHours:(t,e)=>Je(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),pausePrint:t=>Je(`/printers/${t}/control/pause`,{method:"POST"}),resumePrint:t=>Je(`/printers/${t}/control/resume`,{method:"POST"}),stopPrint:(t,e)=>Je(`/printers/${t}/control/stop`,{method:"POST",body:JSON.stringify({confirm_token:e})}),setBedTemperature:(t,e,n)=>Je(`/printers/${t}/control/temperature/bed`,{method:"POST",body:JSON.stringify({target:e,confirm_token:n})}),setNozzleTemperature:(t,e,n=0,r)=>Je(`/printers/${t}/control/temperature/nozzle`,{method:"POST",body:JSON.stringify({target:e,nozzle:n,confirm_token:r})}),setChamberTemperature:(t,e,n)=>Je(`/printers/${t}/control/temperature/chamber`,{method:"POST",body:JSON.stringify({target:e,confirm_token:n})}),setPrintSpeed:(t,e)=>Je(`/printers/${t}/control/speed`,{method:"POST",body:JSON.stringify({mode:e})}),setPartFan:(t,e)=>Je(`/printers/${t}/control/fan/part`,{method:"POST",body:JSON.stringify({speed:e})}),setAuxFan:(t,e)=>Je(`/printers/${t}/control/fan/aux`,{method:"POST",body:JSON.stringify({speed:e})}),setChamberFan:(t,e)=>Je(`/printers/${t}/control/fan/chamber`,{method:"POST",body:JSON.stringify({speed:e})}),setAirductMode:(t,e)=>Je(`/printers/${t}/control/airduct`,{method:"POST",body:JSON.stringify({mode:e})}),setChamberLight:(t,e)=>Je(`/printers/${t}/control/light`,{method:"POST",body:JSON.stringify({on:e})}),selectExtruder:(t,e)=>Je(`/printers/${t}/control/extruder`,{method:"POST",body:JSON.stringify({extruder:e})}),homeAxes:(t,e="XYZ",n)=>Je(`/printers/${t}/control/home`,{method:"POST",body:JSON.stringify({axes:e,confirm_token:n})}),moveAxis:(t,e,n,r=3e3,i)=>Je(`/printers/${t}/control/move`,{method:"POST",body:JSON.stringify({axis:e,distance:n,speed:r,confirm_token:i})}),disableMotors:(t,e)=>Je(`/printers/${t}/control/motors/disable`,{method:"POST",body:JSON.stringify({confirm_token:e})}),enableMotors:t=>Je(`/printers/${t}/control/motors/enable`,{method:"POST"}),amsLoadFilament:(t,e,n)=>Je(`/printers/${t}/control/ams/load`,{method:"POST",body:JSON.stringify({tray_id:e,extruder_id:n})}),amsUnloadFilament:t=>Je(`/printers/${t}/control/ams/unload`,{method:"POST"}),amsSetFilamentSetting:(t,e)=>Je(`/printers/${t}/control/ams/filament-setting`,{method:"POST",body:JSON.stringify(e)}),sendGcode:(t,e,n)=>Je(`/printers/${t}/control/gcode`,{method:"POST",body:JSON.stringify({command:e,confirm_token:n})}),getCameraStreamUrl:(t,e=10)=>`${Rr}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Rr}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Je(`/printers/${t}/camera/test`),setTimelapse:(t,e)=>Je(`/printers/${t}/control/camera/timelapse`,{method:"POST",body:JSON.stringify({enable:e})}),setLiveview:(t,e)=>Je(`/printers/${t}/control/camera/liveview`,{method:"POST",body:JSON.stringify({enable:e})}),refreshStatus:t=>Je(`/printers/${t}/control/refresh`,{method:"POST"}),refreshAmsTray:(t,e,n)=>Je(`/printers/${t}/control/ams/refresh-tray`,{method:"POST",body:JSON.stringify({ams_id:e,tray_id:n})}),setPrintOption:(t,e,n,r=!0,i="medium")=>{const a=new URLSearchParams({module_name:e,enabled:String(n),print_halt:String(r),sensitivity:i});return Je(`/printers/${t}/print-options?${a}`,{method:"POST"})},startCalibration:(t,e)=>{const n=new URLSearchParams;return e.bed_leveling&&n.append("bed_leveling","true"),e.vibration&&n.append("vibration","true"),e.motor_noise&&n.append("motor_noise","true"),e.nozzle_offset&&n.append("nozzle_offset","true"),e.high_temp_heatbed&&n.append("high_temp_heatbed","true"),Je(`/printers/${t}/calibration?${n}`,{method:"POST"})}},m_=[{id:"printers",to:"/",icon:mc,labelKey:"nav.printers"},{id:"control",to:"/control",icon:Hse,labelKey:"nav.control"},{id:"archives",to:"/archives",icon:Dae,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Zo,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Jae,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:BP,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Gp,labelKey:"nav.maintenance"},{id:"settings",to:"/settings",icon:Koe,labelKey:"nav.settings"}];function Wle(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map(m_.map(i=>[i.id,i])),r=[];for(const i of e){const a=n.get(i);a&&(r.push(a),n.delete(i))}for(const i of n.values())r.push(i);return r}catch{return m_}return m_}function qle(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function y9(){return localStorage.getItem("defaultView")||"/"}function Xle(t){localStorage.setItem("defaultView",t)}function Kle(){const t=KS(),e=Ec(),{theme:n,toggleTheme:r}=$le(),{t:i}=PP(),[a,s]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[o,l]=E.useState(!1),[c,u]=E.useState(Wle),[f,g]=E.useState(null),[m,y]=E.useState(null),v=E.useRef(!1),{data:b}=Ut({queryKey:["version"],queryFn:Fe.getVersion,staleTime:1/0}),{data:x}=Ut({queryKey:["settings"],queryFn:Fe.getSettings,staleTime:300*1e3}),{data:M}=Ut({queryKey:["updateCheck"],queryFn:Fe.checkForUpdates,enabled:x?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3});E.useEffect(()=>{if(!v.current&&e.pathname==="/"){const C=y9();C!=="/"&&(v.current=!0,t(C,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]);const w=(C,k)=>{g(k),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",String(k))},A=(C,k)=>{C.preventDefault(),C.dataTransfer.dropEffect="move",y(k)},T=()=>{y(null)},R=(C,k)=>{if(C.preventDefault(),f===null||f===k){g(null),y(null);return}const U=[...c],[I]=U.splice(f,1);U.splice(k,0,I),u(U),qle(U),g(null),y(null)},N=()=>{g(null),y(null)},j=E.useCallback(C=>{const k=C.target;if(!(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)&&!C.metaKey&&!C.ctrlKey&&!C.altKey){const U=parseInt(C.key);if(U>=1&&U<=c.length){C.preventDefault(),t(c[U-1].to);return}switch(C.key){case"?":C.preventDefault(),l(!0);break;case"Escape":l(!1);break}}},[t,c]);return E.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),h.jsxs("div",{className:"flex min-h-screen",children:[h.jsxs("aside",{className:`${a?"w-64":"w-16"} bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col fixed inset-y-0 left-0 z-30 transition-all duration-300`,children:[h.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a?"p-4":"p-2"}`,children:h.jsx("img",{src:n==="dark"?"/img/bambusy_logo_dark.png":"/img/bambusy_logo_light.png",alt:"Bambusy",className:a?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),h.jsx("nav",{className:"flex-1 p-2",children:h.jsx("ul",{className:"space-y-2",children:c.map(({id:C,to:k,icon:U,labelKey:I},H)=>h.jsx("li",{draggable:!0,onDragStart:O=>w(O,H),onDragOver:O=>A(O,H),onDragLeave:T,onDrop:O=>R(O,H),onDragEnd:N,className:`relative ${f===H?"opacity-50":""} ${m===H&&f!==H?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:h.jsxs(GG,{to:k,className:({isActive:O})=>`flex items-center ${a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${O?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:a?void 0:i(I),children:[a&&h.jsx($P,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),h.jsx(U,{className:"w-5 h-5 flex-shrink-0"}),a&&h.jsx("span",{children:i(I)})]})},C))})}),h.jsx("button",{onClick:()=>s(!a),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(a?"nav.collapseSidebar":"nav.expandSidebar"),children:a?h.jsx(Af,{className:"w-5 h-5"}):h.jsx(Wf,{className:"w-5 h-5"})}),h.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a?h.jsxs("div",{className:"flex items-center justify-between px-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",b?.version||"..."]}),M?.update_available&&h.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:M.latest_version}),children:[h.jsx(qU,{className:"w-4 h-4"}),h.jsx("span",{children:i("nav.update")})]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:h.jsx(QU,{className:"w-5 h-5"})}),h.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:h.jsx(IN,{className:"w-5 h-5"})}),h.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"?h.jsx(tF,{className:"w-5 h-5"}):h.jsx(G_,{className:"w-5 h-5"})})]})]}):h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[M?.update_available&&h.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:M.latest_version}),children:h.jsx(qU,{className:"w-5 h-5"})}),h.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:h.jsx(QU,{className:"w-5 h-5"})}),h.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:h.jsx(IN,{className:"w-5 h-5"})}),h.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"?h.jsx(tF,{className:"w-5 h-5"}):h.jsx(G_,{className:"w-5 h-5"})})]})})]}),h.jsx("main",{className:`flex-1 bg-bambu-dark overflow-auto ${a?"ml-64":"ml-16"} transition-all duration-300`,children:h.jsx(cie,{})}),o&&h.jsx(Gle,{onClose:()=>l(!1),navItems:c})]})}function ct({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",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-6 py-3 text-base gap-2"};return h.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...i,children:r})}function ii({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){E.useEffect(()=>{const c=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const l={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:h.jsx(Yt,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:h.jsxs(on,{className:"p-6",children:[h.jsxs("div",{className:"flex items-start gap-4",children:[h.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:h.jsx(ya,{className:"w-6 h-6"})}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),h.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),h.jsxs("div",{className:"flex gap-3 mt-6",children:[h.jsx(ct,{variant:"secondary",onClick:s,className:"flex-1",children:r}),h.jsx(ct,{onClick:a,className:`flex-1 ${l.button}`,children:n})]})]})})})}const _9=E.createContext(void 0);function eo(){const t=E.useContext(_9);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Yle={success:h.jsx(ld,{className:"w-5 h-5 text-green-400"}),error:h.jsx(L0,{className:"w-5 h-5 text-red-400"}),warning:h.jsx(od,{className:"w-5 h-5 text-yellow-400"}),info:h.jsx(c9,{className:"w-5 h-5 text-blue-400"})},Zle={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30"};function Qle({children:t}){const[e,n]=E.useState([]),r=E.useCallback((a,s="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:a,type:s}]),setTimeout(()=>{n(l=>l.filter(c=>c.id!==o))},3e3)},[]),i=E.useCallback(a=>{n(s=>s.filter(o=>o.id!==a))},[]);return h.jsxs(_9.Provider,{value:{showToast:r},children:[t,h.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>h.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Zle[a.type]}`,children:[Yle[a.type],h.jsx("span",{className:"text-white text-sm",children:a.message}),h.jsx("button",{onClick:()=>i(a.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-4 h-4"})})]},a.id))})]})}function Jle(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 ece(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 tce(t,e){if(e)return Use;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Tse;case"gcode":return Sp;case"mp4":case"avi":return Np;case"png":case"jpg":case"jpeg":return JS;default:return s9}}function nce({printerId:t,printerName:e,onClose:n}){const{showToast:r}=eo(),i=In(),[a,s]=E.useState("/"),[o,l]=E.useState(null),[c,u]=E.useState(""),[f,g]=E.useState(null);E.useEffect(()=>{const N=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:m,isLoading:y,refetch:v}=Ut({queryKey:["printerFiles",t,a],queryFn:()=>Fe.getPrinterFiles(t,a)}),{data:b}=Ut({queryKey:["printerStorage",t],queryFn:()=>Fe.getPrinterStorage(t),staleTime:3e4}),x=yt({mutationFn:N=>Fe.deletePrinterFile(t,N),onSuccess:(N,j)=>{r(`Deleted: ${j.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),M=N=>{s(N),l(null)},w=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(N.length?"/"+N.join("/"):"/"),l(null)},A=N=>{window.open(Fe.getPrinterFileDownloadUrl(t,N),"_blank")},T=N=>{g(N)},R=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return h.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[h.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(l9,{className:"w-5 h-5 text-bambu-green"}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[b?.used_bytes!=null&&b.used_bytes>0&&h.jsxs("div",{className:"text-sm text-bambu-gray",children:["Used: ",ece(b.used_bytes)]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]})]}),h.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[R.map(N=>h.jsx("button",{onClick:()=>{M(N.path),u("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"relative",children:[h.jsx(q_,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:N=>u(N.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),h.jsx(ct,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:y,children:h.jsx(el,{className:`w-4 h-4 ${y?"animate-spin":""}`})})]}),h.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[h.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:h.jsx(Af,{className:"w-4 h-4"})}),h.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:y?h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?h.jsx("div",{className:"space-y-1",children:[...m.files].filter(N=>!c||N.name.toLowerCase().includes(c.toLowerCase())).sort((N,j)=>N.is_directory&&!j.is_directory?-1:!N.is_directory&&j.is_directory?1:N.name.localeCompare(j.name)).map(N=>{const j=tce(N.name,N.is_directory),C=o===N.path;return h.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${C?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?M(N.path):l(C?null:N.path)},children:[h.jsx(j,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),h.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&h.jsx("span",{className:"text-sm text-bambu-gray",children:Jle(N.size)}),N.is_directory&&h.jsx(Af,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),h.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[h.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${m?.files?.filter(N=>N.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(ct,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[h.jsx(Ku,{className:"w-4 h-4"}),"Download"]}),h.jsxs(ct,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(aa,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&h.jsx(ii,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(f),g(null)},onCancel:()=>g(null)})]})}function rce({printerId:t,printerName:e,onClose:n}){const r=In(),[i,a]=E.useState(!0),[s,o]=E.useState(new Set),l=E.useRef(null),{data:c,isLoading:u,refetch:f}=Ut({queryKey:["mqtt-logs",t],queryFn:()=>Fe.getMQTTLogs(t),refetchInterval:1e3}),g=yt({mutationFn:()=>Fe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),m=yt({mutationFn:()=>Fe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),y=yt({mutationFn:()=>Fe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const A=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]),E.useEffect(()=>{i&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[c?.logs,i]);const v=A=>{o(T=>{const R=new Set(T);return R.has(A)?R.delete(A):R.add(A),R})},b=A=>new Date(A).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),x=(A,T)=>{const R=JSON.stringify(A,null,T?2:0);return!T&&R.length>100?R.substring(0,100)+"...":R},M=c?.logging_enabled??!1,w=c?.logs??[];return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[M?h.jsxs(ct,{size:"sm",variant:"secondary",onClick:()=>m.mutate(),disabled:m.isPending,children:[h.jsx($p,{className:"w-4 h-4"}),"Stop"]}):h.jsxs(ct,{size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:[h.jsx(ew,{className:"w-4 h-4"}),"Start Logging"]}),h.jsxs(ct,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending||w.length===0,children:[h.jsx(aa,{className:"w-4 h-4"}),"Clear"]}),h.jsx(ct,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:u,children:h.jsx(el,{className:`w-4 h-4 ${u?"animate-spin":""}`})}),h.jsx("div",{className:"flex-1"}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i,onChange:A=>a(A.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),h.jsxs("span",{className:"text-sm text-bambu-gray",children:[w.length," message",w.length!==1?"s":""]})]}),h.jsx("div",{ref:l,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-bambu-dark min-h-[400px]",children:w.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[h.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!M&&h.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):h.jsx("div",{className:"space-y-1",children:w.map((A,T)=>{const R=s.has(T),N=A.direction==="in";return h.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${R?"bg-bambu-dark-secondary":""}`,onClick:()=>v(T),children:[h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx("span",{className:"text-bambu-gray shrink-0",children:b(A.timestamp)}),h.jsx("span",{className:`shrink-0 ${N?"text-blue-400":"text-green-400"}`,title:N?"Incoming":"Outgoing",children:N?h.jsx(Lae,{className:"w-3 h-3"}):h.jsx(Fae,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-purple-400 shrink-0",children:A.topic})]}),h.jsx("pre",{className:`mt-1 text-white/80 overflow-x-auto ${R?"whitespace-pre-wrap":"truncate"}`,children:x(A.payload,R)})]},T)})})}),h.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[h.jsx("div",{className:"text-sm text-bambu-gray",children:M?h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):h.jsx("span",{children:"Logging stopped"})}),h.jsx(ct,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const ice={"0700_5500_0002_0001":"A binding error occurred between AMS and the extruder. Please perform AMS initialization again.","0500_0300_0002_000E":"Some modules are incompatible with the printer firmware version. Please update firmware.","0300_0100_0002_0054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0500_0100_0005_0005":"Motor driver overheated. Let the printer cool down.","0500_0100_0005_0006":"Motor driver communication error.","0700_0100_0007_0001":"AMS communication error.","0700_0100_0007_0002":"AMS filament runout.","0700_0100_0007_0003":"AMS filament not detected.","0C00_0100_000C_0003":"First layer inspection failed.","0C00_0100_000C_0004":"Nozzle clog detected.","0C00_0100_000C_8000":"Foreign object detected on print bed.","0500_0100_0005_0000":"Motor X axis lost steps.","0500_0100_0005_0001":"Motor Y axis lost steps.","0500_0100_0005_0002":"Motor Z axis lost steps."};function ace(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:ya};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:ya};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:od};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:c9}}}function S9(t,e){const n=(t>>24&255).toString(16).padStart(2,"0").toUpperCase(),r=(t>>16&255).toString(16).padStart(2,"0").toUpperCase(),i=(t>>8&255).toString(16).padStart(2,"0").toUpperCase(),a=(t&255).toString(16).padStart(2,"0").toUpperCase(),s=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),o=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),l=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),c=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${r}_${i}${a}_${s}${o}_${l}${c}`}function sce(t,e,n){const r=S9(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function oce({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),E.useEffect(()=>{const r=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ya,{className:"w-5 h-5 text-orange-400"}),h.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),h.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(mn,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(od,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No HMS errors"})]}):h.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:a,color:s,bgColor:o,Icon:l}=ace(r.severity),c=parseInt(r.code.replace("0x",""),16)||0,u=S9(r.attr,c),f=ice[u]||"Unknown error. Click the link below for details.",g=sce(r.attr,c,t),m=`HMS_${u.replace(/_/g,"-")}`;return h.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx(l,{className:`w-5 h-5 ${s} flex-shrink-0 mt-0.5`}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:`font-mono text-sm ${s}`,children:m}),h.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${s}`,children:a})]}),h.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:f}),h.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[h.jsx(Qo,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:h.jsx("p",{className:"text-xs text-bambu-gray",children:"HMS (Health Management System) monitors printer health. Clear errors on the printer to dismiss them here."})})]})})}function lce(t){if(!t)return"ASAP";const e=new Date(t),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 cce({printerId:t}){const{data:e}=Ut({queryKey:["queue",t,"pending"],queryFn:()=>Fe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:h.jsx("div",{className:"mt-3 p-2 bg-bambu-dark rounded-lg",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(Zo,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),h.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[h.jsx(ba,{className:"w-3 h-3"}),lce(n?.scheduled_time||null)]}),r>1&&h.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),h.jsx(ZS,{to:"/queue",className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors text-bambu-gray hover:text-white",title:"View queue",children:h.jsx(Wf,{className:"w-4 h-4"})})]})]})})}function uce(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function dce({url:t,printName:e}){const[n,r]=E.useState(!1),[i,a]=E.useState(!1),[s,o]=E.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!i?h.jsxs(h.Fragment,{children:[h.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&h.jsx(Hx,{className:"w-8 h-8 text-bambu-gray"})]}):h.jsx(Hx,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&h.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:h.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[h.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&h.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function fce({printer:t,hideIfDisconnected:e,maintenanceInfo:n}){const r=In(),i=KS(),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,g]=E.useState(!1),[m,y]=E.useState(!1),[v,b]=E.useState(!1),[x,M]=E.useState(!1),{data:w}=Ut({queryKey:["printerStatus",t.id],queryFn:()=>Fe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:A}=Ut({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Fe.getSmartPlugByPrinter(t.id)}),{data:T}=Ut({queryKey:["smartPlugStatus",A?.id],queryFn:()=>A?Fe.getSmartPlugStatus(A.id):null,enabled:!!A,refetchInterval:1e4}),R=e&&w&&!w.connected,N=yt({mutationFn:()=>Fe.deletePrinter(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]})}}),j=yt({mutationFn:()=>Fe.connectPrinter(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["printerStatus",t.id]})}}),C=yt({mutationFn:U=>A?Fe.controlSmartPlug(A.id,U):Promise.reject("No plug"),onSuccess:()=>{r.invalidateQueries({queryKey:["smartPlugStatus",A?.id]})}}),k=yt({mutationFn:U=>A?Fe.updateSmartPlug(A.id,{auto_off:U}):Promise.reject("No plug"),onSuccess:()=>{r.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})}});return R?null:h.jsxs(Yt,{className:"relative",children:[h.jsxs(on,{children:[h.jsxs("div",{className:"flex items-start justify-between mb-4",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:t.name}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",n&&n.total_print_hours>0&&h.jsxs("span",{className:"ml-2 text-bambu-gray",children:[h.jsx(ba,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${w?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[w?.connected?h.jsx(WP,{className:"w-3 h-3"}):h.jsx(Vp,{className:"w-3 h-3"}),w?.connected?"Connected":"Offline"]}),w?.connected&&h.jsxs("button",{onClick:()=>M(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${w.hms_errors&&w.hms_errors.length>0?w.hms_errors.some(U=>U.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[h.jsx(ya,{className:"w-3 h-3"}),w.hms_errors&&w.hms_errors.length>0?w.hms_errors.length:"OK"]}),n&&h.jsxs("button",{onClick:()=>i("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[h.jsx(Gp,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),h.jsxs("div",{className:"relative",children:[h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>s(!a),children:h.jsx(_se,{className:"w-4 h-4"})}),a&&h.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{j.mutate(),s(!1)},children:[h.jsx(el,{className:"w-4 h-4"}),"Reconnect"]}),h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),s(!1)},children:[h.jsx(dle,{className:"w-4 h-4"}),"MQTT Debug"]}),h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{l(!0),s(!1)},children:[h.jsx(aa,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),o&&h.jsx(ii,{title:"Delete Printer",message:`Are you sure you want to delete "${t.name}"? This will also remove all connection settings.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),l(!1)},onCancel:()=>l(!1)}),w?.connected&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:h.jsxs("div",{className:"flex gap-3",children:[h.jsx(dce,{url:w.state==="RUNNING"?w.cover_url:null,printName:w.state==="RUNNING"&&(w.subtask_name||w.current_print)||void 0}),h.jsx("div",{className:"flex-1 min-w-0",children:w.current_print&&w.state==="RUNNING"?h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),h.jsx("p",{className:"text-white text-sm mb-2 truncate",children:w.subtask_name||w.current_print}),h.jsxs("div",{className:"flex items-center justify-between text-sm",children:[h.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:h.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${w.progress||0}%`}})}),h.jsxs("span",{className:"text-white",children:[Math.round(w.progress||0),"%"]})]}),h.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[w.remaining_time!=null&&w.remaining_time>0&&h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(ba,{className:"w-3 h-3"}),uce(w.remaining_time*60)]}),w.layer_num!=null&&w.total_layers!=null&&w.total_layers>0&&h.jsxs("span",{children:["Layer ",w.layer_num,"/",w.total_layers]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),h.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:w.state?.toLowerCase()||"Idle"}),h.jsxs("div",{className:"flex items-center justify-between text-sm",children:[h.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:h.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),h.jsx("span",{className:"text-bambu-gray",children:"—"})]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),w.state!=="RUNNING"&&h.jsx(cce,{printerId:t.id}),w.temperatures&&h.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(p_,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.nozzle||0),"°C"]})]}),h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(p_,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.bed||0),"°C"]})]}),w.temperatures.chamber!==void 0&&h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(p_,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.chamber||0),"°C"]})]})]})]}),A&&h.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(v9,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),h.jsx("span",{className:"text-sm text-white truncate",children:A.name}),T&&h.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${T.state==="ON"?"bg-bambu-green/20 text-bambu-green":T.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:T.state||"?"}),T?.energy?.power!=null&&T.state==="ON"&&h.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[T.energy.power,"W"]})]}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsxs("button",{onClick:()=>y(!0),disabled:C.isPending||T?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${T?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(tw,{className:"w-3 h-3"}),"On"]}),h.jsxs("button",{onClick:()=>b(!0),disabled:C.isPending||T?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${T?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(m9,{className:"w-3 h-3"}),"Off"]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsx("span",{className:`text-xs hidden sm:inline ${A.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:A.auto_off_executed?"Auto-off done":"Auto-off"}),h.jsx("button",{onClick:()=>k.mutate(!A.auto_off),disabled:k.isPending||A.auto_off_executed,title:A.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 ${A.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":A.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:h.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${A.auto_off||A.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),h.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[h.jsxs("div",{className:"text-xs text-bambu-gray",children:[h.jsx("p",{children:t.ip_address}),h.jsx("p",{className:"truncate",children:t.serial_number})]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>u(!0),title:"Browse printer files",children:[h.jsx(l9,{className:"w-4 h-4"}),"Files"]})]})]}),c&&h.jsx(nce,{printerId:t.id,printerName:t.name,onClose:()=>u(!1)}),f&&h.jsx(rce,{printerId:t.id,printerName:t.name,onClose:()=>g(!1)}),m&&A&&h.jsx(ii,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{C.mutate("on"),y(!1)},onCancel:()=>y(!1)}),v&&A&&h.jsx(ii,{title:"Power Off Printer",message:w?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{C.mutate("off"),b(!1)},onCancel:()=>b(!1)}),x&&h.jsx(oce,{printerName:t.name,errors:w?.hms_errors||[],onClose:()=>M(!1)})]})}function hce({onClose:t,onAdd:e}){const[n,r]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:h.jsx(Yt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:h.jsxs(on,{children:[h.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),h.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),h.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),h.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),h.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),h.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[h.jsx("option",{value:"",children:"Select model..."}),h.jsxs("optgroup",{label:"H2 Series",children:[h.jsx("option",{value:"H2C",children:"H2C"}),h.jsx("option",{value:"H2D",children:"H2D"}),h.jsx("option",{value:"H2S",children:"H2S"})]}),h.jsxs("optgroup",{label:"X1 Series",children:[h.jsx("option",{value:"X1E",children:"X1E"}),h.jsx("option",{value:"X1C",children:"X1 Carbon"}),h.jsx("option",{value:"X1",children:"X1"})]}),h.jsxs("optgroup",{label:"P Series",children:[h.jsx("option",{value:"P2S",children:"P2S"}),h.jsx("option",{value:"P1S",children:"P1S"}),h.jsx("option",{value:"P1P",children:"P1P"})]}),h.jsxs("optgroup",{label:"A1 Series",children:[h.jsx("option",{value:"A1",children:"A1"}),h.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:i=>r({...n,auto_archive:i.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),h.jsxs("div",{className:"flex gap-3 pt-4",children:[h.jsx(ct,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),h.jsx(ct,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function pce(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),i=In(),{data:a,isLoading:s}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:o}=Ut({queryKey:["maintenanceOverview"],queryFn:Fe.getMaintenanceOverview,staleTime:60*1e3}),l=o?.reduce((f,g)=>(f[g.printer_id]={due_count:g.due_count,warning_count:g.warning_count,total_print_hours:g.total_print_hours},f),{})||{},c=yt({mutationFn:Fe.createPrinter,onSuccess:()=>{i.invalidateQueries({queryKey:["printers"]}),e(!1)}}),u=()=>{const f=!n;r(f),localStorage.setItem("hideDisconnectedPrinters",String(f))};return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"flex items-center justify-between mb-8",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),h.jsx("p",{className:"text-bambu-gray",children:"Manage your Bambu Lab printers"})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:n,onChange:u,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),h.jsxs(ct,{onClick:()=>e(!0),children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add Printer"]})]})]}),s?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):a?.length===0?h.jsx(Yt,{children:h.jsxs(on,{className:"text-center py-12",children:[h.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),h.jsxs(ct,{onClick:()=>e(!0),children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:a?.map(f=>h.jsx(fce,{printer:f,hideIfDisconnected:n,maintenanceInfo:l[f.id]},f.id))}),t&&h.jsx(hce,{onClose:()=>e(!1),onAdd:f=>c.mutate(f)})]})}const qP="181",Rp={ROTATE:0,DOLLY:1,PAN:2},wp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},mce=0,iF=1,gce=2,w9=1,xce=2,Vl=3,Yu=0,Fa=1,Ho=2,oc=0,Pp=1,aF=2,sF=3,oF=4,vce=5,Xd=100,bce=101,yce=102,_ce=103,Sce=104,wce=200,Mce=201,Ece=202,Ace=203,UN=204,FN=205,Tce=206,Cce=207,Nce=208,Rce=209,Pce=210,kce=211,Dce=212,Oce=213,Lce=214,zN=0,BN=1,HN=2,Wp=3,$N=4,VN=5,GN=6,WN=7,XP=0,Ice=1,jce=2,zu=0,Uce=1,Fce=2,zce=3,Bce=4,Hce=5,$ce=6,Vce=7,M9=300,qp=301,Xp=302,qN=303,XN=304,rw=306,KN=1e3,ec=1001,YN=1002,fs=1003,Gce=1004,Db=1005,$s=1006,UA=1007,tf=1008,tl=1009,E9=1010,A9=1011,qx=1012,KP=1013,Tf=1014,tc=1015,_m=1016,YP=1017,ZP=1018,Xx=1020,T9=35902,C9=35899,N9=1021,R9=1022,yo=1023,Kx=1026,Yx=1027,P9=1028,QP=1029,JP=1030,ek=1031,tk=1033,g_=33776,x_=33777,v_=33778,b_=33779,ZN=35840,QN=35841,JN=35842,e3=35843,t3=36196,n3=37492,r3=37496,i3=37808,a3=37809,s3=37810,o3=37811,l3=37812,c3=37813,u3=37814,d3=37815,f3=37816,h3=37817,p3=37818,m3=37819,g3=37820,x3=37821,v3=36492,b3=36494,y3=36495,_3=36283,S3=36284,w3=36285,M3=36286,Wce=3200,qce=3201,k9=0,Xce=1,Nu="",Ls="srgb",Kp="srgb-linear",K_="linear",Bn="srgb",kh=7680,lF=519,Kce=512,Yce=513,Zce=514,D9=515,Qce=516,Jce=517,eue=518,tue=519,cF=35044,uF="300 es",Go=2e3,Y_=2001;function O9(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Z_(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function nue(){const t=Z_("canvas");return t.style.display="block",t}const dF={};function fF(...t){const e="THREE."+t.shift();console.log(e,...t)}function Wt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function kr(...t){const e="THREE."+t.shift();console.error(e,...t)}function Zx(...t){const e=t.join(" ");e in dF||(dF[e]=!0,Wt(...t))}function rue(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 qf=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,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}};const Ki=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],y_=Math.PI/180,E3=180/Math.PI;function j0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ki[t&255]+Ki[t>>8&255]+Ki[t>>16&255]+Ki[t>>24&255]+"-"+Ki[e&255]+Ki[e>>8&255]+"-"+Ki[e>>16&15|64]+Ki[e>>24&255]+"-"+Ki[n&63|128]+Ki[n>>8&255]+"-"+Ki[n>>16&255]+Ki[n>>24&255]+Ki[r&255]+Ki[r>>8&255]+Ki[r>>16&255]+Ki[r>>24&255]).toLowerCase()}function pn(t,e,n){return Math.max(e,Math.min(n,t))}function iue(t,e){return(t%e+e)%e}function FA(t,e,n){return(1-n)*t+n*e}function Dg(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 Da(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 aue={DEG2RAD:y_};let an=class L9{constructor(e=0,n=0){L9.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=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(pn(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(pn(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,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Cf=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,s,o){let l=r[i+0],c=r[i+1],u=r[i+2],f=r[i+3],g=a[s+0],m=a[s+1],y=a[s+2],v=a[s+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=y,e[n+3]=v;return}if(f!==v||l!==g||c!==m||u!==y){let b=l*g+c*m+u*y+f*v;b<0&&(g=-g,m=-m,y=-y,v=-v,b=-b);let x=1-o;if(b<.9995){const M=Math.acos(b),w=Math.sin(M);x=Math.sin(x*M)/w,o=Math.sin(o*M)/w,l=l*x+g*o,c=c*x+m*o,u=u*x+y*o,f=f*x+v*o}else{l=l*x+g*o,c=c*x+m*o,u=u*x+y*o,f=f*x+v*o;const M=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=M,c*=M,u*=M,f*=M}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],f=a[s],g=a[s+1],m=a[s+2],y=a[s+3];return e[n]=o*y+u*f+l*m-c*g,e[n+1]=l*y+u*g+c*f-o*m,e[n+2]=c*y+u*m+o*g-l*f,e[n+3]=u*y-o*f-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,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,s=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),f=o(a/2),g=l(r/2),m=l(i/2),y=l(a/2);switch(s){case"XYZ":this._x=g*u*f+c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f-g*m*y;break;case"YXZ":this._x=g*u*f+c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f+g*m*y;break;case"ZXY":this._x=g*u*f-c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f-g*m*y;break;case"ZYX":this._x=g*u*f-c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f+g*m*y;break;case"YZX":this._x=g*u*f+c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f-g*m*y;break;case"XZY":this._x=g*u*f-c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f+g*m*y;break;default:Wt("Quaternion: .setFromEuler() encountered an unknown order: "+s)}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],s=n[1],o=n[5],l=n[9],c=n[2],u=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(a-c)*m,this._z=(s-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(u-l)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-c)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+c)/m,this._y=(l+u)/m,this._z=.25*m}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(pn(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,s=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+s*o+i*c-a*l,this._y=i*u+s*l+a*o-r*c,this._z=a*u+s*c+r*l-i*o,this._w=s*u-r*o-i*l-a*c,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,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let l=1-n;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,n=Math.sin(n*c)/u,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+a*n,this._w=this._w*l+s*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+a*n,this._w=this._w*l+s*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}},Ge=class I9{constructor(e=0,n=0,r=0){I9.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(hF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(hF.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,s=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])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*i-o*r),u=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+l*c+s*f-o*u,this.y=r+l*u+o*c-a*f,this.z=i+l*f+a*u-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,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=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this.z=pn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this.z=pn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(pn(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,s=n.x,o=n.y,l=n.z;return this.x=i*l-a*o,this.y=a*s-r*l,this.z=r*o-i*s,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 zA.copy(this).projectOnVector(e),this.sub(zA)}reflect(e){return this.sub(zA.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(pn(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 zA=new Ge,hF=new Cf;let cn=class j9{constructor(e,n,r,i,a,s,o,l,c){j9.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c)}set(e,n,r,i,a,s,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=r,u[7]=s,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,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,s=r[0],o=r[3],l=r[6],c=r[1],u=r[4],f=r[7],g=r[2],m=r[5],y=r[8],v=i[0],b=i[3],x=i[6],M=i[1],w=i[4],A=i[7],T=i[2],R=i[5],N=i[8];return a[0]=s*v+o*M+l*T,a[3]=s*b+o*w+l*R,a[6]=s*x+o*A+l*N,a[1]=c*v+u*M+f*T,a[4]=c*b+u*w+f*R,a[7]=c*x+u*A+f*N,a[2]=g*v+m*M+y*T,a[5]=g*b+m*w+y*R,a[8]=g*x+m*A+y*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*s*u-n*o*c-r*a*u+r*o*l+i*a*c-i*s*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],f=u*s-o*c,g=o*l-u*a,m=c*a-s*l,y=n*f+r*g+i*m;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/y;return e[0]=f*v,e[1]=(i*c-u*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(u*n-i*l)*v,e[5]=(i*a-o*n)*v,e[6]=m*v,e[7]=(r*l-c*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(r*l,r*c,-r*(l*s+c*o)+s+e,-i*c,i*l,-i*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(BA.makeScale(e,n)),this}rotate(e){return this.premultiply(BA.makeRotation(-e)),this}translate(e,n){return this.premultiply(BA.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 BA=new cn,pF=new cn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mF=new cn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function sue(){const t={enabled:!0,workingColorSpace:Kp,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Bn&&(i.r=lc(i.r),i.g=lc(i.g),i.b=lc(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Bn&&(i.r=kp(i.r),i.g=kp(i.g),i.b=kp(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===Nu?K_: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,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].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 Zx("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return Zx("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({[Kp]:{primaries:e,whitePoint:r,transfer:K_,toXYZ:pF,fromXYZ:mF,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ls},outputColorSpaceConfig:{drawingBufferColorSpace:Ls}},[Ls]:{primaries:e,whitePoint:r,transfer:Bn,toXYZ:pF,fromXYZ:mF,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ls}}}),t}const En=sue();function lc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function kp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Dh,oue=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{Dh===void 0&&(Dh=Z_("canvas")),Dh.width=e.width,Dh.height=e.height;const i=Dh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Dh}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=Z_("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 s=0;s<a.length;s++)a[s]=lc(a[s]/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(lc(n[r]/255)*255):n[r]=lc(n[r]);return{data:n,width:e.width,height:e.height}}else return Wt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},lue=0,nk=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:lue++}),this.uuid=j0(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(HA(i[s].image)):a.push(HA(i[s]))}else a=HA(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function HA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?oue.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Wt("Texture: Unable to serialize Texture."),{})}let cue=0;const $A=new Ge;let To=class __ extends qf{constructor(e=__.DEFAULT_IMAGE,n=__.DEFAULT_MAPPING,r=ec,i=ec,a=$s,s=tf,o=yo,l=tl,c=__.DEFAULT_ANISOTROPY,u=Nu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:cue++}),this.uuid=j0(),this.name="",this.source=new nk(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new an(0,0),this.repeat=new an(1,1),this.center=new an(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new cn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize($A).x}get height(){return this.source.getSize($A).y}get depth(){return this.source.getSize($A).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){Wt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Wt(`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!==M9)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case KN:e.x=e.x-Math.floor(e.x);break;case ec:e.x=e.x<0?0:1;break;case YN: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 KN:e.y=e.y-Math.floor(e.y);break;case ec:e.y=e.y<0?0:1;break;case YN:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};To.DEFAULT_IMAGE=null;To.DEFAULT_MAPPING=M9;To.DEFAULT_ANISOTROPY=1;let $r=class U9{constructor(e=0,n=0,r=0,i=1){U9.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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const l=e.elements,c=l[0],u=l[4],f=l[8],g=l[1],m=l[5],y=l[9],v=l[2],b=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(f-v)<.01&&Math.abs(y-b)<.01){if(Math.abs(u+g)<.1&&Math.abs(f+v)<.1&&Math.abs(y+b)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,A=(m+1)/2,T=(x+1)/2,R=(u+g)/4,N=(f+v)/4,j=(y+b)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=R/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=R/i,a=j/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=j/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-y)*(b-y)+(f-v)*(f-v)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(b-y)/M,this.y=(f-v)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this.z=pn(this.z,e.z,n.z),this.w=pn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this.z=pn(this.z,e,n),this.w=pn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(pn(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}},uue=class extends qf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:$s,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 $r(0,0,e,n),this.scissorTest=!1,this.viewport=new $r(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new To(i);this.textures=[];const s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(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:$s,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 nk(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"})}},Nf=class extends uue{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},F9=class extends To{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=fs,this.minFilter=fs,this.wrapR=ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},due=class extends To{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=fs,this.minFilter=fs,this.wrapR=ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Rf=class{constructor(e=new Ge(1/0,1/0,1/0),n=new Ge(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(oo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(oo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=oo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,oo):oo.fromBufferAttribute(a,s),oo.applyMatrix4(e.matrixWorld),this.expandByPoint(oo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ob.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ob.copy(r.boundingBox)),Ob.applyMatrix4(e.matrixWorld),this.union(Ob)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,oo),oo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Og),Lb.subVectors(this.max,Og),Oh.subVectors(e.a,Og),Lh.subVectors(e.b,Og),Ih.subVectors(e.c,Og),iu.subVectors(Lh,Oh),au.subVectors(Ih,Lh),Pd.subVectors(Oh,Ih);let n=[0,-iu.z,iu.y,0,-au.z,au.y,0,-Pd.z,Pd.y,iu.z,0,-iu.x,au.z,0,-au.x,Pd.z,0,-Pd.x,-iu.y,iu.x,0,-au.y,au.x,0,-Pd.y,Pd.x,0];return!VA(n,Oh,Lh,Ih,Lb)||(n=[1,0,0,0,1,0,0,0,1],!VA(n,Oh,Lh,Ih,Lb))?!1:(Ib.crossVectors(iu,au),n=[Ib.x,Ib.y,Ib.z],VA(n,Oh,Lh,Ih,Lb))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Rl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Rl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Rl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Rl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Rl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Rl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Rl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Rl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Rl),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 Rl=[new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge],oo=new Ge,Ob=new Rf,Oh=new Ge,Lh=new Ge,Ih=new Ge,iu=new Ge,au=new Ge,Pd=new Ge,Og=new Ge,Lb=new Ge,Ib=new Ge,kd=new Ge;function VA(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){kd.fromArray(t,a);const o=i.x*Math.abs(kd.x)+i.y*Math.abs(kd.y)+i.z*Math.abs(kd.z),l=e.dot(kd),c=n.dot(kd),u=r.dot(kd);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const fue=new Rf,Lg=new Ge,GA=new Ge;let iw=class{constructor(e=new Ge,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):fue.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;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;Lg.subVectors(e,this.center);const n=Lg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Lg,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):(GA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Lg.copy(e.center).add(GA)),this.expandByPoint(Lg.copy(e.center).sub(GA))),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 Pl=new Ge,WA=new Ge,jb=new Ge,su=new Ge,qA=new Ge,Ub=new Ge,XA=new Ge;let rk=class{constructor(e=new Ge,n=new Ge(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Pl)),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=Pl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Pl.copy(this.origin).addScaledVector(this.direction,n),Pl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){WA.copy(e).add(n).multiplyScalar(.5),jb.copy(n).sub(e).normalize(),su.copy(this.origin).sub(WA);const a=e.distanceTo(n)*.5,s=-this.direction.dot(jb),o=su.dot(this.direction),l=-su.dot(jb),c=su.lengthSq(),u=Math.abs(1-s*s);let f,g,m,y;if(u>0)if(f=s*l-o,g=s*o-l,y=a*u,f>=0)if(g>=-y)if(g<=y){const v=1/u;f*=v,g*=v,m=f*(f+s*g+2*o)+g*(s*f+g+2*l)+c}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;else g<=-y?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-l),a),m=-f*f+g*(g+2*l)+c):g<=y?(f=0,g=Math.min(Math.max(-a,-l),a),m=g*(g+2*l)+c):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-l),a),m=-f*f+g*(g+2*l)+c);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(WA).addScaledVector(jb,g),m}intersectSphere(e,n){Pl.subVectors(e.center,this.origin);const r=Pl.dot(this.direction),i=Pl.dot(Pl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,l=r+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,s,o,l;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(a=(e.min.y-g.y)*u,s=(e.max.y-g.y)*u):(a=(e.max.y-g.y)*u,s=(e.min.y-g.y)*u),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Pl)!==null}intersectTriangle(e,n,r,i,a){qA.subVectors(n,e),Ub.subVectors(r,e),XA.crossVectors(qA,Ub);let s=this.direction.dot(XA),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;su.subVectors(this.origin,e);const l=o*this.direction.dot(Ub.crossVectors(su,Ub));if(l<0)return null;const c=o*this.direction.dot(qA.cross(su));if(c<0||l+c>s)return null;const u=-o*su.dot(XA);return u<0?null:this.at(u/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},qr=class A3{constructor(e,n,r,i,a,s,o,l,c,u,f,g,m,y,v,b){A3.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,s,o,l,c,u,f,g,m,y,v,b)}set(e,n,r,i,a,s,o,l,c,u,f,g,m,y,v,b){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=f,x[14]=g,x[3]=m,x[7]=y,x[11]=v,x[15]=b,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 A3().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/jh.setFromMatrixColumn(e,0).length(),a=1/jh.setFromMatrixColumn(e,1).length(),s=1/jh.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]*s,n[9]=r[9]*s,n[10]=r[10]*s,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,s=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*u,m=s*f,y=o*u,v=o*f;n[0]=l*u,n[4]=-l*f,n[8]=c,n[1]=m+y*c,n[5]=g-v*c,n[9]=-o*l,n[2]=v-g*c,n[6]=y+m*c,n[10]=s*l}else if(e.order==="YXZ"){const g=l*u,m=l*f,y=c*u,v=c*f;n[0]=g+v*o,n[4]=y*o-m,n[8]=s*c,n[1]=s*f,n[5]=s*u,n[9]=-o,n[2]=m*o-y,n[6]=v+g*o,n[10]=s*l}else if(e.order==="ZXY"){const g=l*u,m=l*f,y=c*u,v=c*f;n[0]=g-v*o,n[4]=-s*f,n[8]=y+m*o,n[1]=m+y*o,n[5]=s*u,n[9]=v-g*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const g=s*u,m=s*f,y=o*u,v=o*f;n[0]=l*u,n[4]=y*c-m,n[8]=g*c+v,n[1]=l*f,n[5]=v*c+g,n[9]=m*c-y,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const g=s*l,m=s*c,y=o*l,v=o*c;n[0]=l*u,n[4]=v-g*f,n[8]=y*f+m,n[1]=f,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*f+y,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*l,m=s*c,y=o*l,v=o*c;n[0]=l*u,n[4]=-f,n[8]=c*u,n[1]=g*f+v,n[5]=s*u,n[9]=m*f-y,n[2]=y*f-m,n[6]=o*u,n[10]=v*f+g}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(hue,e,pue)}lookAt(e,n,r){const i=this.elements;return ts.subVectors(e,n),ts.lengthSq()===0&&(ts.z=1),ts.normalize(),ou.crossVectors(r,ts),ou.lengthSq()===0&&(Math.abs(r.z)===1?ts.x+=1e-4:ts.z+=1e-4,ts.normalize(),ou.crossVectors(r,ts)),ou.normalize(),Fb.crossVectors(ts,ou),i[0]=ou.x,i[4]=Fb.x,i[8]=ts.x,i[1]=ou.y,i[5]=Fb.y,i[9]=ts.y,i[2]=ou.z,i[6]=Fb.z,i[10]=ts.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,s=r[0],o=r[4],l=r[8],c=r[12],u=r[1],f=r[5],g=r[9],m=r[13],y=r[2],v=r[6],b=r[10],x=r[14],M=r[3],w=r[7],A=r[11],T=r[15],R=i[0],N=i[4],j=i[8],C=i[12],k=i[1],U=i[5],I=i[9],H=i[13],O=i[2],B=i[6],V=i[10],G=i[14],K=i[3],Y=i[7],oe=i[11],$=i[15];return a[0]=s*R+o*k+l*O+c*K,a[4]=s*N+o*U+l*B+c*Y,a[8]=s*j+o*I+l*V+c*oe,a[12]=s*C+o*H+l*G+c*$,a[1]=u*R+f*k+g*O+m*K,a[5]=u*N+f*U+g*B+m*Y,a[9]=u*j+f*I+g*V+m*oe,a[13]=u*C+f*H+g*G+m*$,a[2]=y*R+v*k+b*O+x*K,a[6]=y*N+v*U+b*B+x*Y,a[10]=y*j+v*I+b*V+x*oe,a[14]=y*C+v*H+b*G+x*$,a[3]=M*R+w*k+A*O+T*K,a[7]=M*N+w*U+A*B+T*Y,a[11]=M*j+w*I+A*V+T*oe,a[15]=M*C+w*H+A*G+T*$,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],s=e[1],o=e[5],l=e[9],c=e[13],u=e[2],f=e[6],g=e[10],m=e[14],y=e[3],v=e[7],b=e[11],x=e[15];return y*(+a*l*f-i*c*f-a*o*g+r*c*g+i*o*m-r*l*m)+v*(+n*l*m-n*c*g+a*s*g-i*s*m+i*c*u-a*l*u)+b*(+n*c*f-n*o*m-a*s*f+r*s*m+a*o*u-r*c*u)+x*(-i*o*u-n*l*f+n*o*g+i*s*f-r*s*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,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],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],f=e[9],g=e[10],m=e[11],y=e[12],v=e[13],b=e[14],x=e[15],M=f*b*c-v*g*c+v*l*m-o*b*m-f*l*x+o*g*x,w=y*g*c-u*b*c-y*l*m+s*b*m+u*l*x-s*g*x,A=u*v*c-y*f*c+y*o*m-s*v*m-u*o*x+s*f*x,T=y*f*l-u*v*l-y*o*g+s*v*g+u*o*b-s*f*b,R=n*M+r*w+i*A+a*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/R;return e[0]=M*N,e[1]=(v*g*a-f*b*a-v*i*m+r*b*m+f*i*x-r*g*x)*N,e[2]=(o*b*a-v*l*a+v*i*c-r*b*c-o*i*x+r*l*x)*N,e[3]=(f*l*a-o*g*a-f*i*c+r*g*c+o*i*m-r*l*m)*N,e[4]=w*N,e[5]=(u*b*a-y*g*a+y*i*m-n*b*m-u*i*x+n*g*x)*N,e[6]=(y*l*a-s*b*a-y*i*c+n*b*c+s*i*x-n*l*x)*N,e[7]=(s*g*a-u*l*a+u*i*c-n*g*c-s*i*m+n*l*m)*N,e[8]=A*N,e[9]=(y*f*a-u*v*a-y*r*m+n*v*m+u*r*x-n*f*x)*N,e[10]=(s*v*a-y*o*a+y*r*c-n*v*c-s*r*x+n*o*x)*N,e[11]=(u*o*a-s*f*a-u*r*c+n*f*c+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(u*v*i-y*f*i+y*r*g-n*v*g-u*r*b+n*f*b)*N,e[14]=(y*o*i-s*v*i-y*r*l+n*v*l+s*r*b-n*o*b)*N,e[15]=(s*f*i-u*o*i+u*r*l-n*f*l-s*r*g+n*o*g)*N,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,s=e.x,o=e.y,l=e.z,c=a*s,u=a*o;return this.set(c*s+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*s,0,c*l-i*o,u*l+i*s,a*l*l+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,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,u=s+s,f=o+o,g=a*c,m=a*u,y=a*f,v=s*u,b=s*f,x=o*f,M=l*c,w=l*u,A=l*f,T=r.x,R=r.y,N=r.z;return i[0]=(1-(v+x))*T,i[1]=(m+A)*T,i[2]=(y-w)*T,i[3]=0,i[4]=(m-A)*R,i[5]=(1-(g+x))*R,i[6]=(b+M)*R,i[7]=0,i[8]=(y+w)*N,i[9]=(b-M)*N,i[10]=(1-(g+v))*N,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=jh.set(i[0],i[1],i[2]).length();const s=jh.set(i[4],i[5],i[6]).length(),o=jh.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],lo.copy(this);const c=1/a,u=1/s,f=1/o;return lo.elements[0]*=c,lo.elements[1]*=c,lo.elements[2]*=c,lo.elements[4]*=u,lo.elements[5]*=u,lo.elements[6]*=u,lo.elements[8]*=f,lo.elements[9]*=f,lo.elements[10]*=f,n.setFromRotationMatrix(lo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=Go,l=!1){const c=this.elements,u=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let y,v;if(l)y=a/(s-a),v=s*a/(s-a);else if(o===Go)y=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(o===Y_)y=-s/(s-a),v=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=f,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=y,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Go,l=!1){const c=this.elements,u=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let y,v;if(l)y=1/(s-a),v=s/(s-a);else if(o===Go)y=-2/(s-a),v=-(s+a)/(s-a);else if(o===Y_)y=-1/(s-a),v=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=f,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=y,c[14]=v,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 jh=new Ge,lo=new qr,hue=new Ge(0,0,0),pue=new Ge(1,1,1),ou=new Ge,Fb=new Ge,ts=new Ge,gF=new qr,xF=new Cf;let Zu=class z9{constructor(e=0,n=0,r=0,i=z9.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],s=i[4],o=i[8],l=i[1],c=i[5],u=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-pn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(pn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-pn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-pn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,m),this._y=0);break;default:Wt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return gF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(gF,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return xF.setFromEuler(this),this.setFromQuaternion(xF,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}};Zu.DEFAULT_ORDER="XYZ";let B9=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}},mue=0;const vF=new Ge,Uh=new Cf,kl=new qr,zb=new Ge,Ig=new Ge,gue=new Ge,xue=new Cf,bF=new Ge(1,0,0),yF=new Ge(0,1,0),_F=new Ge(0,0,1),SF={type:"added"},vue={type:"removed"},Fh={type:"childadded",child:null},KA={type:"childremoved",child:null};let gs=class S_ extends qf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mue++}),this.uuid=j0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=S_.DEFAULT_UP.clone();const e=new Ge,n=new Zu,r=new Cf,i=new Ge(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new qr},normalMatrix:{value:new cn}}),this.matrix=new qr,this.matrixWorld=new qr,this.matrixAutoUpdate=S_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=S_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new B9,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 Uh.setFromAxisAngle(e,n),this.quaternion.multiply(Uh),this}rotateOnWorldAxis(e,n){return Uh.setFromAxisAngle(e,n),this.quaternion.premultiply(Uh),this}rotateX(e){return this.rotateOnAxis(bF,e)}rotateY(e){return this.rotateOnAxis(yF,e)}rotateZ(e){return this.rotateOnAxis(_F,e)}translateOnAxis(e,n){return vF.copy(e).applyQuaternion(this.quaternion),this.position.add(vF.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(bF,e)}translateY(e){return this.translateOnAxis(yF,e)}translateZ(e){return this.translateOnAxis(_F,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?zb.copy(e):zb.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ig.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kl.lookAt(Ig,zb,this.up):kl.lookAt(zb,Ig,this.up),this.quaternion.setFromRotationMatrix(kl),i&&(kl.extractRotation(i.matrixWorld),Uh.setFromRotationMatrix(kl),this.quaternion.premultiply(Uh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(kr("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(SF),Fh.child=e,this.dispatchEvent(Fh),Fh.child=null):kr("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(vue),KA.child=e,this.dispatchEvent(KA),KA.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),kl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kl.multiply(e.parent.matrixWorld)),e.applyMatrix4(kl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(SF),Fh.child=e,this.dispatchEvent(Fh),Fh.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 s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;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(Ig,e,gue),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ig,xue,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,s=i.length;a<s;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(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),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(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.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 o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const f=l[c];a(e.shapes,f)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(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 o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),u=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),y=s(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),y.length>0&&(r.nodes=y)}return r.object=i,r;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};gs.DEFAULT_UP=new Ge(0,1,0);gs.DEFAULT_MATRIX_AUTO_UPDATE=!0;gs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const co=new Ge,Dl=new Ge,YA=new Ge,Ol=new Ge,zh=new Ge,Bh=new Ge,wF=new Ge,ZA=new Ge,QA=new Ge,JA=new Ge,eT=new $r,tT=new $r,nT=new $r;let jg=class gp{constructor(e=new Ge,n=new Ge,r=new Ge){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),co.subVectors(e,n),i.cross(co);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){co.subVectors(i,n),Dl.subVectors(r,n),YA.subVectors(e,n);const s=co.dot(co),o=co.dot(Dl),l=co.dot(YA),c=Dl.dot(Dl),u=Dl.dot(YA),f=s*c-o*o;if(f===0)return a.set(0,0,0),null;const g=1/f,m=(c*l-o*u)*g,y=(s*u-o*l)*g;return a.set(1-m-y,y,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Ol)===null?!1:Ol.x>=0&&Ol.y>=0&&Ol.x+Ol.y<=1}static getInterpolation(e,n,r,i,a,s,o,l){return this.getBarycoord(e,n,r,i,Ol)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,Ol.x),l.addScaledVector(s,Ol.y),l.addScaledVector(o,Ol.z),l)}static getInterpolatedAttribute(e,n,r,i,a,s){return eT.setScalar(0),tT.setScalar(0),nT.setScalar(0),eT.fromBufferAttribute(e,n),tT.fromBufferAttribute(e,r),nT.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(eT,a.x),s.addScaledVector(tT,a.y),s.addScaledVector(nT,a.z),s}static isFrontFacing(e,n,r,i){return co.subVectors(r,n),Dl.subVectors(e,n),co.cross(Dl).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 co.subVectors(this.c,this.b),Dl.subVectors(this.a,this.b),co.cross(Dl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return gp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return gp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return gp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return gp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return gp.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 s,o;zh.subVectors(i,r),Bh.subVectors(a,r),ZA.subVectors(e,r);const l=zh.dot(ZA),c=Bh.dot(ZA);if(l<=0&&c<=0)return n.copy(r);QA.subVectors(e,i);const u=zh.dot(QA),f=Bh.dot(QA);if(u>=0&&f<=u)return n.copy(i);const g=l*f-u*c;if(g<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(r).addScaledVector(zh,s);JA.subVectors(e,a);const m=zh.dot(JA),y=Bh.dot(JA);if(y>=0&&m<=y)return n.copy(a);const v=m*c-l*y;if(v<=0&&c>=0&&y<=0)return o=c/(c-y),n.copy(r).addScaledVector(Bh,o);const b=u*y-m*f;if(b<=0&&f-u>=0&&m-y>=0)return wF.subVectors(a,i),o=(f-u)/(f-u+(m-y)),n.copy(i).addScaledVector(wF,o);const x=1/(b+v+g);return s=v*x,o=g*x,n.copy(r).addScaledVector(zh,s).addScaledVector(Bh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const H9={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lu={h:0,s:0,l:0},Bb={h:0,s:0,l:0};function rT(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 bn=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=Ls){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,En.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=En.workingColorSpace){return this.r=e,this.g=n,this.b=r,En.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=En.workingColorSpace){if(e=iue(e,1),n=pn(n,0,1),r=pn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=rT(s,a,e+1/3),this.g=rT(s,a,e),this.b=rT(s,a,e-1/3)}return En.colorSpaceToWorking(this,i),this}setStyle(e,n=Ls){function r(a){a!==void 0&&parseFloat(a)<1&&Wt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return 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(o))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(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Wt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);Wt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ls){const r=H9[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Wt("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=lc(e.r),this.g=lc(e.g),this.b=lc(e.b),this}copyLinearToSRGB(e){return this.r=kp(e.r),this.g=kp(e.g),this.b=kp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ls){return En.workingToColorSpace(Yi.copy(this),e),Math.round(pn(Yi.r*255,0,255))*65536+Math.round(pn(Yi.g*255,0,255))*256+Math.round(pn(Yi.b*255,0,255))}getHexString(e=Ls){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=En.workingColorSpace){En.workingToColorSpace(Yi.copy(this),n);const r=Yi.r,i=Yi.g,a=Yi.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let l,c;const u=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=u<=.5?f/(s+o):f/(2-s-o),s){case r:l=(i-a)/f+(i<a?6:0);break;case i:l=(a-r)/f+2;break;case a:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=En.workingColorSpace){return En.workingToColorSpace(Yi.copy(this),n),e.r=Yi.r,e.g=Yi.g,e.b=Yi.b,e}getStyle(e=Ls){En.workingToColorSpace(Yi.copy(this),e);const n=Yi.r,r=Yi.g,i=Yi.b;return e!==Ls?`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(lu),this.setHSL(lu.h+e,lu.s+n,lu.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(lu),e.getHSL(Bb);const r=FA(lu.h,Bb.h,n),i=FA(lu.s,Bb.s,n),a=FA(lu.l,Bb.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 Yi=new bn;bn.NAMES=H9;let bue=0,Sm=class extends qf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bue++}),this.uuid=j0(),this.name="",this.type="Material",this.blending=Pp,this.side=Yu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=UN,this.blendDst=FN,this.blendEquation=Xd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new bn(0,0,0),this.blendAlpha=0,this.depthFunc=Wp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kh,this.stencilZFail=kh,this.stencilZPass=kh,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){Wt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Wt(`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!==Pp&&(r.blending=this.blending),this.side!==Yu&&(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!==UN&&(r.blendSrc=this.blendSrc),this.blendDst!==FN&&(r.blendDst=this.blendDst),this.blendEquation!==Xd&&(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!==Wp&&(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!==lF&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==kh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==kh&&(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 s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}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++}},ik=class extends Sm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new bn(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 Zu,this.combine=XP,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 zr=new Ge,Hb=new an;let yue=0,Gs=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:yue++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=cF,this.updateRanges=[],this.gpuType=tc,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++)Hb.fromBufferAttribute(this,n),Hb.applyMatrix3(e),this.setXY(n,Hb.x,Hb.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)zr.fromBufferAttribute(this,n),zr.applyMatrix3(e),this.setXYZ(n,zr.x,zr.y,zr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)zr.fromBufferAttribute(this,n),zr.applyMatrix4(e),this.setXYZ(n,zr.x,zr.y,zr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)zr.fromBufferAttribute(this,n),zr.applyNormalMatrix(e),this.setXYZ(n,zr.x,zr.y,zr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)zr.fromBufferAttribute(this,n),zr.transformDirection(e),this.setXYZ(n,zr.x,zr.y,zr.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=Dg(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Da(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Dg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Da(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Dg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Da(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=Dg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Da(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=Dg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Da(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Da(n,this.array),r=Da(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=Da(n,this.array),r=Da(r,this.array),i=Da(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=Da(n,this.array),r=Da(r,this.array),i=Da(i,this.array),a=Da(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!==cF&&(e.usage=this.usage),e}},$9=class extends Gs{constructor(e,n,r){super(new Uint16Array(e),n,r)}},V9=class extends Gs{constructor(e,n,r){super(new Uint32Array(e),n,r)}},wo=class extends Gs{constructor(e,n,r){super(new Float32Array(e),n,r)}},_ue=0;const As=new qr,iT=new gs,Hh=new Ge,ns=new Rf,Ug=new Rf,bi=new Ge;let dl=class G9 extends qf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_ue++}),this.uuid=j0(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(O9(e)?V9:$9)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new cn().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 As.makeRotationFromQuaternion(e),this.applyMatrix4(As),this}rotateX(e){return As.makeRotationX(e),this.applyMatrix4(As),this}rotateY(e){return As.makeRotationY(e),this.applyMatrix4(As),this}rotateZ(e){return As.makeRotationZ(e),this.applyMatrix4(As),this}translate(e,n,r){return As.makeTranslation(e,n,r),this.applyMatrix4(As),this}scale(e,n,r){return As.makeScale(e,n,r),this.applyMatrix4(As),this}lookAt(e){return iT.lookAt(e),iT.updateMatrix(),this.applyMatrix4(iT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hh).negate(),this.translate(Hh.x,Hh.y,Hh.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 s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new wo(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&&Wt("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 Rf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){kr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Ge(-1/0,-1/0,-1/0),new Ge(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ns.setFromBufferAttribute(a),this.morphTargetsRelative?(bi.addVectors(this.boundingBox.min,ns.min),this.boundingBox.expandByPoint(bi),bi.addVectors(this.boundingBox.max,ns.max),this.boundingBox.expandByPoint(bi)):(this.boundingBox.expandByPoint(ns.min),this.boundingBox.expandByPoint(ns.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&kr('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 iw);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){kr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Ge,1/0);return}if(e){const r=this.boundingSphere.center;if(ns.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Ug.setFromBufferAttribute(o),this.morphTargetsRelative?(bi.addVectors(ns.min,Ug.min),ns.expandByPoint(bi),bi.addVectors(ns.max,Ug.max),ns.expandByPoint(bi)):(ns.expandByPoint(Ug.min),ns.expandByPoint(Ug.max))}ns.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)bi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(bi));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)bi.fromBufferAttribute(o,c),l&&(Hh.fromBufferAttribute(e,c),bi.add(Hh)),i=Math.max(i,r.distanceToSquared(bi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&kr('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){kr("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 Gs(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],l=[];for(let j=0;j<r.count;j++)o[j]=new Ge,l[j]=new Ge;const c=new Ge,u=new Ge,f=new Ge,g=new an,m=new an,y=new an,v=new Ge,b=new Ge;function x(j,C,k){c.fromBufferAttribute(r,j),u.fromBufferAttribute(r,C),f.fromBufferAttribute(r,k),g.fromBufferAttribute(a,j),m.fromBufferAttribute(a,C),y.fromBufferAttribute(a,k),u.sub(c),f.sub(c),m.sub(g),y.sub(g);const U=1/(m.x*y.y-y.x*m.y);isFinite(U)&&(v.copy(u).multiplyScalar(y.y).addScaledVector(f,-m.y).multiplyScalar(U),b.copy(f).multiplyScalar(m.x).addScaledVector(u,-y.x).multiplyScalar(U),o[j].add(v),o[C].add(v),o[k].add(v),l[j].add(b),l[C].add(b),l[k].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let j=0,C=M.length;j<C;++j){const k=M[j],U=k.start,I=k.count;for(let H=U,O=U+I;H<O;H+=3)x(e.getX(H+0),e.getX(H+1),e.getX(H+2))}const w=new Ge,A=new Ge,T=new Ge,R=new Ge;function N(j){T.fromBufferAttribute(i,j),R.copy(T);const C=o[j];w.copy(C),w.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(R,C);const U=A.dot(l[j])<0?-1:1;s.setXYZW(j,w.x,w.y,w.z,U)}for(let j=0,C=M.length;j<C;++j){const k=M[j],U=k.start,I=k.count;for(let H=U,O=U+I;H<O;H+=3)N(e.getX(H+0)),N(e.getX(H+1)),N(e.getX(H+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 Gs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Ge,a=new Ge,s=new Ge,o=new Ge,l=new Ge,c=new Ge,u=new Ge,f=new Ge;if(e)for(let g=0,m=e.count;g<m;g+=3){const y=e.getX(g+0),v=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,b),u.subVectors(s,a),f.subVectors(i,a),u.cross(f),o.fromBufferAttribute(r,y),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,b),o.add(u),l.add(u),c.add(u),r.setXYZ(y,o.x,o.y,o.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),u.subVectors(s,a),f.subVectors(i,a),u.cross(f),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)bi.fromBufferAttribute(e,n),bi.normalize(),e.setXYZ(n,bi.x,bi.y,bi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,f=o.normalized,g=new c.constructor(l.length*u);let m=0,y=0;for(let v=0,b=l.length;v<b;v++){o.isInterleavedBufferAttribute?m=l[v]*o.data.stride+o.offset:m=l[v]*u;for(let x=0;x<u;x++)g[y++]=c[m++]}return new Gs(g,u,f)}if(this.index===null)return Wt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new G9,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let u=0,f=c.length;u<f;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,g=c.length;f<g;f++){const m=c[f];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],f=a[c];for(let g=0,m=f.length;g<m;g++)u.push(f[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;c++){const f=s[c];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const MF=new qr,Dd=new rk,$b=new iw,EF=new Ge,Vb=new Ge,Gb=new Ge,Wb=new Ge,aT=new Ge,qb=new Ge,AF=new Ge,Xb=new Ge;let nl=class extends gs{constructor(e=new dl,n=new ik){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,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){qb.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],f=a[l];u!==0&&(aT.fromBufferAttribute(f,e),s?qb.addScaledVector(aT,u):qb.addScaledVector(aT.sub(n),u))}n.add(qb)}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),Dd.copy(e.ray).recast(e.near),!($b.containsPoint(Dd.origin)===!1&&(Dd.intersectSphere($b,EF)===null||Dd.origin.distanceToSquared(EF)>(e.far-e.near)**2))&&(MF.copy(a).invert(),Dd.copy(e.ray).applyMatrix4(MF),!(r.boundingBox!==null&&Dd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Dd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,v=g.length;y<v;y++){const b=g[y],x=s[b.materialIndex],M=Math.max(b.start,m.start),w=Math.min(o.count,Math.min(b.start+b.count,m.start+m.count));for(let A=M,T=w;A<T;A+=3){const R=o.getX(A),N=o.getX(A+1),j=o.getX(A+2);i=Kb(this,x,e,r,c,u,f,R,N,j),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const y=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let b=y,x=v;b<x;b+=3){const M=o.getX(b),w=o.getX(b+1),A=o.getX(b+2);i=Kb(this,s,e,r,c,u,f,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(s))for(let y=0,v=g.length;y<v;y++){const b=g[y],x=s[b.materialIndex],M=Math.max(b.start,m.start),w=Math.min(l.count,Math.min(b.start+b.count,m.start+m.count));for(let A=M,T=w;A<T;A+=3){const R=A,N=A+1,j=A+2;i=Kb(this,x,e,r,c,u,f,R,N,j),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const y=Math.max(0,m.start),v=Math.min(l.count,m.start+m.count);for(let b=y,x=v;b<x;b+=3){const M=b,w=b+1,A=b+2;i=Kb(this,s,e,r,c,u,f,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function Sue(t,e,n,r,i,a,s,o){let l;if(e.side===Fa?l=r.intersectTriangle(s,a,i,!0,o):l=r.intersectTriangle(i,a,s,e.side===Yu,o),l===null)return null;Xb.copy(o),Xb.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Xb);return c<n.near||c>n.far?null:{distance:c,point:Xb.clone(),object:t}}function Kb(t,e,n,r,i,a,s,o,l,c){t.getVertexPosition(o,Vb),t.getVertexPosition(l,Gb),t.getVertexPosition(c,Wb);const u=Sue(t,e,n,r,Vb,Gb,Wb,AF);if(u){const f=new Ge;jg.getBarycoord(AF,Vb,Gb,Wb,f),i&&(u.uv=jg.getInterpolatedAttribute(i,o,l,c,f,new an)),a&&(u.uv1=jg.getInterpolatedAttribute(a,o,l,c,f,new an)),s&&(u.normal=jg.getInterpolatedAttribute(s,o,l,c,f,new Ge),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const g={a:o,b:l,c,normal:new Ge,materialIndex:0};jg.getNormal(Vb,Gb,Wb,g.normal),u.face=g,u.barycoord=f}return u}let ak=class W9 extends dl{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],u=[],f=[];let g=0,m=0;y("z","y","x",-1,-1,r,n,e,s,a,0),y("z","y","x",1,-1,r,n,-e,s,a,1),y("x","z","y",1,1,e,r,n,i,s,2),y("x","z","y",1,-1,e,r,-n,i,s,3),y("x","y","z",1,-1,e,n,r,i,a,4),y("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(l),this.setAttribute("position",new wo(c,3)),this.setAttribute("normal",new wo(u,3)),this.setAttribute("uv",new wo(f,2));function y(v,b,x,M,w,A,T,R,N,j,C){const k=A/N,U=T/j,I=A/2,H=T/2,O=R/2,B=N+1,V=j+1;let G=0,K=0;const Y=new Ge;for(let oe=0;oe<V;oe++){const $=oe*U-H;for(let X=0;X<B;X++){const ae=X*k-I;Y[v]=ae*M,Y[b]=$*w,Y[x]=O,c.push(Y.x,Y.y,Y.z),Y[v]=0,Y[b]=0,Y[x]=R>0?1:-1,u.push(Y.x,Y.y,Y.z),f.push(X/N),f.push(1-oe/j),G+=1}}for(let oe=0;oe<j;oe++)for(let $=0;$<N;$++){const X=g+$+B*oe,ae=g+$+B*(oe+1),ce=g+($+1)+B*(oe+1),xe=g+($+1)+B*oe;l.push(X,ae,xe),l.push(ae,ce,xe),K+=6}o.addGroup(m,K,C),m+=K,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new W9(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Yp(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?(Wt("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 fa(t){const e={};for(let n=0;n<t.length;n++){const r=Yp(t[n]);for(const i in r)e[i]=r[i]}return e}function wue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function q9(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:En.workingColorSpace}const Mue={clone:Yp,merge:fa};var Eue=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,Aue=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let gc=class extends Sm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Eue,this.fragmentShader=Aue,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=Yp(e.uniforms),this.uniformsGroups=wue(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 s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},X9=class extends gs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qr,this.projectionMatrix=new qr,this.projectionMatrixInverse=new qr,this.coordinateSystem=Go,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const cu=new Ge,TF=new an,CF=new an;let Us=class extends X9{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=E3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(y_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return E3*2*Math.atan(Math.tan(y_*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){cu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(cu.x,cu.y).multiplyScalar(-e/cu.z),cu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(cu.x,cu.y).multiplyScalar(-e/cu.z)}getViewSize(e,n){return this.getViewBounds(e,TF,CF),n.subVectors(CF,TF)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(y_*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*i/l,n-=s.offsetY*r/c,i*=s.width/l,r*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/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 $h=-90,Vh=1;let Tue=class extends gs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Us($h,Vh,e,n);i.layers=this.layers,this.add(i);const a=new Us($h,Vh,e,n);a.layers=this.layers,this.add(a);const s=new Us($h,Vh,e,n);s.layers=this.layers,this.add(s);const o=new Us($h,Vh,e,n);o.layers=this.layers,this.add(o);const l=new Us($h,Vh,e,n);l.layers=this.layers,this.add(l);const c=new Us($h,Vh,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===Go)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),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Y_)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),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,u]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(f,g,m),e.xr.enabled=y,r.texture.needsPMREMUpdate=!0}},K9=class extends To{constructor(e=[],n=qp,r,i,a,s,o,l,c,u){super(e,n,r,i,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Cue=class extends Nf{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 K9(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:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new ak(5,5,5),a=new gc({name:"CubemapFromEquirect",uniforms:Yp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Fa,blending:oc});a.uniforms.tEquirect.value=n;const s=new nl(i,a),o=n.minFilter;return n.minFilter===tf&&(n.minFilter=$s),new Tue(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},ax=class extends gs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Nue={type:"move"};let sT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ax,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 ax,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ge,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ge),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ax,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ge,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ge),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const 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,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const v of e.hand.values()){const b=n.getJointPose(v,r),x=this._getHandJoint(c,v);b!==null&&(x.matrix.fromArray(b.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=b.radius),x.visible=b!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],g=u.position.distanceTo(f.position),m=.02,y=.005;c.inputState.pinching&&g>m+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Nue)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new ax;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Rue=class extends gs{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Zu,this.environmentIntensity=1,this.environmentRotation=new Zu,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}},Pue=class extends To{constructor(e=null,n=1,r=1,i,a,s,o,l,c=fs,u=fs,f,g){super(null,s,o,l,c,u,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const oT=new Ge,kue=new Ge,Due=new cn;let _u=class{constructor(e=new Ge(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,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=oT.subVectors(r,n).cross(kue.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(oT),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||Due.getNormalMatrix(e),i=this.coplanarPoint(oT).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 Od=new iw,Oue=new an(.5,.5),Yb=new Ge;let sk=class{constructor(e=new _u,n=new _u,r=new _u,i=new _u,a=new _u,s=new _u){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),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=Go,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],l=a[2],c=a[3],u=a[4],f=a[5],g=a[6],m=a[7],y=a[8],v=a[9],b=a[10],x=a[11],M=a[12],w=a[13],A=a[14],T=a[15];if(i[0].setComponents(c-s,m-u,x-y,T-M).normalize(),i[1].setComponents(c+s,m+u,x+y,T+M).normalize(),i[2].setComponents(c+o,m+f,x+v,T+w).normalize(),i[3].setComponents(c-o,m-f,x-v,T-w).normalize(),r)i[4].setComponents(l,g,b,A).normalize(),i[5].setComponents(c-l,m-g,x-b,T-A).normalize();else if(i[4].setComponents(c-l,m-g,x-b,T-A).normalize(),n===Go)i[5].setComponents(c+l,m+g,x+b,T+A).normalize();else if(n===Y_)i[5].setComponents(l,g,b,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Od.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Od.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Od)}intersectsSprite(e){Od.center.set(0,0,0);const n=Oue.distanceTo(e.center);return Od.radius=.7071067811865476+n,Od.applyMatrix4(e.matrixWorld),this.intersectsSphere(Od)}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(Yb.x=i.normal.x>0?e.max.x:e.min.x,Yb.y=i.normal.y>0?e.max.y:e.min.y,Yb.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Yb)<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)}},Y9=class extends Sm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new bn(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 Q_=new Ge,J_=new Ge,NF=new qr,Fg=new rk,Zb=new iw,lT=new Ge,RF=new Ge;let Lue=class extends gs{constructor(e=new dl,n=new Y9){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++)Q_.fromBufferAttribute(n,i-1),J_.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Q_.distanceTo(J_);e.setAttribute("lineDistance",new wo(r,1))}else Wt("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,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Zb.copy(r.boundingSphere),Zb.applyMatrix4(i),Zb.radius+=a,e.ray.intersectsSphere(Zb)===!1)return;NF.copy(i).invert(),Fg.copy(e.ray).applyMatrix4(NF);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=r.index,g=r.attributes.position;if(u!==null){const m=Math.max(0,s.start),y=Math.min(u.count,s.start+s.count);for(let v=m,b=y-1;v<b;v+=c){const x=u.getX(v),M=u.getX(v+1),w=Qb(this,e,Fg,l,x,M,v);w&&n.push(w)}if(this.isLineLoop){const v=u.getX(y-1),b=u.getX(m),x=Qb(this,e,Fg,l,v,b,y-1);x&&n.push(x)}}else{const m=Math.max(0,s.start),y=Math.min(g.count,s.start+s.count);for(let v=m,b=y-1;v<b;v+=c){const x=Qb(this,e,Fg,l,v,v+1,v);x&&n.push(x)}if(this.isLineLoop){const v=Qb(this,e,Fg,l,y-1,m,y-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function Qb(t,e,n,r,i,a,s){const o=t.geometry.attributes.position;if(Q_.fromBufferAttribute(o,i),J_.fromBufferAttribute(o,a),n.distanceSqToSegment(Q_,J_,lT,RF)>r)return;lT.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(lT);if(!(c<e.near||c>e.far))return{distance:c,point:RF.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const PF=new Ge,kF=new Ge;let Iue=class extends Lue{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)PF.fromBufferAttribute(n,i),kF.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+PF.distanceTo(kF);e.setAttribute("lineDistance",new wo(r,1))}else Wt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Z9=class extends To{constructor(e,n,r=Tf,i,a,s,o=fs,l=fs,c,u=Kx,f=1){if(u!==Kx&&u!==Yx)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,s,o,l,u,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new nk(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 Q9 extends To{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let ok=class J9 extends dl{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,s=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,f=e/o,g=n/l,m=[],y=[],v=[],b=[];for(let x=0;x<u;x++){const M=x*g-s;for(let w=0;w<c;w++){const A=w*f-a;y.push(A,-M,0),v.push(0,0,1),b.push(w/o),b.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,A=M+c*(x+1),T=M+1+c*(x+1),R=M+1+c*x;m.push(w,A,R),m.push(A,T,R)}this.setIndex(m),this.setAttribute("position",new wo(y,3)),this.setAttribute("normal",new wo(v,3)),this.setAttribute("uv",new wo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new J9(e.width,e.height,e.widthSegments,e.heightSegments)}};class jue extends Sm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new bn(16777215),this.specular=new bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=k9,this.normalScale=new an(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zu,this.combine=XP,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 Uue=class extends Sm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Wce,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}},Fue=class extends Sm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},eW=class extends gs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new bn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const cT=new qr,DF=new Ge,OF=new Ge;let zue=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new an(512,512),this.mapType=tl,this.map=null,this.mapPass=null,this.matrix=new qr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new sk,this._frameExtents=new an(1,1),this._viewportCount=1,this._viewports=[new $r(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;DF.setFromMatrixPosition(e.matrixWorld),n.position.copy(DF),OF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(OF),n.updateMatrixWorld(),cT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(cT,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(cT)}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}},tW=class extends X9{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class Bue extends zue{constructor(){super(new tW(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class LF extends eW{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gs.DEFAULT_UP),this.updateMatrix(),this.target=new gs,this.shadow=new Bue}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Hue=class extends eW{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},$ue=class extends Us{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},IF=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=pn(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(pn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Vue extends Iue{constructor(e=10,n=10,r=4473924,i=8947848){r=new bn(r),i=new bn(i);const a=n/2,s=e/n,o=e/2,l=[],c=[];for(let g=0,m=0,y=-o;g<=n;g++,y+=s){l.push(-o,0,y,o,0,y),l.push(y,0,-o,y,0,o);const v=g===a?r:i;v.toArray(c,m),m+=3,v.toArray(c,m),m+=3,v.toArray(c,m),m+=3,v.toArray(c,m),m+=3}const u=new dl;u.setAttribute("position",new wo(l,3)),u.setAttribute("color",new wo(c,3));const f=new Y9({vertexColors:!0,toneMapped:!1});super(u,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Gue extends qf{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){Wt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function jF(t,e,n,r){const i=Wue(r);switch(n){case N9:return t*e;case P9:return t*e/i.components*i.byteLength;case QP:return t*e/i.components*i.byteLength;case JP:return t*e*2/i.components*i.byteLength;case ek:return t*e*2/i.components*i.byteLength;case R9:return t*e*3/i.components*i.byteLength;case yo:return t*e*4/i.components*i.byteLength;case tk:return t*e*4/i.components*i.byteLength;case g_:case x_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case v_:case b_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case QN:case e3:return Math.max(t,16)*Math.max(e,8)/4;case ZN:case JN:return Math.max(t,8)*Math.max(e,8)/2;case t3:case n3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case r3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case i3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case a3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case s3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case o3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case l3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case c3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case u3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case d3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case f3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case h3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case p3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case m3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case g3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case x3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case v3:case b3:case y3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case _3:case S3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case w3:case M3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Wue(t){switch(t){case tl:case E9:return{byteLength:1,components:1};case qx:case A9:case _m:return{byteLength:2,components:1};case YP:case ZP:return{byteLength:2,components:4};case Tf:case KP:case tc:return{byteLength:4,components:1};case T9:case C9:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qP}}));typeof window<"u"&&(window.__THREE__?Wt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qP);function nW(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),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 que(t){const e=new WeakMap;function n(o,l){const c=o.array,u=o.usage,f=c.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,c,u),o.onUploadCallback();let m;if(c instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=t.SHORT;else if(c instanceof Uint32Array)m=t.UNSIGNED_INT;else if(c instanceof Int32Array)m=t.INT;else if(c instanceof Int8Array)m=t.BYTE;else if(c instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:g,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:f}}function r(o,l,c){const u=l.array,f=l.updateRanges;if(t.bindBuffer(c,o),f.length===0)t.bufferSubData(c,0,u);else{f.sort((m,y)=>m.start-y.start);let g=0;for(let m=1;m<f.length;m++){const y=f[g],v=f[m];v.start<=y.start+y.count+1?y.count=Math.max(y.count,v.start+v.count-y.start):(++g,f[g]=v)}f.length=g+1;for(let m=0,y=f.length;m<y;m++){const v=f[m];t.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function s(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:a,update:s}}var Xue=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,Kue=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,Yue=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,Zue=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,Que=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,Jue=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,ede=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,tde=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,nde=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,rde=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,ide=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,ade=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,sde=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,ode=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. 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 ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,lde=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,cde=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,ude=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,dde=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,fde=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,hde=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,pde=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,mde=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,gde=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,xde=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,vde=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,bde=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,yde=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,_de=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,Sde=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,wde=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,Mde="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ede=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. 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 );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. 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 );
  529. }`,Ade=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,Tde=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,Cde=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,Nde=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,Rde=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,Pde=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,kde=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,Dde=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,Ode=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,Lde=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,Ide=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,jde=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,Ude=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. 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 ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. 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 ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Fde=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,zde=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,Bde=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,Hde=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. 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 ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. 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 ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$de=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,Vde=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. 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 ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. 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 ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Gde=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,Wde=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. 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 ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. 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 ) {
  1136. #else
  1137. 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 ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. 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 ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. 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 ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. 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 ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. 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) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,qde=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,Xde=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,Kde=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,Yde=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,Zde=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,Qde=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,Jde=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,efe=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,tfe=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,nfe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,rfe=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,ife=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,afe=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,sfe=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,ofe=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,lfe=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,cfe=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,ufe=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,dfe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,ffe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,hfe=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,pfe=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,mfe=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,gfe=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,xfe=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,vfe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,bfe=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,yfe=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,_fe=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Sfe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,wfe=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,Mfe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,Efe=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,Afe=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,Tfe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,Cfe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,Nfe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. 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 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,Rfe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,Pfe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,kfe=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,Dfe=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,Ofe=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,Lfe=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,Ife=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,jfe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,Ufe=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,Ffe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,zfe=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,Bfe=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,Hfe=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,$fe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,Vfe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,Gfe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,Wfe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const qfe=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,Xfe=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. 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 );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,Kfe=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,Yfe=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,Zfe=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,Qfe=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,Jfe=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,ehe=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,the=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,nhe=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,rhe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,ihe=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,ahe=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,she=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,ohe=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,lhe=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,che=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,uhe=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,dhe=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,fhe=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,hhe=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,phe=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,mhe=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,ghe=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,xhe=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,vhe=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,bhe=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,yhe=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,_he=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,She=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,whe=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,Mhe=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,Ehe=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,Ahe=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,nn={alphahash_fragment:Xue,alphahash_pars_fragment:Kue,alphamap_fragment:Yue,alphamap_pars_fragment:Zue,alphatest_fragment:Que,alphatest_pars_fragment:Jue,aomap_fragment:ede,aomap_pars_fragment:tde,batching_pars_vertex:nde,batching_vertex:rde,begin_vertex:ide,beginnormal_vertex:ade,bsdfs:sde,iridescence_fragment:ode,bumpmap_pars_fragment:lde,clipping_planes_fragment:cde,clipping_planes_pars_fragment:ude,clipping_planes_pars_vertex:dde,clipping_planes_vertex:fde,color_fragment:hde,color_pars_fragment:pde,color_pars_vertex:mde,color_vertex:gde,common:xde,cube_uv_reflection_fragment:vde,defaultnormal_vertex:bde,displacementmap_pars_vertex:yde,displacementmap_vertex:_de,emissivemap_fragment:Sde,emissivemap_pars_fragment:wde,colorspace_fragment:Mde,colorspace_pars_fragment:Ede,envmap_fragment:Ade,envmap_common_pars_fragment:Tde,envmap_pars_fragment:Cde,envmap_pars_vertex:Nde,envmap_physical_pars_fragment:zde,envmap_vertex:Rde,fog_vertex:Pde,fog_pars_vertex:kde,fog_fragment:Dde,fog_pars_fragment:Ode,gradientmap_pars_fragment:Lde,lightmap_pars_fragment:Ide,lights_lambert_fragment:jde,lights_lambert_pars_fragment:Ude,lights_pars_begin:Fde,lights_toon_fragment:Bde,lights_toon_pars_fragment:Hde,lights_phong_fragment:$de,lights_phong_pars_fragment:Vde,lights_physical_fragment:Gde,lights_physical_pars_fragment:Wde,lights_fragment_begin:qde,lights_fragment_maps:Xde,lights_fragment_end:Kde,logdepthbuf_fragment:Yde,logdepthbuf_pars_fragment:Zde,logdepthbuf_pars_vertex:Qde,logdepthbuf_vertex:Jde,map_fragment:efe,map_pars_fragment:tfe,map_particle_fragment:nfe,map_particle_pars_fragment:rfe,metalnessmap_fragment:ife,metalnessmap_pars_fragment:afe,morphinstance_vertex:sfe,morphcolor_vertex:ofe,morphnormal_vertex:lfe,morphtarget_pars_vertex:cfe,morphtarget_vertex:ufe,normal_fragment_begin:dfe,normal_fragment_maps:ffe,normal_pars_fragment:hfe,normal_pars_vertex:pfe,normal_vertex:mfe,normalmap_pars_fragment:gfe,clearcoat_normal_fragment_begin:xfe,clearcoat_normal_fragment_maps:vfe,clearcoat_pars_fragment:bfe,iridescence_pars_fragment:yfe,opaque_fragment:_fe,packing:Sfe,premultiplied_alpha_fragment:wfe,project_vertex:Mfe,dithering_fragment:Efe,dithering_pars_fragment:Afe,roughnessmap_fragment:Tfe,roughnessmap_pars_fragment:Cfe,shadowmap_pars_fragment:Nfe,shadowmap_pars_vertex:Rfe,shadowmap_vertex:Pfe,shadowmask_pars_fragment:kfe,skinbase_vertex:Dfe,skinning_pars_vertex:Ofe,skinning_vertex:Lfe,skinnormal_vertex:Ife,specularmap_fragment:jfe,specularmap_pars_fragment:Ufe,tonemapping_fragment:Ffe,tonemapping_pars_fragment:zfe,transmission_fragment:Bfe,transmission_pars_fragment:Hfe,uv_pars_fragment:$fe,uv_pars_vertex:Vfe,uv_vertex:Gfe,worldpos_vertex:Wfe,background_vert:qfe,background_frag:Xfe,backgroundCube_vert:Kfe,backgroundCube_frag:Yfe,cube_vert:Zfe,cube_frag:Qfe,depth_vert:Jfe,depth_frag:ehe,distanceRGBA_vert:the,distanceRGBA_frag:nhe,equirect_vert:rhe,equirect_frag:ihe,linedashed_vert:ahe,linedashed_frag:she,meshbasic_vert:ohe,meshbasic_frag:lhe,meshlambert_vert:che,meshlambert_frag:uhe,meshmatcap_vert:dhe,meshmatcap_frag:fhe,meshnormal_vert:hhe,meshnormal_frag:phe,meshphong_vert:mhe,meshphong_frag:ghe,meshphysical_vert:xhe,meshphysical_frag:vhe,meshtoon_vert:bhe,meshtoon_frag:yhe,points_vert:_he,points_frag:She,shadow_vert:whe,shadow_frag:Mhe,sprite_vert:Ehe,sprite_frag:Ahe},wt={common:{diffuse:{value:new bn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new cn},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new cn}},envmap:{envMap:{value:null},envMapRotation:{value:new cn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new cn},normalScale:{value:new an(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new cn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new bn(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 bn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0},uvTransform:{value:new cn}},sprite:{diffuse:{value:new bn(16777215)},opacity:{value:1},center:{value:new an(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new cn},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0}}},Bo={basic:{uniforms:fa([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.fog]),vertexShader:nn.meshbasic_vert,fragmentShader:nn.meshbasic_frag},lambert:{uniforms:fa([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new bn(0)}}]),vertexShader:nn.meshlambert_vert,fragmentShader:nn.meshlambert_frag},phong:{uniforms:fa([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new bn(0)},specular:{value:new bn(1118481)},shininess:{value:30}}]),vertexShader:nn.meshphong_vert,fragmentShader:nn.meshphong_frag},standard:{uniforms:fa([wt.common,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.roughnessmap,wt.metalnessmap,wt.fog,wt.lights,{emissive:{value:new bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nn.meshphysical_vert,fragmentShader:nn.meshphysical_frag},toon:{uniforms:fa([wt.common,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.gradientmap,wt.fog,wt.lights,{emissive:{value:new bn(0)}}]),vertexShader:nn.meshtoon_vert,fragmentShader:nn.meshtoon_frag},matcap:{uniforms:fa([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,{matcap:{value:null}}]),vertexShader:nn.meshmatcap_vert,fragmentShader:nn.meshmatcap_frag},points:{uniforms:fa([wt.points,wt.fog]),vertexShader:nn.points_vert,fragmentShader:nn.points_frag},dashed:{uniforms:fa([wt.common,wt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nn.linedashed_vert,fragmentShader:nn.linedashed_frag},depth:{uniforms:fa([wt.common,wt.displacementmap]),vertexShader:nn.depth_vert,fragmentShader:nn.depth_frag},normal:{uniforms:fa([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,{opacity:{value:1}}]),vertexShader:nn.meshnormal_vert,fragmentShader:nn.meshnormal_frag},sprite:{uniforms:fa([wt.sprite,wt.fog]),vertexShader:nn.sprite_vert,fragmentShader:nn.sprite_frag},background:{uniforms:{uvTransform:{value:new cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:nn.background_vert,fragmentShader:nn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new cn}},vertexShader:nn.backgroundCube_vert,fragmentShader:nn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:nn.cube_vert,fragmentShader:nn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nn.equirect_vert,fragmentShader:nn.equirect_frag},distanceRGBA:{uniforms:fa([wt.common,wt.displacementmap,{referencePosition:{value:new Ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nn.distanceRGBA_vert,fragmentShader:nn.distanceRGBA_frag},shadow:{uniforms:fa([wt.lights,wt.fog,{color:{value:new bn(0)},opacity:{value:1}}]),vertexShader:nn.shadow_vert,fragmentShader:nn.shadow_frag}};Bo.physical={uniforms:fa([Bo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new cn},clearcoatNormalScale:{value:new an(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new cn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new cn},sheen:{value:0},sheenColor:{value:new bn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new cn},transmissionSamplerSize:{value:new an},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new cn},attenuationDistance:{value:0},attenuationColor:{value:new bn(0)},specularColor:{value:new bn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new cn},anisotropyVector:{value:new an},anisotropyMap:{value:null},anisotropyMapTransform:{value:new cn}}]),vertexShader:nn.meshphysical_vert,fragmentShader:nn.meshphysical_frag};const Jb={r:0,b:0,g:0},Ld=new Zu,The=new qr;function Che(t,e,n,r,i,a,s){const o=new bn(0);let l=a===!0?0:1,c,u,f=null,g=0,m=null;function y(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function v(w){let A=!1;const T=y(w);T===null?x(o,l):T&&T.isColor&&(x(T,1),A=!0);const R=t.xr.getEnvironmentBlendMode();R==="additive"?r.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(w,A){const T=y(A);T&&(T.isCubeTexture||T.mapping===rw)?(u===void 0&&(u=new nl(new ak(1,1,1),new gc({name:"BackgroundCubeMaterial",uniforms:Yp(Bo.backgroundCube.uniforms),vertexShader:Bo.backgroundCube.vertexShader,fragmentShader:Bo.backgroundCube.fragmentShader,side:Fa,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(R,N,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Ld.copy(A.backgroundRotation),Ld.x*=-1,Ld.y*=-1,Ld.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Ld.y*=-1,Ld.z*=-1),u.material.uniforms.envMap.value=T,u.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(The.makeRotationFromEuler(Ld)),u.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,(f!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null)):T&&T.isTexture&&(c===void 0&&(c=new nl(new ok(2,2),new gc({name:"BackgroundMaterial",uniforms:Yp(Bo.background.uniforms),vertexShader:Bo.background.vertexShader,fragmentShader:Bo.background.fragmentShader,side:Yu,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=T,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,T.matrixAutoUpdate===!0&&T.updateMatrix(),c.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function x(w,A){w.getRGB(Jb,q9(t)),r.buffers.color.setClear(Jb.r,Jb.g,Jb.b,A,s)}function M(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,A=1){o.set(w),l=A,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:v,addToRenderList:b,dispose:M}}function Nhe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function o(k,U,I,H,O){let B=!1;const V=f(H,I,U);a!==V&&(a=V,c(a.object)),B=m(k,H,I,O),B&&y(k,H,I,O),O!==null&&e.update(O,t.ELEMENT_ARRAY_BUFFER),(B||s)&&(s=!1,A(k,U,I,H),O!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return t.createVertexArray()}function c(k){return t.bindVertexArray(k)}function u(k){return t.deleteVertexArray(k)}function f(k,U,I){const H=I.wireframe===!0;let O=r[k.id];O===void 0&&(O={},r[k.id]=O);let B=O[U.id];B===void 0&&(B={},O[U.id]=B);let V=B[H];return V===void 0&&(V=g(l()),B[H]=V),V}function g(k){const U=[],I=[],H=[];for(let O=0;O<n;O++)U[O]=0,I[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:I,attributeDivisors:H,object:k,attributes:{},index:null}}function m(k,U,I,H){const O=a.attributes,B=U.attributes;let V=0;const G=I.getAttributes();for(const K in G)if(G[K].location>=0){const oe=O[K];let $=B[K];if($===void 0&&(K==="instanceMatrix"&&k.instanceMatrix&&($=k.instanceMatrix),K==="instanceColor"&&k.instanceColor&&($=k.instanceColor)),oe===void 0||oe.attribute!==$||$&&oe.data!==$.data)return!0;V++}return a.attributesNum!==V||a.index!==H}function y(k,U,I,H){const O={},B=U.attributes;let V=0;const G=I.getAttributes();for(const K in G)if(G[K].location>=0){let oe=B[K];oe===void 0&&(K==="instanceMatrix"&&k.instanceMatrix&&(oe=k.instanceMatrix),K==="instanceColor"&&k.instanceColor&&(oe=k.instanceColor));const $={};$.attribute=oe,oe&&oe.data&&($.data=oe.data),O[K]=$,V++}a.attributes=O,a.attributesNum=V,a.index=H}function v(){const k=a.newAttributes;for(let U=0,I=k.length;U<I;U++)k[U]=0}function b(k){x(k,0)}function x(k,U){const I=a.newAttributes,H=a.enabledAttributes,O=a.attributeDivisors;I[k]=1,H[k]===0&&(t.enableVertexAttribArray(k),H[k]=1),O[k]!==U&&(t.vertexAttribDivisor(k,U),O[k]=U)}function M(){const k=a.newAttributes,U=a.enabledAttributes;for(let I=0,H=U.length;I<H;I++)U[I]!==k[I]&&(t.disableVertexAttribArray(I),U[I]=0)}function w(k,U,I,H,O,B,V){V===!0?t.vertexAttribIPointer(k,U,I,O,B):t.vertexAttribPointer(k,U,I,H,O,B)}function A(k,U,I,H){v();const O=H.attributes,B=I.getAttributes(),V=U.defaultAttributeValues;for(const G in B){const K=B[G];if(K.location>=0){let Y=O[G];if(Y===void 0&&(G==="instanceMatrix"&&k.instanceMatrix&&(Y=k.instanceMatrix),G==="instanceColor"&&k.instanceColor&&(Y=k.instanceColor)),Y!==void 0){const oe=Y.normalized,$=Y.itemSize,X=e.get(Y);if(X===void 0)continue;const ae=X.buffer,ce=X.type,xe=X.bytesPerElement,te=ce===t.INT||ce===t.UNSIGNED_INT||Y.gpuType===KP;if(Y.isInterleavedBufferAttribute){const ve=Y.data,De=ve.stride,he=Y.offset;if(ve.isInstancedInterleavedBuffer){for(let me=0;me<K.locationSize;me++)x(K.location+me,ve.meshPerAttribute);k.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let me=0;me<K.locationSize;me++)b(K.location+me);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let me=0;me<K.locationSize;me++)w(K.location+me,$/K.locationSize,ce,oe,De*xe,(he+$/K.locationSize*me)*xe,te)}else{if(Y.isInstancedBufferAttribute){for(let ve=0;ve<K.locationSize;ve++)x(K.location+ve,Y.meshPerAttribute);k.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let ve=0;ve<K.locationSize;ve++)b(K.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let ve=0;ve<K.locationSize;ve++)w(K.location+ve,$/K.locationSize,ce,oe,$*xe,$/K.locationSize*ve*xe,te)}}else if(V!==void 0){const oe=V[G];if(oe!==void 0)switch(oe.length){case 2:t.vertexAttrib2fv(K.location,oe);break;case 3:t.vertexAttrib3fv(K.location,oe);break;case 4:t.vertexAttrib4fv(K.location,oe);break;default:t.vertexAttrib1fv(K.location,oe)}}}}M()}function T(){j();for(const k in r){const U=r[k];for(const I in U){const H=U[I];for(const O in H)u(H[O].object),delete H[O];delete U[I]}delete r[k]}}function R(k){if(r[k.id]===void 0)return;const U=r[k.id];for(const I in U){const H=U[I];for(const O in H)u(H[O].object),delete H[O];delete U[I]}delete r[k.id]}function N(k){for(const U in r){const I=r[U];if(I[k.id]===void 0)continue;const H=I[k.id];for(const O in H)u(H[O].object),delete H[O];delete I[k.id]}}function j(){C(),s=!0,a!==i&&(a=i,c(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:j,resetDefaultState:C,dispose:T,releaseStatesOfGeometry:R,releaseStatesOfProgram:N,initAttributes:v,enableAttribute:b,disableUnusedAttributes:M}}function Rhe(t,e,n){let r;function i(c){r=c}function a(c,u){t.drawArrays(r,c,u),n.update(u,r,1)}function s(c,u,f){f!==0&&(t.drawArraysInstanced(r,c,u,f),n.update(u,r,f))}function o(c,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,u,0,f);let m=0;for(let y=0;y<f;y++)m+=u[y];n.update(m,r,1)}function l(c,u,f,g){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let y=0;y<c.length;y++)s(c[y],u[y],g[y]);else{m.multiDrawArraysInstancedWEBGL(r,c,0,u,0,g,0,f);let y=0;for(let v=0;v<f;v++)y+=u[v]*g[v];n.update(y,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Phe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(N){return!(N!==yo&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const j=N===_m&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==tl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==tc&&!j)}function l(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const u=l(c);u!==c&&(Wt("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),x=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=y>0,R=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:s,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:y,maxTextureSize:v,maxCubemapSize:b,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:R}}function khe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new _u,o=new cn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=u(f,g,0)},this.setState=function(f,g,m){const y=f.clippingPlanes,v=f.clipIntersection,b=f.clipShadows,x=t.get(f);if(!i||y===null||y.length===0||a&&!b)a?u(null):c();else{const M=a?0:r,w=M*4;let A=x.clippingState||null;l.value=A,A=u(y,g,w,m);for(let T=0;T!==w;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(f,g,m,y){const v=f!==null?f.length:0;let b=null;if(v!==0){if(b=l.value,y!==!0||b===null){const x=m+v*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(b===null||b.length<x)&&(b=new Float32Array(x));for(let w=0,A=m;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(b,A),b[A+3]=s.constant}l.value=b,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,b}}function Dhe(t){let e=new WeakMap;function n(s,o){return o===qN?s.mapping=qp:o===XN&&(s.mapping=Xp),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===qN||o===XN)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new Cue(l.height);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",i),n(c.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const Du=4,UF=[.125,.215,.35,.446,.526,.582],Kd=20,Ohe=256,zg=new tW,FF=new bn;let uT=null,dT=0,fT=0,hT=!1;const Lhe=new Ge;let zF=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:s=256,position:o=Lhe}=a;uT=this._renderer.getRenderTarget(),dT=this._renderer.getActiveCubeFace(),fT=this._renderer.getActiveMipmapLevel(),hT=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$F(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=HF(),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(uT,dT,fT),this._renderer.xr.enabled=hT,e.scissorTest=!1,Gh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===qp||e.mapping===Xp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),uT=this._renderer.getRenderTarget(),dT=this._renderer.getActiveCubeFace(),fT=this._renderer.getActiveMipmapLevel(),hT=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:$s,minFilter:$s,generateMipmaps:!1,type:_m,format:yo,colorSpace:Kp,depthBuffer:!1},i=BF(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=BF(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Ihe(a)),this._blurMaterial=Uhe(a,e,n),this._ggxMaterial=jhe(a,e,n)}return i}_compileMaterial(e){const n=new nl(new dl,e);this._renderer.compile(n,zg)}_sceneToCubeUV(e,n,r,i,a){const l=new Us(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,m=f.toneMapping;f.getClearColor(FF),f.toneMapping=zu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new nl(new ak,new ik({name:"PMREM.Background",side:Fa,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,b=v.material;let x=!1;const M=e.background;M?M.isColor&&(b.color.copy(M),e.background=null,x=!0):(b.color.copy(FF),x=!0);for(let w=0;w<6;w++){const A=w%3;A===0?(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+u[w],a.y,a.z)):A===1?(l.up.set(0,0,c[w]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+u[w],a.z)):(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+u[w]));const T=this._cubeSize;Gh(i,A*T,w>2?T:0,T,T),f.setRenderTarget(i),x&&f.render(v,l),f.render(e,l)}f.toneMapping=m,f.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===qp||e.mapping===Xp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=$F()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=HF());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;Gh(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(s,zg)}_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,s=this._ggxMaterial,o=this._lodMeshes[r];o.material=s;const l=s.uniforms,c=r/(this._lodMeshes.length-1),u=n/(this._lodMeshes.length-1),f=Math.sqrt(c*c-u*u),g=.05+c*.95,m=f*g,{_lodMax:y}=this,v=this._sizeLods[r],b=3*v*(r>y-Du?r-y+Du:0),x=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=y-n,Gh(a,b,x,3*v,2*v),i.setRenderTarget(a),i.render(o,zg),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=y-r,Gh(e,b,x,3*v,2*v),i.setRenderTarget(e),i.render(o,zg)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&kr("blur direction must be either latitudinal or longitudinal!");const u=3,f=this._lodMeshes[i];f.material=c;const g=c.uniforms,m=this._sizeLods[r]-1,y=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Kd-1),v=a/y,b=isFinite(a)?1+Math.floor(u*v):Kd;b>Kd&&Wt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Kd}`);const x=[];let M=0;for(let N=0;N<Kd;++N){const j=N/v,C=Math.exp(-j*j/2);x.push(C),N===0?M+=C:N<b&&(M+=2*C)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=y,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Du?i-w+Du:0),R=4*(this._cubeSize-A);Gh(n,T,R,3*A,2*A),l.setRenderTarget(n),l.render(f,zg)}};function Ihe(t){const e=[],n=[],r=[];let i=t;const a=t-Du+1+UF.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);e.push(o);let l=1/o;s>t-Du?l=UF[s-t+Du-1]:s===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,f=1+c,g=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,y=6,v=3,b=2,x=1,M=new Float32Array(v*y*m),w=new Float32Array(b*y*m),A=new Float32Array(x*y*m);for(let R=0;R<m;R++){const N=R%3*2/3-1,j=R>2?0:-1,C=[N,j,0,N+2/3,j,0,N+2/3,j+1,0,N,j,0,N+2/3,j+1,0,N,j+1,0];M.set(C,v*y*R),w.set(g,b*y*R);const k=[R,R,R,R,R,R];A.set(k,x*y*R)}const T=new dl;T.setAttribute("position",new Gs(M,v)),T.setAttribute("uv",new Gs(w,b)),T.setAttribute("faceIndex",new Gs(A,x)),r.push(new nl(T,null)),i>Du&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function BF(t,e,n){const r=new Nf(t,e,n);return r.texture.mapping=rw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Gh(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function jhe(t,e,n){return new gc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Ohe,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:aw(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:oc,depthTest:!1,depthWrite:!1})}function Uhe(t,e,n){const r=new Float32Array(Kd),i=new Ge(0,1,0);return new gc({name:"SphericalGaussianBlur",defines:{n:Kd,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:aw(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:oc,depthTest:!1,depthWrite:!1})}function HF(){return new gc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:aw(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:oc,depthTest:!1,depthWrite:!1})}function $F(){return new gc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:aw(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:oc,depthTest:!1,depthWrite:!1})}function aw(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function Fhe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===qN||l===XN,u=l===qp||l===Xp;if(c||u){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new zF(t)),f=c?n.fromEquirectangular(o,f):n.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return c&&m&&m.height>0||u&&m&&i(m)?(n===null&&(n=new zF(t)),f=c?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",a),f.texture):null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function zhe(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&&Zx("WebGLRenderer: "+r+" extension not supported."),i}}}function Bhe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const y in g.attributes)e.remove(g.attributes[y]);g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function c(f){const g=[],m=f.index,y=f.attributes.position;let v=0;if(m!==null){const M=m.array;v=m.version;for(let w=0,A=M.length;w<A;w+=3){const T=M[w+0],R=M[w+1],N=M[w+2];g.push(T,R,R,N,N,T)}}else if(y!==void 0){const M=y.array;v=y.version;for(let w=0,A=M.length/3-1;w<A;w+=3){const T=w+0,R=w+1,N=w+2;g.push(T,R,R,N,N,T)}}else return;const b=new(O9(g)?V9:$9)(g,1);b.version=v;const x=a.get(f);x&&e.remove(x),a.set(f,b)}function u(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:u}}function Hhe(t,e,n){let r;function i(g){r=g}let a,s;function o(g){a=g.type,s=g.bytesPerElement}function l(g,m){t.drawElements(r,m,a,g*s),n.update(m,r,1)}function c(g,m,y){y!==0&&(t.drawElementsInstanced(r,m,a,g*s,y),n.update(m,r,y))}function u(g,m,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,g,0,y);let b=0;for(let x=0;x<y;x++)b+=m[x];n.update(b,r,1)}function f(g,m,y,v){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let x=0;x<g.length;x++)c(g[x]/s,m[x],v[x]);else{b.multiDrawElementsInstancedWEBGL(r,m,0,a,g,0,v,0,y);let x=0;for(let M=0;M<y;M++)x+=m[M]*v[M];n.update(x,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=f}function $he(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:kr("WebGLInfo: Unknown draw mode:",s);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 Vhe(t,e,n){const r=new WeakMap,i=new $r;function a(s,o,l){const c=s.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=u!==void 0?u.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let k=function(){j.dispose(),r.delete(o),o.removeEventListener("dispose",k)};var m=k;g!==void 0&&g.texture.dispose();const y=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,b=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let A=0;y===!0&&(A=1),v===!0&&(A=2),b===!0&&(A=3);let T=o.attributes.position.count*A,R=1;T>e.maxTextureSize&&(R=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*R*4*f),j=new F9(N,T,R,f);j.type=tc,j.needsUpdate=!0;const C=A*4;for(let U=0;U<f;U++){const I=x[U],H=M[U],O=w[U],B=T*R*4*U;for(let V=0;V<I.count;V++){const G=V*C;y===!0&&(i.fromBufferAttribute(I,V),N[B+G+0]=i.x,N[B+G+1]=i.y,N[B+G+2]=i.z,N[B+G+3]=0),v===!0&&(i.fromBufferAttribute(H,V),N[B+G+4]=i.x,N[B+G+5]=i.y,N[B+G+6]=i.z,N[B+G+7]=0),b===!0&&(i.fromBufferAttribute(O,V),N[B+G+8]=i.x,N[B+G+9]=i.y,N[B+G+10]=i.z,N[B+G+11]=O.itemSize===4?i.w:1)}}g={count:f,texture:j,size:new an(T,R)},r.set(o,g),o.addEventListener("dispose",k)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let y=0;for(let b=0;b<c.length;b++)y+=c[b];const v=o.morphTargetsRelative?1:1-y;l.getUniforms().setValue(t,"morphTargetBaseInfluence",v),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function Ghe(t,e,n,r){let i=new WeakMap;function a(l){const c=r.render.frame,u=l.geometry,f=e.get(l,u);if(i.get(f)!==c&&(e.update(f),i.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return f}function s(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}const rW=new To,VF=new Z9(1,1),iW=new F9,aW=new due,sW=new K9,GF=[],WF=[],qF=new Float32Array(16),XF=new Float32Array(9),KF=new Float32Array(4);function wm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=GF[i];if(a===void 0&&(a=new Float32Array(i),GF[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function ai(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function si(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function sw(t,e){let n=WF[e];n===void 0&&(n=new Int32Array(e),WF[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Whe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function qhe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2fv(this.addr,e),si(n,e)}}function Xhe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ai(n,e))return;t.uniform3fv(this.addr,e),si(n,e)}}function Khe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4fv(this.addr,e),si(n,e)}}function Yhe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;KF.set(r),t.uniformMatrix2fv(this.addr,!1,KF),si(n,r)}}function Zhe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;XF.set(r),t.uniformMatrix3fv(this.addr,!1,XF),si(n,r)}}function Qhe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;qF.set(r),t.uniformMatrix4fv(this.addr,!1,qF),si(n,r)}}function Jhe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function epe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2iv(this.addr,e),si(n,e)}}function tpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ai(n,e))return;t.uniform3iv(this.addr,e),si(n,e)}}function npe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4iv(this.addr,e),si(n,e)}}function rpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ipe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2uiv(this.addr,e),si(n,e)}}function ape(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ai(n,e))return;t.uniform3uiv(this.addr,e),si(n,e)}}function spe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4uiv(this.addr,e),si(n,e)}}function ope(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?(VF.compareFunction=D9,a=VF):a=rW,n.setTexture2D(e||a,i)}function lpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||aW,i)}function cpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||sW,i)}function upe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||iW,i)}function dpe(t){switch(t){case 5126:return Whe;case 35664:return qhe;case 35665:return Xhe;case 35666:return Khe;case 35674:return Yhe;case 35675:return Zhe;case 35676:return Qhe;case 5124:case 35670:return Jhe;case 35667:case 35671:return epe;case 35668:case 35672:return tpe;case 35669:case 35673:return npe;case 5125:return rpe;case 36294:return ipe;case 36295:return ape;case 36296:return spe;case 35678:case 36198:case 36298:case 36306:case 35682:return ope;case 35679:case 36299:case 36307:return lpe;case 35680:case 36300:case 36308:case 36293:return cpe;case 36289:case 36303:case 36311:case 36292:return upe}}function fpe(t,e){t.uniform1fv(this.addr,e)}function hpe(t,e){const n=wm(e,this.size,2);t.uniform2fv(this.addr,n)}function ppe(t,e){const n=wm(e,this.size,3);t.uniform3fv(this.addr,n)}function mpe(t,e){const n=wm(e,this.size,4);t.uniform4fv(this.addr,n)}function gpe(t,e){const n=wm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function xpe(t,e){const n=wm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function vpe(t,e){const n=wm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function bpe(t,e){t.uniform1iv(this.addr,e)}function ype(t,e){t.uniform2iv(this.addr,e)}function _pe(t,e){t.uniform3iv(this.addr,e)}function Spe(t,e){t.uniform4iv(this.addr,e)}function wpe(t,e){t.uniform1uiv(this.addr,e)}function Mpe(t,e){t.uniform2uiv(this.addr,e)}function Epe(t,e){t.uniform3uiv(this.addr,e)}function Ape(t,e){t.uniform4uiv(this.addr,e)}function Tpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||rW,a[s])}function Cpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||aW,a[s])}function Npe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||sW,a[s])}function Rpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||iW,a[s])}function Ppe(t){switch(t){case 5126:return fpe;case 35664:return hpe;case 35665:return ppe;case 35666:return mpe;case 35674:return gpe;case 35675:return xpe;case 35676:return vpe;case 5124:case 35670:return bpe;case 35667:case 35671:return ype;case 35668:case 35672:return _pe;case 35669:case 35673:return Spe;case 5125:return wpe;case 36294:return Mpe;case 36295:return Epe;case 36296:return Ape;case 35678:case 36198:case 36298:case 36306:case 35682:return Tpe;case 35679:case 36299:case 36307:return Cpe;case 35680:case 36300:case 36308:case 36293:return Npe;case 36289:case 36303:case 36311:case 36292:return Rpe}}let kpe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=dpe(n.type)}},Dpe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Ppe(n.type)}},Ope=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}};const pT=/(\w+)(\])?(\[|\.)?/g;function YF(t,e){t.seq.push(e),t.map[e.id]=e}function Lpe(t,e,n){const r=t.name,i=r.length;for(pT.lastIndex=0;;){const a=pT.exec(r),s=pT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===i){YF(n,c===void 0?new kpe(o,t,e):new Dpe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Ope(o),YF(n,f)),n=f}}}let w_=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);Lpe(a,s,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,s=n.length;a!==s;++a){const o=n[a],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function ZF(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Ipe=37297;let jpe=0;function Upe(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  3751. `)}const QF=new cn;function Fpe(t){En._getMatrix(QF,En.workingColorSpace,t);const e=`mat3( ${QF.elements.map(n=>n.toFixed(4))} )`;switch(En.getTransfer(t)){case K_:return[e,"LinearTransferOETF"];case Bn:return[e,"sRGBTransferOETF"];default:return Wt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function JF(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  3752. `+a+`
  3753. `+Upe(t.getShaderSource(e),o)}else return a}function zpe(t,e){const n=Fpe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function Bpe(t,e){let n;switch(e){case Uce:n="Linear";break;case Fce:n="Reinhard";break;case zce:n="Cineon";break;case Bce:n="ACESFilmic";break;case $ce:n="AgX";break;case Vce:n="Neutral";break;case Hce:n="Custom";break;default:Wt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const ey=new Ge;function Hpe(){En.getLuminanceCoefficients(ey);const t=ey.x.toFixed(4),e=ey.y.toFixed(4),n=ey.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function $pe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sx).join(`
  3756. `)}function Vpe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function Gpe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function sx(t){return t!==""}function ez(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 tz(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Wpe=/^[ \t]*#include +<([\w\d./]+)>/gm;function T3(t){return t.replace(Wpe,Xpe)}const qpe=new Map;function Xpe(t,e){let n=nn[e];if(n===void 0){const r=qpe.get(e);if(r!==void 0)n=nn[r],Wt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return T3(n)}const Kpe=/#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 nz(t){return t.replace(Kpe,Ype)}function Ype(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 rz(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function Zpe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===w9?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===xce?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Vl&&(e="SHADOWMAP_TYPE_VSM"),e}function Qpe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case qp:case Xp:e="ENVMAP_TYPE_CUBE";break;case rw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Jpe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Xp:e="ENVMAP_MODE_REFRACTION";break}return e}function eme(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case XP:e="ENVMAP_BLENDING_MULTIPLY";break;case Ice:e="ENVMAP_BLENDING_MIX";break;case jce:e="ENVMAP_BLENDING_ADD";break}return e}function tme(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 nme(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=Zpe(n),c=Qpe(n),u=Jpe(n),f=eme(n),g=tme(n),m=$pe(n),y=Vpe(a),v=i.createProgram();let b,x,M=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(sx).join(`
  3779. `),b.length>0&&(b+=`
  3780. `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(sx).join(`
  3781. `),x.length>0&&(x+=`
  3782. `)):(b=[rz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3783. `].filter(sx).join(`
  3784. `),x=[rz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==zu?"#define TONE_MAPPING":"",n.toneMapping!==zu?nn.tonemapping_pars_fragment:"",n.toneMapping!==zu?Bpe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",nn.colorspace_pars_fragment,zpe("linearToOutputTexel",n.outputColorSpace),Hpe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(sx).join(`
  3786. `)),s=T3(s),s=ez(s,n),s=tz(s,n),o=T3(o),o=ez(o,n),o=tz(o,n),s=nz(s),o=nz(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  3787. `,b=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+b,x=["#define varying in",n.glslVersion===uF?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===uF?"":"#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(`
  3790. `)+`
  3791. `+x);const w=M+b+s,A=M+x+o,T=ZF(i,i.VERTEX_SHADER,w),R=ZF(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,R),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(U){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v)||"",H=i.getShaderInfoLog(T)||"",O=i.getShaderInfoLog(R)||"",B=I.trim(),V=H.trim(),G=O.trim();let K=!0,Y=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,R);else{const oe=JF(i,T,"vertex"),$=JF(i,R,"fragment");kr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3792. Material Name: `+U.name+`
  3793. Material Type: `+U.type+`
  3794. Program Info Log: `+B+`
  3795. `+oe+`
  3796. `+$)}else B!==""?Wt("WebGLProgram: Program Info Log:",B):(V===""||G==="")&&(Y=!1);Y&&(U.diagnostics={runnable:K,programLog:B,vertexShader:{log:V,prefix:b},fragmentShader:{log:G,prefix:x}})}i.deleteShader(T),i.deleteShader(R),j=new w_(i,v),C=Gpe(i,v)}let j;this.getUniforms=function(){return j===void 0&&N(this),j};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(v,Ipe)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=jpe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=R,this}let rme=0,ime=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),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.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 ame(e),n.set(e,r)),r}},ame=class{constructor(e){this.id=rme++,this.code=e,this.usedTimes=0}};function sme(t,e,n,r,i,a,s){const o=new B9,l=new ime,c=new Set,u=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const y={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(C){return c.add(C),C===0?"uv":`uv${C}`}function b(C,k,U,I,H){const O=I.fog,B=H.geometry,V=C.isMeshStandardMaterial?I.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||V),K=G&&G.mapping===rw?G.image.height:null,Y=y[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Wt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const oe=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,$=oe!==void 0?oe.length:0;let X=0;B.morphAttributes.position!==void 0&&(X=1),B.morphAttributes.normal!==void 0&&(X=2),B.morphAttributes.color!==void 0&&(X=3);let ae,ce,xe,te;if(Y){const Rt=Bo[Y];ae=Rt.vertexShader,ce=Rt.fragmentShader}else ae=C.vertexShader,ce=C.fragmentShader,l.update(C),xe=l.getVertexShaderID(C),te=l.getFragmentShaderID(C);const ve=t.getRenderTarget(),De=t.state.buffers.depth.getReversed(),he=H.isInstancedMesh===!0,me=H.isBatchedMesh===!0,we=!!C.map,se=!!C.matcap,st=!!G,z=!!C.aoMap,q=!!C.lightMap,ie=!!C.bumpMap,Q=!!C.normalMap,ee=!!C.displacementMap,le=!!C.emissiveMap,Re=!!C.metalnessMap,Pe=!!C.roughnessMap,ne=C.anisotropy>0,F=C.clearcoat>0,L=C.dispersion>0,Z=C.iridescence>0,ge=C.sheen>0,ye=C.transmission>0,pe=ne&&!!C.anisotropyMap,Ze=F&&!!C.clearcoatMap,Ie=F&&!!C.clearcoatNormalMap,Xe=F&&!!C.clearcoatRoughnessMap,ot=Z&&!!C.iridescenceMap,je=Z&&!!C.iridescenceThicknessMap,ke=ge&&!!C.sheenColorMap,pt=ge&&!!C.sheenRoughnessMap,rt=!!C.specularMap,nt=!!C.specularColorMap,dt=!!C.specularIntensityMap,de=ye&&!!C.transmissionMap,it=ye&&!!C.thicknessMap,fe=!!C.gradientMap,Le=!!C.alphaMap,Ee=C.alphaTest>0,be=!!C.alphaHash,He=!!C.extensions;let ut=zu;C.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(ut=t.toneMapping);const _t={shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ae,fragmentShader:ce,defines:C.defines,customVertexShaderID:xe,customFragmentShaderID:te,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:me,batchingColor:me&&H._colorsTexture!==null,instancing:he,instancingColor:he&&H.instanceColor!==null,instancingMorph:he&&H.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:Kp,alphaToCoverage:!!C.alphaToCoverage,map:we,matcap:se,envMap:st,envMapMode:st&&G.mapping,envMapCubeUVHeight:K,aoMap:z,lightMap:q,bumpMap:ie,normalMap:Q,displacementMap:g&&ee,emissiveMap:le,normalMapObjectSpace:Q&&C.normalMapType===Xce,normalMapTangentSpace:Q&&C.normalMapType===k9,metalnessMap:Re,roughnessMap:Pe,anisotropy:ne,anisotropyMap:pe,clearcoat:F,clearcoatMap:Ze,clearcoatNormalMap:Ie,clearcoatRoughnessMap:Xe,dispersion:L,iridescence:Z,iridescenceMap:ot,iridescenceThicknessMap:je,sheen:ge,sheenColorMap:ke,sheenRoughnessMap:pt,specularMap:rt,specularColorMap:nt,specularIntensityMap:dt,transmission:ye,transmissionMap:de,thicknessMap:it,gradientMap:fe,opaque:C.transparent===!1&&C.blending===Pp&&C.alphaToCoverage===!1,alphaMap:Le,alphaTest:Ee,alphaHash:be,combine:C.combine,mapUv:we&&v(C.map.channel),aoMapUv:z&&v(C.aoMap.channel),lightMapUv:q&&v(C.lightMap.channel),bumpMapUv:ie&&v(C.bumpMap.channel),normalMapUv:Q&&v(C.normalMap.channel),displacementMapUv:ee&&v(C.displacementMap.channel),emissiveMapUv:le&&v(C.emissiveMap.channel),metalnessMapUv:Re&&v(C.metalnessMap.channel),roughnessMapUv:Pe&&v(C.roughnessMap.channel),anisotropyMapUv:pe&&v(C.anisotropyMap.channel),clearcoatMapUv:Ze&&v(C.clearcoatMap.channel),clearcoatNormalMapUv:Ie&&v(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&v(C.clearcoatRoughnessMap.channel),iridescenceMapUv:ot&&v(C.iridescenceMap.channel),iridescenceThicknessMapUv:je&&v(C.iridescenceThicknessMap.channel),sheenColorMapUv:ke&&v(C.sheenColorMap.channel),sheenRoughnessMapUv:pt&&v(C.sheenRoughnessMap.channel),specularMapUv:rt&&v(C.specularMap.channel),specularColorMapUv:nt&&v(C.specularColorMap.channel),specularIntensityMapUv:dt&&v(C.specularIntensityMap.channel),transmissionMapUv:de&&v(C.transmissionMap.channel),thicknessMapUv:it&&v(C.thicknessMap.channel),alphaMapUv:Le&&v(C.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(Q||ne),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:H.isPoints===!0&&!!B.attributes.uv&&(we||Le),fog:!!O,useFog:C.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:De,skinning:H.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:$,morphTextureStride:X,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:ut,decodeVideoTexture:we&&C.map.isVideoTexture===!0&&En.getTransfer(C.map.colorSpace)===Bn,decodeVideoTextureEmissive:le&&C.emissiveMap.isVideoTexture===!0&&En.getTransfer(C.emissiveMap.colorSpace)===Bn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Ho,flipSided:C.side===Fa,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:He&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&C.extensions.multiDraw===!0||me)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return _t.vertexUv1s=c.has(1),_t.vertexUv2s=c.has(2),_t.vertexUv3s=c.has(3),c.clear(),_t}function x(C){const k=[];if(C.shaderID?k.push(C.shaderID):(k.push(C.customVertexShaderID),k.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)k.push(U),k.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(M(k,C),w(k,C),k.push(t.outputColorSpace)),k.push(C.customProgramCacheKey),k.join()}function M(C,k){C.push(k.precision),C.push(k.outputColorSpace),C.push(k.envMapMode),C.push(k.envMapCubeUVHeight),C.push(k.mapUv),C.push(k.alphaMapUv),C.push(k.lightMapUv),C.push(k.aoMapUv),C.push(k.bumpMapUv),C.push(k.normalMapUv),C.push(k.displacementMapUv),C.push(k.emissiveMapUv),C.push(k.metalnessMapUv),C.push(k.roughnessMapUv),C.push(k.anisotropyMapUv),C.push(k.clearcoatMapUv),C.push(k.clearcoatNormalMapUv),C.push(k.clearcoatRoughnessMapUv),C.push(k.iridescenceMapUv),C.push(k.iridescenceThicknessMapUv),C.push(k.sheenColorMapUv),C.push(k.sheenRoughnessMapUv),C.push(k.specularMapUv),C.push(k.specularColorMapUv),C.push(k.specularIntensityMapUv),C.push(k.transmissionMapUv),C.push(k.thicknessMapUv),C.push(k.combine),C.push(k.fogExp2),C.push(k.sizeAttenuation),C.push(k.morphTargetsCount),C.push(k.morphAttributeCount),C.push(k.numDirLights),C.push(k.numPointLights),C.push(k.numSpotLights),C.push(k.numSpotLightMaps),C.push(k.numHemiLights),C.push(k.numRectAreaLights),C.push(k.numDirLightShadows),C.push(k.numPointLightShadows),C.push(k.numSpotLightShadows),C.push(k.numSpotLightShadowsWithMaps),C.push(k.numLightProbes),C.push(k.shadowMapType),C.push(k.toneMapping),C.push(k.numClippingPlanes),C.push(k.numClipIntersection),C.push(k.depthPacking)}function w(C,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),C.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),C.push(o.mask)}function A(C){const k=y[C.type];let U;if(k){const I=Bo[k];U=Mue.clone(I.uniforms)}else U=C.uniforms;return U}function T(C,k){let U;for(let I=0,H=u.length;I<H;I++){const O=u[I];if(O.cacheKey===k){U=O,++U.usedTimes;break}}return U===void 0&&(U=new nme(t,k,C,a),u.push(U)),U}function R(C){if(--C.usedTimes===0){const k=u.indexOf(C);u[k]=u[u.length-1],u.pop(),C.destroy()}}function N(C){l.remove(C)}function j(){l.dispose()}return{getParameters:b,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:R,releaseShaderCache:N,programs:u,dispose:j}}function ome(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function r(s){t.delete(s)}function i(s,o,l){t.get(s)[o]=l}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function lme(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 iz(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 az(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,y,v,b){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:g,material:m,groupOrder:y,renderOrder:f.renderOrder,z:v,group:b},t[e]=x):(x.id=f.id,x.object=f,x.geometry=g,x.material=m,x.groupOrder=y,x.renderOrder=f.renderOrder,x.z=v,x.group=b),e++,x}function o(f,g,m,y,v,b){const x=s(f,g,m,y,v,b);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(f,g,m,y,v,b){const x=s(f,g,m,y,v,b);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(f,g){n.length>1&&n.sort(f||lme),r.length>1&&r.sort(g||iz),i.length>1&&i.sort(g||iz)}function u(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:l,finish:u,sort:c}}function cme(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new az,t.set(r,[s])):i>=a.length?(s=new az,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function ume(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ge,color:new bn};break;case"SpotLight":n={position:new Ge,direction:new Ge,color:new bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ge,color:new bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ge,skyColor:new bn,groundColor:new bn};break;case"RectAreaLight":n={color:new bn,position:new Ge,halfWidth:new Ge,halfHeight:new Ge};break}return t[e.id]=n,n}}}function dme(){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 an};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new an};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new an,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let fme=0;function hme(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function pme(t){const e=new ume,n=dme(),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 c=0;c<9;c++)r.probe.push(new Ge);const i=new Ge,a=new qr,s=new qr;function o(c){let u=0,f=0,g=0;for(let C=0;C<9;C++)r.probe[C].set(0,0,0);let m=0,y=0,v=0,b=0,x=0,M=0,w=0,A=0,T=0,R=0,N=0;c.sort(hme);for(let C=0,k=c.length;C<k;C++){const U=c[C],I=U.color,H=U.intensity,O=U.distance,B=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)u+=I.r*H,f+=I.g*H,g+=I.b*H;else if(U.isLightProbe){for(let V=0;V<9;V++)r.probe[V].addScaledVector(U.sh.coefficients[V],H);N++}else if(U.isDirectionalLight){const V=e.get(U);if(V.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const G=U.shadow,K=n.get(U);K.shadowIntensity=G.intensity,K.shadowBias=G.bias,K.shadowNormalBias=G.normalBias,K.shadowRadius=G.radius,K.shadowMapSize=G.mapSize,r.directionalShadow[m]=K,r.directionalShadowMap[m]=B,r.directionalShadowMatrix[m]=U.shadow.matrix,M++}r.directional[m]=V,m++}else if(U.isSpotLight){const V=e.get(U);V.position.setFromMatrixPosition(U.matrixWorld),V.color.copy(I).multiplyScalar(H),V.distance=O,V.coneCos=Math.cos(U.angle),V.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),V.decay=U.decay,r.spot[v]=V;const G=U.shadow;if(U.map&&(r.spotLightMap[T]=U.map,T++,G.updateMatrices(U),U.castShadow&&R++),r.spotLightMatrix[v]=G.matrix,U.castShadow){const K=n.get(U);K.shadowIntensity=G.intensity,K.shadowBias=G.bias,K.shadowNormalBias=G.normalBias,K.shadowRadius=G.radius,K.shadowMapSize=G.mapSize,r.spotShadow[v]=K,r.spotShadowMap[v]=B,A++}v++}else if(U.isRectAreaLight){const V=e.get(U);V.color.copy(I).multiplyScalar(H),V.halfWidth.set(U.width*.5,0,0),V.halfHeight.set(0,U.height*.5,0),r.rectArea[b]=V,b++}else if(U.isPointLight){const V=e.get(U);if(V.color.copy(U.color).multiplyScalar(U.intensity),V.distance=U.distance,V.decay=U.decay,U.castShadow){const G=U.shadow,K=n.get(U);K.shadowIntensity=G.intensity,K.shadowBias=G.bias,K.shadowNormalBias=G.normalBias,K.shadowRadius=G.radius,K.shadowMapSize=G.mapSize,K.shadowCameraNear=G.camera.near,K.shadowCameraFar=G.camera.far,r.pointShadow[y]=K,r.pointShadowMap[y]=B,r.pointShadowMatrix[y]=U.shadow.matrix,w++}r.point[y]=V,y++}else if(U.isHemisphereLight){const V=e.get(U);V.skyColor.copy(U.color).multiplyScalar(H),V.groundColor.copy(U.groundColor).multiplyScalar(H),r.hemi[x]=V,x++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=wt.LTC_FLOAT_1,r.rectAreaLTC2=wt.LTC_FLOAT_2):(r.rectAreaLTC1=wt.LTC_HALF_1,r.rectAreaLTC2=wt.LTC_HALF_2)),r.ambient[0]=u,r.ambient[1]=f,r.ambient[2]=g;const j=r.hash;(j.directionalLength!==m||j.pointLength!==y||j.spotLength!==v||j.rectAreaLength!==b||j.hemiLength!==x||j.numDirectionalShadows!==M||j.numPointShadows!==w||j.numSpotShadows!==A||j.numSpotMaps!==T||j.numLightProbes!==N)&&(r.directional.length=m,r.spot.length=v,r.rectArea.length=b,r.point.length=y,r.hemi.length=x,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+T-R,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=R,r.numLightProbes=N,j.directionalLength=m,j.pointLength=y,j.spotLength=v,j.rectAreaLength=b,j.hemiLength=x,j.numDirectionalShadows=M,j.numPointShadows=w,j.numSpotShadows=A,j.numSpotMaps=T,j.numLightProbes=N,r.version=fme++)}function l(c,u){let f=0,g=0,m=0,y=0,v=0;const b=u.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),f++}else if(w.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),m++}else if(w.isRectAreaLight){const A=r.rectArea[y];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),s.identity(),a.copy(w.matrixWorld),a.premultiply(b),s.extractRotation(a),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),y++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),g++}else if(w.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(b),v++}}}return{setup:o,setupView:l,state:r}}function sz(t){const e=new pme(t),n=[],r=[];function i(u){c.camera=u,n.length=0,r.length=0}function a(u){n.push(u)}function s(u){r.push(u)}function o(){e.setup(n)}function l(u){e.setupView(n,u)}const c={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:s}}function mme(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let o;return s===void 0?(o=new sz(t),e.set(i,[o])):a>=s.length?(o=new sz(t),s.push(o)):o=s[a],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const gme=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,xme=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function vme(t,e,n){let r=new sk;const i=new an,a=new an,s=new $r,o=new Uue({depthPacking:qce}),l=new Fue,c={},u=n.maxTextureSize,f={[Yu]:Fa,[Fa]:Yu,[Ho]:Ho},g=new gc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new an},radius:{value:4}},vertexShader:gme,fragmentShader:xme}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const y=new dl;y.setAttribute("position",new Gs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new nl(y,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=w9;let x=this.type;this.render=function(R,N,j){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||R.length===0)return;const C=t.getRenderTarget(),k=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),I=t.state;I.setBlending(oc),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const H=x!==Vl&&this.type===Vl,O=x===Vl&&this.type!==Vl;for(let B=0,V=R.length;B<V;B++){const G=R[B],K=G.shadow;if(K===void 0){Wt("WebGLShadowMap:",G,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;i.copy(K.mapSize);const Y=K.getFrameExtents();if(i.multiply(Y),a.copy(K.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/Y.x),i.x=a.x*Y.x,K.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/Y.y),i.y=a.y*Y.y,K.mapSize.y=a.y)),K.map===null||H===!0||O===!0){const $=this.type!==Vl?{minFilter:fs,magFilter:fs}:{};K.map!==null&&K.map.dispose(),K.map=new Nf(i.x,i.y,$),K.map.texture.name=G.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const oe=K.getViewportCount();for(let $=0;$<oe;$++){const X=K.getViewport($);s.set(a.x*X.x,a.y*X.y,a.x*X.z,a.y*X.w),I.viewport(s),K.updateMatrices(G,$),r=K.getFrustum(),A(N,j,K.camera,G,this.type)}K.isPointLightShadow!==!0&&this.type===Vl&&M(K,j),K.needsUpdate=!1}x=this.type,b.needsUpdate=!1,t.setRenderTarget(C,k,U)};function M(R,N){const j=e.update(v);g.defines.VSM_SAMPLES!==R.blurSamples&&(g.defines.VSM_SAMPLES=R.blurSamples,m.defines.VSM_SAMPLES=R.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new Nf(i.x,i.y)),g.uniforms.shadow_pass.value=R.map.texture,g.uniforms.resolution.value=R.mapSize,g.uniforms.radius.value=R.radius,t.setRenderTarget(R.mapPass),t.clear(),t.renderBufferDirect(N,null,j,g,v,null),m.uniforms.shadow_pass.value=R.mapPass.texture,m.uniforms.resolution.value=R.mapSize,m.uniforms.radius.value=R.radius,t.setRenderTarget(R.map),t.clear(),t.renderBufferDirect(N,null,j,m,v,null)}function w(R,N,j,C){let k=null;const U=j.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(U!==void 0)k=U;else if(k=j.isPointLight===!0?l:o,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const I=k.uuid,H=N.uuid;let O=c[I];O===void 0&&(O={},c[I]=O);let B=O[H];B===void 0&&(B=k.clone(),O[H]=B,N.addEventListener("dispose",T)),k=B}if(k.visible=N.visible,k.wireframe=N.wireframe,C===Vl?k.side=N.shadowSide!==null?N.shadowSide:N.side:k.side=N.shadowSide!==null?N.shadowSide:f[N.side],k.alphaMap=N.alphaMap,k.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,k.map=N.map,k.clipShadows=N.clipShadows,k.clippingPlanes=N.clippingPlanes,k.clipIntersection=N.clipIntersection,k.displacementMap=N.displacementMap,k.displacementScale=N.displacementScale,k.displacementBias=N.displacementBias,k.wireframeLinewidth=N.wireframeLinewidth,k.linewidth=N.linewidth,j.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const I=t.properties.get(k);I.light=j}return k}function A(R,N,j,C,k){if(R.visible===!1)return;if(R.layers.test(N.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&k===Vl)&&(!R.frustumCulled||r.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,R.matrixWorld);const H=e.update(R),O=R.material;if(Array.isArray(O)){const B=H.groups;for(let V=0,G=B.length;V<G;V++){const K=B[V],Y=O[K.materialIndex];if(Y&&Y.visible){const oe=w(R,Y,C,k);R.onBeforeShadow(t,R,N,j,H,oe,K),t.renderBufferDirect(j,null,H,oe,R,K),R.onAfterShadow(t,R,N,j,H,oe,K)}}}else if(O.visible){const B=w(R,O,C,k);R.onBeforeShadow(t,R,N,j,H,B,null),t.renderBufferDirect(j,null,H,B,R,null),R.onAfterShadow(t,R,N,j,H,B,null)}}const I=R.children;for(let H=0,O=I.length;H<O;H++)A(I[H],N,j,C,k)}function T(R){R.target.removeEventListener("dispose",T);for(const j in c){const C=c[j],k=R.target.uuid;k in C&&(C[k].dispose(),delete C[k])}}}const bme={[zN]:BN,[HN]:GN,[$N]:WN,[Wp]:VN,[BN]:zN,[GN]:HN,[WN]:$N,[VN]:Wp};function yme(t,e){function n(){let de=!1;const it=new $r;let fe=null;const Le=new $r(0,0,0,0);return{setMask:function(Ee){fe!==Ee&&!de&&(t.colorMask(Ee,Ee,Ee,Ee),fe=Ee)},setLocked:function(Ee){de=Ee},setClear:function(Ee,be,He,ut,_t){_t===!0&&(Ee*=ut,be*=ut,He*=ut),it.set(Ee,be,He,ut),Le.equals(it)===!1&&(t.clearColor(Ee,be,He,ut),Le.copy(it))},reset:function(){de=!1,fe=null,Le.set(-1,0,0,0)}}}function r(){let de=!1,it=!1,fe=null,Le=null,Ee=null;return{setReversed:function(be){if(it!==be){const He=e.get("EXT_clip_control");be?He.clipControlEXT(He.LOWER_LEFT_EXT,He.ZERO_TO_ONE_EXT):He.clipControlEXT(He.LOWER_LEFT_EXT,He.NEGATIVE_ONE_TO_ONE_EXT),it=be;const ut=Ee;Ee=null,this.setClear(ut)}},getReversed:function(){return it},setTest:function(be){be?ve(t.DEPTH_TEST):De(t.DEPTH_TEST)},setMask:function(be){fe!==be&&!de&&(t.depthMask(be),fe=be)},setFunc:function(be){if(it&&(be=bme[be]),Le!==be){switch(be){case zN:t.depthFunc(t.NEVER);break;case BN:t.depthFunc(t.ALWAYS);break;case HN:t.depthFunc(t.LESS);break;case Wp:t.depthFunc(t.LEQUAL);break;case $N:t.depthFunc(t.EQUAL);break;case VN:t.depthFunc(t.GEQUAL);break;case GN:t.depthFunc(t.GREATER);break;case WN:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Le=be}},setLocked:function(be){de=be},setClear:function(be){Ee!==be&&(it&&(be=1-be),t.clearDepth(be),Ee=be)},reset:function(){de=!1,fe=null,Le=null,Ee=null,it=!1}}}function i(){let de=!1,it=null,fe=null,Le=null,Ee=null,be=null,He=null,ut=null,_t=null;return{setTest:function(Rt){de||(Rt?ve(t.STENCIL_TEST):De(t.STENCIL_TEST))},setMask:function(Rt){it!==Rt&&!de&&(t.stencilMask(Rt),it=Rt)},setFunc:function(Rt,ln,Dt){(fe!==Rt||Le!==ln||Ee!==Dt)&&(t.stencilFunc(Rt,ln,Dt),fe=Rt,Le=ln,Ee=Dt)},setOp:function(Rt,ln,Dt){(be!==Rt||He!==ln||ut!==Dt)&&(t.stencilOp(Rt,ln,Dt),be=Rt,He=ln,ut=Dt)},setLocked:function(Rt){de=Rt},setClear:function(Rt){_t!==Rt&&(t.clearStencil(Rt),_t=Rt)},reset:function(){de=!1,it=null,fe=null,Le=null,Ee=null,be=null,He=null,ut=null,_t=null}}}const a=new n,s=new r,o=new i,l=new WeakMap,c=new WeakMap;let u={},f={},g=new WeakMap,m=[],y=null,v=!1,b=null,x=null,M=null,w=null,A=null,T=null,R=null,N=new bn(0,0,0),j=0,C=!1,k=null,U=null,I=null,H=null,O=null;const B=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let V=!1,G=0;const K=t.getParameter(t.VERSION);K.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(K)[1]),V=G>=1):K.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),V=G>=2);let Y=null,oe={};const $=t.getParameter(t.SCISSOR_BOX),X=t.getParameter(t.VIEWPORT),ae=new $r().fromArray($),ce=new $r().fromArray(X);function xe(de,it,fe,Le){const Ee=new Uint8Array(4),be=t.createTexture();t.bindTexture(de,be),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let He=0;He<fe;He++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(it,0,t.RGBA,1,1,Le,0,t.RGBA,t.UNSIGNED_BYTE,Ee):t.texImage2D(it+He,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ee);return be}const te={};te[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),te[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),te[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),te[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ve(t.DEPTH_TEST),s.setFunc(Wp),ie(!1),Q(iF),ve(t.CULL_FACE),z(oc);function ve(de){u[de]!==!0&&(t.enable(de),u[de]=!0)}function De(de){u[de]!==!1&&(t.disable(de),u[de]=!1)}function he(de,it){return f[de]!==it?(t.bindFramebuffer(de,it),f[de]=it,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=it),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=it),!0):!1}function me(de,it){let fe=m,Le=!1;if(de){fe=g.get(it),fe===void 0&&(fe=[],g.set(it,fe));const Ee=de.textures;if(fe.length!==Ee.length||fe[0]!==t.COLOR_ATTACHMENT0){for(let be=0,He=Ee.length;be<He;be++)fe[be]=t.COLOR_ATTACHMENT0+be;fe.length=Ee.length,Le=!0}}else fe[0]!==t.BACK&&(fe[0]=t.BACK,Le=!0);Le&&t.drawBuffers(fe)}function we(de){return y!==de?(t.useProgram(de),y=de,!0):!1}const se={[Xd]:t.FUNC_ADD,[bce]:t.FUNC_SUBTRACT,[yce]:t.FUNC_REVERSE_SUBTRACT};se[_ce]=t.MIN,se[Sce]=t.MAX;const st={[wce]:t.ZERO,[Mce]:t.ONE,[Ece]:t.SRC_COLOR,[UN]:t.SRC_ALPHA,[Pce]:t.SRC_ALPHA_SATURATE,[Nce]:t.DST_COLOR,[Tce]:t.DST_ALPHA,[Ace]:t.ONE_MINUS_SRC_COLOR,[FN]:t.ONE_MINUS_SRC_ALPHA,[Rce]:t.ONE_MINUS_DST_COLOR,[Cce]:t.ONE_MINUS_DST_ALPHA,[kce]:t.CONSTANT_COLOR,[Dce]:t.ONE_MINUS_CONSTANT_COLOR,[Oce]:t.CONSTANT_ALPHA,[Lce]:t.ONE_MINUS_CONSTANT_ALPHA};function z(de,it,fe,Le,Ee,be,He,ut,_t,Rt){if(de===oc){v===!0&&(De(t.BLEND),v=!1);return}if(v===!1&&(ve(t.BLEND),v=!0),de!==vce){if(de!==b||Rt!==C){if((x!==Xd||A!==Xd)&&(t.blendEquation(t.FUNC_ADD),x=Xd,A=Xd),Rt)switch(de){case Pp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case aF:t.blendFunc(t.ONE,t.ONE);break;case sF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case oF:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:kr("WebGLState: Invalid blending: ",de);break}else switch(de){case Pp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case aF:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case sF:kr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case oF:kr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:kr("WebGLState: Invalid blending: ",de);break}M=null,w=null,T=null,R=null,N.set(0,0,0),j=0,b=de,C=Rt}return}Ee=Ee||it,be=be||fe,He=He||Le,(it!==x||Ee!==A)&&(t.blendEquationSeparate(se[it],se[Ee]),x=it,A=Ee),(fe!==M||Le!==w||be!==T||He!==R)&&(t.blendFuncSeparate(st[fe],st[Le],st[be],st[He]),M=fe,w=Le,T=be,R=He),(ut.equals(N)===!1||_t!==j)&&(t.blendColor(ut.r,ut.g,ut.b,_t),N.copy(ut),j=_t),b=de,C=!1}function q(de,it){de.side===Ho?De(t.CULL_FACE):ve(t.CULL_FACE);let fe=de.side===Fa;it&&(fe=!fe),ie(fe),de.blending===Pp&&de.transparent===!1?z(oc):z(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),s.setFunc(de.depthFunc),s.setTest(de.depthTest),s.setMask(de.depthWrite),a.setMask(de.colorWrite);const Le=de.stencilWrite;o.setTest(Le),Le&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),le(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?ve(t.SAMPLE_ALPHA_TO_COVERAGE):De(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(de){k!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),k=de)}function Q(de){de!==mce?(ve(t.CULL_FACE),de!==U&&(de===iF?t.cullFace(t.BACK):de===gce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):De(t.CULL_FACE),U=de}function ee(de){de!==I&&(V&&t.lineWidth(de),I=de)}function le(de,it,fe){de?(ve(t.POLYGON_OFFSET_FILL),(H!==it||O!==fe)&&(t.polygonOffset(it,fe),H=it,O=fe)):De(t.POLYGON_OFFSET_FILL)}function Re(de){de?ve(t.SCISSOR_TEST):De(t.SCISSOR_TEST)}function Pe(de){de===void 0&&(de=t.TEXTURE0+B-1),Y!==de&&(t.activeTexture(de),Y=de)}function ne(de,it,fe){fe===void 0&&(Y===null?fe=t.TEXTURE0+B-1:fe=Y);let Le=oe[fe];Le===void 0&&(Le={type:void 0,texture:void 0},oe[fe]=Le),(Le.type!==de||Le.texture!==it)&&(Y!==fe&&(t.activeTexture(fe),Y=fe),t.bindTexture(de,it||te[de]),Le.type=de,Le.texture=it)}function F(){const de=oe[Y];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Z(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ge(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ye(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function pe(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ze(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Ie(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Xe(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ot(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function je(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ke(de){ae.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),ae.copy(de))}function pt(de){ce.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),ce.copy(de))}function rt(de,it){let fe=c.get(it);fe===void 0&&(fe=new WeakMap,c.set(it,fe));let Le=fe.get(de);Le===void 0&&(Le=t.getUniformBlockIndex(it,de.name),fe.set(de,Le))}function nt(de,it){const Le=c.get(it).get(de);l.get(it)!==Le&&(t.uniformBlockBinding(it,Le,de.__bindingPointIndex),l.set(it,Le))}function dt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),u={},Y=null,oe={},f={},g=new WeakMap,m=[],y=null,v=!1,b=null,x=null,M=null,w=null,A=null,T=null,R=null,N=new bn(0,0,0),j=0,C=!1,k=null,U=null,I=null,H=null,O=null,ae.set(0,0,t.canvas.width,t.canvas.height),ce.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ve,disable:De,bindFramebuffer:he,drawBuffers:me,useProgram:we,setBlending:z,setMaterial:q,setFlipSided:ie,setCullFace:Q,setLineWidth:ee,setPolygonOffset:le,setScissorTest:Re,activeTexture:Pe,bindTexture:ne,unbindTexture:F,compressedTexImage2D:L,compressedTexImage3D:Z,texImage2D:ot,texImage3D:je,updateUBOMapping:rt,uniformBlockBinding:nt,texStorage2D:Ie,texStorage3D:Xe,texSubImage2D:ge,texSubImage3D:ye,compressedTexSubImage2D:pe,compressedTexSubImage3D:Ze,scissor:ke,viewport:pt,reset:dt}}function _me(t,e,n,r,i,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new an,u=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(F,L){return m?new OffscreenCanvas(F,L):Z_("canvas")}function v(F,L,Z){let ge=1;const ye=ne(F);if((ye.width>Z||ye.height>Z)&&(ge=Z/Math.max(ye.width,ye.height)),ge<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){const pe=Math.floor(ge*ye.width),Ze=Math.floor(ge*ye.height);f===void 0&&(f=y(pe,Ze));const Ie=L?y(pe,Ze):f;return Ie.width=pe,Ie.height=Ze,Ie.getContext("2d").drawImage(F,0,0,pe,Ze),Wt("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+pe+"x"+Ze+")."),Ie}else return"data"in F&&Wt("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),F;return F}function b(F){return F.generateMipmaps}function x(F){t.generateMipmap(F)}function M(F){return F.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?t.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(F,L,Z,ge,ye=!1){if(F!==null){if(t[F]!==void 0)return t[F];Wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let pe=L;if(L===t.RED&&(Z===t.FLOAT&&(pe=t.R32F),Z===t.HALF_FLOAT&&(pe=t.R16F),Z===t.UNSIGNED_BYTE&&(pe=t.R8)),L===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(pe=t.R8UI),Z===t.UNSIGNED_SHORT&&(pe=t.R16UI),Z===t.UNSIGNED_INT&&(pe=t.R32UI),Z===t.BYTE&&(pe=t.R8I),Z===t.SHORT&&(pe=t.R16I),Z===t.INT&&(pe=t.R32I)),L===t.RG&&(Z===t.FLOAT&&(pe=t.RG32F),Z===t.HALF_FLOAT&&(pe=t.RG16F),Z===t.UNSIGNED_BYTE&&(pe=t.RG8)),L===t.RG_INTEGER&&(Z===t.UNSIGNED_BYTE&&(pe=t.RG8UI),Z===t.UNSIGNED_SHORT&&(pe=t.RG16UI),Z===t.UNSIGNED_INT&&(pe=t.RG32UI),Z===t.BYTE&&(pe=t.RG8I),Z===t.SHORT&&(pe=t.RG16I),Z===t.INT&&(pe=t.RG32I)),L===t.RGB_INTEGER&&(Z===t.UNSIGNED_BYTE&&(pe=t.RGB8UI),Z===t.UNSIGNED_SHORT&&(pe=t.RGB16UI),Z===t.UNSIGNED_INT&&(pe=t.RGB32UI),Z===t.BYTE&&(pe=t.RGB8I),Z===t.SHORT&&(pe=t.RGB16I),Z===t.INT&&(pe=t.RGB32I)),L===t.RGBA_INTEGER&&(Z===t.UNSIGNED_BYTE&&(pe=t.RGBA8UI),Z===t.UNSIGNED_SHORT&&(pe=t.RGBA16UI),Z===t.UNSIGNED_INT&&(pe=t.RGBA32UI),Z===t.BYTE&&(pe=t.RGBA8I),Z===t.SHORT&&(pe=t.RGBA16I),Z===t.INT&&(pe=t.RGBA32I)),L===t.RGB&&(Z===t.UNSIGNED_INT_5_9_9_9_REV&&(pe=t.RGB9_E5),Z===t.UNSIGNED_INT_10F_11F_11F_REV&&(pe=t.R11F_G11F_B10F)),L===t.RGBA){const Ze=ye?K_:En.getTransfer(ge);Z===t.FLOAT&&(pe=t.RGBA32F),Z===t.HALF_FLOAT&&(pe=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(pe=Ze===Bn?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(pe=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(pe=t.RGB5_A1)}return(pe===t.R16F||pe===t.R32F||pe===t.RG16F||pe===t.RG32F||pe===t.RGBA16F||pe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function A(F,L){let Z;return F?L===null||L===Tf||L===Xx?Z=t.DEPTH24_STENCIL8:L===tc?Z=t.DEPTH32F_STENCIL8:L===qx&&(Z=t.DEPTH24_STENCIL8,Wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Tf||L===Xx?Z=t.DEPTH_COMPONENT24:L===tc?Z=t.DEPTH_COMPONENT32F:L===qx&&(Z=t.DEPTH_COMPONENT16),Z}function T(F,L){return b(F)===!0||F.isFramebufferTexture&&F.minFilter!==fs&&F.minFilter!==$s?Math.log2(Math.max(L.width,L.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?L.mipmaps.length:1}function R(F){const L=F.target;L.removeEventListener("dispose",R),j(L),L.isVideoTexture&&u.delete(L)}function N(F){const L=F.target;L.removeEventListener("dispose",N),k(L)}function j(F){const L=r.get(F);if(L.__webglInit===void 0)return;const Z=F.source,ge=g.get(Z);if(ge){const ye=ge[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&C(F),Object.keys(ge).length===0&&g.delete(Z)}r.remove(F)}function C(F){const L=r.get(F);t.deleteTexture(L.__webglTexture);const Z=F.source,ge=g.get(Z);delete ge[L.__cacheKey],s.memory.textures--}function k(F){const L=r.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),r.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++){if(Array.isArray(L.__webglFramebuffer[ge]))for(let ye=0;ye<L.__webglFramebuffer[ge].length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[ge][ye]);else t.deleteFramebuffer(L.__webglFramebuffer[ge]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ge])}else{if(Array.isArray(L.__webglFramebuffer))for(let ge=0;ge<L.__webglFramebuffer.length;ge++)t.deleteFramebuffer(L.__webglFramebuffer[ge]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ge=0;ge<L.__webglColorRenderbuffer.length;ge++)L.__webglColorRenderbuffer[ge]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ge]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const Z=F.textures;for(let ge=0,ye=Z.length;ge<ye;ge++){const pe=r.get(Z[ge]);pe.__webglTexture&&(t.deleteTexture(pe.__webglTexture),s.memory.textures--),r.remove(Z[ge])}r.remove(F)}let U=0;function I(){U=0}function H(){const F=U;return F>=i.maxTextures&&Wt("WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+i.maxTextures),U+=1,F}function O(F){const L=[];return L.push(F.wrapS),L.push(F.wrapT),L.push(F.wrapR||0),L.push(F.magFilter),L.push(F.minFilter),L.push(F.anisotropy),L.push(F.internalFormat),L.push(F.format),L.push(F.type),L.push(F.generateMipmaps),L.push(F.premultiplyAlpha),L.push(F.flipY),L.push(F.unpackAlignment),L.push(F.colorSpace),L.join()}function B(F,L){const Z=r.get(F);if(F.isVideoTexture&&Re(F),F.isRenderTargetTexture===!1&&F.isExternalTexture!==!0&&F.version>0&&Z.__version!==F.version){const ge=F.image;if(ge===null)Wt("WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)Wt("WebGLRenderer: Texture marked for update but image is incomplete");else{te(Z,F,L);return}}else F.isExternalTexture&&(Z.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+L)}function V(F,L){const Z=r.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&Z.__version!==F.version){te(Z,F,L);return}else F.isExternalTexture&&(Z.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+L)}function G(F,L){const Z=r.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&Z.__version!==F.version){te(Z,F,L);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+L)}function K(F,L){const Z=r.get(F);if(F.version>0&&Z.__version!==F.version){ve(Z,F,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+L)}const Y={[KN]:t.REPEAT,[ec]:t.CLAMP_TO_EDGE,[YN]:t.MIRRORED_REPEAT},oe={[fs]:t.NEAREST,[Gce]:t.NEAREST_MIPMAP_NEAREST,[Db]:t.NEAREST_MIPMAP_LINEAR,[$s]:t.LINEAR,[UA]:t.LINEAR_MIPMAP_NEAREST,[tf]:t.LINEAR_MIPMAP_LINEAR},$={[Kce]:t.NEVER,[tue]:t.ALWAYS,[Yce]:t.LESS,[D9]:t.LEQUAL,[Zce]:t.EQUAL,[eue]:t.GEQUAL,[Qce]:t.GREATER,[Jce]:t.NOTEQUAL};function X(F,L){if(L.type===tc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===$s||L.magFilter===UA||L.magFilter===Db||L.magFilter===tf||L.minFilter===$s||L.minFilter===UA||L.minFilter===Db||L.minFilter===tf)&&Wt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(F,t.TEXTURE_WRAP_S,Y[L.wrapS]),t.texParameteri(F,t.TEXTURE_WRAP_T,Y[L.wrapT]),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri(F,t.TEXTURE_MAG_FILTER,oe[L.magFilter]),t.texParameteri(F,t.TEXTURE_MIN_FILTER,oe[L.minFilter]),L.compareFunction&&(t.texParameteri(F,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(F,t.TEXTURE_COMPARE_FUNC,$[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===fs||L.minFilter!==Db&&L.minFilter!==tf||L.type===tc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const Z=e.get("EXT_texture_filter_anisotropic");t.texParameterf(F,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ae(F,L){let Z=!1;F.__webglInit===void 0&&(F.__webglInit=!0,L.addEventListener("dispose",R));const ge=L.source;let ye=g.get(ge);ye===void 0&&(ye={},g.set(ge,ye));const pe=O(L);if(pe!==F.__cacheKey){ye[pe]===void 0&&(ye[pe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,Z=!0),ye[pe].usedTimes++;const Ze=ye[F.__cacheKey];Ze!==void 0&&(ye[F.__cacheKey].usedTimes--,Ze.usedTimes===0&&C(L)),F.__cacheKey=pe,F.__webglTexture=ye[pe].texture}return Z}function ce(F,L,Z){return Math.floor(Math.floor(F/Z)/L)}function xe(F,L,Z,ge){const pe=F.updateRanges;if(pe.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,Z,ge,L.data);else{pe.sort((je,ke)=>je.start-ke.start);let Ze=0;for(let je=1;je<pe.length;je++){const ke=pe[Ze],pt=pe[je],rt=ke.start+ke.count,nt=ce(pt.start,L.width,4),dt=ce(ke.start,L.width,4);pt.start<=rt+1&&nt===dt&&ce(pt.start+pt.count-1,L.width,4)===nt?ke.count=Math.max(ke.count,pt.start+pt.count-ke.start):(++Ze,pe[Ze]=pt)}pe.length=Ze+1;const Ie=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),ot=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let je=0,ke=pe.length;je<ke;je++){const pt=pe[je],rt=Math.floor(pt.start/4),nt=Math.ceil(pt.count/4),dt=rt%L.width,de=Math.floor(rt/L.width),it=nt,fe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,dt),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,dt,de,it,fe,Z,ge,L.data)}F.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ie),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,ot)}}function te(F,L,Z){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const ye=ae(F,L),pe=L.source;n.bindTexture(ge,F.__webglTexture,t.TEXTURE0+Z);const Ze=r.get(pe);if(pe.version!==Ze.__version||ye===!0){n.activeTexture(t.TEXTURE0+Z);const Ie=En.getPrimaries(En.workingColorSpace),Xe=L.colorSpace===Nu?null:En.getPrimaries(L.colorSpace),ot=L.colorSpace===Nu||Ie===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,ot);let je=v(L.image,!1,i.maxTextureSize);je=Pe(L,je);const ke=a.convert(L.format,L.colorSpace),pt=a.convert(L.type);let rt=w(L.internalFormat,ke,pt,L.colorSpace,L.isVideoTexture);X(ge,L);let nt;const dt=L.mipmaps,de=L.isVideoTexture!==!0,it=Ze.__version===void 0||ye===!0,fe=pe.dataReady,Le=T(L,je);if(L.isDepthTexture)rt=A(L.format===Yx,L.type),it&&(de?n.texStorage2D(t.TEXTURE_2D,1,rt,je.width,je.height):n.texImage2D(t.TEXTURE_2D,0,rt,je.width,je.height,0,ke,pt,null));else if(L.isDataTexture)if(dt.length>0){de&&it&&n.texStorage2D(t.TEXTURE_2D,Le,rt,dt[0].width,dt[0].height);for(let Ee=0,be=dt.length;Ee<be;Ee++)nt=dt[Ee],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Ee,0,0,nt.width,nt.height,ke,pt,nt.data):n.texImage2D(t.TEXTURE_2D,Ee,rt,nt.width,nt.height,0,ke,pt,nt.data);L.generateMipmaps=!1}else de?(it&&n.texStorage2D(t.TEXTURE_2D,Le,rt,je.width,je.height),fe&&xe(L,je,ke,pt)):n.texImage2D(t.TEXTURE_2D,0,rt,je.width,je.height,0,ke,pt,je.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&it&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Le,rt,dt[0].width,dt[0].height,je.depth);for(let Ee=0,be=dt.length;Ee<be;Ee++)if(nt=dt[Ee],L.format!==yo)if(ke!==null)if(de){if(fe)if(L.layerUpdates.size>0){const He=jF(nt.width,nt.height,L.format,L.type);for(const ut of L.layerUpdates){const _t=nt.data.subarray(ut*He/nt.data.BYTES_PER_ELEMENT,(ut+1)*He/nt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ee,0,0,ut,nt.width,nt.height,1,ke,_t)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ee,0,0,0,nt.width,nt.height,je.depth,ke,nt.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ee,rt,nt.width,nt.height,je.depth,0,nt.data,0,0);else Wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?fe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ee,0,0,0,nt.width,nt.height,je.depth,ke,pt,nt.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ee,rt,nt.width,nt.height,je.depth,0,ke,pt,nt.data)}else{de&&it&&n.texStorage2D(t.TEXTURE_2D,Le,rt,dt[0].width,dt[0].height);for(let Ee=0,be=dt.length;Ee<be;Ee++)nt=dt[Ee],L.format!==yo?ke!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ee,0,0,nt.width,nt.height,ke,nt.data):n.compressedTexImage2D(t.TEXTURE_2D,Ee,rt,nt.width,nt.height,0,nt.data):Wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?fe&&n.texSubImage2D(t.TEXTURE_2D,Ee,0,0,nt.width,nt.height,ke,pt,nt.data):n.texImage2D(t.TEXTURE_2D,Ee,rt,nt.width,nt.height,0,ke,pt,nt.data)}else if(L.isDataArrayTexture)if(de){if(it&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Le,rt,je.width,je.height,je.depth),fe)if(L.layerUpdates.size>0){const Ee=jF(je.width,je.height,L.format,L.type);for(const be of L.layerUpdates){const He=je.data.subarray(be*Ee/je.data.BYTES_PER_ELEMENT,(be+1)*Ee/je.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,be,je.width,je.height,1,ke,pt,He)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,je.width,je.height,je.depth,ke,pt,je.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,rt,je.width,je.height,je.depth,0,ke,pt,je.data);else if(L.isData3DTexture)de?(it&&n.texStorage3D(t.TEXTURE_3D,Le,rt,je.width,je.height,je.depth),fe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,je.width,je.height,je.depth,ke,pt,je.data)):n.texImage3D(t.TEXTURE_3D,0,rt,je.width,je.height,je.depth,0,ke,pt,je.data);else if(L.isFramebufferTexture){if(it)if(de)n.texStorage2D(t.TEXTURE_2D,Le,rt,je.width,je.height);else{let Ee=je.width,be=je.height;for(let He=0;He<Le;He++)n.texImage2D(t.TEXTURE_2D,He,rt,Ee,be,0,ke,pt,null),Ee>>=1,be>>=1}}else if(dt.length>0){if(de&&it){const Ee=ne(dt[0]);n.texStorage2D(t.TEXTURE_2D,Le,rt,Ee.width,Ee.height)}for(let Ee=0,be=dt.length;Ee<be;Ee++)nt=dt[Ee],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Ee,0,0,ke,pt,nt):n.texImage2D(t.TEXTURE_2D,Ee,rt,ke,pt,nt);L.generateMipmaps=!1}else if(de){if(it){const Ee=ne(je);n.texStorage2D(t.TEXTURE_2D,Le,rt,Ee.width,Ee.height)}fe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ke,pt,je)}else n.texImage2D(t.TEXTURE_2D,0,rt,ke,pt,je);b(L)&&x(ge),Ze.__version=pe.version,L.onUpdate&&L.onUpdate(L)}F.__version=L.version}function ve(F,L,Z){if(L.image.length!==6)return;const ge=ae(F,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,F.__webglTexture,t.TEXTURE0+Z);const pe=r.get(ye);if(ye.version!==pe.__version||ge===!0){n.activeTexture(t.TEXTURE0+Z);const Ze=En.getPrimaries(En.workingColorSpace),Ie=L.colorSpace===Nu?null:En.getPrimaries(L.colorSpace),Xe=L.colorSpace===Nu||Ze===Ie?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 ot=L.isCompressedTexture||L.image[0].isCompressedTexture,je=L.image[0]&&L.image[0].isDataTexture,ke=[];for(let be=0;be<6;be++)!ot&&!je?ke[be]=v(L.image[be],!0,i.maxCubemapSize):ke[be]=je?L.image[be].image:L.image[be],ke[be]=Pe(L,ke[be]);const pt=ke[0],rt=a.convert(L.format,L.colorSpace),nt=a.convert(L.type),dt=w(L.internalFormat,rt,nt,L.colorSpace),de=L.isVideoTexture!==!0,it=pe.__version===void 0||ge===!0,fe=ye.dataReady;let Le=T(L,pt);X(t.TEXTURE_CUBE_MAP,L);let Ee;if(ot){de&&it&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Le,dt,pt.width,pt.height);for(let be=0;be<6;be++){Ee=ke[be].mipmaps;for(let He=0;He<Ee.length;He++){const ut=Ee[He];L.format!==yo?rt!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,0,0,ut.width,ut.height,rt,ut.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,dt,ut.width,ut.height,0,ut.data):Wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,0,0,ut.width,ut.height,rt,nt,ut.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,dt,ut.width,ut.height,0,rt,nt,ut.data)}}}else{if(Ee=L.mipmaps,de&&it){Ee.length>0&&Le++;const be=ne(ke[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Le,dt,be.width,be.height)}for(let be=0;be<6;be++)if(je){de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,ke[be].width,ke[be].height,rt,nt,ke[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,dt,ke[be].width,ke[be].height,0,rt,nt,ke[be].data);for(let He=0;He<Ee.length;He++){const _t=Ee[He].image[be].image;de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,0,0,_t.width,_t.height,rt,nt,_t.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,dt,_t.width,_t.height,0,rt,nt,_t.data)}}else{de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,rt,nt,ke[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,dt,rt,nt,ke[be]);for(let He=0;He<Ee.length;He++){const ut=Ee[He];de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,0,0,rt,nt,ut.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,dt,rt,nt,ut.image[be])}}}b(L)&&x(t.TEXTURE_CUBE_MAP),pe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}F.__version=L.version}function De(F,L,Z,ge,ye,pe){const Ze=a.convert(Z.format,Z.colorSpace),Ie=a.convert(Z.type),Xe=w(Z.internalFormat,Ze,Ie,Z.colorSpace),ot=r.get(L),je=r.get(Z);if(je.__renderTarget=L,!ot.__hasExternalTextures){const ke=Math.max(1,L.width>>pe),pt=Math.max(1,L.height>>pe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,pe,Xe,ke,pt,L.depth,0,Ze,Ie,null):n.texImage2D(ye,pe,Xe,ke,pt,0,Ze,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,F),le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,ye,je.__webglTexture,0,ee(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,ye,je.__webglTexture,pe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(F,L,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,F),L.depthBuffer){const ge=L.depthTexture,ye=ge&&ge.isDepthTexture?ge.type:null,pe=A(L.stencilBuffer,ye),Ze=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=ee(L);le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ie,pe,L.width,L.height):Z?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ie,pe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,pe,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ze,t.RENDERBUFFER,F)}else{const ge=L.textures;for(let ye=0;ye<ge.length;ye++){const pe=ge[ye],Ze=a.convert(pe.format,pe.colorSpace),Ie=a.convert(pe.type),Xe=w(pe.internalFormat,Ze,Ie,pe.colorSpace),ot=ee(L);Z&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,Xe,L.width,L.height):le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ot,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function me(F,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,F),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ge=r.get(L.depthTexture);ge.__renderTarget=L,(!ge.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),B(L.depthTexture,0);const ye=ge.__webglTexture,pe=ee(L);if(L.depthTexture.format===Kx)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,pe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===Yx)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,pe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function we(F){const L=r.get(F),Z=F.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==F.depthTexture){const ge=F.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ge){const ye=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ge.removeEventListener("dispose",ye)};ge.addEventListener("dispose",ye),L.__depthDisposeCallback=ye}L.__boundDepthTexture=ge}if(F.depthTexture&&!L.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");const ge=F.texture.mipmaps;ge&&ge.length>0?me(L.__webglFramebuffer[0],F):me(L.__webglFramebuffer,F)}else if(Z){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]===void 0)L.__webglDepthbuffer[ge]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ge],F,!1);else{const ye=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,pe=L.__webglDepthbuffer[ge];t.bindRenderbuffer(t.RENDERBUFFER,pe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,pe)}}else{const ge=F.texture.mipmaps;if(ge&&ge.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,F,!1);else{const ye=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,pe=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,pe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,pe)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function se(F,L,Z){const ge=r.get(F);L!==void 0&&De(ge.__webglFramebuffer,F,F.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&we(F)}function st(F){const L=F.texture,Z=r.get(F),ge=r.get(L);F.addEventListener("dispose",N);const ye=F.textures,pe=F.isWebGLCubeRenderTarget===!0,Ze=ye.length>1;if(Ze||(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,s.memory.textures++),pe){Z.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer[Ie]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Z.__webglFramebuffer[Ie][Xe]=t.createFramebuffer()}else Z.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)Z.__webglFramebuffer[Ie]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if(Ze)for(let Ie=0,Xe=ye.length;Ie<Xe;Ie++){const ot=r.get(ye[Ie]);ot.__webglTexture===void 0&&(ot.__webglTexture=t.createTexture(),s.memory.textures++)}if(F.samples>0&&le(F)===!1){Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Ie=0;Ie<ye.length;Ie++){const Xe=ye[Ie];Z.__webglColorRenderbuffer[Ie]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[Ie]);const ot=a.convert(Xe.format,Xe.colorSpace),je=a.convert(Xe.type),ke=w(Xe.internalFormat,ot,je,Xe.colorSpace,F.isXRRenderTarget===!0),pt=ee(F);t.renderbufferStorageMultisample(t.RENDERBUFFER,pt,ke,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ie,t.RENDERBUFFER,Z.__webglColorRenderbuffer[Ie])}t.bindRenderbuffer(t.RENDERBUFFER,null),F.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),he(Z.__webglDepthRenderbuffer,F,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(pe){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),X(t.TEXTURE_CUBE_MAP,L);for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)De(Z.__webglFramebuffer[Ie][Xe],F,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Xe);else De(Z.__webglFramebuffer[Ie],F,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);b(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ze){for(let Ie=0,Xe=ye.length;Ie<Xe;Ie++){const ot=ye[Ie],je=r.get(ot);let ke=t.TEXTURE_2D;(F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(ke=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ke,je.__webglTexture),X(ke,ot),De(Z.__webglFramebuffer,F,ot,t.COLOR_ATTACHMENT0+Ie,ke,0),b(ot)&&x(ke)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(Ie=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ie,ge.__webglTexture),X(Ie,L),L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)De(Z.__webglFramebuffer[Xe],F,L,t.COLOR_ATTACHMENT0,Ie,Xe);else De(Z.__webglFramebuffer,F,L,t.COLOR_ATTACHMENT0,Ie,0);b(L)&&x(Ie),n.unbindTexture()}F.depthBuffer&&we(F)}function z(F){const L=F.textures;for(let Z=0,ge=L.length;Z<ge;Z++){const ye=L[Z];if(b(ye)){const pe=M(F),Ze=r.get(ye).__webglTexture;n.bindTexture(pe,Ze),x(pe),n.unbindTexture()}}}const q=[],ie=[];function Q(F){if(F.samples>0){if(le(F)===!1){const L=F.textures,Z=F.width,ge=F.height;let ye=t.COLOR_BUFFER_BIT;const pe=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ze=r.get(F),Ie=L.length>1;if(Ie)for(let ot=0;ot<L.length;ot++)n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ze.__webglMultisampledFramebuffer);const Xe=F.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglFramebuffer);for(let ot=0;ot<L.length;ot++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ie){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ze.__webglColorRenderbuffer[ot]);const je=r.get(L[ot]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,je,0)}t.blitFramebuffer(0,0,Z,ge,0,0,Z,ge,ye,t.NEAREST),l===!0&&(q.length=0,ie.length=0,q.push(t.COLOR_ATTACHMENT0+ot),F.depthBuffer&&F.resolveDepthBuffer===!1&&(q.push(pe),ie.push(pe),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,q))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ie)for(let ot=0;ot<L.length;ot++){n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,Ze.__webglColorRenderbuffer[ot]);const je=r.get(L[ot]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ze.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&l){const L=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function ee(F){return Math.min(i.maxSamples,F.samples)}function le(F){const L=r.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Re(F){const L=s.render.frame;u.get(F)!==L&&(u.set(F,L),F.update())}function Pe(F,L){const Z=F.colorSpace,ge=F.format,ye=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||Z!==Kp&&Z!==Nu&&(En.getTransfer(Z)===Bn?(ge!==yo||ye!==tl)&&Wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):kr("WebGLTextures: Unsupported texture color space:",Z)),L}function ne(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(c.width=F.naturalWidth||F.width,c.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(c.width=F.displayWidth,c.height=F.displayHeight):(c.width=F.width,c.height=F.height),c}this.allocateTextureUnit=H,this.resetTextureUnits=I,this.setTexture2D=B,this.setTexture2DArray=V,this.setTexture3D=G,this.setTextureCube=K,this.rebindTextures=se,this.setupRenderTarget=st,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=De,this.useMultisampledRTT=le}function Sme(t,e){function n(r,i=Nu){let a;const s=En.getTransfer(i);if(r===tl)return t.UNSIGNED_BYTE;if(r===YP)return t.UNSIGNED_SHORT_4_4_4_4;if(r===ZP)return t.UNSIGNED_SHORT_5_5_5_1;if(r===T9)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===C9)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===E9)return t.BYTE;if(r===A9)return t.SHORT;if(r===qx)return t.UNSIGNED_SHORT;if(r===KP)return t.INT;if(r===Tf)return t.UNSIGNED_INT;if(r===tc)return t.FLOAT;if(r===_m)return t.HALF_FLOAT;if(r===N9)return t.ALPHA;if(r===R9)return t.RGB;if(r===yo)return t.RGBA;if(r===Kx)return t.DEPTH_COMPONENT;if(r===Yx)return t.DEPTH_STENCIL;if(r===P9)return t.RED;if(r===QP)return t.RED_INTEGER;if(r===JP)return t.RG;if(r===ek)return t.RG_INTEGER;if(r===tk)return t.RGBA_INTEGER;if(r===g_||r===x_||r===v_||r===b_)if(s===Bn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===g_)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===x_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===v_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===b_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===g_)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===x_)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===v_)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===b_)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===ZN||r===QN||r===JN||r===e3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===ZN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===QN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===JN)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===e3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===t3||r===n3||r===r3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===t3||r===n3)return s===Bn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===r3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===i3||r===a3||r===s3||r===o3||r===l3||r===c3||r===u3||r===d3||r===f3||r===h3||r===p3||r===m3||r===g3||r===x3)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===i3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===a3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===s3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===o3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===l3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===c3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===u3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===d3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===f3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===h3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===p3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===m3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===g3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===x3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===v3||r===b3||r===y3)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===v3)return s===Bn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===b3)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===y3)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===_3||r===S3||r===w3||r===M3)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===_3)return a.COMPRESSED_RED_RGTC1_EXT;if(r===S3)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===w3)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===M3)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Xx?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const wme=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,Mme=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class Eme{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new Q9(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 gc({vertexShader:wme,fragmentShader:Mme,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new nl(new ok(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let Ame=class extends qf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,f=null,g=null,m=null,y=null;const v=typeof XRWebGLBinding<"u",b=new Eme,x={},M=n.getContextAttributes();let w=null,A=null;const T=[],R=[],N=new an;let j=null;const C=new Us;C.viewport=new $r;const k=new Us;k.viewport=new $r;const U=[C,k],I=new $ue;let H=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let ve=T[te];return ve===void 0&&(ve=new sT,T[te]=ve),ve.getTargetRaySpace()},this.getControllerGrip=function(te){let ve=T[te];return ve===void 0&&(ve=new sT,T[te]=ve),ve.getGripSpace()},this.getHand=function(te){let ve=T[te];return ve===void 0&&(ve=new sT,T[te]=ve),ve.getHandSpace()};function B(te){const ve=R.indexOf(te.inputSource);if(ve===-1)return;const De=T[ve];De!==void 0&&(De.update(te.inputSource,te.frame,c||s),De.dispatchEvent({type:te.type,data:te.inputSource}))}function V(){i.removeEventListener("select",B),i.removeEventListener("selectstart",B),i.removeEventListener("selectend",B),i.removeEventListener("squeeze",B),i.removeEventListener("squeezestart",B),i.removeEventListener("squeezeend",B),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",G);for(let te=0;te<T.length;te++){const ve=R[te];ve!==null&&(R[te]=null,T[te].disconnect(ve))}H=null,O=null,b.reset();for(const te in x)delete x[te];e.setRenderTarget(w),m=null,g=null,f=null,i=null,A=null,xe.stop(),r.isPresenting=!1,e.setPixelRatio(j),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){a=te,r.isPresenting===!0&&Wt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){o=te,r.isPresenting===!0&&Wt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(te){c=te},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return y},this.getSession=function(){return i},this.setSession=async function(te){if(i=te,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",B),i.addEventListener("selectstart",B),i.addEventListener("selectend",B),i.addEventListener("squeeze",B),i.addEventListener("squeezestart",B),i.addEventListener("squeezeend",B),i.addEventListener("end",V),i.addEventListener("inputsourceschange",G),M.xrCompatible!==!0&&await n.makeXRCompatible(),j=e.getPixelRatio(),e.getSize(N),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let De=null,he=null,me=null;M.depth&&(me=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,De=M.stencil?Yx:Kx,he=M.stencil?Xx:Tf);const we={colorFormat:n.RGBA8,depthFormat:me,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(we),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new Nf(g.textureWidth,g.textureHeight,{format:yo,type:tl,depthTexture:new Z9(g.textureWidth,g.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,De),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const De={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,De),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new Nf(m.framebufferWidth,m.framebufferHeight,{format:yo,type:tl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await i.requestReferenceSpace(o),xe.setContext(i),xe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function G(te){for(let ve=0;ve<te.removed.length;ve++){const De=te.removed[ve],he=R.indexOf(De);he>=0&&(R[he]=null,T[he].disconnect(De))}for(let ve=0;ve<te.added.length;ve++){const De=te.added[ve];let he=R.indexOf(De);if(he===-1){for(let we=0;we<T.length;we++)if(we>=R.length){R.push(De),he=we;break}else if(R[we]===null){R[we]=De,he=we;break}if(he===-1)break}const me=T[he];me&&me.connect(De)}}const K=new Ge,Y=new Ge;function oe(te,ve,De){K.setFromMatrixPosition(ve.matrixWorld),Y.setFromMatrixPosition(De.matrixWorld);const he=K.distanceTo(Y),me=ve.projectionMatrix.elements,we=De.projectionMatrix.elements,se=me[14]/(me[10]-1),st=me[14]/(me[10]+1),z=(me[9]+1)/me[5],q=(me[9]-1)/me[5],ie=(me[8]-1)/me[0],Q=(we[8]+1)/we[0],ee=se*ie,le=se*Q,Re=he/(-ie+Q),Pe=Re*-ie;if(ve.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(Pe),te.translateZ(Re),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert(),me[10]===-1)te.projectionMatrix.copy(ve.projectionMatrix),te.projectionMatrixInverse.copy(ve.projectionMatrixInverse);else{const ne=se+Re,F=st+Re,L=ee-Pe,Z=le+(he-Pe),ge=z*st/F*ne,ye=q*st/F*ne;te.projectionMatrix.makePerspective(L,Z,ge,ye,ne,F),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}}function $(te,ve){ve===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(ve.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(i===null)return;let ve=te.near,De=te.far;b.texture!==null&&(b.depthNear>0&&(ve=b.depthNear),b.depthFar>0&&(De=b.depthFar)),I.near=k.near=C.near=ve,I.far=k.far=C.far=De,(H!==I.near||O!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),H=I.near,O=I.far),I.layers.mask=te.layers.mask|6,C.layers.mask=I.layers.mask&3,k.layers.mask=I.layers.mask&5;const he=te.parent,me=I.cameras;$(I,he);for(let we=0;we<me.length;we++)$(me[we],he);me.length===2?oe(I,C,k):I.projectionMatrix.copy(C.projectionMatrix),X(te,I,he)};function X(te,ve,De){De===null?te.matrix.copy(ve.matrixWorld):(te.matrix.copy(De.matrixWorld),te.matrix.invert(),te.matrix.multiply(ve.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(ve.projectionMatrix),te.projectionMatrixInverse.copy(ve.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=E3*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(te){l=te,g!==null&&(g.fixedFoveation=te),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=te)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(I)},this.getCameraTexture=function(te){return x[te]};let ae=null;function ce(te,ve){if(u=ve.getViewerPose(c||s),y=ve,u!==null){const De=u.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let he=!1;De.length!==I.cameras.length&&(I.cameras.length=0,he=!0);for(let st=0;st<De.length;st++){const z=De[st];let q=null;if(m!==null)q=m.getViewport(z);else{const Q=f.getViewSubImage(g,z);q=Q.viewport,st===0&&(e.setRenderTargetTextures(A,Q.colorTexture,Q.depthStencilTexture),e.setRenderTarget(A))}let ie=U[st];ie===void 0&&(ie=new Us,ie.layers.enable(st),ie.viewport=new $r,U[st]=ie),ie.matrix.fromArray(z.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(z.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(q.x,q.y,q.width,q.height),st===0&&(I.matrix.copy(ie.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),he===!0&&I.cameras.push(ie)}const me=i.enabledFeatures;if(me&&me.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const st=f.getDepthInformation(De[0]);st&&st.isValid&&st.texture&&b.init(st,i.renderState)}if(me&&me.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let st=0;st<De.length;st++){const z=De[st].camera;if(z){let q=x[z];q||(q=new Q9,x[z]=q);const ie=f.getCameraImage(z);q.sourceTexture=ie}}}}for(let De=0;De<T.length;De++){const he=R[De],me=T[De];he!==null&&me!==void 0&&me.update(he,ve,c||s)}ae&&ae(te,ve),ve.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ve}),y=null}const xe=new nW;xe.setAnimationLoop(ce),this.setAnimationLoop=function(te){ae=te},this.dispose=function(){}}};const Id=new Zu,Tme=new qr;function Cme(t,e){function n(b,x){b.matrixAutoUpdate===!0&&b.updateMatrix(),x.value.copy(b.matrix)}function r(b,x){x.color.getRGB(b.fogColor.value,q9(t)),x.isFog?(b.fogNear.value=x.near,b.fogFar.value=x.far):x.isFogExp2&&(b.fogDensity.value=x.density)}function i(b,x,M,w,A){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(b,x):x.isMeshToonMaterial?(a(b,x),f(b,x)):x.isMeshPhongMaterial?(a(b,x),u(b,x)):x.isMeshStandardMaterial?(a(b,x),g(b,x),x.isMeshPhysicalMaterial&&m(b,x,A)):x.isMeshMatcapMaterial?(a(b,x),y(b,x)):x.isMeshDepthMaterial?a(b,x):x.isMeshDistanceMaterial?(a(b,x),v(b,x)):x.isMeshNormalMaterial?a(b,x):x.isLineBasicMaterial?(s(b,x),x.isLineDashedMaterial&&o(b,x)):x.isPointsMaterial?l(b,x,M,w):x.isSpriteMaterial?c(b,x):x.isShadowMaterial?(b.color.value.copy(x.color),b.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(b,x){b.opacity.value=x.opacity,x.color&&b.diffuse.value.copy(x.color),x.emissive&&b.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(b.map.value=x.map,n(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.bumpMap&&(b.bumpMap.value=x.bumpMap,n(x.bumpMap,b.bumpMapTransform),b.bumpScale.value=x.bumpScale,x.side===Fa&&(b.bumpScale.value*=-1)),x.normalMap&&(b.normalMap.value=x.normalMap,n(x.normalMap,b.normalMapTransform),b.normalScale.value.copy(x.normalScale),x.side===Fa&&b.normalScale.value.negate()),x.displacementMap&&(b.displacementMap.value=x.displacementMap,n(x.displacementMap,b.displacementMapTransform),b.displacementScale.value=x.displacementScale,b.displacementBias.value=x.displacementBias),x.emissiveMap&&(b.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,b.emissiveMapTransform)),x.specularMap&&(b.specularMap.value=x.specularMap,n(x.specularMap,b.specularMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest);const M=e.get(x),w=M.envMap,A=M.envMapRotation;w&&(b.envMap.value=w,Id.copy(A),Id.x*=-1,Id.y*=-1,Id.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Id.y*=-1,Id.z*=-1),b.envMapRotation.value.setFromMatrix4(Tme.makeRotationFromEuler(Id)),b.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=x.reflectivity,b.ior.value=x.ior,b.refractionRatio.value=x.refractionRatio),x.lightMap&&(b.lightMap.value=x.lightMap,b.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,b.lightMapTransform)),x.aoMap&&(b.aoMap.value=x.aoMap,b.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,b.aoMapTransform))}function s(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,x.map&&(b.map.value=x.map,n(x.map,b.mapTransform))}function o(b,x){b.dashSize.value=x.dashSize,b.totalSize.value=x.dashSize+x.gapSize,b.scale.value=x.scale}function l(b,x,M,w){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.size.value=x.size*M,b.scale.value=w*.5,x.map&&(b.map.value=x.map,n(x.map,b.uvTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function c(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.rotation.value=x.rotation,x.map&&(b.map.value=x.map,n(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function u(b,x){b.specular.value.copy(x.specular),b.shininess.value=Math.max(x.shininess,1e-4)}function f(b,x){x.gradientMap&&(b.gradientMap.value=x.gradientMap)}function g(b,x){b.metalness.value=x.metalness,x.metalnessMap&&(b.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,b.metalnessMapTransform)),b.roughness.value=x.roughness,x.roughnessMap&&(b.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,b.roughnessMapTransform)),x.envMap&&(b.envMapIntensity.value=x.envMapIntensity)}function m(b,x,M){b.ior.value=x.ior,x.sheen>0&&(b.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),b.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(b.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,b.sheenColorMapTransform)),x.sheenRoughnessMap&&(b.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,b.sheenRoughnessMapTransform))),x.clearcoat>0&&(b.clearcoat.value=x.clearcoat,b.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(b.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,b.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(b.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Fa&&b.clearcoatNormalScale.value.negate())),x.dispersion>0&&(b.dispersion.value=x.dispersion),x.iridescence>0&&(b.iridescence.value=x.iridescence,b.iridescenceIOR.value=x.iridescenceIOR,b.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(b.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,b.iridescenceMapTransform)),x.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),x.transmission>0&&(b.transmission.value=x.transmission,b.transmissionSamplerMap.value=M.texture,b.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(b.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,b.transmissionMapTransform)),b.thickness.value=x.thickness,x.thicknessMap&&(b.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=x.attenuationDistance,b.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(b.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(b.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=x.specularIntensity,b.specularColor.value.copy(x.specularColor),x.specularColorMap&&(b.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,b.specularColorMapTransform)),x.specularIntensityMap&&(b.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,b.specularIntensityMapTransform))}function y(b,x){x.matcap&&(b.matcap.value=x.matcap)}function v(b,x){const M=e.get(x).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Nme(t,e,n,r){let i={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,w){const A=w.program;r.uniformBlockBinding(M,A)}function c(M,w){let A=i[M.id];A===void 0&&(y(M),A=u(M),i[M.id]=A,M.addEventListener("dispose",b));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;a[M.id]!==R&&(g(M),a[M.id]=R)}function u(M){const w=f();M.__bindingPointIndex=w;const A=t.createBuffer(),T=M.__size,R=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,R),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return kr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let R=0,N=A.length;R<N;R++){const j=Array.isArray(A[R])?A[R]:[A[R]];for(let C=0,k=j.length;C<k;C++){const U=j[C];if(m(U,R,C,T)===!0){const I=U.__offset,H=Array.isArray(U.value)?U.value:[U.value];let O=0;for(let B=0;B<H.length;B++){const V=H[B],G=v(V);typeof V=="number"||typeof V=="boolean"?(U.__data[0]=V,t.bufferSubData(t.UNIFORM_BUFFER,I+O,U.__data)):V.isMatrix3?(U.__data[0]=V.elements[0],U.__data[1]=V.elements[1],U.__data[2]=V.elements[2],U.__data[3]=0,U.__data[4]=V.elements[3],U.__data[5]=V.elements[4],U.__data[6]=V.elements[5],U.__data[7]=0,U.__data[8]=V.elements[6],U.__data[9]=V.elements[7],U.__data[10]=V.elements[8],U.__data[11]=0):(V.toArray(U.__data,O),O+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,A,T){const R=M.value,N=w+"_"+A;if(T[N]===void 0)return typeof R=="number"||typeof R=="boolean"?T[N]=R:T[N]=R.clone(),!0;{const j=T[N];if(typeof R=="number"||typeof R=="boolean"){if(j!==R)return T[N]=R,!0}else if(j.equals(R)===!1)return j.copy(R),!0}return!1}function y(M){const w=M.uniforms;let A=0;const T=16;for(let N=0,j=w.length;N<j;N++){const C=Array.isArray(w[N])?w[N]:[w[N]];for(let k=0,U=C.length;k<U;k++){const I=C[k],H=Array.isArray(I.value)?I.value:[I.value];for(let O=0,B=H.length;O<B;O++){const V=H[O],G=v(V),K=A%T,Y=K%G.boundary,oe=K+Y;A+=Y,oe!==0&&T-oe<G.storage&&(A+=T-oe),I.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=G.storage}}}const R=A%T;return R>0&&(A+=T-R),M.__size=A,M.__cache={},this}function v(M){const w={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?Wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Wt("WebGLRenderer: Unsupported uniform value type.",M),w}function b(M){const w=M.target;w.removeEventListener("dispose",b);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:l,update:c,dispose:x}}const Rme=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Ll=null;function Pme(){return Ll===null&&(Ll=new Pue(Rme,32,32,JP,_m),Ll.minFilter=$s,Ll.magFilter=$s,Ll.wrapS=ec,Ll.wrapT=ec,Ll.generateMipmaps=!1,Ll.needsUpdate=!0),Ll}let kme=class{constructor(e={}){const{canvas:n=nue(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=s;const y=new Set([tk,ek,QP]),v=new Set([tl,Tf,qx,Xx,YP,ZP]),b=new Uint32Array(4),x=new Int32Array(4);let M=null,w=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=zu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const R=this;let N=!1;this._outputColorSpace=Ls;let j=0,C=0,k=null,U=-1,I=null;const H=new $r,O=new $r;let B=null;const V=new bn(0);let G=0,K=n.width,Y=n.height,oe=1,$=null,X=null;const ae=new $r(0,0,K,Y),ce=new $r(0,0,K,Y);let xe=!1;const te=new sk;let ve=!1,De=!1;const he=new qr,me=new Ge,we=new $r,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let st=!1;function z(){return k===null?oe:1}let q=r;function ie(J,_e){return n.getContext(J,_e)}try{const J={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${qP}`),n.addEventListener("webglcontextlost",Ee,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",He,!1),q===null){const _e="webgl2";if(q=ie(_e,J),q===null)throw ie(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(J){throw J("WebGLRenderer: "+J.message),J}let Q,ee,le,Re,Pe,ne,F,L,Z,ge,ye,pe,Ze,Ie,Xe,ot,je,ke,pt,rt,nt,dt,de,it;function fe(){Q=new zhe(q),Q.init(),dt=new Sme(q,Q),ee=new Phe(q,Q,e,dt),le=new yme(q,Q),ee.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),Re=new $he(q),Pe=new ome,ne=new _me(q,Q,le,Pe,ee,dt,Re),F=new Dhe(R),L=new Fhe(R),Z=new que(q),de=new Nhe(q,Z),ge=new Bhe(q,Z,Re,de),ye=new Ghe(q,ge,Z,Re),pt=new Vhe(q,ee,ne),ot=new khe(Pe),pe=new sme(R,F,L,Q,ee,de,ot),Ze=new Cme(R,Pe),Ie=new cme,Xe=new mme(Q),ke=new Che(R,F,L,le,ye,m,l),je=new vme(R,ye,ee),it=new Nme(q,Re,ee,le),rt=new Rhe(q,Q,Re),nt=new Hhe(q,Q,Re),Re.programs=pe.programs,R.capabilities=ee,R.extensions=Q,R.properties=Pe,R.renderLists=Ie,R.shadowMap=je,R.state=le,R.info=Re}fe();const Le=new Ame(R,q);this.xr=Le,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const J=Q.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){const J=Q.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return oe},this.setPixelRatio=function(J){J!==void 0&&(oe=J,this.setSize(K,Y,!1))},this.getSize=function(J){return J.set(K,Y)},this.setSize=function(J,_e,Ne=!0){if(Le.isPresenting){Wt("WebGLRenderer: Can't change size while VR device is presenting.");return}K=J,Y=_e,n.width=Math.floor(J*oe),n.height=Math.floor(_e*oe),Ne===!0&&(n.style.width=J+"px",n.style.height=_e+"px"),this.setViewport(0,0,J,_e)},this.getDrawingBufferSize=function(J){return J.set(K*oe,Y*oe).floor()},this.setDrawingBufferSize=function(J,_e,Ne){K=J,Y=_e,oe=Ne,n.width=Math.floor(J*Ne),n.height=Math.floor(_e*Ne),this.setViewport(0,0,J,_e)},this.getCurrentViewport=function(J){return J.copy(H)},this.getViewport=function(J){return J.copy(ae)},this.setViewport=function(J,_e,Ne,Ce){J.isVector4?ae.set(J.x,J.y,J.z,J.w):ae.set(J,_e,Ne,Ce),le.viewport(H.copy(ae).multiplyScalar(oe).round())},this.getScissor=function(J){return J.copy(ce)},this.setScissor=function(J,_e,Ne,Ce){J.isVector4?ce.set(J.x,J.y,J.z,J.w):ce.set(J,_e,Ne,Ce),le.scissor(O.copy(ce).multiplyScalar(oe).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(J){le.setScissorTest(xe=J)},this.setOpaqueSort=function(J){$=J},this.setTransparentSort=function(J){X=J},this.getClearColor=function(J){return J.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor(...arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha(...arguments)},this.clear=function(J=!0,_e=!0,Ne=!0){let Ce=0;if(J){let Me=!1;if(k!==null){const Qe=k.texture.format;Me=y.has(Qe)}if(Me){const Qe=k.texture.type,ft=v.has(Qe),vt=ke.getClearColor(),xt=ke.getClearAlpha(),Pt=vt.r,Mt=vt.g,mt=vt.b;ft?(b[0]=Pt,b[1]=Mt,b[2]=mt,b[3]=xt,q.clearBufferuiv(q.COLOR,0,b)):(x[0]=Pt,x[1]=Mt,x[2]=mt,x[3]=xt,q.clearBufferiv(q.COLOR,0,x))}else Ce|=q.COLOR_BUFFER_BIT}_e&&(Ce|=q.DEPTH_BUFFER_BIT),Ne&&(Ce|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(Ce)},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",Ee,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",He,!1),ke.dispose(),Ie.dispose(),Xe.dispose(),Pe.dispose(),F.dispose(),L.dispose(),ye.dispose(),de.dispose(),it.dispose(),pe.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",qn),Le.removeEventListener("sessionend",pi),Zr.stop()};function Ee(J){J.preventDefault(),fF("WebGLRenderer: Context Lost."),N=!0}function be(){fF("WebGLRenderer: Context Restored."),N=!1;const J=Re.autoReset,_e=je.enabled,Ne=je.autoUpdate,Ce=je.needsUpdate,Me=je.type;fe(),Re.autoReset=J,je.enabled=_e,je.autoUpdate=Ne,je.needsUpdate=Ce,je.type=Me}function He(J){kr("WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function ut(J){const _e=J.target;_e.removeEventListener("dispose",ut),_t(_e)}function _t(J){Rt(J),Pe.remove(J)}function Rt(J){const _e=Pe.get(J).programs;_e!==void 0&&(_e.forEach(function(Ne){pe.releaseProgram(Ne)}),J.isShaderMaterial&&pe.releaseShaderCache(J))}this.renderBufferDirect=function(J,_e,Ne,Ce,Me,Qe){_e===null&&(_e=se);const ft=Me.isMesh&&Me.matrixWorld.determinant()<0,vt=ue(J,_e,Ne,Ce,Me);le.setMaterial(Ce,ft);let xt=Ne.index,Pt=1;if(Ce.wireframe===!0){if(xt=ge.getWireframeAttribute(Ne),xt===void 0)return;Pt=2}const Mt=Ne.drawRange,mt=Ne.attributes.position;let Gt=Mt.start*Pt,Lt=(Mt.start+Mt.count)*Pt;Qe!==null&&(Gt=Math.max(Gt,Qe.start*Pt),Lt=Math.min(Lt,(Qe.start+Qe.count)*Pt)),xt!==null?(Gt=Math.max(Gt,0),Lt=Math.min(Lt,xt.count)):mt!=null&&(Gt=Math.max(Gt,0),Lt=Math.min(Lt,mt.count));const en=Lt-Gt;if(en<0||en===1/0)return;de.setup(Me,Ce,vt,Ne,xt);let un,gn=rt;if(xt!==null&&(un=Z.get(xt),gn=nt,gn.setIndex(un)),Me.isMesh)Ce.wireframe===!0?(le.setLineWidth(Ce.wireframeLinewidth*z()),gn.setMode(q.LINES)):gn.setMode(q.TRIANGLES);else if(Me.isLine){let Ot=Ce.linewidth;Ot===void 0&&(Ot=1),le.setLineWidth(Ot*z()),Me.isLineSegments?gn.setMode(q.LINES):Me.isLineLoop?gn.setMode(q.LINE_LOOP):gn.setMode(q.LINE_STRIP)}else Me.isPoints?gn.setMode(q.POINTS):Me.isSprite&&gn.setMode(q.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)Zx("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gn.renderMultiDrawInstances(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount,Me._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))gn.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{const Ot=Me._multiDrawStarts,Xt=Me._multiDrawCounts,Zt=Me._multiDrawCount,br=xt?Z.get(xt).bytesPerElement:1,Tr=Pe.get(Ce).currentProgram.getUniforms();for(let Nn=0;Nn<Zt;Nn++)Tr.setValue(q,"_gl_DrawID",Nn),gn.render(Ot[Nn]/br,Xt[Nn])}else if(Me.isInstancedMesh)gn.renderInstances(Gt,en,Me.count);else if(Ne.isInstancedBufferGeometry){const Ot=Ne._maxInstanceCount!==void 0?Ne._maxInstanceCount:1/0,Xt=Math.min(Ne.instanceCount,Ot);gn.renderInstances(Gt,en,Xt)}else gn.render(Gt,en)};function ln(J,_e,Ne){J.transparent===!0&&J.side===Ho&&J.forceSinglePass===!1?(J.side=Fa,J.needsUpdate=!0,Ar(J,_e,Ne),J.side=Yu,J.needsUpdate=!0,Ar(J,_e,Ne),J.side=Ho):Ar(J,_e,Ne)}this.compile=function(J,_e,Ne=null){Ne===null&&(Ne=J),w=Xe.get(Ne),w.init(_e),T.push(w),Ne.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),J!==Ne&&J.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),w.setupLights();const Ce=new Set;return J.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;const Qe=Me.material;if(Qe)if(Array.isArray(Qe))for(let ft=0;ft<Qe.length;ft++){const vt=Qe[ft];ln(vt,Ne,Me),Ce.add(vt)}else ln(Qe,Ne,Me),Ce.add(Qe)}),w=T.pop(),Ce},this.compileAsync=function(J,_e,Ne=null){const Ce=this.compile(J,_e,Ne);return new Promise(Me=>{function Qe(){if(Ce.forEach(function(ft){Pe.get(ft).currentProgram.isReady()&&Ce.delete(ft)}),Ce.size===0){Me(J);return}setTimeout(Qe,10)}Q.get("KHR_parallel_shader_compile")!==null?Qe():setTimeout(Qe,10)})};let Dt=null;function Rn(J){Dt&&Dt(J)}function qn(){Zr.stop()}function pi(){Zr.start()}const Zr=new nW;Zr.setAnimationLoop(Rn),typeof self<"u"&&Zr.setContext(self),this.setAnimationLoop=function(J){Dt=J,Le.setAnimationLoop(J),J===null?Zr.stop():Zr.start()},Le.addEventListener("sessionstart",qn),Le.addEventListener("sessionend",pi),this.render=function(J,_e){if(_e!==void 0&&_e.isCamera!==!0){kr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(_e),_e=Le.getCamera()),J.isScene===!0&&J.onBeforeRender(R,J,_e,k),w=Xe.get(J,T.length),w.init(_e),T.push(w),he.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),te.setFromProjectionMatrix(he,Go,_e.reversedDepth),De=this.localClippingEnabled,ve=ot.init(this.clippingPlanes,De),M=Ie.get(J,A.length),M.init(),A.push(M),Le.enabled===!0&&Le.isPresenting===!0){const Qe=R.xr.getDepthSensingMesh();Qe!==null&&mi(Qe,_e,-1/0,R.sortObjects)}mi(J,_e,0,R.sortObjects),M.finish(),R.sortObjects===!0&&M.sort($,X),st=Le.enabled===!1||Le.isPresenting===!1||Le.hasDepthSensing()===!1,st&&ke.addToRenderList(M,J),this.info.render.frame++,ve===!0&&ot.beginShadows();const Ne=w.state.shadowsArray;je.render(Ne,J,_e),ve===!0&&ot.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ce=M.opaque,Me=M.transmissive;if(w.setupLights(),_e.isArrayCamera){const Qe=_e.cameras;if(Me.length>0)for(let ft=0,vt=Qe.length;ft<vt;ft++){const xt=Qe[ft];qi(Ce,Me,J,xt)}st&&ke.render(J);for(let ft=0,vt=Qe.length;ft<vt;ft++){const xt=Qe[ft];Pi(M,J,xt,xt.viewport)}}else Me.length>0&&qi(Ce,Me,J,_e),st&&ke.render(J),Pi(M,J,_e);k!==null&&C===0&&(ne.updateMultisampleRenderTarget(k),ne.updateRenderTargetMipmap(k)),J.isScene===!0&&J.onAfterRender(R,J,_e),de.resetDefaultState(),U=-1,I=null,T.pop(),T.length>0?(w=T[T.length-1],ve===!0&&ot.setGlobalState(R.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function mi(J,_e,Ne,Ce){if(J.visible===!1)return;if(J.layers.test(_e.layers)){if(J.isGroup)Ne=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(_e);else if(J.isLight)w.pushLight(J),J.castShadow&&w.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||te.intersectsSprite(J)){Ce&&we.setFromMatrixPosition(J.matrixWorld).applyMatrix4(he);const ft=ye.update(J),vt=J.material;vt.visible&&M.push(J,ft,vt,Ne,we.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(!J.frustumCulled||te.intersectsObject(J))){const ft=ye.update(J),vt=J.material;if(Ce&&(J.boundingSphere!==void 0?(J.boundingSphere===null&&J.computeBoundingSphere(),we.copy(J.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),we.copy(ft.boundingSphere.center)),we.applyMatrix4(J.matrixWorld).applyMatrix4(he)),Array.isArray(vt)){const xt=ft.groups;for(let Pt=0,Mt=xt.length;Pt<Mt;Pt++){const mt=xt[Pt],Gt=vt[mt.materialIndex];Gt&&Gt.visible&&M.push(J,ft,Gt,Ne,we.z,mt)}}else vt.visible&&M.push(J,ft,vt,Ne,we.z,null)}}const Qe=J.children;for(let ft=0,vt=Qe.length;ft<vt;ft++)mi(Qe[ft],_e,Ne,Ce)}function Pi(J,_e,Ne,Ce){const{opaque:Me,transmissive:Qe,transparent:ft}=J;w.setupLightsView(Ne),ve===!0&&ot.setGlobalState(R.clippingPlanes,Ne),Ce&&le.viewport(H.copy(Ce)),Me.length>0&&Lr(Me,_e,Ne),Qe.length>0&&Lr(Qe,_e,Ne),ft.length>0&&Lr(ft,_e,Ne),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function qi(J,_e,Ne,Ce){if((Ne.isScene===!0?Ne.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Ce.id]===void 0&&(w.state.transmissionRenderTarget[Ce.id]=new Nf(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?_m:tl,minFilter:tf,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:En.workingColorSpace}));const Qe=w.state.transmissionRenderTarget[Ce.id],ft=Ce.viewport||H;Qe.setSize(ft.z*R.transmissionResolutionScale,ft.w*R.transmissionResolutionScale);const vt=R.getRenderTarget(),xt=R.getActiveCubeFace(),Pt=R.getActiveMipmapLevel();R.setRenderTarget(Qe),R.getClearColor(V),G=R.getClearAlpha(),G<1&&R.setClearColor(16777215,.5),R.clear(),st&&ke.render(Ne);const Mt=R.toneMapping;R.toneMapping=zu;const mt=Ce.viewport;if(Ce.viewport!==void 0&&(Ce.viewport=void 0),w.setupLightsView(Ce),ve===!0&&ot.setGlobalState(R.clippingPlanes,Ce),Lr(J,Ne,Ce),ne.updateMultisampleRenderTarget(Qe),ne.updateRenderTargetMipmap(Qe),Q.has("WEBGL_multisampled_render_to_texture")===!1){let Gt=!1;for(let Lt=0,en=_e.length;Lt<en;Lt++){const un=_e[Lt],{object:gn,geometry:Ot,material:Xt,group:Zt}=un;if(Xt.side===Ho&&gn.layers.test(Ce.layers)){const br=Xt.side;Xt.side=Fa,Xt.needsUpdate=!0,hr(gn,Ne,Ce,Ot,Xt,Zt),Xt.side=br,Xt.needsUpdate=!0,Gt=!0}}Gt===!0&&(ne.updateMultisampleRenderTarget(Qe),ne.updateRenderTargetMipmap(Qe))}R.setRenderTarget(vt,xt,Pt),R.setClearColor(V,G),mt!==void 0&&(Ce.viewport=mt),R.toneMapping=Mt}function Lr(J,_e,Ne){const Ce=_e.isScene===!0?_e.overrideMaterial:null;for(let Me=0,Qe=J.length;Me<Qe;Me++){const ft=J[Me],{object:vt,geometry:xt,group:Pt}=ft;let Mt=ft.material;Mt.allowOverride===!0&&Ce!==null&&(Mt=Ce),vt.layers.test(Ne.layers)&&hr(vt,_e,Ne,xt,Mt,Pt)}}function hr(J,_e,Ne,Ce,Me,Qe){J.onBeforeRender(R,_e,Ne,Ce,Me,Qe),J.modelViewMatrix.multiplyMatrices(Ne.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Me.onBeforeRender(R,_e,Ne,Ce,J,Qe),Me.transparent===!0&&Me.side===Ho&&Me.forceSinglePass===!1?(Me.side=Fa,Me.needsUpdate=!0,R.renderBufferDirect(Ne,_e,Ce,Me,J,Qe),Me.side=Yu,Me.needsUpdate=!0,R.renderBufferDirect(Ne,_e,Ce,Me,J,Qe),Me.side=Ho):R.renderBufferDirect(Ne,_e,Ce,Me,J,Qe),J.onAfterRender(R,_e,Ne,Ce,Me,Qe)}function Ar(J,_e,Ne){_e.isScene!==!0&&(_e=se);const Ce=Pe.get(J),Me=w.state.lights,Qe=w.state.shadowsArray,ft=Me.state.version,vt=pe.getParameters(J,Me.state,Qe,_e,Ne),xt=pe.getProgramCacheKey(vt);let Pt=Ce.programs;Ce.environment=J.isMeshStandardMaterial?_e.environment:null,Ce.fog=_e.fog,Ce.envMap=(J.isMeshStandardMaterial?L:F).get(J.envMap||Ce.environment),Ce.envMapRotation=Ce.environment!==null&&J.envMap===null?_e.environmentRotation:J.envMapRotation,Pt===void 0&&(J.addEventListener("dispose",ut),Pt=new Map,Ce.programs=Pt);let Mt=Pt.get(xt);if(Mt!==void 0){if(Ce.currentProgram===Mt&&Ce.lightsStateVersion===ft)return Oc(J,vt),Mt}else vt.uniforms=pe.getUniforms(J),J.onBeforeCompile(vt,R),Mt=pe.acquireProgram(vt,xt),Pt.set(xt,Mt),Ce.uniforms=vt.uniforms;const mt=Ce.uniforms;return(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(mt.clippingPlanes=ot.uniform),Oc(J,vt),Ce.needsLights=qe(J),Ce.lightsStateVersion=ft,Ce.needsLights&&(mt.ambientLightColor.value=Me.state.ambient,mt.lightProbe.value=Me.state.probe,mt.directionalLights.value=Me.state.directional,mt.directionalLightShadows.value=Me.state.directionalShadow,mt.spotLights.value=Me.state.spot,mt.spotLightShadows.value=Me.state.spotShadow,mt.rectAreaLights.value=Me.state.rectArea,mt.ltc_1.value=Me.state.rectAreaLTC1,mt.ltc_2.value=Me.state.rectAreaLTC2,mt.pointLights.value=Me.state.point,mt.pointLightShadows.value=Me.state.pointShadow,mt.hemisphereLights.value=Me.state.hemi,mt.directionalShadowMap.value=Me.state.directionalShadowMap,mt.directionalShadowMatrix.value=Me.state.directionalShadowMatrix,mt.spotShadowMap.value=Me.state.spotShadowMap,mt.spotLightMatrix.value=Me.state.spotLightMatrix,mt.spotLightMap.value=Me.state.spotLightMap,mt.pointShadowMap.value=Me.state.pointShadowMap,mt.pointShadowMatrix.value=Me.state.pointShadowMatrix),Ce.currentProgram=Mt,Ce.uniformsList=null,Mt}function no(J){if(J.uniformsList===null){const _e=J.currentProgram.getUniforms();J.uniformsList=w_.seqWithValue(_e.seq,J.uniforms)}return J.uniformsList}function Oc(J,_e){const Ne=Pe.get(J);Ne.outputColorSpace=_e.outputColorSpace,Ne.batching=_e.batching,Ne.batchingColor=_e.batchingColor,Ne.instancing=_e.instancing,Ne.instancingColor=_e.instancingColor,Ne.instancingMorph=_e.instancingMorph,Ne.skinning=_e.skinning,Ne.morphTargets=_e.morphTargets,Ne.morphNormals=_e.morphNormals,Ne.morphColors=_e.morphColors,Ne.morphTargetsCount=_e.morphTargetsCount,Ne.numClippingPlanes=_e.numClippingPlanes,Ne.numIntersection=_e.numClipIntersection,Ne.vertexAlphas=_e.vertexAlphas,Ne.vertexTangents=_e.vertexTangents,Ne.toneMapping=_e.toneMapping}function ue(J,_e,Ne,Ce,Me){_e.isScene!==!0&&(_e=se),ne.resetTextureUnits();const Qe=_e.fog,ft=Ce.isMeshStandardMaterial?_e.environment:null,vt=k===null?R.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Kp,xt=(Ce.isMeshStandardMaterial?L:F).get(Ce.envMap||ft),Pt=Ce.vertexColors===!0&&!!Ne.attributes.color&&Ne.attributes.color.itemSize===4,Mt=!!Ne.attributes.tangent&&(!!Ce.normalMap||Ce.anisotropy>0),mt=!!Ne.morphAttributes.position,Gt=!!Ne.morphAttributes.normal,Lt=!!Ne.morphAttributes.color;let en=zu;Ce.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(en=R.toneMapping);const un=Ne.morphAttributes.position||Ne.morphAttributes.normal||Ne.morphAttributes.color,gn=un!==void 0?un.length:0,Ot=Pe.get(Ce),Xt=w.state.lights;if(ve===!0&&(De===!0||J!==I)){const xi=J===I&&Ce.id===U;ot.setState(Ce,J,xi)}let Zt=!1;Ce.version===Ot.__version?(Ot.needsLights&&Ot.lightsStateVersion!==Xt.state.version||Ot.outputColorSpace!==vt||Me.isBatchedMesh&&Ot.batching===!1||!Me.isBatchedMesh&&Ot.batching===!0||Me.isBatchedMesh&&Ot.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&Ot.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&Ot.instancing===!1||!Me.isInstancedMesh&&Ot.instancing===!0||Me.isSkinnedMesh&&Ot.skinning===!1||!Me.isSkinnedMesh&&Ot.skinning===!0||Me.isInstancedMesh&&Ot.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&Ot.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&Ot.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&Ot.instancingMorph===!1&&Me.morphTexture!==null||Ot.envMap!==xt||Ce.fog===!0&&Ot.fog!==Qe||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==ot.numPlanes||Ot.numIntersection!==ot.numIntersection)||Ot.vertexAlphas!==Pt||Ot.vertexTangents!==Mt||Ot.morphTargets!==mt||Ot.morphNormals!==Gt||Ot.morphColors!==Lt||Ot.toneMapping!==en||Ot.morphTargetsCount!==gn)&&(Zt=!0):(Zt=!0,Ot.__version=Ce.version);let br=Ot.currentProgram;Zt===!0&&(br=Ar(Ce,_e,Me));let Tr=!1,Nn=!1,ro=!1;const Pn=br.getUniforms(),gi=Ot.uniforms;if(le.useProgram(br.program)&&(Tr=!0,Nn=!0,ro=!0),Ce.id!==U&&(U=Ce.id,Nn=!0),Tr||I!==J){le.buffers.depth.getReversed()&&J.reversedDepth!==!0&&(J._reversedDepth=!0,J.updateProjectionMatrix()),Pn.setValue(q,"projectionMatrix",J.projectionMatrix),Pn.setValue(q,"viewMatrix",J.matrixWorldInverse);const ki=Pn.map.cameraPosition;ki!==void 0&&ki.setValue(q,me.setFromMatrixPosition(J.matrixWorld)),ee.logarithmicDepthBuffer&&Pn.setValue(q,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),(Ce.isMeshPhongMaterial||Ce.isMeshToonMaterial||Ce.isMeshLambertMaterial||Ce.isMeshBasicMaterial||Ce.isMeshStandardMaterial||Ce.isShaderMaterial)&&Pn.setValue(q,"isOrthographic",J.isOrthographicCamera===!0),I!==J&&(I=J,Nn=!0,ro=!0)}if(Me.isSkinnedMesh){Pn.setOptional(q,Me,"bindMatrix"),Pn.setOptional(q,Me,"bindMatrixInverse");const xi=Me.skeleton;xi&&(xi.boneTexture===null&&xi.computeBoneTexture(),Pn.setValue(q,"boneTexture",xi.boneTexture,ne))}Me.isBatchedMesh&&(Pn.setOptional(q,Me,"batchingTexture"),Pn.setValue(q,"batchingTexture",Me._matricesTexture,ne),Pn.setOptional(q,Me,"batchingIdTexture"),Pn.setValue(q,"batchingIdTexture",Me._indirectTexture,ne),Pn.setOptional(q,Me,"batchingColorTexture"),Me._colorsTexture!==null&&Pn.setValue(q,"batchingColorTexture",Me._colorsTexture,ne));const Qr=Ne.morphAttributes;if((Qr.position!==void 0||Qr.normal!==void 0||Qr.color!==void 0)&&pt.update(Me,Ne,br),(Nn||Ot.receiveShadow!==Me.receiveShadow)&&(Ot.receiveShadow=Me.receiveShadow,Pn.setValue(q,"receiveShadow",Me.receiveShadow)),Ce.isMeshGouraudMaterial&&Ce.envMap!==null&&(gi.envMap.value=xt,gi.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Ce.isMeshStandardMaterial&&Ce.envMap===null&&_e.environment!==null&&(gi.envMapIntensity.value=_e.environmentIntensity),gi.dfgLUT!==void 0&&(gi.dfgLUT.value=Pme()),Nn&&(Pn.setValue(q,"toneMappingExposure",R.toneMappingExposure),Ot.needsLights&&Ue(gi,ro),Qe&&Ce.fog===!0&&Ze.refreshFogUniforms(gi,Qe),Ze.refreshMaterialUniforms(gi,Ce,oe,Y,w.state.transmissionRenderTarget[J.id]),w_.upload(q,no(Ot),gi,ne)),Ce.isShaderMaterial&&Ce.uniformsNeedUpdate===!0&&(w_.upload(q,no(Ot),gi,ne),Ce.uniformsNeedUpdate=!1),Ce.isSpriteMaterial&&Pn.setValue(q,"center",Me.center),Pn.setValue(q,"modelViewMatrix",Me.modelViewMatrix),Pn.setValue(q,"normalMatrix",Me.normalMatrix),Pn.setValue(q,"modelMatrix",Me.matrixWorld),Ce.isShaderMaterial||Ce.isRawShaderMaterial){const xi=Ce.uniformsGroups;for(let ki=0,No=xi.length;ki<No;ki++){const fl=xi[ki];it.update(fl,br),it.bind(fl,br)}}return br}function Ue(J,_e){J.ambientLightColor.needsUpdate=_e,J.lightProbe.needsUpdate=_e,J.directionalLights.needsUpdate=_e,J.directionalLightShadows.needsUpdate=_e,J.pointLights.needsUpdate=_e,J.pointLightShadows.needsUpdate=_e,J.spotLights.needsUpdate=_e,J.spotLightShadows.needsUpdate=_e,J.rectAreaLights.needsUpdate=_e,J.hemisphereLights.needsUpdate=_e}function qe(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(J,_e,Ne){const Ce=Pe.get(J);Ce.__autoAllocateDepthBuffer=J.resolveDepthBuffer===!1,Ce.__autoAllocateDepthBuffer===!1&&(Ce.__useRenderToTexture=!1),Pe.get(J.texture).__webglTexture=_e,Pe.get(J.depthTexture).__webglTexture=Ce.__autoAllocateDepthBuffer?void 0:Ne,Ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(J,_e){const Ne=Pe.get(J);Ne.__webglFramebuffer=_e,Ne.__useDefaultFramebuffer=_e===void 0};const Ke=q.createFramebuffer();this.setRenderTarget=function(J,_e=0,Ne=0){k=J,j=_e,C=Ne;let Ce=!0,Me=null,Qe=!1,ft=!1;if(J){const xt=Pe.get(J);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(q.FRAMEBUFFER,null),Ce=!1;else if(xt.__webglFramebuffer===void 0)ne.setupRenderTarget(J);else if(xt.__hasExternalTextures)ne.rebindTextures(J,Pe.get(J.texture).__webglTexture,Pe.get(J.depthTexture).__webglTexture);else if(J.depthBuffer){const mt=J.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Pe.has(mt)&&(J.width!==mt.image.width||J.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ne.setupDepthRenderbuffer(J)}}const Pt=J.texture;(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)&&(ft=!0);const Mt=Pe.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Array.isArray(Mt[_e])?Me=Mt[_e][Ne]:Me=Mt[_e],Qe=!0):J.samples>0&&ne.useMultisampledRTT(J)===!1?Me=Pe.get(J).__webglMultisampledFramebuffer:Array.isArray(Mt)?Me=Mt[Ne]:Me=Mt,H.copy(J.viewport),O.copy(J.scissor),B=J.scissorTest}else H.copy(ae).multiplyScalar(oe).floor(),O.copy(ce).multiplyScalar(oe).floor(),B=xe;if(Ne!==0&&(Me=Ke),le.bindFramebuffer(q.FRAMEBUFFER,Me)&&Ce&&le.drawBuffers(J,Me),le.viewport(H),le.scissor(O),le.setScissorTest(B),Qe){const xt=Pe.get(J.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+_e,xt.__webglTexture,Ne)}else if(ft){const xt=_e;for(let Pt=0;Pt<J.textures.length;Pt++){const Mt=Pe.get(J.textures[Pt]);q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0+Pt,Mt.__webglTexture,Ne,xt)}}else if(J!==null&&Ne!==0){const xt=Pe.get(J.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,xt.__webglTexture,Ne)}U=-1},this.readRenderTargetPixels=function(J,_e,Ne,Ce,Me,Qe,ft,vt=0){if(!(J&&J.isWebGLRenderTarget)){kr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Pe.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt){le.bindFramebuffer(q.FRAMEBUFFER,xt);try{const Pt=J.textures[vt],Mt=Pt.format,mt=Pt.type;if(!ee.textureFormatReadable(Mt)){kr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ee.textureTypeReadable(mt)){kr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=J.width-Ce&&Ne>=0&&Ne<=J.height-Me&&(J.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+vt),q.readPixels(_e,Ne,Ce,Me,dt.convert(Mt),dt.convert(mt),Qe))}finally{const Pt=k!==null?Pe.get(k).__webglFramebuffer:null;le.bindFramebuffer(q.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(J,_e,Ne,Ce,Me,Qe,ft,vt=0){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Pe.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt)if(_e>=0&&_e<=J.width-Ce&&Ne>=0&&Ne<=J.height-Me){le.bindFramebuffer(q.FRAMEBUFFER,xt);const Pt=J.textures[vt],Mt=Pt.format,mt=Pt.type;if(!ee.textureFormatReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Gt=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,Gt),q.bufferData(q.PIXEL_PACK_BUFFER,Qe.byteLength,q.STREAM_READ),J.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+vt),q.readPixels(_e,Ne,Ce,Me,dt.convert(Mt),dt.convert(mt),0);const Lt=k!==null?Pe.get(k).__webglFramebuffer:null;le.bindFramebuffer(q.FRAMEBUFFER,Lt);const en=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await rue(q,en,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,Gt),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,Qe),q.deleteBuffer(Gt),q.deleteSync(en),Qe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(J,_e=null,Ne=0){const Ce=Math.pow(2,-Ne),Me=Math.floor(J.image.width*Ce),Qe=Math.floor(J.image.height*Ce),ft=_e!==null?_e.x:0,vt=_e!==null?_e.y:0;ne.setTexture2D(J,0),q.copyTexSubImage2D(q.TEXTURE_2D,Ne,0,0,ft,vt,Me,Qe),le.unbindTexture()};const We=q.createFramebuffer(),St=q.createFramebuffer();this.copyTextureToTexture=function(J,_e,Ne=null,Ce=null,Me=0,Qe=null){Qe===null&&(Me!==0?(Zx("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Qe=Me,Me=0):Qe=0);let ft,vt,xt,Pt,Mt,mt,Gt,Lt,en;const un=J.isCompressedTexture?J.mipmaps[Qe]:J.image;if(Ne!==null)ft=Ne.max.x-Ne.min.x,vt=Ne.max.y-Ne.min.y,xt=Ne.isBox3?Ne.max.z-Ne.min.z:1,Pt=Ne.min.x,Mt=Ne.min.y,mt=Ne.isBox3?Ne.min.z:0;else{const Qr=Math.pow(2,-Me);ft=Math.floor(un.width*Qr),vt=Math.floor(un.height*Qr),J.isDataArrayTexture?xt=un.depth:J.isData3DTexture?xt=Math.floor(un.depth*Qr):xt=1,Pt=0,Mt=0,mt=0}Ce!==null?(Gt=Ce.x,Lt=Ce.y,en=Ce.z):(Gt=0,Lt=0,en=0);const gn=dt.convert(_e.format),Ot=dt.convert(_e.type);let Xt;_e.isData3DTexture?(ne.setTexture3D(_e,0),Xt=q.TEXTURE_3D):_e.isDataArrayTexture||_e.isCompressedArrayTexture?(ne.setTexture2DArray(_e,0),Xt=q.TEXTURE_2D_ARRAY):(ne.setTexture2D(_e,0),Xt=q.TEXTURE_2D),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,_e.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,_e.unpackAlignment);const Zt=q.getParameter(q.UNPACK_ROW_LENGTH),br=q.getParameter(q.UNPACK_IMAGE_HEIGHT),Tr=q.getParameter(q.UNPACK_SKIP_PIXELS),Nn=q.getParameter(q.UNPACK_SKIP_ROWS),ro=q.getParameter(q.UNPACK_SKIP_IMAGES);q.pixelStorei(q.UNPACK_ROW_LENGTH,un.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,un.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,Pt),q.pixelStorei(q.UNPACK_SKIP_ROWS,Mt),q.pixelStorei(q.UNPACK_SKIP_IMAGES,mt);const Pn=J.isDataArrayTexture||J.isData3DTexture,gi=_e.isDataArrayTexture||_e.isData3DTexture;if(J.isDepthTexture){const Qr=Pe.get(J),xi=Pe.get(_e),ki=Pe.get(Qr.__renderTarget),No=Pe.get(xi.__renderTarget);le.bindFramebuffer(q.READ_FRAMEBUFFER,ki.__webglFramebuffer),le.bindFramebuffer(q.DRAW_FRAMEBUFFER,No.__webglFramebuffer);for(let fl=0;fl<xt;fl++)Pn&&(q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Pe.get(J).__webglTexture,Me,mt+fl),q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Pe.get(_e).__webglTexture,Qe,en+fl)),q.blitFramebuffer(Pt,Mt,ft,vt,Gt,Lt,ft,vt,q.DEPTH_BUFFER_BIT,q.NEAREST);le.bindFramebuffer(q.READ_FRAMEBUFFER,null),le.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else if(Me!==0||J.isRenderTargetTexture||Pe.has(J)){const Qr=Pe.get(J),xi=Pe.get(_e);le.bindFramebuffer(q.READ_FRAMEBUFFER,We),le.bindFramebuffer(q.DRAW_FRAMEBUFFER,St);for(let ki=0;ki<xt;ki++)Pn?q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Qr.__webglTexture,Me,mt+ki):q.framebufferTexture2D(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,Qr.__webglTexture,Me),gi?q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,xi.__webglTexture,Qe,en+ki):q.framebufferTexture2D(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,xi.__webglTexture,Qe),Me!==0?q.blitFramebuffer(Pt,Mt,ft,vt,Gt,Lt,ft,vt,q.COLOR_BUFFER_BIT,q.NEAREST):gi?q.copyTexSubImage3D(Xt,Qe,Gt,Lt,en+ki,Pt,Mt,ft,vt):q.copyTexSubImage2D(Xt,Qe,Gt,Lt,Pt,Mt,ft,vt);le.bindFramebuffer(q.READ_FRAMEBUFFER,null),le.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else gi?J.isDataTexture||J.isData3DTexture?q.texSubImage3D(Xt,Qe,Gt,Lt,en,ft,vt,xt,gn,Ot,un.data):_e.isCompressedArrayTexture?q.compressedTexSubImage3D(Xt,Qe,Gt,Lt,en,ft,vt,xt,gn,un.data):q.texSubImage3D(Xt,Qe,Gt,Lt,en,ft,vt,xt,gn,Ot,un):J.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,Qe,Gt,Lt,ft,vt,gn,Ot,un.data):J.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,Qe,Gt,Lt,un.width,un.height,gn,un.data):q.texSubImage2D(q.TEXTURE_2D,Qe,Gt,Lt,ft,vt,gn,Ot,un);q.pixelStorei(q.UNPACK_ROW_LENGTH,Zt),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,br),q.pixelStorei(q.UNPACK_SKIP_PIXELS,Tr),q.pixelStorei(q.UNPACK_SKIP_ROWS,Nn),q.pixelStorei(q.UNPACK_SKIP_IMAGES,ro),Qe===0&&_e.generateMipmaps&&q.generateMipmap(Xt),le.unbindTexture()},this.initRenderTarget=function(J){Pe.get(J).__webglFramebuffer===void 0&&ne.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?ne.setTextureCube(J,0):J.isData3DTexture?ne.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?ne.setTexture2DArray(J,0):ne.setTexture2D(J,0),le.unbindTexture()},this.resetState=function(){j=0,C=0,k=null,le.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Go}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=En._getDrawingBufferColorSpace(e),n.unpackColorSpace=En._getUnpackColorSpace()}};const oz={type:"change"},lk={type:"start"},oW={type:"end"},ty=new rk,lz=new _u,Dme=Math.cos(70*aue.DEG2RAD),ei=new Ge,Oa=2*Math.PI,Vn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},mT=1e-6;class Ome extends Gue{constructor(e,n=null){super(e,n),this.state=Vn.NONE,this.target=new Ge,this.cursor=new Ge,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Rp.ROTATE,MIDDLE:Rp.DOLLY,RIGHT:Rp.PAN},this.touches={ONE:wp.ROTATE,TWO:wp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Ge,this._lastQuaternion=new Cf,this._lastTargetPosition=new Ge,this._quat=new Cf().setFromUnitVectors(e.up,new Ge(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new IF,this._sphericalDelta=new IF,this._scale=1,this._panOffset=new Ge,this._rotateStart=new an,this._rotateEnd=new an,this._rotateDelta=new an,this._panStart=new an,this._panEnd=new an,this._panDelta=new an,this._dollyStart=new an,this._dollyEnd=new an,this._dollyDelta=new an,this._dollyDirection=new Ge,this._mouse=new an,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ime.bind(this),this._onPointerDown=Lme.bind(this),this._onPointerUp=jme.bind(this),this._onContextMenu=Vme.bind(this),this._onMouseWheel=zme.bind(this),this._onKeyDown=Bme.bind(this),this._onTouchStart=Hme.bind(this),this._onTouchMove=$me.bind(this),this._onMouseDown=Ume.bind(this),this._onMouseMove=Fme.bind(this),this._interceptControlDown=Gme.bind(this),this._interceptControlUp=Wme.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(oz),this.update(),this.state=Vn.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===Vn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Oa:r>Math.PI&&(r-=Oa),i<-Math.PI?i+=Oa:i>Math.PI&&(i-=Oa),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 s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=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 s=null;if(this.object.isPerspectiveCamera){const o=ei.length();s=this._clampDistance(o*this._scale);const l=o-s;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const o=new Ge(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new Ge(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=ei.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(ty.origin.copy(this.object.position),ty.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ty.direction))<Dme?this.object.lookAt(this.target):(lz.setFromNormalAndCoplanarPoint(this.object.up,this.target),ty.intersectPlane(lz,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>mT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>mT||this._lastTargetPosition.distanceToSquared(this.target)>mT?(this.dispatchEvent(oz),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Oa/60*this.autoRotateSpeed*e:Oa/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,s=r.width,o=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Oa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Oa*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(Oa*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(-Oa*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(Oa*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(-Oa*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(Oa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Oa*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 s=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new an,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 Lme(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function Ime(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function jme(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(oW),this.state=Vn.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function Ume(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 Rp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Vn.DOLLY;break;case Rp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}break;case Rp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(lk)}function Fme(t){switch(this.state){case Vn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Vn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Vn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function zme(t){this.enabled===!1||this.enableZoom===!1||this.state!==Vn.NONE||(t.preventDefault(),this.dispatchEvent(lk),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(oW))}function Bme(t){this.enabled!==!1&&this._handleKeyDown(t)}function Hme(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case wp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Vn.TOUCH_ROTATE;break;case wp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Vn.TOUCH_PAN;break;default:this.state=Vn.NONE}break;case 2:switch(this.touches.TWO){case wp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Vn.TOUCH_DOLLY_PAN;break;case wp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Vn.TOUCH_DOLLY_ROTATE;break;default:this.state=Vn.NONE}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(lk)}function $me(t){switch(this._trackPointer(t),this.state){case Vn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Vn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Vn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Vn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Vn.NONE}}function Vme(t){this.enabled!==!1&&t.preventDefault()}function Gme(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Wme(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function qme(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={},s={},o=t[0].morphTargetsRelative,l=new dl;let c=0;for(let u=0;u<t.length;++u){const f=t[u];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;s[m]===void 0&&(s[m]=[]),s[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,u),c+=m}}if(n){let u=0;const f=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let y=0;y<m.count;++y)f.push(m.getX(y)+u);u+=t[g].attributes.position.count}l.setIndex(f)}for(const u in a){const f=cz(a[u]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,f)}for(const u in s){const f=s[u][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let g=0;g<f;++g){const m=[];for(let v=0;v<s[u].length;++v)m.push(s[u][v][g]);const y=cz(m);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(y)}}return l}function cz(t){let e,n,r,i=-1,a=0;for(let c=0;c<t.length;++c){const u=t[c];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=u.count*n}const s=new e(a),o=new Gs(s,n,r);let l=0;for(let c=0;c<t.length;++c){const u=t[c];if(u.isInterleavedBufferAttribute){const f=l/n;for(let g=0,m=u.count;g<m;g++)for(let y=0;y<n;y++){const v=u.getComponent(g,y);o.setComponent(g+f,y,v)}}else s.set(u.array,l);l+=u.count*n}return i!==void 0&&(o.gpuType=i),o}function ny(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 gT={exports:{}};var uz;function Xme(){return uz||(uz=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(c,u){if(!i[c]){if(!r[c]){var f=typeof ny=="function"&&ny;if(!u&&f)return f(c,!0);if(o)return o(c,!0);var g=new Error("Cannot find module '"+c+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[c]={exports:{}};r[c][0].call(m.exports,function(y){var v=r[c][1][y];return s(v||y)},m,m.exports,n,r,i,a)}return i[c].exports}for(var o=typeof ny=="function"&&ny,l=0;l<a.length;l++)s(a[l]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,u,f,g,m,y,v,b=[],x=0,M=l.length,w=M,A=a.getTypeOf(l)!=="string";x<l.length;)w=M-x,f=A?(c=l[x++],u=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),u=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),g=c>>2,m=(3&c)<<4|u>>4,y=1<w?(15&u)<<2|f>>6:64,v=2<w?63&f:64,b.push(o.charAt(g)+o.charAt(m)+o.charAt(y)+o.charAt(v));return b.join("")},i.decode=function(l){var c,u,f,g,m,y,v=0,b=0,x="data:";if(l.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var M,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&w--,l.charAt(l.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=s.uint8array?new Uint8Array(0|w):new Array(0|w);v<l.length;)c=o.indexOf(l.charAt(v++))<<2|(g=o.indexOf(l.charAt(v++)))>>4,u=(15&g)<<4|(m=o.indexOf(l.charAt(v++)))>>2,f=(3&m)<<6|(y=o.indexOf(l.charAt(v++))),M[b++]=c,m!==64&&(M[b++]=u),y!==64&&(M[b++]=f);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,f,g,m,y){this.compressedSize=u,this.uncompressedSize=f,this.crc32=g,this.compression=m,this.compressedContent=y}c.prototype={getContentWorker:function(){var u=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return u.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,f,g){return u.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=c},{"./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"),s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(c,u,f,g){var m=s,y=g+f;c^=-1;for(var v=g;v<y;v++)c=c>>>8^m[255&(c^u[v])];return-1^c})(0|l,o,o.length,0):(function(c,u,f,g){var m=s,y=g+f;c^=-1;for(var v=g;v<y;v++)c=c>>>8^m[255&(c^u.charCodeAt(v))];return-1^c})(0|l,o,o.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",s=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=a?"uint8array":"array";function u(f,g){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(u,l),u.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,f.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new u("Deflate",f)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,y){var v,b="";for(v=0;v<y;v++)b+=String.fromCharCode(255&m),m>>>=8;return b}function s(m,y,v,b,x,M){var w,A,T=m.file,R=m.compression,N=M!==c.utf8encode,j=o.transformTo("string",M(T.name)),C=o.transformTo("string",c.utf8encode(T.name)),k=T.comment,U=o.transformTo("string",M(k)),I=o.transformTo("string",c.utf8encode(k)),H=C.length!==T.name.length,O=I.length!==k.length,B="",V="",G="",K=T.dir,Y=T.date,oe={crc32:0,compressedSize:0,uncompressedSize:0};y&&!v||(oe.crc32=m.crc32,oe.compressedSize=m.compressedSize,oe.uncompressedSize=m.uncompressedSize);var $=0;y&&($|=8),N||!H&&!O||($|=2048);var X=0,ae=0;K&&(X|=16),x==="UNIX"?(ae=798,X|=(function(xe,te){var ve=xe;return xe||(ve=te?16893:33204),(65535&ve)<<16})(T.unixPermissions,K)):(ae=20,X|=(function(xe){return 63&(xe||0)})(T.dosPermissions)),w=Y.getUTCHours(),w<<=6,w|=Y.getUTCMinutes(),w<<=5,w|=Y.getUTCSeconds()/2,A=Y.getUTCFullYear()-1980,A<<=4,A|=Y.getUTCMonth()+1,A<<=5,A|=Y.getUTCDate(),H&&(V=a(1,1)+a(u(j),4)+C,B+="up"+a(V.length,2)+V),O&&(G=a(1,1)+a(u(U),4)+I,B+="uc"+a(G.length,2)+G);var ce="";return ce+=`
  3839. \0`,ce+=a($,2),ce+=R.magic,ce+=a(w,2),ce+=a(A,2),ce+=a(oe.crc32,4),ce+=a(oe.compressedSize,4),ce+=a(oe.uncompressedSize,4),ce+=a(j.length,2),ce+=a(B.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ce+j+B,dirRecord:f.CENTRAL_FILE_HEADER+a(ae,2)+ce+a(U.length,2)+"\0\0\0\0"+a(X,4)+a(b,4)+j+B+U}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),f=n("../signature");function g(m,y,v,b){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=v,this.encodeFileName=b,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,l),g.prototype.push=function(m){var y=m.meta.percent||0,v=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:v?(y+100*(v-b-1))/v:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var y=this.streamFiles&&!m.file.dir;if(y){var v=s(m,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var y=this.streamFiles&&!m.file.dir,v=s(m,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),y)this.push({data:(function(b){return f.DATA_DESCRIPTOR+a(b.crc32,4)+a(b.compressedSize,4)+a(b.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var v=this.bytesWritten-m,b=(function(x,M,w,A,T){var R=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(x,2)+a(x,2)+a(M,4)+a(w,4)+a(R.length,2)+R})(this.dirRecords.length,v,m,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var y=this;return m.on("data",function(v){y.processChunk(v)}),m.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),m.on("error",function(v){y.error(v)}),this},g.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var y=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var v=0;v<y.length;v++)try{y[v].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,y=0;y<m.length;y++)m[y].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(o,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),f=0;try{o.forEach(function(g,m){f++;var y=(function(M,w){var A=M||w,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,l.compression),v=m.options.compressionOptions||l.compressionOptions||{},b=m.dir,x=m.date;m._compressWorker(y,v).withStreamInfo("file",{name:g,dir:b,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(u)}),u.entriesCount=f}catch(g){u.error(g)}return u}},{"../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 s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function f(g){return new s.Promise(function(m,y){var v=g.decompressed.getContentWorker().pipe(new c);v.on("error",function(b){y(b)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var y=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),u.isNode&&u.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(v){var b=new l(m);return b.load(v),b}).then(function(v){var b=[s.Promise.resolve(v)],x=v.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)b.push(f(x[M]));return s.Promise.all(b)}).then(function(v){for(var b=v.shift(),x=b.files,M=0;M<x.length;M++){var w=x[M],A=w.fileNameStr,T=a.resolve(w.fileNameStr);y.file(T,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:m.createFolders}),w.dir||(y.file(T).unsafeOriginalName=A)}return b.zipComment.length&&(y.comment=b.zipComment),y})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function o(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}a.inherits(o,s),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(o,l,c){a.call(this,l),this._helper=o;var u=this;o.on("data",function(f,g){u.push(f)||u._helper.pause(),c&&c(g)}).on("error",function(f){u.emit("error",f)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,R,N){var j,C=o.getTypeOf(R),k=o.extend(N||{},u);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(T=x(T)),k.createFolders&&(j=b(T))&&M.call(this,j,!0);var U=C==="string"&&k.binary===!1&&k.base64===!1;N&&N.binary!==void 0||(k.binary=!U),(R instanceof f&&R.uncompressedSize===0||k.dir||!R||R.length===0)&&(k.base64=!1,k.binary=!0,R="",k.compression="STORE",C="string");var I=null;I=R instanceof f||R instanceof l?R:y.isNode&&y.isStream(R)?new v(T,R):o.prepareContent(T,R,k.binary,k.optimizedBinaryString,k.base64);var H=new g(T,I,k);this.files[T]=H}var s=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),y=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),b=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var R=T.lastIndexOf("/");return 0<R?T.substring(0,R):""},x=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},M=function(T,R){return R=R!==void 0?R:u.createFolders,T=x(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:R}),this.files[T]};function w(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var R,N,j;for(R in this.files)j=this.files[R],(N=R.slice(this.root.length,R.length))&&R.slice(0,this.root.length)===this.root&&T(N,j)},filter:function(T){var R=[];return this.forEach(function(N,j){T(N,j)&&R.push(j)}),R},file:function(T,R,N){if(arguments.length!==1)return T=this.root+T,a.call(this,T,R,N),this;if(w(T)){var j=T;return this.filter(function(k,U){return!U.dir&&j.test(k)})}var C=this.files[this.root+T];return C&&!C.dir?C:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(C,k){return k.dir&&T.test(C)});var R=this.root+T,N=M.call(this,R),j=this.clone();return j.root=N.name,j},remove:function(T){T=this.root+T;var R=this.files[T];if(R||(T.slice(-1)!=="/"&&(T+="/"),R=this.files[T]),R&&!R.dir)delete this.files[T];else for(var N=this.filter(function(C,k){return k.name.slice(0,T.length)===T}),j=0;j<N.length;j++)delete this.files[N[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var R,N={};try{if((N=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");o.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var j=N.comment||this.comment||"";R=m.generateWorker(this,N,j)}catch(C){(R=new l("error")).error(C)}return new c(R,N.type||"string",N.mimeType)},generateAsync:function(T,R){return this.generateInternalStream(T).accumulate(R)},generateNodeStream:function(T,R){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(R)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===c&&this.data[g+2]===u&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&c===g[1]&&u===g[2]&&f===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new c(f):s.uint8array?new u(a.transformTo("uint8array",f)):new o(a.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,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"),s=n("../utils");function o(l){a.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(o,a),o.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}a.inherits(o,s),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=a.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(l){o.processChunk(l)}),s.on("end",function(){o.end()}),s.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),f=null;if(c.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(y,v){return new u.Promise(function(b,x){var M=[],w=y._internalType,A=y._outputType,T=y._mimeType;y.on("data",function(R,N){M.push(R),v&&v(N)}).on("error",function(R){M=[],x(R)}).on("end",function(){try{var R=(function(N,j,C){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",j),C);case"base64":return l.encode(j);default:return a.transformTo(N,j)}})(A,(function(N,j){var C,k=0,U=null,I=0;for(C=0;C<j.length;C++)I+=j[C].length;switch(N){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(U=new Uint8Array(I),C=0;C<j.length;C++)U.set(j[C],k),k+=j[C].length;return U;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+N+"'")}})(w,M),T);b(R)}catch(N){x(N)}M=[]}).resume()})}function m(y,v,b){var x=v;switch(v){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=v,this._mimeType=b,a.checkSupport(x),this._worker=y.pipe(new s(x)),y.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(y){return g(this,y)},on:function(y,v){var b=this;return y==="data"?this._worker.on(y,function(x){v.call(b,x.data,x.meta)}):this._worker.on(y,function(){a.delay(v,arguments,b)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},y)}},r.exports=m},{"../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 s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.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"),s=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return s.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(y){var v,b,x,M,w,A=y.length,T=0;for(M=0;M<A;M++)(64512&(b=y.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=y.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(x-56320),M++),T+=b<128?1:b<2048?2:b<65536?3:4;for(v=s.uint8array?new Uint8Array(T):new Array(T),M=w=0;w<T;M++)(64512&(b=y.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=y.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(x-56320),M++),b<128?v[w++]=b:(b<2048?v[w++]=192|b>>>6:(b<65536?v[w++]=224|b>>>12:(v[w++]=240|b>>>18,v[w++]=128|b>>>12&63),v[w++]=128|b>>>6&63),v[w++]=128|63&b);return v})(m)},i.utf8decode=function(m){return s.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(y){var v,b,x,M,w=y.length,A=new Array(2*w);for(v=b=0;v<w;)if((x=y[v++])<128)A[b++]=x;else if(4<(M=c[x]))A[b++]=65533,v+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&v<w;)x=x<<6|63&y[v++],M--;1<M?A[b++]=65533:x<65536?A[b++]=x:(x-=65536,A[b++]=55296|x>>10&1023,A[b++]=56320|1023&x)}return A.length!==b&&(A.subarray?A=A.subarray(0,b):A.length=b),a.applyFromCharCode(A)})(m=a.transformTo(s.uint8array?"uint8array":"array",m))},a.inherits(f,l),f.prototype.processChunk=function(m){var y=a.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=y;(y=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),y.set(v,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var b=(function(M,w){var A;for((w=w||M.length)>M.length&&(w=M.length),A=w-1;0<=A&&(192&M[A])==128;)A--;return A<0||A===0?w:A+c[M[A]]>w?A:w})(y),x=y;b!==y.length&&(s.uint8array?(x=y.subarray(0,b),this.leftOver=y.subarray(b,y.length)):(x=y.slice(0,b),this.leftOver=y.slice(b,y.length))),this.push({data:i.utf8decode(x),meta:m.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(g,l),g.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(v){return v}function u(v,b){for(var x=0;x<v.length;++x)b[x]=255&v.charCodeAt(x);return b}n("setimmediate"),i.newBlob=function(v,b){i.checkSupport("blob");try{return new Blob([v],{type:b})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(v),x.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,b,x){var M=[],w=0,A=v.length;if(A<=x)return String.fromCharCode.apply(null,v);for(;w<A;)b==="array"||b==="nodebuffer"?M.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+x,A)))):M.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+x,A)))),w+=x;return M.join("")},stringifyByChar:function(v){for(var b="",x=0;x<v.length;x++)b+=String.fromCharCode(v[x]);return b},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(v){var b=65536,x=i.getTypeOf(v),M=!0;if(x==="uint8array"?M=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<b;)try{return f.stringifyByChunk(v,x,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(v)}function m(v,b){for(var x=0;x<v.length;x++)b[x]=v[x];return b}i.applyFromCharCode=g;var y={};y.string={string:c,array:function(v){return u(v,new Array(v.length))},arraybuffer:function(v){return y.string.uint8array(v).buffer},uint8array:function(v){return u(v,new Uint8Array(v.length))},nodebuffer:function(v){return u(v,o.allocBuffer(v.length))}},y.array={string:g,array:c,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(v)}},y.arraybuffer={string:function(v){return g(new Uint8Array(v))},array:function(v){return m(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:c,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(new Uint8Array(v))}},y.uint8array={string:g,array:function(v){return m(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:c,nodebuffer:function(v){return o.newBufferFrom(v)}},y.nodebuffer={string:g,array:function(v){return m(v,new Array(v.length))},arraybuffer:function(v){return y.nodebuffer.uint8array(v).buffer},uint8array:function(v){return m(v,new Uint8Array(v.length))},nodebuffer:c},i.transformTo=function(v,b){if(b=b||"",!v)return b;i.checkSupport(v);var x=i.getTypeOf(b);return y[x][v](b)},i.resolve=function(v){for(var b=v.split("/"),x=[],M=0;M<b.length;M++){var w=b[M];w==="."||w===""&&M!==0&&M!==b.length-1||(w===".."?x.pop():x.push(w))}return x.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var b,x,M="";for(x=0;x<(v||"").length;x++)M+="\\x"+((b=v.charCodeAt(x))<16?"0":"")+b.toString(16).toUpperCase();return M},i.delay=function(v,b,x){setImmediate(function(){v.apply(x||null,b||[])})},i.inherits=function(v,b){function x(){}x.prototype=b.prototype,v.prototype=new x},i.extend=function(){var v,b,x={};for(v=0;v<arguments.length;v++)for(b in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],b)&&x[b]===void 0&&(x[b]=arguments[v][b]);return x},i.prepareContent=function(v,b,x,M,w){return l.Promise.resolve(b).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,R){var N=new FileReader;N.onload=function(j){T(j.target.result)},N.onerror=function(j){R(j.target.error)},N.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(w?A=s.decode(A):x&&M!==!0&&(A=(function(R){return u(R,a.uint8array?new Uint8Array(R.length):new Array(R.length))})(A))),A):l.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(f){this.files=[],this.loadOptions=f}u.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var m=this.reader.index;this.reader.setIndex(f);var y=this.reader.readString(4)===g;return this.reader.setIndex(m),y},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=c.uint8array?"uint8array":"array",m=s.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,m,y=this.zip64EndOfCentralSize-44;0<y;)f=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var y=g-m;if(0<y)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),f=n("./support");function g(m,y){this.options=m,this.loadOptions=y}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var y,v;if(m.skip(22),this.fileNameLength=m.readInt(2),v=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((y=(function(b){for(var x in u)if(Object.prototype.hasOwnProperty.call(u,x)&&u[x].magic===b)return u[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,y,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var y=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(y),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var y,v,b,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)y=m.readInt(2),v=m.readInt(2),b=m.readData(v),this.extraFields[y]={id:y,length:v,value:b};m.setIndex(x)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(y!==null)this.fileNameStr=y;else{var v=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var x=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var y=a(m.value);return y.readInt(1)!==1||l(this.fileName)!==y.readInt(4)?null:c.utf8decode(y.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var y=a(m.value);return y.readInt(1)!==1||l(this.fileComment)!==y.readInt(4)?null:c.utf8decode(y.readData(m.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(y,v,b){this.name=y,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=v,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");a.prototype={internalStream:function(y){var v=null,b="string";try{if(!y)throw new Error("No output type specified.");var x=(b=y.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),v=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(v=v.pipe(new l.Utf8EncodeWorker)),!M&&x&&(v=v.pipe(new l.Utf8DecodeWorker))}catch(w){(v=new u("error")).error(w)}return new s(v,b,"")},async:function(y,v){return this.internalStream(y).accumulate(v)},nodeStream:function(y,v){return this.internalStream(y||"nodebuffer").toNodejsStream(v)},_compressWorker:function(y,v){if(this._data instanceof c&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(b,y,v)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,o,l=a.MutationObserver||a.WebKitMutationObserver;if(l){var c=0,u=new l(y),f=a.document.createTextNode("");u.observe(f,{characterData:!0}),s=function(){f.data=c=++c%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){y(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(y,0)};else{var g=new a.MessageChannel;g.port1.onmessage=y,s=function(){g.port2.postMessage(0)}}var m=[];function y(){var v,b;o=!0;for(var x=m.length;x;){for(b=m,m=[],v=-1;++v<x;)b[v]();x=m.length}o=!1}r.exports=function(v){m.push(v)!==1||o||s()}}).call(this,typeof Nb<"u"?Nb:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var o={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,x!==s&&v(this,x)}function g(x,M,w){this.promise=x,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function m(x,M,w){a(function(){var A;try{A=M(w)}catch(T){return o.reject(x,T)}A===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,A)})}function y(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function v(x,M){var w=!1;function A(N){w||(w=!0,o.reject(x,N))}function T(N){w||(w=!0,o.resolve(x,N))}var R=b(function(){M(T,A)});R.status==="error"&&A(R.value)}function b(x,M){var w={};try{w.value=x(M),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(x){if(typeof x!="function")return this;var M=this.constructor;return this.then(function(w){return M.resolve(x()).then(function(){return w})},function(w){return M.resolve(x()).then(function(){throw w})})},f.prototype.catch=function(x){return this.then(null,x)},f.prototype.then=function(x,M){if(typeof x!="function"&&this.state===c||typeof M!="function"&&this.state===l)return this;var w=new this.constructor(s);return this.state!==u?m(w,this.state===c?x:M,this.outcome):this.queue.push(new g(w,x,M)),w},g.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},g.prototype.otherCallFulfilled=function(x){m(this.promise,this.onFulfilled,x)},g.prototype.callRejected=function(x){o.reject(this.promise,x)},g.prototype.otherCallRejected=function(x){m(this.promise,this.onRejected,x)},o.resolve=function(x,M){var w=b(y,M);if(w.status==="error")return o.reject(x,w.value);var A=w.value;if(A)v(x,A);else{x.state=c,x.outcome=M;for(var T=-1,R=x.queue.length;++T<R;)x.queue[T].callFulfilled(M)}return x},o.reject=function(x,M){x.state=l,x.outcome=M;for(var w=-1,A=x.queue.length;++w<A;)x.queue[w].callRejected(M);return x},f.resolve=function(x){return x instanceof this?x:o.resolve(new this(s),x)},f.reject=function(x){var M=new this(s);return o.reject(M,x)},f.all=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,A=!1;if(!w)return this.resolve([]);for(var T=new Array(w),R=0,N=-1,j=new this(s);++N<w;)C(x[N],N);return j;function C(k,U){M.resolve(k).then(function(I){T[U]=I,++R!==w||A||(A=!0,o.resolve(j,T))},function(I){A||(A=!0,o.reject(j,I))})}},f.race=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,A=!1;if(!w)return this.resolve([]);for(var T=-1,R=new this(s);++T<w;)N=x[T],M.resolve(N).then(function(j){A||(A=!0,o.resolve(R,j))},function(j){A||(A=!0,o.reject(R,j))});var N;return R}},{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"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,f=0,g=-1,m=0,y=8;function v(x){if(!(this instanceof v))return new v(x);this.options=s.assign({level:g,method:y,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},x||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(w!==f)throw new Error(l[w]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var A;if(A=typeof M.dictionary=="string"?o.string2buf(M.dictionary):u.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(l[w]);this._dict_set=!0}}function b(x,M){var w=new v(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}v.prototype.push=function(x,M){var w,A,T=this.strm,R=this.options.chunkSize;if(this.ended)return!1;A=M===~~M?M:M===!0?4:0,typeof x=="string"?T.input=o.string2buf(x):u.call(x)==="[object ArrayBuffer]"?T.input=new Uint8Array(x):T.input=x,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(R),T.next_out=0,T.avail_out=R),(w=a.deflate(T,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return A===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},v.prototype.onData=function(x){this.chunks.push(x)},v.prototype.onEnd=function(x){x===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=v,i.deflate=b,i.deflateRaw=function(x,M){return(M=M||{}).raw=!0,b(x,M)},i.gzip=function(x,M){return(M=M||{}).gzip=!0,b(x,M)}},{"./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"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function m(v){if(!(this instanceof m))return new m(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||v&&v.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var x=a.inflateInit2(this.strm,b.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function y(v,b){var x=new m(b);if(x.push(v,!0),x.err)throw x.msg||c[x.err];return x.result}m.prototype.push=function(v,b){var x,M,w,A,T,R,N=this.strm,j=this.options.chunkSize,C=this.options.dictionary,k=!1;if(this.ended)return!1;M=b===~~b?b:b===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof v=="string"?N.input=o.binstring2buf(v):g.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(j),N.next_out=0,N.avail_out=j),(x=a.inflate(N,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(R=typeof C=="string"?o.string2buf(C):g.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,x=a.inflateSetDictionary(this.strm,R)),x===l.Z_BUF_ERROR&&k===!0&&(x=l.Z_OK,k=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&x!==l.Z_STREAM_END&&(N.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(N.output,N.next_out),A=N.next_out-w,T=o.buf2string(N.output,w),N.next_out=A,N.avail_out=j-A,A&&s.arraySet(N.output,N.output,w,A,0),this.onData(T)):this.onData(s.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(k=!0)}while((0<N.avail_in||N.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(M=l.Z_FINISH),M===l.Z_FINISH?(x=a.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):M!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(N.avail_out=0))},m.prototype.onData=function(v){this.chunks.push(v)},m.prototype.onEnd=function(v){v===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=m,i.inflate=y,i.inflateRaw=function(v,b){return(b=b||{}).raw=!0,y(v,b)},i.ungzip=y},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var f in u)u.hasOwnProperty(f)&&(l[f]=u[f])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,f,g){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+f),g);else for(var m=0;m<f;m++)l[g+m]=c[u+m]},flattenChunks:function(l){var c,u,f,g,m,y;for(c=f=0,u=l.length;c<u;c++)f+=l[c].length;for(y=new Uint8Array(f),c=g=0,u=l.length;c<u;c++)m=l[c],y.set(m,g),g+=m.length;return y}},o={arraySet:function(l,c,u,f,g){for(var m=0;m<f;m++)l[g+m]=c[u+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new a.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var m="",y=0;y<g;y++)m+=String.fromCharCode(f[y]);return m}l[254]=l[254]=1,i.string2buf=function(f){var g,m,y,v,b,x=f.length,M=0;for(v=0;v<x;v++)(64512&(m=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),v++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new a.Buf8(M),v=b=0;b<M;v++)(64512&(m=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),v++),m<128?g[b++]=m:(m<2048?g[b++]=192|m>>>6:(m<65536?g[b++]=224|m>>>12:(g[b++]=240|m>>>18,g[b++]=128|m>>>12&63),g[b++]=128|m>>>6&63),g[b++]=128|63&m);return g},i.buf2binstring=function(f){return u(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),m=0,y=g.length;m<y;m++)g[m]=f.charCodeAt(m);return g},i.buf2string=function(f,g){var m,y,v,b,x=g||f.length,M=new Array(2*x);for(m=y=0;m<x;)if((v=f[m++])<128)M[y++]=v;else if(4<(b=l[v]))M[y++]=65533,m+=b-1;else{for(v&=b===2?31:b===3?15:7;1<b&&m<x;)v=v<<6|63&f[m++],b--;1<b?M[y++]=65533:v<65536?M[y++]=v:(v-=65536,M[y++]=55296|v>>10&1023,M[y++]=56320|1023&v)}return u(M,y)},i.utf8border=function(f,g){var m;for((g=g||f.length)>f.length&&(g=f.length),m=g-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?g:m+l[f[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,o,l){for(var c=65535&a|0,u=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;u=u+(c=c+s[l++]|0)|0,--f;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,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 s,o=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;o[l]=s}return o})();r.exports=function(s,o,l,c){var u=a,f=c+l;s^=-1;for(var g=c;g<f;g++)s=s>>>8^u[255&(s^o[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),f=0,g=4,m=0,y=-2,v=-1,b=4,x=2,M=8,w=9,A=286,T=30,R=19,N=2*A+1,j=15,C=3,k=258,U=k+C+1,I=42,H=113,O=1,B=2,V=3,G=4;function K(z,q){return z.msg=u[q],q}function Y(z){return(z<<1)-(4<z?9:0)}function oe(z){for(var q=z.length;0<=--q;)z[q]=0}function $(z){var q=z.state,ie=q.pending;ie>z.avail_out&&(ie=z.avail_out),ie!==0&&(s.arraySet(z.output,q.pending_buf,q.pending_out,ie,z.next_out),z.next_out+=ie,q.pending_out+=ie,z.total_out+=ie,z.avail_out-=ie,q.pending-=ie,q.pending===0&&(q.pending_out=0))}function X(z,q){o._tr_flush_block(z,0<=z.block_start?z.block_start:-1,z.strstart-z.block_start,q),z.block_start=z.strstart,$(z.strm)}function ae(z,q){z.pending_buf[z.pending++]=q}function ce(z,q){z.pending_buf[z.pending++]=q>>>8&255,z.pending_buf[z.pending++]=255&q}function xe(z,q){var ie,Q,ee=z.max_chain_length,le=z.strstart,Re=z.prev_length,Pe=z.nice_match,ne=z.strstart>z.w_size-U?z.strstart-(z.w_size-U):0,F=z.window,L=z.w_mask,Z=z.prev,ge=z.strstart+k,ye=F[le+Re-1],pe=F[le+Re];z.prev_length>=z.good_match&&(ee>>=2),Pe>z.lookahead&&(Pe=z.lookahead);do if(F[(ie=q)+Re]===pe&&F[ie+Re-1]===ye&&F[ie]===F[le]&&F[++ie]===F[le+1]){le+=2,ie++;do;while(F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&F[++le]===F[++ie]&&le<ge);if(Q=k-(ge-le),le=ge-k,Re<Q){if(z.match_start=q,Pe<=(Re=Q))break;ye=F[le+Re-1],pe=F[le+Re]}}while((q=Z[q&L])>ne&&--ee!=0);return Re<=z.lookahead?Re:z.lookahead}function te(z){var q,ie,Q,ee,le,Re,Pe,ne,F,L,Z=z.w_size;do{if(ee=z.window_size-z.lookahead-z.strstart,z.strstart>=Z+(Z-U)){for(s.arraySet(z.window,z.window,Z,Z,0),z.match_start-=Z,z.strstart-=Z,z.block_start-=Z,q=ie=z.hash_size;Q=z.head[--q],z.head[q]=Z<=Q?Q-Z:0,--ie;);for(q=ie=Z;Q=z.prev[--q],z.prev[q]=Z<=Q?Q-Z:0,--ie;);ee+=Z}if(z.strm.avail_in===0)break;if(Re=z.strm,Pe=z.window,ne=z.strstart+z.lookahead,F=ee,L=void 0,L=Re.avail_in,F<L&&(L=F),ie=L===0?0:(Re.avail_in-=L,s.arraySet(Pe,Re.input,Re.next_in,L,ne),Re.state.wrap===1?Re.adler=l(Re.adler,Pe,L,ne):Re.state.wrap===2&&(Re.adler=c(Re.adler,Pe,L,ne)),Re.next_in+=L,Re.total_in+=L,L),z.lookahead+=ie,z.lookahead+z.insert>=C)for(le=z.strstart-z.insert,z.ins_h=z.window[le],z.ins_h=(z.ins_h<<z.hash_shift^z.window[le+1])&z.hash_mask;z.insert&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[le+C-1])&z.hash_mask,z.prev[le&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=le,le++,z.insert--,!(z.lookahead+z.insert<C)););}while(z.lookahead<U&&z.strm.avail_in!==0)}function ve(z,q){for(var ie,Q;;){if(z.lookahead<U){if(te(z),z.lookahead<U&&q===f)return O;if(z.lookahead===0)break}if(ie=0,z.lookahead>=C&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+C-1])&z.hash_mask,ie=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),ie!==0&&z.strstart-ie<=z.w_size-U&&(z.match_length=xe(z,ie)),z.match_length>=C)if(Q=o._tr_tally(z,z.strstart-z.match_start,z.match_length-C),z.lookahead-=z.match_length,z.match_length<=z.max_lazy_match&&z.lookahead>=C){for(z.match_length--;z.strstart++,z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+C-1])&z.hash_mask,ie=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart,--z.match_length!=0;);z.strstart++}else z.strstart+=z.match_length,z.match_length=0,z.ins_h=z.window[z.strstart],z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+1])&z.hash_mask;else Q=o._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++;if(Q&&(X(z,!1),z.strm.avail_out===0))return O}return z.insert=z.strstart<C-1?z.strstart:C-1,q===g?(X(z,!0),z.strm.avail_out===0?V:G):z.last_lit&&(X(z,!1),z.strm.avail_out===0)?O:B}function De(z,q){for(var ie,Q,ee;;){if(z.lookahead<U){if(te(z),z.lookahead<U&&q===f)return O;if(z.lookahead===0)break}if(ie=0,z.lookahead>=C&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+C-1])&z.hash_mask,ie=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),z.prev_length=z.match_length,z.prev_match=z.match_start,z.match_length=C-1,ie!==0&&z.prev_length<z.max_lazy_match&&z.strstart-ie<=z.w_size-U&&(z.match_length=xe(z,ie),z.match_length<=5&&(z.strategy===1||z.match_length===C&&4096<z.strstart-z.match_start)&&(z.match_length=C-1)),z.prev_length>=C&&z.match_length<=z.prev_length){for(ee=z.strstart+z.lookahead-C,Q=o._tr_tally(z,z.strstart-1-z.prev_match,z.prev_length-C),z.lookahead-=z.prev_length-1,z.prev_length-=2;++z.strstart<=ee&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+C-1])&z.hash_mask,ie=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),--z.prev_length!=0;);if(z.match_available=0,z.match_length=C-1,z.strstart++,Q&&(X(z,!1),z.strm.avail_out===0))return O}else if(z.match_available){if((Q=o._tr_tally(z,0,z.window[z.strstart-1]))&&X(z,!1),z.strstart++,z.lookahead--,z.strm.avail_out===0)return O}else z.match_available=1,z.strstart++,z.lookahead--}return z.match_available&&(Q=o._tr_tally(z,0,z.window[z.strstart-1]),z.match_available=0),z.insert=z.strstart<C-1?z.strstart:C-1,q===g?(X(z,!0),z.strm.avail_out===0?V:G):z.last_lit&&(X(z,!1),z.strm.avail_out===0)?O:B}function he(z,q,ie,Q,ee){this.good_length=z,this.max_lazy=q,this.nice_length=ie,this.max_chain=Q,this.func=ee}function me(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*R+1)),oe(this.dyn_ltree),oe(this.dyn_dtree),oe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(j+1),this.heap=new s.Buf16(2*A+1),oe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),oe(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 we(z){var q;return z&&z.state?(z.total_in=z.total_out=0,z.data_type=x,(q=z.state).pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?I:H,z.adler=q.wrap===2?0:1,q.last_flush=f,o._tr_init(q),m):K(z,y)}function se(z){var q=we(z);return q===m&&(function(ie){ie.window_size=2*ie.w_size,oe(ie.head),ie.max_lazy_match=a[ie.level].max_lazy,ie.good_match=a[ie.level].good_length,ie.nice_match=a[ie.level].nice_length,ie.max_chain_length=a[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=C-1,ie.match_available=0,ie.ins_h=0})(z.state),q}function st(z,q,ie,Q,ee,le){if(!z)return y;var Re=1;if(q===v&&(q=6),Q<0?(Re=0,Q=-Q):15<Q&&(Re=2,Q-=16),ee<1||w<ee||ie!==M||Q<8||15<Q||q<0||9<q||le<0||b<le)return K(z,y);Q===8&&(Q=9);var Pe=new me;return(z.state=Pe).strm=z,Pe.wrap=Re,Pe.gzhead=null,Pe.w_bits=Q,Pe.w_size=1<<Pe.w_bits,Pe.w_mask=Pe.w_size-1,Pe.hash_bits=ee+7,Pe.hash_size=1<<Pe.hash_bits,Pe.hash_mask=Pe.hash_size-1,Pe.hash_shift=~~((Pe.hash_bits+C-1)/C),Pe.window=new s.Buf8(2*Pe.w_size),Pe.head=new s.Buf16(Pe.hash_size),Pe.prev=new s.Buf16(Pe.w_size),Pe.lit_bufsize=1<<ee+6,Pe.pending_buf_size=4*Pe.lit_bufsize,Pe.pending_buf=new s.Buf8(Pe.pending_buf_size),Pe.d_buf=1*Pe.lit_bufsize,Pe.l_buf=3*Pe.lit_bufsize,Pe.level=q,Pe.strategy=le,Pe.method=ie,se(z)}a=[new he(0,0,0,0,function(z,q){var ie=65535;for(ie>z.pending_buf_size-5&&(ie=z.pending_buf_size-5);;){if(z.lookahead<=1){if(te(z),z.lookahead===0&&q===f)return O;if(z.lookahead===0)break}z.strstart+=z.lookahead,z.lookahead=0;var Q=z.block_start+ie;if((z.strstart===0||z.strstart>=Q)&&(z.lookahead=z.strstart-Q,z.strstart=Q,X(z,!1),z.strm.avail_out===0)||z.strstart-z.block_start>=z.w_size-U&&(X(z,!1),z.strm.avail_out===0))return O}return z.insert=0,q===g?(X(z,!0),z.strm.avail_out===0?V:G):(z.strstart>z.block_start&&(X(z,!1),z.strm.avail_out),O)}),new he(4,4,8,4,ve),new he(4,5,16,8,ve),new he(4,6,32,32,ve),new he(4,4,16,16,De),new he(8,16,32,32,De),new he(8,16,128,128,De),new he(8,32,128,256,De),new he(32,128,258,1024,De),new he(32,258,258,4096,De)],i.deflateInit=function(z,q){return st(z,q,M,15,8,0)},i.deflateInit2=st,i.deflateReset=se,i.deflateResetKeep=we,i.deflateSetHeader=function(z,q){return z&&z.state?z.state.wrap!==2?y:(z.state.gzhead=q,m):y},i.deflate=function(z,q){var ie,Q,ee,le;if(!z||!z.state||5<q||q<0)return z?K(z,y):y;if(Q=z.state,!z.output||!z.input&&z.avail_in!==0||Q.status===666&&q!==g)return K(z,z.avail_out===0?-5:y);if(Q.strm=z,ie=Q.last_flush,Q.last_flush=q,Q.status===I)if(Q.wrap===2)z.adler=0,ae(Q,31),ae(Q,139),ae(Q,8),Q.gzhead?(ae(Q,(Q.gzhead.text?1:0)+(Q.gzhead.hcrc?2:0)+(Q.gzhead.extra?4:0)+(Q.gzhead.name?8:0)+(Q.gzhead.comment?16:0)),ae(Q,255&Q.gzhead.time),ae(Q,Q.gzhead.time>>8&255),ae(Q,Q.gzhead.time>>16&255),ae(Q,Q.gzhead.time>>24&255),ae(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),ae(Q,255&Q.gzhead.os),Q.gzhead.extra&&Q.gzhead.extra.length&&(ae(Q,255&Q.gzhead.extra.length),ae(Q,Q.gzhead.extra.length>>8&255)),Q.gzhead.hcrc&&(z.adler=c(z.adler,Q.pending_buf,Q.pending,0)),Q.gzindex=0,Q.status=69):(ae(Q,0),ae(Q,0),ae(Q,0),ae(Q,0),ae(Q,0),ae(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),ae(Q,3),Q.status=H);else{var Re=M+(Q.w_bits-8<<4)<<8;Re|=(2<=Q.strategy||Q.level<2?0:Q.level<6?1:Q.level===6?2:3)<<6,Q.strstart!==0&&(Re|=32),Re+=31-Re%31,Q.status=H,ce(Q,Re),Q.strstart!==0&&(ce(Q,z.adler>>>16),ce(Q,65535&z.adler)),z.adler=1}if(Q.status===69)if(Q.gzhead.extra){for(ee=Q.pending;Q.gzindex<(65535&Q.gzhead.extra.length)&&(Q.pending!==Q.pending_buf_size||(Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),$(z),ee=Q.pending,Q.pending!==Q.pending_buf_size));)ae(Q,255&Q.gzhead.extra[Q.gzindex]),Q.gzindex++;Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),Q.gzindex===Q.gzhead.extra.length&&(Q.gzindex=0,Q.status=73)}else Q.status=73;if(Q.status===73)if(Q.gzhead.name){ee=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),$(z),ee=Q.pending,Q.pending===Q.pending_buf_size)){le=1;break}le=Q.gzindex<Q.gzhead.name.length?255&Q.gzhead.name.charCodeAt(Q.gzindex++):0,ae(Q,le)}while(le!==0);Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),le===0&&(Q.gzindex=0,Q.status=91)}else Q.status=91;if(Q.status===91)if(Q.gzhead.comment){ee=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),$(z),ee=Q.pending,Q.pending===Q.pending_buf_size)){le=1;break}le=Q.gzindex<Q.gzhead.comment.length?255&Q.gzhead.comment.charCodeAt(Q.gzindex++):0,ae(Q,le)}while(le!==0);Q.gzhead.hcrc&&Q.pending>ee&&(z.adler=c(z.adler,Q.pending_buf,Q.pending-ee,ee)),le===0&&(Q.status=103)}else Q.status=103;if(Q.status===103&&(Q.gzhead.hcrc?(Q.pending+2>Q.pending_buf_size&&$(z),Q.pending+2<=Q.pending_buf_size&&(ae(Q,255&z.adler),ae(Q,z.adler>>8&255),z.adler=0,Q.status=H)):Q.status=H),Q.pending!==0){if($(z),z.avail_out===0)return Q.last_flush=-1,m}else if(z.avail_in===0&&Y(q)<=Y(ie)&&q!==g)return K(z,-5);if(Q.status===666&&z.avail_in!==0)return K(z,-5);if(z.avail_in!==0||Q.lookahead!==0||q!==f&&Q.status!==666){var Pe=Q.strategy===2?(function(ne,F){for(var L;;){if(ne.lookahead===0&&(te(ne),ne.lookahead===0)){if(F===f)return O;break}if(ne.match_length=0,L=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++,L&&(X(ne,!1),ne.strm.avail_out===0))return O}return ne.insert=0,F===g?(X(ne,!0),ne.strm.avail_out===0?V:G):ne.last_lit&&(X(ne,!1),ne.strm.avail_out===0)?O:B})(Q,q):Q.strategy===3?(function(ne,F){for(var L,Z,ge,ye,pe=ne.window;;){if(ne.lookahead<=k){if(te(ne),ne.lookahead<=k&&F===f)return O;if(ne.lookahead===0)break}if(ne.match_length=0,ne.lookahead>=C&&0<ne.strstart&&(Z=pe[ge=ne.strstart-1])===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]){ye=ne.strstart+k;do;while(Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&Z===pe[++ge]&&ge<ye);ne.match_length=k-(ye-ge),ne.match_length>ne.lookahead&&(ne.match_length=ne.lookahead)}if(ne.match_length>=C?(L=o._tr_tally(ne,1,ne.match_length-C),ne.lookahead-=ne.match_length,ne.strstart+=ne.match_length,ne.match_length=0):(L=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++),L&&(X(ne,!1),ne.strm.avail_out===0))return O}return ne.insert=0,F===g?(X(ne,!0),ne.strm.avail_out===0?V:G):ne.last_lit&&(X(ne,!1),ne.strm.avail_out===0)?O:B})(Q,q):a[Q.level].func(Q,q);if(Pe!==V&&Pe!==G||(Q.status=666),Pe===O||Pe===V)return z.avail_out===0&&(Q.last_flush=-1),m;if(Pe===B&&(q===1?o._tr_align(Q):q!==5&&(o._tr_stored_block(Q,0,0,!1),q===3&&(oe(Q.head),Q.lookahead===0&&(Q.strstart=0,Q.block_start=0,Q.insert=0))),$(z),z.avail_out===0))return Q.last_flush=-1,m}return q!==g?m:Q.wrap<=0?1:(Q.wrap===2?(ae(Q,255&z.adler),ae(Q,z.adler>>8&255),ae(Q,z.adler>>16&255),ae(Q,z.adler>>24&255),ae(Q,255&z.total_in),ae(Q,z.total_in>>8&255),ae(Q,z.total_in>>16&255),ae(Q,z.total_in>>24&255)):(ce(Q,z.adler>>>16),ce(Q,65535&z.adler)),$(z),0<Q.wrap&&(Q.wrap=-Q.wrap),Q.pending!==0?m:1)},i.deflateEnd=function(z){var q;return z&&z.state?(q=z.state.status)!==I&&q!==69&&q!==73&&q!==91&&q!==103&&q!==H&&q!==666?K(z,y):(z.state=null,q===H?K(z,-3):m):y},i.deflateSetDictionary=function(z,q){var ie,Q,ee,le,Re,Pe,ne,F,L=q.length;if(!z||!z.state||(le=(ie=z.state).wrap)===2||le===1&&ie.status!==I||ie.lookahead)return y;for(le===1&&(z.adler=l(z.adler,q,L,0)),ie.wrap=0,L>=ie.w_size&&(le===0&&(oe(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),F=new s.Buf8(ie.w_size),s.arraySet(F,q,L-ie.w_size,ie.w_size,0),q=F,L=ie.w_size),Re=z.avail_in,Pe=z.next_in,ne=z.input,z.avail_in=L,z.next_in=0,z.input=q,te(ie);ie.lookahead>=C;){for(Q=ie.strstart,ee=ie.lookahead-(C-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[Q+C-1])&ie.hash_mask,ie.prev[Q&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=Q,Q++,--ee;);ie.strstart=Q,ie.lookahead=C-1,te(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=C-1,ie.match_available=0,z.next_in=Pe,z.input=ne,z.avail_in=Re,ie.wrap=le,m},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,s){var o,l,c,u,f,g,m,y,v,b,x,M,w,A,T,R,N,j,C,k,U,I,H,O,B;o=a.state,l=a.next_in,O=a.input,c=l+(a.avail_in-5),u=a.next_out,B=a.output,f=u-(s-a.avail_out),g=u+(a.avail_out-257),m=o.dmax,y=o.wsize,v=o.whave,b=o.wnext,x=o.window,M=o.hold,w=o.bits,A=o.lencode,T=o.distcode,R=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{w<15&&(M+=O[l++]<<w,w+=8,M+=O[l++]<<w,w+=8),j=A[M&R];t:for(;;){if(M>>>=C=j>>>24,w-=C,(C=j>>>16&255)===0)B[u++]=65535&j;else{if(!(16&C)){if((64&C)==0){j=A[(65535&j)+(M&(1<<C)-1)];continue t}if(32&C){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}k=65535&j,(C&=15)&&(w<C&&(M+=O[l++]<<w,w+=8),k+=M&(1<<C)-1,M>>>=C,w-=C),w<15&&(M+=O[l++]<<w,w+=8,M+=O[l++]<<w,w+=8),j=T[M&N];n:for(;;){if(M>>>=C=j>>>24,w-=C,!(16&(C=j>>>16&255))){if((64&C)==0){j=T[(65535&j)+(M&(1<<C)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(U=65535&j,w<(C&=15)&&(M+=O[l++]<<w,(w+=8)<C&&(M+=O[l++]<<w,w+=8)),m<(U+=M&(1<<C)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=C,w-=C,(C=u-f)<U){if(v<(C=U-C)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(H=x,(I=0)===b){if(I+=y-C,C<k){for(k-=C;B[u++]=x[I++],--C;);I=u-U,H=B}}else if(b<C){if(I+=y+b-C,(C-=b)<k){for(k-=C;B[u++]=x[I++],--C;);if(I=0,b<k){for(k-=C=b;B[u++]=x[I++],--C;);I=u-U,H=B}}}else if(I+=b-C,C<k){for(k-=C;B[u++]=x[I++],--C;);I=u-U,H=B}for(;2<k;)B[u++]=H[I++],B[u++]=H[I++],B[u++]=H[I++],k-=3;k&&(B[u++]=H[I++],1<k&&(B[u++]=H[I++]))}else{for(I=u-U;B[u++]=B[I++],B[u++]=B[I++],B[u++]=B[I++],2<(k-=3););k&&(B[u++]=B[I++],1<k&&(B[u++]=B[I++]))}break}}break}}while(l<c&&u<g);l-=k=w>>3,M&=(1<<(w-=k<<3))-1,a.next_in=l,a.next_out=u,a.avail_in=l<c?c-l+5:5-(l-c),a.avail_out=u<g?g-u+257:257-(u-g),o.hold=M,o.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,f=2,g=0,m=-2,y=1,v=852,b=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(I){var H;return I&&I.state?(H=I.state,I.total_in=I.total_out=H.total=0,I.msg="",H.wrap&&(I.adler=1&H.wrap),H.mode=y,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new a.Buf32(v),H.distcode=H.distdyn=new a.Buf32(b),H.sane=1,H.back=-1,g):m}function A(I){var H;return I&&I.state?((H=I.state).wsize=0,H.whave=0,H.wnext=0,w(I)):m}function T(I,H){var O,B;return I&&I.state?(B=I.state,H<0?(O=0,H=-H):(O=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?m:(B.window!==null&&B.wbits!==H&&(B.window=null),B.wrap=O,B.wbits=H,A(I))):m}function R(I,H){var O,B;return I?(B=new M,(I.state=B).window=null,(O=T(I,H))!==g&&(I.state=null),O):m}var N,j,C=!0;function k(I){if(C){var H;for(N=new a.Buf32(512),j=new a.Buf32(32),H=0;H<144;)I.lens[H++]=8;for(;H<256;)I.lens[H++]=9;for(;H<280;)I.lens[H++]=7;for(;H<288;)I.lens[H++]=8;for(c(u,I.lens,0,288,N,0,I.work,{bits:9}),H=0;H<32;)I.lens[H++]=5;c(f,I.lens,0,32,j,0,I.work,{bits:5}),C=!1}I.lencode=N,I.lenbits=9,I.distcode=j,I.distbits=5}function U(I,H,O,B){var V,G=I.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),B>=G.wsize?(a.arraySet(G.window,H,O-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(B<(V=G.wsize-G.wnext)&&(V=B),a.arraySet(G.window,H,O-B,V,G.wnext),(B-=V)?(a.arraySet(G.window,H,O-B,B,0),G.wnext=B,G.whave=G.wsize):(G.wnext+=V,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=V))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(I){return R(I,15)},i.inflateInit2=R,i.inflate=function(I,H){var O,B,V,G,K,Y,oe,$,X,ae,ce,xe,te,ve,De,he,me,we,se,st,z,q,ie,Q,ee=0,le=new a.Buf8(4),Re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return m;(O=I.state).mode===12&&(O.mode=13),K=I.next_out,V=I.output,oe=I.avail_out,G=I.next_in,B=I.input,Y=I.avail_in,$=O.hold,X=O.bits,ae=Y,ce=oe,q=g;e:for(;;)switch(O.mode){case y:if(O.wrap===0){O.mode=13;break}for(;X<16;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if(2&O.wrap&&$===35615){le[O.check=0]=255&$,le[1]=$>>>8&255,O.check=o(O.check,le,2,0),X=$=0,O.mode=2;break}if(O.flags=0,O.head&&(O.head.done=!1),!(1&O.wrap)||(((255&$)<<8)+($>>8))%31){I.msg="incorrect header check",O.mode=30;break}if((15&$)!=8){I.msg="unknown compression method",O.mode=30;break}if(X-=4,z=8+(15&($>>>=4)),O.wbits===0)O.wbits=z;else if(z>O.wbits){I.msg="invalid window size",O.mode=30;break}O.dmax=1<<z,I.adler=O.check=1,O.mode=512&$?10:12,X=$=0;break;case 2:for(;X<16;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if(O.flags=$,(255&O.flags)!=8){I.msg="unknown compression method",O.mode=30;break}if(57344&O.flags){I.msg="unknown header flags set",O.mode=30;break}O.head&&(O.head.text=$>>8&1),512&O.flags&&(le[0]=255&$,le[1]=$>>>8&255,O.check=o(O.check,le,2,0)),X=$=0,O.mode=3;case 3:for(;X<32;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.head&&(O.head.time=$),512&O.flags&&(le[0]=255&$,le[1]=$>>>8&255,le[2]=$>>>16&255,le[3]=$>>>24&255,O.check=o(O.check,le,4,0)),X=$=0,O.mode=4;case 4:for(;X<16;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.head&&(O.head.xflags=255&$,O.head.os=$>>8),512&O.flags&&(le[0]=255&$,le[1]=$>>>8&255,O.check=o(O.check,le,2,0)),X=$=0,O.mode=5;case 5:if(1024&O.flags){for(;X<16;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.length=$,O.head&&(O.head.extra_len=$),512&O.flags&&(le[0]=255&$,le[1]=$>>>8&255,O.check=o(O.check,le,2,0)),X=$=0}else O.head&&(O.head.extra=null);O.mode=6;case 6:if(1024&O.flags&&(Y<(xe=O.length)&&(xe=Y),xe&&(O.head&&(z=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),a.arraySet(O.head.extra,B,G,xe,z)),512&O.flags&&(O.check=o(O.check,B,xe,G)),Y-=xe,G+=xe,O.length-=xe),O.length))break e;O.length=0,O.mode=7;case 7:if(2048&O.flags){if(Y===0)break e;for(xe=0;z=B[G+xe++],O.head&&z&&O.length<65536&&(O.head.name+=String.fromCharCode(z)),z&&xe<Y;);if(512&O.flags&&(O.check=o(O.check,B,xe,G)),Y-=xe,G+=xe,z)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=8;case 8:if(4096&O.flags){if(Y===0)break e;for(xe=0;z=B[G+xe++],O.head&&z&&O.length<65536&&(O.head.comment+=String.fromCharCode(z)),z&&xe<Y;);if(512&O.flags&&(O.check=o(O.check,B,xe,G)),Y-=xe,G+=xe,z)break e}else O.head&&(O.head.comment=null);O.mode=9;case 9:if(512&O.flags){for(;X<16;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if($!==(65535&O.check)){I.msg="header crc mismatch",O.mode=30;break}X=$=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),I.adler=O.check=0,O.mode=12;break;case 10:for(;X<32;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}I.adler=O.check=x($),X=$=0,O.mode=11;case 11:if(O.havedict===0)return I.next_out=K,I.avail_out=oe,I.next_in=G,I.avail_in=Y,O.hold=$,O.bits=X,2;I.adler=O.check=1,O.mode=12;case 12:if(H===5||H===6)break e;case 13:if(O.last){$>>>=7&X,X-=7&X,O.mode=27;break}for(;X<3;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}switch(O.last=1&$,X-=1,3&($>>>=1)){case 0:O.mode=14;break;case 1:if(k(O),O.mode=20,H!==6)break;$>>>=2,X-=2;break e;case 2:O.mode=17;break;case 3:I.msg="invalid block type",O.mode=30}$>>>=2,X-=2;break;case 14:for($>>>=7&X,X-=7&X;X<32;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if((65535&$)!=($>>>16^65535)){I.msg="invalid stored block lengths",O.mode=30;break}if(O.length=65535&$,X=$=0,O.mode=15,H===6)break e;case 15:O.mode=16;case 16:if(xe=O.length){if(Y<xe&&(xe=Y),oe<xe&&(xe=oe),xe===0)break e;a.arraySet(V,B,G,xe,K),Y-=xe,G+=xe,oe-=xe,K+=xe,O.length-=xe;break}O.mode=12;break;case 17:for(;X<14;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if(O.nlen=257+(31&$),$>>>=5,X-=5,O.ndist=1+(31&$),$>>>=5,X-=5,O.ncode=4+(15&$),$>>>=4,X-=4,286<O.nlen||30<O.ndist){I.msg="too many length or distance symbols",O.mode=30;break}O.have=0,O.mode=18;case 18:for(;O.have<O.ncode;){for(;X<3;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.lens[Re[O.have++]]=7&$,$>>>=3,X-=3}for(;O.have<19;)O.lens[Re[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,ie={bits:O.lenbits},q=c(0,O.lens,0,19,O.lencode,0,O.work,ie),O.lenbits=ie.bits,q){I.msg="invalid code lengths set",O.mode=30;break}O.have=0,O.mode=19;case 19:for(;O.have<O.nlen+O.ndist;){for(;he=(ee=O.lencode[$&(1<<O.lenbits)-1])>>>16&255,me=65535&ee,!((De=ee>>>24)<=X);){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if(me<16)$>>>=De,X-=De,O.lens[O.have++]=me;else{if(me===16){for(Q=De+2;X<Q;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if($>>>=De,X-=De,O.have===0){I.msg="invalid bit length repeat",O.mode=30;break}z=O.lens[O.have-1],xe=3+(3&$),$>>>=2,X-=2}else if(me===17){for(Q=De+3;X<Q;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}X-=De,z=0,xe=3+(7&($>>>=De)),$>>>=3,X-=3}else{for(Q=De+7;X<Q;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}X-=De,z=0,xe=11+(127&($>>>=De)),$>>>=7,X-=7}if(O.have+xe>O.nlen+O.ndist){I.msg="invalid bit length repeat",O.mode=30;break}for(;xe--;)O.lens[O.have++]=z}}if(O.mode===30)break;if(O.lens[256]===0){I.msg="invalid code -- missing end-of-block",O.mode=30;break}if(O.lenbits=9,ie={bits:O.lenbits},q=c(u,O.lens,0,O.nlen,O.lencode,0,O.work,ie),O.lenbits=ie.bits,q){I.msg="invalid literal/lengths set",O.mode=30;break}if(O.distbits=6,O.distcode=O.distdyn,ie={bits:O.distbits},q=c(f,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,ie),O.distbits=ie.bits,q){I.msg="invalid distances set",O.mode=30;break}if(O.mode=20,H===6)break e;case 20:O.mode=21;case 21:if(6<=Y&&258<=oe){I.next_out=K,I.avail_out=oe,I.next_in=G,I.avail_in=Y,O.hold=$,O.bits=X,l(I,ce),K=I.next_out,V=I.output,oe=I.avail_out,G=I.next_in,B=I.input,Y=I.avail_in,$=O.hold,X=O.bits,O.mode===12&&(O.back=-1);break}for(O.back=0;he=(ee=O.lencode[$&(1<<O.lenbits)-1])>>>16&255,me=65535&ee,!((De=ee>>>24)<=X);){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if(he&&(240&he)==0){for(we=De,se=he,st=me;he=(ee=O.lencode[st+(($&(1<<we+se)-1)>>we)])>>>16&255,me=65535&ee,!(we+(De=ee>>>24)<=X);){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}$>>>=we,X-=we,O.back+=we}if($>>>=De,X-=De,O.back+=De,O.length=me,he===0){O.mode=26;break}if(32&he){O.back=-1,O.mode=12;break}if(64&he){I.msg="invalid literal/length code",O.mode=30;break}O.extra=15&he,O.mode=22;case 22:if(O.extra){for(Q=O.extra;X<Q;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.length+=$&(1<<O.extra)-1,$>>>=O.extra,X-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=23;case 23:for(;he=(ee=O.distcode[$&(1<<O.distbits)-1])>>>16&255,me=65535&ee,!((De=ee>>>24)<=X);){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if((240&he)==0){for(we=De,se=he,st=me;he=(ee=O.distcode[st+(($&(1<<we+se)-1)>>we)])>>>16&255,me=65535&ee,!(we+(De=ee>>>24)<=X);){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}$>>>=we,X-=we,O.back+=we}if($>>>=De,X-=De,O.back+=De,64&he){I.msg="invalid distance code",O.mode=30;break}O.offset=me,O.extra=15&he,O.mode=24;case 24:if(O.extra){for(Q=O.extra;X<Q;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}O.offset+=$&(1<<O.extra)-1,$>>>=O.extra,X-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){I.msg="invalid distance too far back",O.mode=30;break}O.mode=25;case 25:if(oe===0)break e;if(xe=ce-oe,O.offset>xe){if((xe=O.offset-xe)>O.whave&&O.sane){I.msg="invalid distance too far back",O.mode=30;break}te=xe>O.wnext?(xe-=O.wnext,O.wsize-xe):O.wnext-xe,xe>O.length&&(xe=O.length),ve=O.window}else ve=V,te=K-O.offset,xe=O.length;for(oe<xe&&(xe=oe),oe-=xe,O.length-=xe;V[K++]=ve[te++],--xe;);O.length===0&&(O.mode=21);break;case 26:if(oe===0)break e;V[K++]=O.length,oe--,O.mode=21;break;case 27:if(O.wrap){for(;X<32;){if(Y===0)break e;Y--,$|=B[G++]<<X,X+=8}if(ce-=oe,I.total_out+=ce,O.total+=ce,ce&&(I.adler=O.check=O.flags?o(O.check,V,ce,K-ce):s(O.check,V,ce,K-ce)),ce=oe,(O.flags?$:x($))!==O.check){I.msg="incorrect data check",O.mode=30;break}X=$=0}O.mode=28;case 28:if(O.wrap&&O.flags){for(;X<32;){if(Y===0)break e;Y--,$+=B[G++]<<X,X+=8}if($!==(4294967295&O.total)){I.msg="incorrect length check",O.mode=30;break}X=$=0}O.mode=29;case 29:q=1;break e;case 30:q=-3;break e;case 31:return-4;case 32:default:return m}return I.next_out=K,I.avail_out=oe,I.next_in=G,I.avail_in=Y,O.hold=$,O.bits=X,(O.wsize||ce!==I.avail_out&&O.mode<30&&(O.mode<27||H!==4))&&U(I,I.output,I.next_out,ce-I.avail_out)?(O.mode=31,-4):(ae-=I.avail_in,ce-=I.avail_out,I.total_in+=ae,I.total_out+=ce,O.total+=ce,O.wrap&&ce&&(I.adler=O.check=O.flags?o(O.check,V,ce,I.next_out-ce):s(O.check,V,ce,I.next_out-ce)),I.data_type=O.bits+(O.last?64:0)+(O.mode===12?128:0)+(O.mode===20||O.mode===15?256:0),(ae==0&&ce===0||H===4)&&q===g&&(q=-5),q)},i.inflateEnd=function(I){if(!I||!I.state)return m;var H=I.state;return H.window&&(H.window=null),I.state=null,g},i.inflateGetHeader=function(I,H){var O;return I&&I.state?(2&(O=I.state).wrap)==0?m:((O.head=H).done=!1,g):m},i.inflateSetDictionary=function(I,H){var O,B=H.length;return I&&I.state?(O=I.state).wrap!==0&&O.mode!==11?m:O.mode===11&&s(1,H,B,0)!==O.check?-3:U(I,H,B,B)?(O.mode=31,-4):(O.havedict=1,g):m},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"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,f,g,m,y,v,b,x){var M,w,A,T,R,N,j,C,k,U=x.bits,I=0,H=0,O=0,B=0,V=0,G=0,K=0,Y=0,oe=0,$=0,X=null,ae=0,ce=new a.Buf16(16),xe=new a.Buf16(16),te=null,ve=0;for(I=0;I<=15;I++)ce[I]=0;for(H=0;H<m;H++)ce[f[g+H]]++;for(V=U,B=15;1<=B&&ce[B]===0;B--);if(B<V&&(V=B),B===0)return y[v++]=20971520,y[v++]=20971520,x.bits=1,0;for(O=1;O<B&&ce[O]===0;O++);for(V<O&&(V=O),I=Y=1;I<=15;I++)if(Y<<=1,(Y-=ce[I])<0)return-1;if(0<Y&&(u===0||B!==1))return-1;for(xe[1]=0,I=1;I<15;I++)xe[I+1]=xe[I]+ce[I];for(H=0;H<m;H++)f[g+H]!==0&&(b[xe[f[g+H]]++]=H);if(N=u===0?(X=te=b,19):u===1?(X=s,ae-=257,te=o,ve-=257,256):(X=l,te=c,-1),I=O,R=v,K=H=$=0,A=-1,T=(oe=1<<(G=V))-1,u===1&&852<oe||u===2&&592<oe)return 1;for(;;){for(j=I-K,k=b[H]<N?(C=0,b[H]):b[H]>N?(C=te[ve+b[H]],X[ae+b[H]]):(C=96,0),M=1<<I-K,O=w=1<<G;y[R+($>>K)+(w-=M)]=j<<24|C<<16|k|0,w!==0;);for(M=1<<I-1;$&M;)M>>=1;if(M!==0?($&=M-1,$+=M):$=0,H++,--ce[I]==0){if(I===B)break;I=f[g+b[H]]}if(V<I&&($&T)!==A){for(K===0&&(K=V),R+=O,Y=1<<(G=I-K);G+K<B&&!((Y-=ce[G+K])<=0);)G++,Y<<=1;if(oe+=1<<G,u===1&&852<oe||u===2&&592<oe)return 1;y[A=$&T]=V<<24|G<<16|R-v|0}}return $!==0&&(y[R+$]=I-K<<24|64<<16|0),x.bits=V,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"),s=0,o=1;function l(ee){for(var le=ee.length;0<=--le;)ee[le]=0}var c=0,u=29,f=256,g=f+1+u,m=30,y=19,v=2*g+1,b=15,x=16,M=7,w=256,A=16,T=17,R=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(g+2));l(U);var I=new Array(2*m);l(I);var H=new Array(512);l(H);var O=new Array(256);l(O);var B=new Array(u);l(B);var V,G,K,Y=new Array(m);function oe(ee,le,Re,Pe,ne){this.static_tree=ee,this.extra_bits=le,this.extra_base=Re,this.elems=Pe,this.max_length=ne,this.has_stree=ee&&ee.length}function $(ee,le){this.dyn_tree=ee,this.max_code=0,this.stat_desc=le}function X(ee){return ee<256?H[ee]:H[256+(ee>>>7)]}function ae(ee,le){ee.pending_buf[ee.pending++]=255&le,ee.pending_buf[ee.pending++]=le>>>8&255}function ce(ee,le,Re){ee.bi_valid>x-Re?(ee.bi_buf|=le<<ee.bi_valid&65535,ae(ee,ee.bi_buf),ee.bi_buf=le>>x-ee.bi_valid,ee.bi_valid+=Re-x):(ee.bi_buf|=le<<ee.bi_valid&65535,ee.bi_valid+=Re)}function xe(ee,le,Re){ce(ee,Re[2*le],Re[2*le+1])}function te(ee,le){for(var Re=0;Re|=1&ee,ee>>>=1,Re<<=1,0<--le;);return Re>>>1}function ve(ee,le,Re){var Pe,ne,F=new Array(b+1),L=0;for(Pe=1;Pe<=b;Pe++)F[Pe]=L=L+Re[Pe-1]<<1;for(ne=0;ne<=le;ne++){var Z=ee[2*ne+1];Z!==0&&(ee[2*ne]=te(F[Z]++,Z))}}function De(ee){var le;for(le=0;le<g;le++)ee.dyn_ltree[2*le]=0;for(le=0;le<m;le++)ee.dyn_dtree[2*le]=0;for(le=0;le<y;le++)ee.bl_tree[2*le]=0;ee.dyn_ltree[2*w]=1,ee.opt_len=ee.static_len=0,ee.last_lit=ee.matches=0}function he(ee){8<ee.bi_valid?ae(ee,ee.bi_buf):0<ee.bi_valid&&(ee.pending_buf[ee.pending++]=ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0}function me(ee,le,Re,Pe){var ne=2*le,F=2*Re;return ee[ne]<ee[F]||ee[ne]===ee[F]&&Pe[le]<=Pe[Re]}function we(ee,le,Re){for(var Pe=ee.heap[Re],ne=Re<<1;ne<=ee.heap_len&&(ne<ee.heap_len&&me(le,ee.heap[ne+1],ee.heap[ne],ee.depth)&&ne++,!me(le,Pe,ee.heap[ne],ee.depth));)ee.heap[Re]=ee.heap[ne],Re=ne,ne<<=1;ee.heap[Re]=Pe}function se(ee,le,Re){var Pe,ne,F,L,Z=0;if(ee.last_lit!==0)for(;Pe=ee.pending_buf[ee.d_buf+2*Z]<<8|ee.pending_buf[ee.d_buf+2*Z+1],ne=ee.pending_buf[ee.l_buf+Z],Z++,Pe===0?xe(ee,ne,le):(xe(ee,(F=O[ne])+f+1,le),(L=N[F])!==0&&ce(ee,ne-=B[F],L),xe(ee,F=X(--Pe),Re),(L=j[F])!==0&&ce(ee,Pe-=Y[F],L)),Z<ee.last_lit;);xe(ee,w,le)}function st(ee,le){var Re,Pe,ne,F=le.dyn_tree,L=le.stat_desc.static_tree,Z=le.stat_desc.has_stree,ge=le.stat_desc.elems,ye=-1;for(ee.heap_len=0,ee.heap_max=v,Re=0;Re<ge;Re++)F[2*Re]!==0?(ee.heap[++ee.heap_len]=ye=Re,ee.depth[Re]=0):F[2*Re+1]=0;for(;ee.heap_len<2;)F[2*(ne=ee.heap[++ee.heap_len]=ye<2?++ye:0)]=1,ee.depth[ne]=0,ee.opt_len--,Z&&(ee.static_len-=L[2*ne+1]);for(le.max_code=ye,Re=ee.heap_len>>1;1<=Re;Re--)we(ee,F,Re);for(ne=ge;Re=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],we(ee,F,1),Pe=ee.heap[1],ee.heap[--ee.heap_max]=Re,ee.heap[--ee.heap_max]=Pe,F[2*ne]=F[2*Re]+F[2*Pe],ee.depth[ne]=(ee.depth[Re]>=ee.depth[Pe]?ee.depth[Re]:ee.depth[Pe])+1,F[2*Re+1]=F[2*Pe+1]=ne,ee.heap[1]=ne++,we(ee,F,1),2<=ee.heap_len;);ee.heap[--ee.heap_max]=ee.heap[1],(function(pe,Ze){var Ie,Xe,ot,je,ke,pt,rt=Ze.dyn_tree,nt=Ze.max_code,dt=Ze.stat_desc.static_tree,de=Ze.stat_desc.has_stree,it=Ze.stat_desc.extra_bits,fe=Ze.stat_desc.extra_base,Le=Ze.stat_desc.max_length,Ee=0;for(je=0;je<=b;je++)pe.bl_count[je]=0;for(rt[2*pe.heap[pe.heap_max]+1]=0,Ie=pe.heap_max+1;Ie<v;Ie++)Le<(je=rt[2*rt[2*(Xe=pe.heap[Ie])+1]+1]+1)&&(je=Le,Ee++),rt[2*Xe+1]=je,nt<Xe||(pe.bl_count[je]++,ke=0,fe<=Xe&&(ke=it[Xe-fe]),pt=rt[2*Xe],pe.opt_len+=pt*(je+ke),de&&(pe.static_len+=pt*(dt[2*Xe+1]+ke)));if(Ee!==0){do{for(je=Le-1;pe.bl_count[je]===0;)je--;pe.bl_count[je]--,pe.bl_count[je+1]+=2,pe.bl_count[Le]--,Ee-=2}while(0<Ee);for(je=Le;je!==0;je--)for(Xe=pe.bl_count[je];Xe!==0;)nt<(ot=pe.heap[--Ie])||(rt[2*ot+1]!==je&&(pe.opt_len+=(je-rt[2*ot+1])*rt[2*ot],rt[2*ot+1]=je),Xe--)}})(ee,le),ve(F,ye,ee.bl_count)}function z(ee,le,Re){var Pe,ne,F=-1,L=le[1],Z=0,ge=7,ye=4;for(L===0&&(ge=138,ye=3),le[2*(Re+1)+1]=65535,Pe=0;Pe<=Re;Pe++)ne=L,L=le[2*(Pe+1)+1],++Z<ge&&ne===L||(Z<ye?ee.bl_tree[2*ne]+=Z:ne!==0?(ne!==F&&ee.bl_tree[2*ne]++,ee.bl_tree[2*A]++):Z<=10?ee.bl_tree[2*T]++:ee.bl_tree[2*R]++,F=ne,ye=(Z=0)===L?(ge=138,3):ne===L?(ge=6,3):(ge=7,4))}function q(ee,le,Re){var Pe,ne,F=-1,L=le[1],Z=0,ge=7,ye=4;for(L===0&&(ge=138,ye=3),Pe=0;Pe<=Re;Pe++)if(ne=L,L=le[2*(Pe+1)+1],!(++Z<ge&&ne===L)){if(Z<ye)for(;xe(ee,ne,ee.bl_tree),--Z!=0;);else ne!==0?(ne!==F&&(xe(ee,ne,ee.bl_tree),Z--),xe(ee,A,ee.bl_tree),ce(ee,Z-3,2)):Z<=10?(xe(ee,T,ee.bl_tree),ce(ee,Z-3,3)):(xe(ee,R,ee.bl_tree),ce(ee,Z-11,7));F=ne,ye=(Z=0)===L?(ge=138,3):ne===L?(ge=6,3):(ge=7,4)}}l(Y);var ie=!1;function Q(ee,le,Re,Pe){ce(ee,(c<<1)+(Pe?1:0),3),(function(ne,F,L,Z){he(ne),ae(ne,L),ae(ne,~L),a.arraySet(ne.pending_buf,ne.window,F,L,ne.pending),ne.pending+=L})(ee,le,Re)}i._tr_init=function(ee){ie||((function(){var le,Re,Pe,ne,F,L=new Array(b+1);for(ne=Pe=0;ne<u-1;ne++)for(B[ne]=Pe,le=0;le<1<<N[ne];le++)O[Pe++]=ne;for(O[Pe-1]=ne,ne=F=0;ne<16;ne++)for(Y[ne]=F,le=0;le<1<<j[ne];le++)H[F++]=ne;for(F>>=7;ne<m;ne++)for(Y[ne]=F<<7,le=0;le<1<<j[ne]-7;le++)H[256+F++]=ne;for(Re=0;Re<=b;Re++)L[Re]=0;for(le=0;le<=143;)U[2*le+1]=8,le++,L[8]++;for(;le<=255;)U[2*le+1]=9,le++,L[9]++;for(;le<=279;)U[2*le+1]=7,le++,L[7]++;for(;le<=287;)U[2*le+1]=8,le++,L[8]++;for(ve(U,g+1,L),le=0;le<m;le++)I[2*le+1]=5,I[2*le]=te(le,5);V=new oe(U,N,f+1,g,b),G=new oe(I,j,0,m,b),K=new oe(new Array(0),C,0,y,M)})(),ie=!0),ee.l_desc=new $(ee.dyn_ltree,V),ee.d_desc=new $(ee.dyn_dtree,G),ee.bl_desc=new $(ee.bl_tree,K),ee.bi_buf=0,ee.bi_valid=0,De(ee)},i._tr_stored_block=Q,i._tr_flush_block=function(ee,le,Re,Pe){var ne,F,L=0;0<ee.level?(ee.strm.data_type===2&&(ee.strm.data_type=(function(Z){var ge,ye=4093624447;for(ge=0;ge<=31;ge++,ye>>>=1)if(1&ye&&Z.dyn_ltree[2*ge]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return o;for(ge=32;ge<f;ge++)if(Z.dyn_ltree[2*ge]!==0)return o;return s})(ee)),st(ee,ee.l_desc),st(ee,ee.d_desc),L=(function(Z){var ge;for(z(Z,Z.dyn_ltree,Z.l_desc.max_code),z(Z,Z.dyn_dtree,Z.d_desc.max_code),st(Z,Z.bl_desc),ge=y-1;3<=ge&&Z.bl_tree[2*k[ge]+1]===0;ge--);return Z.opt_len+=3*(ge+1)+5+5+4,ge})(ee),ne=ee.opt_len+3+7>>>3,(F=ee.static_len+3+7>>>3)<=ne&&(ne=F)):ne=F=Re+5,Re+4<=ne&&le!==-1?Q(ee,le,Re,Pe):ee.strategy===4||F===ne?(ce(ee,2+(Pe?1:0),3),se(ee,U,I)):(ce(ee,4+(Pe?1:0),3),(function(Z,ge,ye,pe){var Ze;for(ce(Z,ge-257,5),ce(Z,ye-1,5),ce(Z,pe-4,4),Ze=0;Ze<pe;Ze++)ce(Z,Z.bl_tree[2*k[Ze]+1],3);q(Z,Z.dyn_ltree,ge-1),q(Z,Z.dyn_dtree,ye-1)})(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,L+1),se(ee,ee.dyn_ltree,ee.dyn_dtree)),De(ee),Pe&&he(ee)},i._tr_tally=function(ee,le,Re){return ee.pending_buf[ee.d_buf+2*ee.last_lit]=le>>>8&255,ee.pending_buf[ee.d_buf+2*ee.last_lit+1]=255&le,ee.pending_buf[ee.l_buf+ee.last_lit]=255&Re,ee.last_lit++,le===0?ee.dyn_ltree[2*Re]++:(ee.matches++,le--,ee.dyn_ltree[2*(O[Re]+f+1)]++,ee.dyn_dtree[2*X(le)]++),ee.last_lit===ee.lit_bufsize-1},i._tr_align=function(ee){ce(ee,2,3),xe(ee,w,U),(function(le){le.bi_valid===16?(ae(le,le.bi_buf),le.bi_buf=0,le.bi_valid=0):8<=le.bi_valid&&(le.pending_buf[le.pending++]=255&le.bi_buf,le.bi_buf>>=8,le.bi_valid-=8)})(ee)}},{"../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(s,o){if(!s.setImmediate){var l,c,u,f,g=1,m={},y=!1,v=s.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(s);b=b&&b.setTimeout?b:s,l={}.toString.call(s.process)==="[object process]"?function(A){process.nextTick(function(){M(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,T=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(A){s.postMessage(f+A,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){u.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(c=v.documentElement,function(A){var T=v.createElement("script");T.onreadystatechange=function(){M(A),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(A){setTimeout(M,0,A)},b.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),R=0;R<T.length;R++)T[R]=arguments[R+1];var N={callback:A,args:T};return m[g]=N,l(g),g++},b.clearImmediate=x}function x(A){delete m[A]}function M(A){if(y)setTimeout(M,0,A);else{var T=m[A];if(T){y=!0;try{(function(R){var N=R.callback,j=R.args;switch(j.length){case 0:N();break;case 1:N(j[0]);break;case 2:N(j[0],j[1]);break;case 3:N(j[0],j[1],j[2]);break;default:N.apply(o,j)}})(T)}finally{x(A),y=!1}}}}function w(A){A.source===s&&typeof A.data=="string"&&A.data.indexOf(f)===0&&M(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Nb<"u"?Nb:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gT)),gT.exports}var Kme=Xme();const Yme=Js(Kme);function Zme(t){const e=new qr;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 dz=Zme;async function fz(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],o=i.getElementsByTagName("vertex");for(let c=0;c<o.length;c++){const u=o[c];a.push(parseFloat(u.getAttribute("x")||"0"),parseFloat(u.getAttribute("y")||"0"),parseFloat(u.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const u=l[c];s.push(parseInt(u.getAttribute("v1")||"0"),parseInt(u.getAttribute("v2")||"0"),parseInt(u.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function Qme(t){const e=await Yme.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(u){const f=u.startsWith("/")?u.slice(1):u,g=e.files[f];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const s=Object.keys(e.files).find(u=>u==="3D/3dmodel.model"||u.endsWith("/3dmodel.model"));if(!s){const u=Object.keys(e.files).find(f=>f.endsWith(".model"));if(u){const f=await a(u);if(f){const g=await fz(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await a(s);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let u=0;u<l.length;u++){const f=l[u],g=f.getAttribute("id");if(!g)continue;const m=[],y=f.getElementsByTagName("mesh");for(let b=0;b<y.length;b++){const x=y[b],M=[],w=[],A=x.getElementsByTagName("vertex");for(let R=0;R<A.length;R++){const N=A[R];M.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let R=0;R<T.length;R++){const N=T[R];w.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&m.push({vertices:M,triangles:w})}const v=f.getElementsByTagName("component");for(let b=0;b<v.length;b++){const x=v[b],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const w=await a(M);if(w){const A=await fz(w),T=x.getAttribute("transform"),R=dz(T);for(const N of A)if(T){const j=[];for(let C=0;C<N.vertices.length;C+=3){const k=new Ge(N.vertices[C],N.vertices[C+1],N.vertices[C+2]);k.applyMatrix4(R),j.push(k.x,k.y,k.z)}m.push({vertices:j,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const c=o.getElementsByTagName("build");if(c.length>0){const u=c[0].getElementsByTagName("item");for(let f=0;f<u.length;f++){const g=u[f],m=g.getAttribute("objectid");if(!m)continue;const y=dz(g.getAttribute("transform"));r.push({objectId:m,transform:y})}}return{objects:n,buildItems:r}}function hz(t){const e=new dl,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 Gs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Jme({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),a=E.useRef(null),s=E.useRef(null),o=E.useRef(null),[l,c]=E.useState(!0),[u,f]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const y=r.current,v=y.clientWidth,b=y.clientHeight,x=new Rue;x.background=new bn(1710618),a.current=x;const M=new Us(45,v/b,.1,1e4);M.position.set(150,150,150),s.current=M;const w=new kme({antialias:!0});w.setSize(v,b),w.setPixelRatio(window.devicePixelRatio),y.appendChild(w.domElement),i.current=w;const A=new Ome(M,w.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new Hue(16777215,.6);x.add(T);const R=new LF(16777215,.8);R.position.set(100,100,100),x.add(R);const N=new LF(16777215,.4);N.position.set(-100,50,-100),x.add(N);const j=Math.max(e.x,e.y),C=Math.ceil(j/16),k=new Vue(j,C,4473924,3355443);x.add(k);const U=new ok(e.x,e.y),I=new ik({color:44610,transparent:!0,opacity:.15,side:Ho}),H=new nl(U,I);H.rotation.x=-Math.PI/2,H.position.y=-.5,x.add(H);let O;const B=()=>{O=requestAnimationFrame(B),A.update(),w.render(x,M)};B(),fetch(t).then(G=>{if(!G.ok)throw new Error("Failed to load file");return G.arrayBuffer()}).then(Qme).then(({objects:G,buildItems:K})=>{if(G.size===0)throw new Error("No meshes found in 3MF file");const Y=new jue({color:44610,shininess:30,flatShading:!1}),oe=new ax,$=[];if(K.length>0)for(const he of K){const me=G.get(he.objectId);if(me)for(const we of me.meshes){const se=[];for(let z=0;z<we.vertices.length;z+=3){const q=new Ge(we.vertices[z],we.vertices[z+1],we.vertices[z+2]);q.applyMatrix4(he.transform),se.push(q.x,q.y,q.z)}const st=hz({vertices:se,triangles:we.triangles});$.push(st)}}else for(const he of G.values())for(const me of he.meshes){const we=hz(me);$.push(we)}if($.length>0){const he=$.length===1?$[0]:qme($,!1);if(he){const me=new nl(he,Y);oe.add(me)}if($.length>1)for(const me of $)me.dispose()}const X=new Rf().setFromObject(oe),ae=X.getCenter(new Ge);oe.position.y=-X.min.y,K.length===0&&(oe.position.x=-ae.x,oe.position.z=-ae.z),x.add(oe);const ce=new Rf().setFromObject(oe),xe=ce.getCenter(new Ge),te=ce.getSize(new Ge),De=Math.max(te.x,te.y,te.z)*1.8;M.position.set(xe.x+De*.7,xe.y+De*.5,xe.z+De*.7),A.target.copy(xe),A.update(),c(!1)}).catch(G=>{f(G.message),c(!1)});const V=()=>{if(!y)return;const G=y.clientWidth,K=y.clientHeight;M.aspect=G/K,M.updateProjectionMatrix(),w.setSize(G,K)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame(O),A.dispose(),w.dispose(),y.removeChild(w.domElement)}},[t,e]);const g=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=y=>{s.current&&s.current.position.multiplyScalar(y)};return h.jsxs("div",{className:`relative ${n}`,children:[h.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}),u&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx("p",{className:"text-red-400",children:u})}),!l&&!u&&h.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[h.jsx(ct,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:h.jsx(Ule,{className:"w-4 h-4"})}),h.jsx(ct,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:h.jsx(Ble,{className:"w-4 h-4"})}),h.jsx(ct,{variant:"secondary",size:"sm",onClick:g,children:h.jsx(nw,{className:"w-4 h-4"})})]})]})}const ow="159",Wh={ROTATE:0,DOLLY:1,PAN:2},qh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ege=0,pz=1,tge=2,lW=1,nge=2,Gl=3,Qu=0,za=1,Yl=2,Bu=0,Dp=1,mz=2,gz=3,xz=4,rge=5,Yd=100,ige=101,age=102,vz=103,bz=104,sge=200,oge=201,lge=202,cge=203,C3=204,N3=205,uge=206,dge=207,fge=208,hge=209,pge=210,mge=211,gge=212,xge=213,vge=214,bge=0,yge=1,_ge=2,e1=3,Sge=4,wge=5,Mge=6,Ege=7,ck=0,Age=1,Tge=2,Hu=0,Cge=1,Nge=2,Rge=3,Pge=4,kge=5,cW=300,Zp=301,Qp=302,R3=303,P3=304,lw=306,k3=1e3,mo=1001,D3=1002,Hi=1003,yz=1004,xT=1005,Fs=1006,Dge=1007,Qx=1008,$u=1009,Oge=1010,Lge=1011,uk=1012,uW=1013,Ou=1014,nc=1015,Jx=1016,dW=1017,fW=1018,uf=1020,Ige=1021,zs=1023,jge=1024,Uge=1025,df=1026,Jp=1027,Fge=1028,hW=1029,zge=1030,pW=1031,mW=1033,vT=33776,bT=33777,yT=33778,_T=33779,_z=35840,Sz=35841,wz=35842,Mz=35843,gW=36196,Ez=37492,Az=37496,Tz=37808,Cz=37809,Nz=37810,Rz=37811,Pz=37812,kz=37813,Dz=37814,Oz=37815,Lz=37816,Iz=37817,jz=37818,Uz=37819,Fz=37820,zz=37821,ST=36492,Bz=36494,Hz=36495,Bge=36283,$z=36284,Vz=36285,Gz=36286,xW=3e3,ff=3001,Hge=3200,$ge=3201,vW=0,Vge=1,Bs="",$i="srgb",xc="srgb-linear",dk="display-p3",cw="display-p3-linear",t1="linear",rr="srgb",n1="rec709",r1="p3",Xh=7680,Wz=519,Gge=512,Wge=513,qge=514,bW=515,Xge=516,Kge=517,Yge=518,Zge=519,O3=35044,qz="300 es",L3=1035,Wo=2e3,e0=2001;class Xf{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,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const Zi=["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 Xz=1234567;const xx=Math.PI/180,t0=180/Math.PI;function cc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Zi[t&255]+Zi[t>>8&255]+Zi[t>>16&255]+Zi[t>>24&255]+"-"+Zi[e&255]+Zi[e>>8&255]+"-"+Zi[e>>16&15|64]+Zi[e>>24&255]+"-"+Zi[n&63|128]+Zi[n>>8&255]+"-"+Zi[n>>16&255]+Zi[n>>24&255]+Zi[r&255]+Zi[r>>8&255]+Zi[r>>16&255]+Zi[r>>24&255]).toLowerCase()}function Vi(t,e,n){return Math.max(e,Math.min(n,t))}function fk(t,e){return(t%e+e)%e}function Qge(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function Jge(t,e,n){return t!==e?(n-t)/(e-t):0}function vx(t,e,n){return(1-n)*t+n*e}function exe(t,e,n,r){return vx(t,e,1-Math.exp(-n*r))}function txe(t,e=1){return e-Math.abs(fk(t,e*2)-e)}function nxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function rxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function ixe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function axe(t,e){return t+Math.random()*(e-t)}function sxe(t){return t*(.5-Math.random())}function oxe(t){t!==void 0&&(Xz=t);let e=Xz+=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 lxe(t){return t*xx}function cxe(t){return t*t0}function I3(t){return(t&t-1)===0&&t!==0}function uxe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function i1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function dxe(t,e,n,r,i){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((e+r)/2),u=s((e+r)/2),f=a((e-r)/2),g=s((e-r)/2),m=a((r-e)/2),y=s((r-e)/2);switch(i){case"XYX":t.set(o*u,l*f,l*g,o*c);break;case"YZY":t.set(l*g,o*u,l*f,o*c);break;case"ZXZ":t.set(l*f,l*g,o*u,o*c);break;case"XZX":t.set(o*u,l*y,l*m,o*c);break;case"YXY":t.set(l*m,o*u,l*y,o*c);break;case"ZYZ":t.set(l*y,l*m,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function $o(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Hn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const yW={DEG2RAD:xx,RAD2DEG:t0,generateUUID:cc,clamp:Vi,euclideanModulo:fk,mapLinear:Qge,inverseLerp:Jge,lerp:vx,damp:exe,pingpong:txe,smoothstep:nxe,smootherstep:rxe,randInt:ixe,randFloat:axe,randFloatSpread:sxe,seededRandom:oxe,degToRad:lxe,radToDeg:cxe,isPowerOfTwo:I3,ceilPowerOfTwo:uxe,floorPowerOfTwo:i1,setQuaternionFromProperEuler:dxe,normalize:Hn,denormalize:$o};class qt{constructor(e=0,n=0){qt.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(Vi(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,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class dn{constructor(e,n,r,i,a,s,o,l,c){dn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c)}set(e,n,r,i,a,s,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=r,u[7]=s,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,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,s=r[0],o=r[3],l=r[6],c=r[1],u=r[4],f=r[7],g=r[2],m=r[5],y=r[8],v=i[0],b=i[3],x=i[6],M=i[1],w=i[4],A=i[7],T=i[2],R=i[5],N=i[8];return a[0]=s*v+o*M+l*T,a[3]=s*b+o*w+l*R,a[6]=s*x+o*A+l*N,a[1]=c*v+u*M+f*T,a[4]=c*b+u*w+f*R,a[7]=c*x+u*A+f*N,a[2]=g*v+m*M+y*T,a[5]=g*b+m*w+y*R,a[8]=g*x+m*A+y*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*s*u-n*o*c-r*a*u+r*o*l+i*a*c-i*s*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],f=u*s-o*c,g=o*l-u*a,m=c*a-s*l,y=n*f+r*g+i*m;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/y;return e[0]=f*v,e[1]=(i*c-u*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(u*n-i*l)*v,e[5]=(i*a-o*n)*v,e[6]=m*v,e[7]=(r*l-c*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(r*l,r*c,-r*(l*s+c*o)+s+e,-i*c,i*l,-i*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(wT.makeScale(e,n)),this}rotate(e){return this.premultiply(wT.makeRotation(-e)),this}translate(e,n){return this.premultiply(wT.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 wT=new dn;function _W(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function a1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fxe(){const t=a1("canvas");return t.style.display="block",t}const Kz={};function bx(t){t in Kz||(Kz[t]=!0,console.warn(t))}const Yz=new dn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Zz=new dn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ry={[xc]:{transfer:t1,primaries:n1,toReference:t=>t,fromReference:t=>t},[$i]:{transfer:rr,primaries:n1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[cw]:{transfer:t1,primaries:r1,toReference:t=>t.applyMatrix3(Zz),fromReference:t=>t.applyMatrix3(Yz)},[dk]:{transfer:rr,primaries:r1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Zz),fromReference:t=>t.applyMatrix3(Yz).convertLinearToSRGB()}},hxe=new Set([xc,cw]),$n={enabled:!0,_workingColorSpace:xc,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!hxe.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=ry[e].toReference,i=ry[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 ry[t].primaries},getTransfer:function(t){return t===Bs?t1:ry[t].transfer}};function Op(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function MT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Kh;class SW{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Kh===void 0&&(Kh=a1("canvas")),Kh.width=e.width,Kh.height=e.height;const r=Kh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Kh}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=a1("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 s=0;s<a.length;s++)a[s]=Op(a[s]/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(Op(n[r]/255)*255):n[r]=Op(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 pxe=0;class wW{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pxe++}),this.uuid=cc(),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 s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(ET(i[s].image)):a.push(ET(i[s]))}else a=ET(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function ET(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?SW.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 mxe=0;class Ba extends Xf{constructor(e=Ba.DEFAULT_IMAGE,n=Ba.DEFAULT_MAPPING,r=mo,i=mo,a=Fs,s=Qx,o=zs,l=$u,c=Ba.DEFAULT_ANISOTROPY,u=Bs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mxe++}),this.uuid=cc(),this.name="",this.source=new wW(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new qt(0,0),this.repeat=new qt(1,1),this.center=new qt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(bx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===ff?$i:Bs),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!==cW)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case k3:e.x=e.x-Math.floor(e.x);break;case mo:e.x=e.x<0?0:1;break;case D3: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 k3:e.y=e.y-Math.floor(e.y);break;case mo:e.y=e.y<0?0:1;break;case D3: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 bx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===$i?ff:xW}set encoding(e){bx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===ff?$i:Bs}}Ba.DEFAULT_IMAGE=null;Ba.DEFAULT_MAPPING=cW;Ba.DEFAULT_ANISOTROPY=1;class Gn{constructor(e=0,n=0,r=0,i=1){Gn.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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const l=e.elements,c=l[0],u=l[4],f=l[8],g=l[1],m=l[5],y=l[9],v=l[2],b=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(f-v)<.01&&Math.abs(y-b)<.01){if(Math.abs(u+g)<.1&&Math.abs(f+v)<.1&&Math.abs(y+b)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,A=(m+1)/2,T=(x+1)/2,R=(u+g)/4,N=(f+v)/4,j=(y+b)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=R/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=R/i,a=j/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=j/a),this.set(r,i,a,n),this}let M=Math.sqrt((b-y)*(b-y)+(f-v)*(f-v)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(b-y)/M,this.y=(f-v)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const 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 gxe extends Xf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Gn(0,0,e,n),this.scissorTest=!1,this.viewport=new Gn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(bx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===ff?$i:Bs),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fs,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ba(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 wW(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 Pf extends gxe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class MW extends Ba{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=Hi,this.minFilter=Hi,this.wrapR=mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class xxe extends Ba{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=Hi,this.minFilter=Hi,this.wrapR=mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class kf{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,s,o){let l=r[i+0],c=r[i+1],u=r[i+2],f=r[i+3];const g=a[s+0],m=a[s+1],y=a[s+2],v=a[s+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=y,e[n+3]=v;return}if(f!==v||l!==g||c!==m||u!==y){let b=1-o;const x=l*g+c*m+u*y+f*v,M=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const T=Math.sqrt(w),R=Math.atan2(T,x*M);b=Math.sin(b*R)/T,o=Math.sin(o*R)/T}const A=o*M;if(l=l*b+g*A,c=c*b+m*A,u=u*b+y*A,f=f*b+v*A,b===1-o){const T=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=T,c*=T,u*=T,f*=T}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],f=a[s],g=a[s+1],m=a[s+2],y=a[s+3];return e[n]=o*y+u*f+l*m-c*g,e[n+1]=l*y+u*g+c*f-o*m,e[n+2]=c*y+u*m+o*g-l*f,e[n+3]=u*y-o*f-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,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,s=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),f=o(a/2),g=l(r/2),m=l(i/2),y=l(a/2);switch(s){case"XYZ":this._x=g*u*f+c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f-g*m*y;break;case"YXZ":this._x=g*u*f+c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f+g*m*y;break;case"ZXY":this._x=g*u*f-c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f-g*m*y;break;case"ZYX":this._x=g*u*f-c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f+g*m*y;break;case"YZX":this._x=g*u*f+c*m*y,this._y=c*m*f+g*u*y,this._z=c*u*y-g*m*f,this._w=c*u*f-g*m*y;break;case"XZY":this._x=g*u*f-c*m*y,this._y=c*m*f-g*u*y,this._z=c*u*y+g*m*f,this._w=c*u*f+g*m*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}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],s=n[1],o=n[5],l=n[9],c=n[2],u=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(a-c)*m,this._z=(s-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(u-l)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-c)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+c)/m,this._y=(l+u)/m,this._z=.25*m}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(Vi(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,s=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+s*o+i*c-a*l,this._y=i*u+s*l+a*o-r*c,this._z=a*u+s*c+r*l-i*o,this._w=s*u-r*o-i*l-a*c,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,s=this._w;let o=s*e._w+r*e._x+i*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*s+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),f=Math.sin((1-n)*u)/c,g=Math.sin(n*u)/c;return this._w=s*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,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 Te{constructor(e=0,n=0,r=0){Te.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(Qz.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Qz.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,s=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])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*i-o*r),u=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+l*c+s*f-o*u,this.y=r+l*u+o*c-a*f,this.z=i+l*f+a*u-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,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,s=n.x,o=n.y,l=n.z;return this.x=i*l-a*o,this.y=a*s-r*l,this.z=r*o-i*s,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 AT.copy(this).projectOnVector(e),this.sub(AT)}reflect(e){return this.sub(AT.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(Vi(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 AT=new Te,Qz=new kf;class Ws{constructor(e=new Te(1/0,1/0,1/0),n=new Te(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(uo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(uo.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=uo.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 s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,uo):uo.fromBufferAttribute(a,s),uo.applyMatrix4(e.matrixWorld),this.expandByPoint(uo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),iy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),iy.copy(r.boundingBox)),iy.applyMatrix4(e.matrixWorld),this.union(iy)}const i=e.children;for(let a=0,s=i.length;a<s;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,uo),uo.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(Bg),ay.subVectors(this.max,Bg),Yh.subVectors(e.a,Bg),Zh.subVectors(e.b,Bg),Qh.subVectors(e.c,Bg),uu.subVectors(Zh,Yh),du.subVectors(Qh,Zh),jd.subVectors(Yh,Qh);let n=[0,-uu.z,uu.y,0,-du.z,du.y,0,-jd.z,jd.y,uu.z,0,-uu.x,du.z,0,-du.x,jd.z,0,-jd.x,-uu.y,uu.x,0,-du.y,du.x,0,-jd.y,jd.x,0];return!TT(n,Yh,Zh,Qh,ay)||(n=[1,0,0,0,1,0,0,0,1],!TT(n,Yh,Zh,Qh,ay))?!1:(sy.crossVectors(uu,du),n=[sy.x,sy.y,sy.z],TT(n,Yh,Zh,Qh,ay))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,uo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(uo).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:(Il[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Il[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Il[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Il[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Il[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Il[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Il[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Il[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Il),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 Il=[new Te,new Te,new Te,new Te,new Te,new Te,new Te,new Te],uo=new Te,iy=new Ws,Yh=new Te,Zh=new Te,Qh=new Te,uu=new Te,du=new Te,jd=new Te,Bg=new Te,ay=new Te,sy=new Te,Ud=new Te;function TT(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Ud.fromArray(t,a);const o=i.x*Math.abs(Ud.x)+i.y*Math.abs(Ud.y)+i.z*Math.abs(Ud.z),l=e.dot(Ud),c=n.dot(Ud),u=r.dot(Ud);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const vxe=new Ws,Hg=new Te,CT=new Te;class Xo{constructor(e=new Te,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):vxe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;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;Hg.subVectors(e,this.center);const n=Hg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Hg,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):(CT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Hg.copy(e.center).add(CT)),this.expandByPoint(Hg.copy(e.center).sub(CT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const jl=new Te,NT=new Te,oy=new Te,fu=new Te,RT=new Te,ly=new Te,PT=new Te;class hk{constructor(e=new Te,n=new Te(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,jl)),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=jl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(jl.copy(this.origin).addScaledVector(this.direction,n),jl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){NT.copy(e).add(n).multiplyScalar(.5),oy.copy(n).sub(e).normalize(),fu.copy(this.origin).sub(NT);const a=e.distanceTo(n)*.5,s=-this.direction.dot(oy),o=fu.dot(this.direction),l=-fu.dot(oy),c=fu.lengthSq(),u=Math.abs(1-s*s);let f,g,m,y;if(u>0)if(f=s*l-o,g=s*o-l,y=a*u,f>=0)if(g>=-y)if(g<=y){const v=1/u;f*=v,g*=v,m=f*(f+s*g+2*o)+g*(s*f+g+2*l)+c}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;else g<=-y?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-l),a),m=-f*f+g*(g+2*l)+c):g<=y?(f=0,g=Math.min(Math.max(-a,-l),a),m=g*(g+2*l)+c):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-l),a),m=-f*f+g*(g+2*l)+c);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(NT).addScaledVector(oy,g),m}intersectSphere(e,n){jl.subVectors(e.center,this.origin);const r=jl.dot(this.direction),i=jl.dot(jl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,l=r+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,s,o,l;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(a=(e.min.y-g.y)*u,s=(e.max.y-g.y)*u):(a=(e.max.y-g.y)*u,s=(e.min.y-g.y)*u),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,jl)!==null}intersectTriangle(e,n,r,i,a){RT.subVectors(n,e),ly.subVectors(r,e),PT.crossVectors(RT,ly);let s=this.direction.dot(PT),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;fu.subVectors(this.origin,e);const l=o*this.direction.dot(ly.crossVectors(fu,ly));if(l<0)return null;const c=o*this.direction.dot(RT.cross(fu));if(c<0||l+c>s)return null;const u=-o*fu.dot(PT);return u<0?null:this.at(u/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn{constructor(e,n,r,i,a,s,o,l,c,u,f,g,m,y,v,b){Jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c,u,f,g,m,y,v,b)}set(e,n,r,i,a,s,o,l,c,u,f,g,m,y,v,b){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=f,x[14]=g,x[3]=m,x[7]=y,x[11]=v,x[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Jn().fromArray(this.elements)}copy(e){const n=this.elements,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/Jh.setFromMatrixColumn(e,0).length(),a=1/Jh.setFromMatrixColumn(e,1).length(),s=1/Jh.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]*s,n[9]=r[9]*s,n[10]=r[10]*s,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,s=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*u,m=s*f,y=o*u,v=o*f;n[0]=l*u,n[4]=-l*f,n[8]=c,n[1]=m+y*c,n[5]=g-v*c,n[9]=-o*l,n[2]=v-g*c,n[6]=y+m*c,n[10]=s*l}else if(e.order==="YXZ"){const g=l*u,m=l*f,y=c*u,v=c*f;n[0]=g+v*o,n[4]=y*o-m,n[8]=s*c,n[1]=s*f,n[5]=s*u,n[9]=-o,n[2]=m*o-y,n[6]=v+g*o,n[10]=s*l}else if(e.order==="ZXY"){const g=l*u,m=l*f,y=c*u,v=c*f;n[0]=g-v*o,n[4]=-s*f,n[8]=y+m*o,n[1]=m+y*o,n[5]=s*u,n[9]=v-g*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const g=s*u,m=s*f,y=o*u,v=o*f;n[0]=l*u,n[4]=y*c-m,n[8]=g*c+v,n[1]=l*f,n[5]=v*c+g,n[9]=m*c-y,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const g=s*l,m=s*c,y=o*l,v=o*c;n[0]=l*u,n[4]=v-g*f,n[8]=y*f+m,n[1]=f,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*f+y,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*l,m=s*c,y=o*l,v=o*c;n[0]=l*u,n[4]=-f,n[8]=c*u,n[1]=g*f+v,n[5]=s*u,n[9]=m*f-y,n[2]=y*f-m,n[6]=o*u,n[10]=v*f+g}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(bxe,e,yxe)}lookAt(e,n,r){const i=this.elements;return rs.subVectors(e,n),rs.lengthSq()===0&&(rs.z=1),rs.normalize(),hu.crossVectors(r,rs),hu.lengthSq()===0&&(Math.abs(r.z)===1?rs.x+=1e-4:rs.z+=1e-4,rs.normalize(),hu.crossVectors(r,rs)),hu.normalize(),cy.crossVectors(rs,hu),i[0]=hu.x,i[4]=cy.x,i[8]=rs.x,i[1]=hu.y,i[5]=cy.y,i[9]=rs.y,i[2]=hu.z,i[6]=cy.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,s=r[0],o=r[4],l=r[8],c=r[12],u=r[1],f=r[5],g=r[9],m=r[13],y=r[2],v=r[6],b=r[10],x=r[14],M=r[3],w=r[7],A=r[11],T=r[15],R=i[0],N=i[4],j=i[8],C=i[12],k=i[1],U=i[5],I=i[9],H=i[13],O=i[2],B=i[6],V=i[10],G=i[14],K=i[3],Y=i[7],oe=i[11],$=i[15];return a[0]=s*R+o*k+l*O+c*K,a[4]=s*N+o*U+l*B+c*Y,a[8]=s*j+o*I+l*V+c*oe,a[12]=s*C+o*H+l*G+c*$,a[1]=u*R+f*k+g*O+m*K,a[5]=u*N+f*U+g*B+m*Y,a[9]=u*j+f*I+g*V+m*oe,a[13]=u*C+f*H+g*G+m*$,a[2]=y*R+v*k+b*O+x*K,a[6]=y*N+v*U+b*B+x*Y,a[10]=y*j+v*I+b*V+x*oe,a[14]=y*C+v*H+b*G+x*$,a[3]=M*R+w*k+A*O+T*K,a[7]=M*N+w*U+A*B+T*Y,a[11]=M*j+w*I+A*V+T*oe,a[15]=M*C+w*H+A*G+T*$,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],s=e[1],o=e[5],l=e[9],c=e[13],u=e[2],f=e[6],g=e[10],m=e[14],y=e[3],v=e[7],b=e[11],x=e[15];return y*(+a*l*f-i*c*f-a*o*g+r*c*g+i*o*m-r*l*m)+v*(+n*l*m-n*c*g+a*s*g-i*s*m+i*c*u-a*l*u)+b*(+n*c*f-n*o*m-a*s*f+r*s*m+a*o*u-r*c*u)+x*(-i*o*u-n*l*f+n*o*g+i*s*f-r*s*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,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],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],f=e[9],g=e[10],m=e[11],y=e[12],v=e[13],b=e[14],x=e[15],M=f*b*c-v*g*c+v*l*m-o*b*m-f*l*x+o*g*x,w=y*g*c-u*b*c-y*l*m+s*b*m+u*l*x-s*g*x,A=u*v*c-y*f*c+y*o*m-s*v*m-u*o*x+s*f*x,T=y*f*l-u*v*l-y*o*g+s*v*g+u*o*b-s*f*b,R=n*M+r*w+i*A+a*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/R;return e[0]=M*N,e[1]=(v*g*a-f*b*a-v*i*m+r*b*m+f*i*x-r*g*x)*N,e[2]=(o*b*a-v*l*a+v*i*c-r*b*c-o*i*x+r*l*x)*N,e[3]=(f*l*a-o*g*a-f*i*c+r*g*c+o*i*m-r*l*m)*N,e[4]=w*N,e[5]=(u*b*a-y*g*a+y*i*m-n*b*m-u*i*x+n*g*x)*N,e[6]=(y*l*a-s*b*a-y*i*c+n*b*c+s*i*x-n*l*x)*N,e[7]=(s*g*a-u*l*a+u*i*c-n*g*c-s*i*m+n*l*m)*N,e[8]=A*N,e[9]=(y*f*a-u*v*a-y*r*m+n*v*m+u*r*x-n*f*x)*N,e[10]=(s*v*a-y*o*a+y*r*c-n*v*c-s*r*x+n*o*x)*N,e[11]=(u*o*a-s*f*a-u*r*c+n*f*c+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(u*v*i-y*f*i+y*r*g-n*v*g-u*r*b+n*f*b)*N,e[14]=(y*o*i-s*v*i-y*r*l+n*v*l+s*r*b-n*o*b)*N,e[15]=(s*f*i-u*o*i+u*r*l-n*f*l-s*r*g+n*o*g)*N,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,s=e.x,o=e.y,l=e.z,c=a*s,u=a*o;return this.set(c*s+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*s,0,c*l-i*o,u*l+i*s,a*l*l+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,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,u=s+s,f=o+o,g=a*c,m=a*u,y=a*f,v=s*u,b=s*f,x=o*f,M=l*c,w=l*u,A=l*f,T=r.x,R=r.y,N=r.z;return i[0]=(1-(v+x))*T,i[1]=(m+A)*T,i[2]=(y-w)*T,i[3]=0,i[4]=(m-A)*R,i[5]=(1-(g+x))*R,i[6]=(b+M)*R,i[7]=0,i[8]=(y+w)*N,i[9]=(b-M)*N,i[10]=(1-(g+v))*N,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=Jh.set(i[0],i[1],i[2]).length();const s=Jh.set(i[4],i[5],i[6]).length(),o=Jh.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],fo.copy(this);const c=1/a,u=1/s,f=1/o;return fo.elements[0]*=c,fo.elements[1]*=c,fo.elements[2]*=c,fo.elements[4]*=u,fo.elements[5]*=u,fo.elements[6]*=u,fo.elements[8]*=f,fo.elements[9]*=f,fo.elements[10]*=f,n.setFromRotationMatrix(fo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=Wo){const l=this.elements,c=2*a/(n-e),u=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let m,y;if(o===Wo)m=-(s+a)/(s-a),y=-2*s*a/(s-a);else if(o===e0)m=-s/(s-a),y=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Wo){const l=this.elements,c=1/(n-e),u=1/(r-i),f=1/(s-a),g=(n+e)*c,m=(r+i)*u;let y,v;if(o===Wo)y=(s+a)*f,v=-2*f;else if(o===e0)y=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=v,l[14]=-y,l[3]=0,l[7]=0,l[11]=0,l[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 Jh=new Te,fo=new Jn,bxe=new Te(0,0,0),yxe=new Te(1,1,1),hu=new Te,cy=new Te,rs=new Te,Jz=new Jn,e5=new kf;class U0{constructor(e=0,n=0,r=0,i=U0.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],s=i[4],o=i[8],l=i[1],c=i[5],u=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Vi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Vi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Vi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Vi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(Vi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Vi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,m),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 Jz.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Jz,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return e5.setFromEuler(this),this.setFromQuaternion(e5,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}}U0.DEFAULT_ORDER="XYZ";class EW{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 _xe=0;const t5=new Te,ep=new kf,Ul=new Jn,uy=new Te,$g=new Te,Sxe=new Te,wxe=new kf,n5=new Te(1,0,0),r5=new Te(0,1,0),i5=new Te(0,0,1),Mxe={type:"added"},Exe={type:"removed"};class va extends Xf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_xe++}),this.uuid=cc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=va.DEFAULT_UP.clone();const e=new Te,n=new U0,r=new kf,i=new Te(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Jn},normalMatrix:{value:new dn}}),this.matrix=new Jn,this.matrixWorld=new Jn,this.matrixAutoUpdate=va.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new EW,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 ep.setFromAxisAngle(e,n),this.quaternion.multiply(ep),this}rotateOnWorldAxis(e,n){return ep.setFromAxisAngle(e,n),this.quaternion.premultiply(ep),this}rotateX(e){return this.rotateOnAxis(n5,e)}rotateY(e){return this.rotateOnAxis(r5,e)}rotateZ(e){return this.rotateOnAxis(i5,e)}translateOnAxis(e,n){return t5.copy(e).applyQuaternion(this.quaternion),this.position.add(t5.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(n5,e)}translateY(e){return this.translateOnAxis(r5,e)}translateZ(e){return this.translateOnAxis(i5,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ul.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?uy.copy(e):uy.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),$g.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ul.lookAt($g,uy,this.up):Ul.lookAt(uy,$g,this.up),this.quaternion.setFromRotationMatrix(Ul),i&&(Ul.extractRotation(i.matrixWorld),ep.setFromRotationMatrix(Ul),this.quaternion.premultiply(ep.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(Mxe)):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(Exe)),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),Ul.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ul.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ul),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 s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;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($g,e,Sxe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($g,wxe,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,s=i.length;a<s;a++){const o=i[a];o.matrixWorldAutoUpdate===!0&&o.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(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),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(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.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 o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const f=l[c];a(e.shapes,f)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(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 o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),u=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),y=s(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),y.length>0&&(r.nodes=y)}return r.object=i,r;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}va.DEFAULT_UP=new Te(0,1,0);va.DEFAULT_MATRIX_AUTO_UPDATE=!0;va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ho=new Te,Fl=new Te,kT=new Te,zl=new Te,tp=new Te,np=new Te,a5=new Te,DT=new Te,OT=new Te,LT=new Te;let dy=!1;class po{constructor(e=new Te,n=new Te,r=new Te){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),Fl.subVectors(r,n),kT.subVectors(e,n);const s=ho.dot(ho),o=ho.dot(Fl),l=ho.dot(kT),c=Fl.dot(Fl),u=Fl.dot(kT),f=s*c-o*o;if(f===0)return a.set(-2,-1,-1);const g=1/f,m=(c*l-o*u)*g,y=(s*u-o*l)*g;return a.set(1-m-y,y,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,zl),zl.x>=0&&zl.y>=0&&zl.x+zl.y<=1}static getUV(e,n,r,i,a,s,o,l){return dy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),dy=!0),this.getInterpolation(e,n,r,i,a,s,o,l)}static getInterpolation(e,n,r,i,a,s,o,l){return this.getBarycoord(e,n,r,i,zl),l.setScalar(0),l.addScaledVector(a,zl.x),l.addScaledVector(s,zl.y),l.addScaledVector(o,zl.z),l}static isFrontFacing(e,n,r,i){return ho.subVectors(r,n),Fl.subVectors(e,n),ho.cross(Fl).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),Fl.subVectors(this.a,this.b),ho.cross(Fl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return po.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return po.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return dy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),dy=!0),po.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return po.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return po.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return po.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 s,o;tp.subVectors(i,r),np.subVectors(a,r),DT.subVectors(e,r);const l=tp.dot(DT),c=np.dot(DT);if(l<=0&&c<=0)return n.copy(r);OT.subVectors(e,i);const u=tp.dot(OT),f=np.dot(OT);if(u>=0&&f<=u)return n.copy(i);const g=l*f-u*c;if(g<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(r).addScaledVector(tp,s);LT.subVectors(e,a);const m=tp.dot(LT),y=np.dot(LT);if(y>=0&&m<=y)return n.copy(a);const v=m*c-l*y;if(v<=0&&c>=0&&y<=0)return o=c/(c-y),n.copy(r).addScaledVector(np,o);const b=u*y-m*f;if(b<=0&&f-u>=0&&m-y>=0)return a5.subVectors(a,i),o=(f-u)/(f-u+(m-y)),n.copy(i).addScaledVector(a5,o);const x=1/(b+v+g);return s=v*x,o=g*x,n.copy(r).addScaledVector(tp,s).addScaledVector(np,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const AW={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},pu={h:0,s:0,l:0},fy={h:0,s:0,l:0};function IT(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 Bt=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=$i){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$n.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=$n.workingColorSpace){return this.r=e,this.g=n,this.b=r,$n.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=$n.workingColorSpace){if(e=fk(e,1),n=Vi(n,0,1),r=Vi(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=IT(s,a,e+1/3),this.g=IT(s,a,e),this.b=IT(s,a,e-1/3)}return $n.toWorkingColorSpace(this,i),this}setStyle(e,n=$i){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 s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return 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(o))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(o))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],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=$i){const r=AW[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=Op(e.r),this.g=Op(e.g),this.b=Op(e.b),this}copyLinearToSRGB(e){return this.r=MT(e.r),this.g=MT(e.g),this.b=MT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$i){return $n.fromWorkingColorSpace(Qi.copy(this),e),Math.round(Vi(Qi.r*255,0,255))*65536+Math.round(Vi(Qi.g*255,0,255))*256+Math.round(Vi(Qi.b*255,0,255))}getHexString(e=$i){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$n.workingColorSpace){$n.fromWorkingColorSpace(Qi.copy(this),n);const r=Qi.r,i=Qi.g,a=Qi.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let l,c;const u=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=u<=.5?f/(s+o):f/(2-s-o),s){case r:l=(i-a)/f+(i<a?6:0);break;case i:l=(a-r)/f+2;break;case a:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=$n.workingColorSpace){return $n.fromWorkingColorSpace(Qi.copy(this),n),e.r=Qi.r,e.g=Qi.g,e.b=Qi.b,e}getStyle(e=$i){$n.fromWorkingColorSpace(Qi.copy(this),e);const n=Qi.r,r=Qi.g,i=Qi.b;return e!==$i?`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(pu),this.setHSL(pu.h+e,pu.s+n,pu.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(pu),e.getHSL(fy);const r=vx(pu.h,fy.h,n),i=vx(pu.s,fy.s,n),a=vx(pu.l,fy.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 Qi=new Bt;Bt.NAMES=AW;let Axe=0;class Mm extends Xf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Axe++}),this.uuid=cc(),this.name="",this.type="Material",this.blending=Dp,this.side=Qu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=C3,this.blendDst=N3,this.blendEquation=Yd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Bt(0,0,0),this.blendAlpha=0,this.depthFunc=e1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Wz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xh,this.stencilZFail=Xh,this.stencilZPass=Xh,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!==Dp&&(r.blending=this.blending),this.side!==Qu&&(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!==C3&&(r.blendSrc=this.blendSrc),this.blendDst!==N3&&(r.blendDst=this.blendDst),this.blendEquation!==Yd&&(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!==e1&&(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!==Wz&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Xh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Xh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Xh&&(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 s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}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 TW extends Mm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Bt(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=ck,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 Br=new Te,hy=new qt;class hs{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=O3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=nc,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++)hy.fromBufferAttribute(this,n),hy.applyMatrix3(e),this.setXY(n,hy.x,hy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyMatrix3(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyMatrix4(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyNormalMatrix(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.transformDirection(e),this.setXYZ(n,Br.x,Br.y,Br.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=$o(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Hn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=$o(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=$o(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=$o(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=$o(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),a=Hn(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!==O3&&(e.usage=this.usage),e}}class CW extends hs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class NW extends hs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Dr extends hs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Txe=0;const Ts=new Jn,jT=new va,rp=new Te,is=new Ws,Vg=new Ws,yi=new Te;class oa extends Xf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Txe++}),this.uuid=cc(),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(_W(e)?NW:CW)(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 dn().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 Ts.makeRotationFromQuaternion(e),this.applyMatrix4(Ts),this}rotateX(e){return Ts.makeRotationX(e),this.applyMatrix4(Ts),this}rotateY(e){return Ts.makeRotationY(e),this.applyMatrix4(Ts),this}rotateZ(e){return Ts.makeRotationZ(e),this.applyMatrix4(Ts),this}translate(e,n,r){return Ts.makeTranslation(e,n,r),this.applyMatrix4(Ts),this}scale(e,n,r){return Ts.makeScale(e,n,r),this.applyMatrix4(Ts),this}lookAt(e){return jT.lookAt(e),jT.updateMatrix(),this.applyMatrix4(jT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rp).negate(),this.translate(rp.x,rp.y,rp.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 Dr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ws);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Te(-1/0,-1/0,-1/0),new Te(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];is.setFromBufferAttribute(a),this.morphTargetsRelative?(yi.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(yi),yi.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(yi)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xo);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Te,1/0);return}if(e){const r=this.boundingSphere.center;if(is.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Vg.setFromBufferAttribute(o),this.morphTargetsRelative?(yi.addVectors(is.min,Vg.min),is.expandByPoint(yi),yi.addVectors(is.max,Vg.max),is.expandByPoint(yi)):(is.expandByPoint(Vg.min),is.expandByPoint(Vg.max))}is.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)yi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(yi));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)yi.fromBufferAttribute(o,c),l&&(rp.fromBufferAttribute(e,c),yi.add(rp)),i=Math.max(i,r.distanceToSquared(yi))}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,s=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new hs(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],u=[];for(let k=0;k<o;k++)c[k]=new Te,u[k]=new Te;const f=new Te,g=new Te,m=new Te,y=new qt,v=new qt,b=new qt,x=new Te,M=new Te;function w(k,U,I){f.fromArray(i,k*3),g.fromArray(i,U*3),m.fromArray(i,I*3),y.fromArray(s,k*2),v.fromArray(s,U*2),b.fromArray(s,I*2),g.sub(f),m.sub(f),v.sub(y),b.sub(y);const H=1/(v.x*b.y-b.x*v.y);isFinite(H)&&(x.copy(g).multiplyScalar(b.y).addScaledVector(m,-v.y).multiplyScalar(H),M.copy(m).multiplyScalar(v.x).addScaledVector(g,-b.x).multiplyScalar(H),c[k].add(x),c[U].add(x),c[I].add(x),u[k].add(M),u[U].add(M),u[I].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let k=0,U=A.length;k<U;++k){const I=A[k],H=I.start,O=I.count;for(let B=H,V=H+O;B<V;B+=3)w(r[B+0],r[B+1],r[B+2])}const T=new Te,R=new Te,N=new Te,j=new Te;function C(k){N.fromArray(a,k*3),j.copy(N);const U=c[k];T.copy(U),T.sub(N.multiplyScalar(N.dot(U))).normalize(),R.crossVectors(j,U);const H=R.dot(u[k])<0?-1:1;l[k*4]=T.x,l[k*4+1]=T.y,l[k*4+2]=T.z,l[k*4+3]=H}for(let k=0,U=A.length;k<U;++k){const I=A[k],H=I.start,O=I.count;for(let B=H,V=H+O;B<V;B+=3)C(r[B+0]),C(r[B+1]),C(r[B+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 hs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Te,a=new Te,s=new Te,o=new Te,l=new Te,c=new Te,u=new Te,f=new Te;if(e)for(let g=0,m=e.count;g<m;g+=3){const y=e.getX(g+0),v=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,b),u.subVectors(s,a),f.subVectors(i,a),u.cross(f),o.fromBufferAttribute(r,y),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,b),o.add(u),l.add(u),c.add(u),r.setXYZ(y,o.x,o.y,o.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),u.subVectors(s,a),f.subVectors(i,a),u.cross(f),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)yi.fromBufferAttribute(e,n),yi.normalize(),e.setXYZ(n,yi.x,yi.y,yi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,f=o.normalized,g=new c.constructor(l.length*u);let m=0,y=0;for(let v=0,b=l.length;v<b;v++){o.isInterleavedBufferAttribute?m=l[v]*o.data.stride+o.offset:m=l[v]*u;for(let x=0;x<u;x++)g[y++]=c[m++]}return new hs(g,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new oa,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let u=0,f=c.length;u<f;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,g=c.length;f<g;f++){const m=c[f];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],f=a[c];for(let g=0,m=f.length;g<m;g++)u.push(f[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;c++){const f=s[c];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const s5=new Jn,Fd=new hk,py=new Xo,o5=new Te,ip=new Te,ap=new Te,sp=new Te,UT=new Te,my=new Te,gy=new qt,xy=new qt,vy=new qt,l5=new Te,c5=new Te,u5=new Te,by=new Te,yy=new Te;class _o extends va{constructor(e=new oa,n=new TW){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,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){my.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],f=a[l];u!==0&&(UT.fromBufferAttribute(f,e),s?my.addScaledVector(UT,u):my.addScaledVector(UT.sub(n),u))}n.add(my)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),py.copy(r.boundingSphere),py.applyMatrix4(a),Fd.copy(e.ray).recast(e.near),!(py.containsPoint(Fd.origin)===!1&&(Fd.intersectSphere(py,o5)===null||Fd.origin.distanceToSquared(o5)>(e.far-e.near)**2))&&(s5.copy(a).invert(),Fd.copy(e.ray).applyMatrix4(s5),!(r.boundingBox!==null&&Fd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Fd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,v=g.length;y<v;y++){const b=g[y],x=s[b.materialIndex],M=Math.max(b.start,m.start),w=Math.min(o.count,Math.min(b.start+b.count,m.start+m.count));for(let A=M,T=w;A<T;A+=3){const R=o.getX(A),N=o.getX(A+1),j=o.getX(A+2);i=_y(this,x,e,r,c,u,f,R,N,j),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const y=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let b=y,x=v;b<x;b+=3){const M=o.getX(b),w=o.getX(b+1),A=o.getX(b+2);i=_y(this,s,e,r,c,u,f,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(s))for(let y=0,v=g.length;y<v;y++){const b=g[y],x=s[b.materialIndex],M=Math.max(b.start,m.start),w=Math.min(l.count,Math.min(b.start+b.count,m.start+m.count));for(let A=M,T=w;A<T;A+=3){const R=A,N=A+1,j=A+2;i=_y(this,x,e,r,c,u,f,R,N,j),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const y=Math.max(0,m.start),v=Math.min(l.count,m.start+m.count);for(let b=y,x=v;b<x;b+=3){const M=b,w=b+1,A=b+2;i=_y(this,s,e,r,c,u,f,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function Cxe(t,e,n,r,i,a,s,o){let l;if(e.side===za?l=r.intersectTriangle(s,a,i,!0,o):l=r.intersectTriangle(i,a,s,e.side===Qu,o),l===null)return null;yy.copy(o),yy.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(yy);return c<n.near||c>n.far?null:{distance:c,point:yy.clone(),object:t}}function _y(t,e,n,r,i,a,s,o,l,c){t.getVertexPosition(o,ip),t.getVertexPosition(l,ap),t.getVertexPosition(c,sp);const u=Cxe(t,e,n,r,ip,ap,sp,by);if(u){i&&(gy.fromBufferAttribute(i,o),xy.fromBufferAttribute(i,l),vy.fromBufferAttribute(i,c),u.uv=po.getInterpolation(by,ip,ap,sp,gy,xy,vy,new qt)),a&&(gy.fromBufferAttribute(a,o),xy.fromBufferAttribute(a,l),vy.fromBufferAttribute(a,c),u.uv1=po.getInterpolation(by,ip,ap,sp,gy,xy,vy,new qt),u.uv2=u.uv1),s&&(l5.fromBufferAttribute(s,o),c5.fromBufferAttribute(s,l),u5.fromBufferAttribute(s,c),u.normal=po.getInterpolation(by,ip,ap,sp,l5,c5,u5,new Te),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new Te,materialIndex:0};po.getNormal(ip,ap,sp,f.normal),u.face=f}return u}class F0 extends oa{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],u=[],f=[];let g=0,m=0;y("z","y","x",-1,-1,r,n,e,s,a,0),y("z","y","x",1,-1,r,n,-e,s,a,1),y("x","z","y",1,1,e,r,n,i,s,2),y("x","z","y",1,-1,e,r,-n,i,s,3),y("x","y","z",1,-1,e,n,r,i,a,4),y("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(l),this.setAttribute("position",new Dr(c,3)),this.setAttribute("normal",new Dr(u,3)),this.setAttribute("uv",new Dr(f,2));function y(v,b,x,M,w,A,T,R,N,j,C){const k=A/N,U=T/j,I=A/2,H=T/2,O=R/2,B=N+1,V=j+1;let G=0,K=0;const Y=new Te;for(let oe=0;oe<V;oe++){const $=oe*U-H;for(let X=0;X<B;X++){const ae=X*k-I;Y[v]=ae*M,Y[b]=$*w,Y[x]=O,c.push(Y.x,Y.y,Y.z),Y[v]=0,Y[b]=0,Y[x]=R>0?1:-1,u.push(Y.x,Y.y,Y.z),f.push(X/N),f.push(1-oe/j),G+=1}}for(let oe=0;oe<j;oe++)for(let $=0;$<N;$++){const X=g+$+B*oe,ae=g+$+B*(oe+1),ce=g+($+1)+B*(oe+1),xe=g+($+1)+B*oe;l.push(X,ae,xe),l.push(ae,ce,xe),K+=6}o.addGroup(m,K,C),m+=K,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new F0(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function em(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 ha(t){const e={};for(let n=0;n<t.length;n++){const r=em(t[n]);for(const i in r)e[i]=r[i]}return e}function Nxe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function RW(t){return t.getRenderTarget()===null?t.outputColorSpace:$n.workingColorSpace}const pk={clone:em,merge:ha};var Rxe=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,Pxe=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class Ju extends Mm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Rxe,this.fragmentShader=Pxe,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=em(e.uniforms),this.uniformsGroups=Nxe(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 s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const 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 PW extends va{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jn,this.projectionMatrix=new Jn,this.projectionMatrixInverse=new Jn,this.coordinateSystem=Wo}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class ls extends PW{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=t0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(xx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return t0*2*Math.atan(Math.tan(xx*.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,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(xx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*i/l,n-=s.offsetY*r/c,i*=s.width/l,r*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/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 op=-90,lp=1;class kxe extends va{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ls(op,lp,e,n);i.layers=this.layers,this.add(i);const a=new ls(op,lp,e,n);a.layers=this.layers,this.add(a);const s=new ls(op,lp,e,n);s.layers=this.layers,this.add(s);const o=new ls(op,lp,e,n);o.layers=this.layers,this.add(o);const l=new ls(op,lp,e,n);l.layers=this.layers,this.add(l);const c=new ls(op,lp,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===Wo)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),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===e0)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),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,u]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(f,g,m),e.xr.enabled=y,r.texture.needsPMREMUpdate=!0}}class kW extends Ba{constructor(e,n,r,i,a,s,o,l,c,u){e=e!==void 0?e:[],n=n!==void 0?n:Zp,super(e,n,r,i,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Dxe extends Pf{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&&(bx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===ff?$i:Bs),this.texture=new kW(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:Fs}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:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new F0(5,5,5),a=new Ju({name:"CubemapFromEquirect",uniforms:em(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:za,blending:Bu});a.uniforms.tEquirect.value=n;const s=new _o(i,a),o=n.minFilter;return n.minFilter===Qx&&(n.minFilter=Fs),new kxe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const FT=new Te,Oxe=new Te,Lxe=new dn;class Su{constructor(e=new Te(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,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=FT.subVectors(r,n).cross(Oxe.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(FT),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||Lxe.getNormalMatrix(e),i=this.coplanarPoint(FT).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 zd=new Xo,Sy=new Te;class uw{constructor(e=new Su,n=new Su,r=new Su,i=new Su,a=new Su,s=new Su){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),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=Wo){const r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],l=i[3],c=i[4],u=i[5],f=i[6],g=i[7],m=i[8],y=i[9],v=i[10],b=i[11],x=i[12],M=i[13],w=i[14],A=i[15];if(r[0].setComponents(l-a,g-c,b-m,A-x).normalize(),r[1].setComponents(l+a,g+c,b+m,A+x).normalize(),r[2].setComponents(l+s,g+u,b+y,A+M).normalize(),r[3].setComponents(l-s,g-u,b-y,A-M).normalize(),r[4].setComponents(l-o,g-f,b-v,A-w).normalize(),n===Wo)r[5].setComponents(l+o,g+f,b+v,A+w).normalize();else if(n===e0)r[5].setComponents(o,f,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),zd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zd)}intersectsSprite(e){return zd.center.set(0,0,0),zd.radius=.7071067811865476,zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(zd)}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(Sy.x=i.normal.x>0?e.max.x:e.min.x,Sy.y=i.normal.y>0?e.max.y:e.min.y,Sy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Sy)<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 DW(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),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 Ixe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(c,u){const f=c.array,g=c.usage,m=f.byteLength,y=t.createBuffer();t.bindBuffer(u,y),t.bufferData(u,f,g),c.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:y,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:m}}function a(c,u,f){const g=u.array,m=u._updateRange,y=u.updateRanges;if(t.bindBuffer(f,c),m.count===-1&&y.length===0&&t.bufferSubData(f,0,g),y.length!==0){for(let v=0,b=y.length;v<b;v++){const x=y[v];n?t.bufferSubData(f,x.start*g.BYTES_PER_ELEMENT,g,x.start,x.count):t.bufferSubData(f,x.start*g.BYTES_PER_ELEMENT,g.subarray(x.start,x.start+x.count))}u.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=r.get(c);u&&(t.deleteBuffer(u.buffer),r.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const g=r.get(c);(!g||g.version<c.version)&&r.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const f=r.get(c);if(f===void 0)r.set(c,i(c,u));else if(f.version<c.version){if(f.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,c,u),f.version=c.version}}return{get:s,remove:o,update:l}}class mk extends oa{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,s=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,f=e/o,g=n/l,m=[],y=[],v=[],b=[];for(let x=0;x<u;x++){const M=x*g-s;for(let w=0;w<c;w++){const A=w*f-a;y.push(A,-M,0),v.push(0,0,1),b.push(w/o),b.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,A=M+c*(x+1),T=M+1+c*(x+1),R=M+1+c*x;m.push(w,A,R),m.push(A,T,R)}this.setIndex(m),this.setAttribute("position",new Dr(y,3)),this.setAttribute("normal",new Dr(v,3)),this.setAttribute("uv",new Dr(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mk(e.width,e.height,e.widthSegments,e.heightSegments)}}var jxe=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,Uxe=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,Fxe=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,zxe=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,Bxe=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,Hxe=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,$xe=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,Vxe=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,Gxe=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,Wxe=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,qxe=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,Xxe=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,Kxe=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,Yxe=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. 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 ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,Zxe=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,Qxe=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,Jxe=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,e0e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,t0e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,n0e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,r0e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,i0e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,a0e=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,s0e=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,o0e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,l0e=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,c0e=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,u0e=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,d0e=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,f0e=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,h0e="gl_FragColor = linearToOutputTexel( gl_FragColor );",p0e=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. 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 );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,m0e=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,g0e=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,x0e=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,v0e=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,b0e=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,y0e=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,_0e=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,S0e=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,w0e=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,M0e=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,E0e=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,A0e=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,T0e=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,C0e=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. 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 ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. 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 ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,N0e=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,R0e=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,P0e=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,k0e=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. 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 ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. 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 ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,D0e=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,O0e=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. 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 ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. 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 ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,L0e=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,I0e=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. 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 ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. 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 ) {
  4950. #else
  4951. 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 ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. 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 ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. 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 ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. 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 ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. 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) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,j0e=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,U0e=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,F0e=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,z0e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,B0e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,H0e=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,$0e=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,V0e=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. 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 );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,G0e=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,W0e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,q0e=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,X0e=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,K0e=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,Y0e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,Z0e=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,Q0e=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,J0e=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,eve=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,tve=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,nve=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,rve=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,ive=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,ave=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,sve=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,ove=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,lve=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,cve=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,uve=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dve=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,fve=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,hve=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,pve=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,mve=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,gve=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,xve=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,vve=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. 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 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,bve=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,yve=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,_ve=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,Sve=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,wve=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,Mve=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,Eve=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,Ave=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,Tve=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,Cve=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,Nve=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,Rve=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,Pve=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,kve=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,Dve=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,Ove=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,Lve=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const Ive=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,jve=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. 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 );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,Uve=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,Fve=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,zve=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,Bve=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,Hve=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,$ve=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,Vve=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,Gve=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,Wve=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,qve=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,Xve=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,Kve=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,Yve=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,Zve=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,Qve=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,Jve=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,ebe=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,tbe=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,nbe=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,rbe=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,ibe=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,abe=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,sbe=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,obe=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,lbe=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,cbe=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,ube=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,dbe=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,fbe=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,hbe=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,pbe=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,mbe=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,rn={alphahash_fragment:jxe,alphahash_pars_fragment:Uxe,alphamap_fragment:Fxe,alphamap_pars_fragment:zxe,alphatest_fragment:Bxe,alphatest_pars_fragment:Hxe,aomap_fragment:$xe,aomap_pars_fragment:Vxe,batching_pars_vertex:Gxe,batching_vertex:Wxe,begin_vertex:qxe,beginnormal_vertex:Xxe,bsdfs:Kxe,iridescence_fragment:Yxe,bumpmap_pars_fragment:Zxe,clipping_planes_fragment:Qxe,clipping_planes_pars_fragment:Jxe,clipping_planes_pars_vertex:e0e,clipping_planes_vertex:t0e,color_fragment:n0e,color_pars_fragment:r0e,color_pars_vertex:i0e,color_vertex:a0e,common:s0e,cube_uv_reflection_fragment:o0e,defaultnormal_vertex:l0e,displacementmap_pars_vertex:c0e,displacementmap_vertex:u0e,emissivemap_fragment:d0e,emissivemap_pars_fragment:f0e,colorspace_fragment:h0e,colorspace_pars_fragment:p0e,envmap_fragment:m0e,envmap_common_pars_fragment:g0e,envmap_pars_fragment:x0e,envmap_pars_vertex:v0e,envmap_physical_pars_fragment:R0e,envmap_vertex:b0e,fog_vertex:y0e,fog_pars_vertex:_0e,fog_fragment:S0e,fog_pars_fragment:w0e,gradientmap_pars_fragment:M0e,lightmap_fragment:E0e,lightmap_pars_fragment:A0e,lights_lambert_fragment:T0e,lights_lambert_pars_fragment:C0e,lights_pars_begin:N0e,lights_toon_fragment:P0e,lights_toon_pars_fragment:k0e,lights_phong_fragment:D0e,lights_phong_pars_fragment:O0e,lights_physical_fragment:L0e,lights_physical_pars_fragment:I0e,lights_fragment_begin:j0e,lights_fragment_maps:U0e,lights_fragment_end:F0e,logdepthbuf_fragment:z0e,logdepthbuf_pars_fragment:B0e,logdepthbuf_pars_vertex:H0e,logdepthbuf_vertex:$0e,map_fragment:V0e,map_pars_fragment:G0e,map_particle_fragment:W0e,map_particle_pars_fragment:q0e,metalnessmap_fragment:X0e,metalnessmap_pars_fragment:K0e,morphcolor_vertex:Y0e,morphnormal_vertex:Z0e,morphtarget_pars_vertex:Q0e,morphtarget_vertex:J0e,normal_fragment_begin:eve,normal_fragment_maps:tve,normal_pars_fragment:nve,normal_pars_vertex:rve,normal_vertex:ive,normalmap_pars_fragment:ave,clearcoat_normal_fragment_begin:sve,clearcoat_normal_fragment_maps:ove,clearcoat_pars_fragment:lve,iridescence_pars_fragment:cve,opaque_fragment:uve,packing:dve,premultiplied_alpha_fragment:fve,project_vertex:hve,dithering_fragment:pve,dithering_pars_fragment:mve,roughnessmap_fragment:gve,roughnessmap_pars_fragment:xve,shadowmap_pars_fragment:vve,shadowmap_pars_vertex:bve,shadowmap_vertex:yve,shadowmask_pars_fragment:_ve,skinbase_vertex:Sve,skinning_pars_vertex:wve,skinning_vertex:Mve,skinnormal_vertex:Eve,specularmap_fragment:Ave,specularmap_pars_fragment:Tve,tonemapping_fragment:Cve,tonemapping_pars_fragment:Nve,transmission_fragment:Rve,transmission_pars_fragment:Pve,uv_pars_fragment:kve,uv_pars_vertex:Dve,uv_vertex:Ove,worldpos_vertex:Lve,background_vert:Ive,background_frag:jve,backgroundCube_vert:Uve,backgroundCube_frag:Fve,cube_vert:zve,cube_frag:Bve,depth_vert:Hve,depth_frag:$ve,distanceRGBA_vert:Vve,distanceRGBA_frag:Gve,equirect_vert:Wve,equirect_frag:qve,linedashed_vert:Xve,linedashed_frag:Kve,meshbasic_vert:Yve,meshbasic_frag:Zve,meshlambert_vert:Qve,meshlambert_frag:Jve,meshmatcap_vert:ebe,meshmatcap_frag:tbe,meshnormal_vert:nbe,meshnormal_frag:rbe,meshphong_vert:ibe,meshphong_frag:abe,meshphysical_vert:sbe,meshphysical_frag:obe,meshtoon_vert:lbe,meshtoon_frag:cbe,points_vert:ube,points_frag:dbe,shadow_vert:fbe,shadow_frag:hbe,sprite_vert:pbe,sprite_frag:mbe},bt={common:{diffuse:{value:new Bt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Bt(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 Bt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new Bt(16777215)},opacity:{value:1},center:{value:new qt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},Ia={basic:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:rn.meshbasic_vert,fragmentShader:rn.meshbasic_frag},lambert:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)}}]),vertexShader:rn.meshlambert_vert,fragmentShader:rn.meshlambert_frag},phong:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)},specular:{value:new Bt(1118481)},shininess:{value:30}}]),vertexShader:rn.meshphong_vert,fragmentShader:rn.meshphong_frag},standard:{uniforms:ha([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag},toon:{uniforms:ha([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)}}]),vertexShader:rn.meshtoon_vert,fragmentShader:rn.meshtoon_frag},matcap:{uniforms:ha([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:rn.meshmatcap_vert,fragmentShader:rn.meshmatcap_frag},points:{uniforms:ha([bt.points,bt.fog]),vertexShader:rn.points_vert,fragmentShader:rn.points_frag},dashed:{uniforms:ha([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:rn.linedashed_vert,fragmentShader:rn.linedashed_frag},depth:{uniforms:ha([bt.common,bt.displacementmap]),vertexShader:rn.depth_vert,fragmentShader:rn.depth_frag},normal:{uniforms:ha([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:rn.meshnormal_vert,fragmentShader:rn.meshnormal_frag},sprite:{uniforms:ha([bt.sprite,bt.fog]),vertexShader:rn.sprite_vert,fragmentShader:rn.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:rn.background_vert,fragmentShader:rn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:rn.backgroundCube_vert,fragmentShader:rn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:rn.cube_vert,fragmentShader:rn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:rn.equirect_vert,fragmentShader:rn.equirect_frag},distanceRGBA:{uniforms:ha([bt.common,bt.displacementmap,{referencePosition:{value:new Te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:rn.distanceRGBA_vert,fragmentShader:rn.distanceRGBA_frag},shadow:{uniforms:ha([bt.lights,bt.fog,{color:{value:new Bt(0)},opacity:{value:1}}]),vertexShader:rn.shadow_vert,fragmentShader:rn.shadow_frag}};Ia.physical={uniforms:ha([Ia.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new Bt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new Bt(0)},specularColor:{value:new Bt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag};const wy={r:0,b:0,g:0};function gbe(t,e,n,r,i,a,s){const o=new Bt(0);let l=a===!0?0:1,c,u,f=null,g=0,m=null;function y(b,x){let M=!1,w=x.isScene===!0?x.background:null;w&&w.isTexture&&(w=(x.backgroundBlurriness>0?n:e).get(w)),w===null?v(o,l):w&&w.isColor&&(v(w,1),M=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===lw)?(u===void 0&&(u=new _o(new F0(1,1,1),new Ju({name:"BackgroundCubeMaterial",uniforms:em(Ia.backgroundCube.uniforms),vertexShader:Ia.backgroundCube.vertexShader,fragmentShader:Ia.backgroundCube.fragmentShader,side:za,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,R,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,(f!==w||g!==w.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,m=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new _o(new mk(2,2),new Ju({name:"BackgroundMaterial",uniforms:em(Ia.background.uniforms),vertexShader:Ia.background.vertexShader,fragmentShader:Ia.background.fragmentShader,side:Qu,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,f=w,g=w.version,m=t.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function v(b,x){b.getRGB(wy,RW(t)),r.buffers.color.setClear(wy.r,wy.g,wy.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(b,x=1){o.set(b),l=x,v(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,v(o,l)},render:y}}function xbe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,o={},l=b(null);let c=l,u=!1;function f(O,B,V,G,K){let Y=!1;if(s){const oe=v(G,V,B);c!==oe&&(c=oe,m(c.object)),Y=x(O,G,V,K),Y&&M(O,G,V,K)}else{const oe=B.wireframe===!0;(c.geometry!==G.id||c.program!==V.id||c.wireframe!==oe)&&(c.geometry=G.id,c.program=V.id,c.wireframe=oe,Y=!0)}K!==null&&n.update(K,t.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,j(O,B,V,G),K!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(K).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(O){return r.isWebGL2?t.bindVertexArray(O):a.bindVertexArrayOES(O)}function y(O){return r.isWebGL2?t.deleteVertexArray(O):a.deleteVertexArrayOES(O)}function v(O,B,V){const G=V.wireframe===!0;let K=o[O.id];K===void 0&&(K={},o[O.id]=K);let Y=K[B.id];Y===void 0&&(Y={},K[B.id]=Y);let oe=Y[G];return oe===void 0&&(oe=b(g()),Y[G]=oe),oe}function b(O){const B=[],V=[],G=[];for(let K=0;K<i;K++)B[K]=0,V[K]=0,G[K]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:V,attributeDivisors:G,object:O,attributes:{},index:null}}function x(O,B,V,G){const K=c.attributes,Y=B.attributes;let oe=0;const $=V.getAttributes();for(const X in $)if($[X].location>=0){const ce=K[X];let xe=Y[X];if(xe===void 0&&(X==="instanceMatrix"&&O.instanceMatrix&&(xe=O.instanceMatrix),X==="instanceColor"&&O.instanceColor&&(xe=O.instanceColor)),ce===void 0||ce.attribute!==xe||xe&&ce.data!==xe.data)return!0;oe++}return c.attributesNum!==oe||c.index!==G}function M(O,B,V,G){const K={},Y=B.attributes;let oe=0;const $=V.getAttributes();for(const X in $)if($[X].location>=0){let ce=Y[X];ce===void 0&&(X==="instanceMatrix"&&O.instanceMatrix&&(ce=O.instanceMatrix),X==="instanceColor"&&O.instanceColor&&(ce=O.instanceColor));const xe={};xe.attribute=ce,ce&&ce.data&&(xe.data=ce.data),K[X]=xe,oe++}c.attributes=K,c.attributesNum=oe,c.index=G}function w(){const O=c.newAttributes;for(let B=0,V=O.length;B<V;B++)O[B]=0}function A(O){T(O,0)}function T(O,B){const V=c.newAttributes,G=c.enabledAttributes,K=c.attributeDivisors;V[O]=1,G[O]===0&&(t.enableVertexAttribArray(O),G[O]=1),K[O]!==B&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](O,B),K[O]=B)}function R(){const O=c.newAttributes,B=c.enabledAttributes;for(let V=0,G=B.length;V<G;V++)B[V]!==O[V]&&(t.disableVertexAttribArray(V),B[V]=0)}function N(O,B,V,G,K,Y,oe){oe===!0?t.vertexAttribIPointer(O,B,V,K,Y):t.vertexAttribPointer(O,B,V,G,K,Y)}function j(O,B,V,G){if(r.isWebGL2===!1&&(O.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const K=G.attributes,Y=V.getAttributes(),oe=B.defaultAttributeValues;for(const $ in Y){const X=Y[$];if(X.location>=0){let ae=K[$];if(ae===void 0&&($==="instanceMatrix"&&O.instanceMatrix&&(ae=O.instanceMatrix),$==="instanceColor"&&O.instanceColor&&(ae=O.instanceColor)),ae!==void 0){const ce=ae.normalized,xe=ae.itemSize,te=n.get(ae);if(te===void 0)continue;const ve=te.buffer,De=te.type,he=te.bytesPerElement,me=r.isWebGL2===!0&&(De===t.INT||De===t.UNSIGNED_INT||ae.gpuType===uW);if(ae.isInterleavedBufferAttribute){const we=ae.data,se=we.stride,st=ae.offset;if(we.isInstancedInterleavedBuffer){for(let z=0;z<X.locationSize;z++)T(X.location+z,we.meshPerAttribute);O.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=we.meshPerAttribute*we.count)}else for(let z=0;z<X.locationSize;z++)A(X.location+z);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let z=0;z<X.locationSize;z++)N(X.location+z,xe/X.locationSize,De,ce,se*he,(st+xe/X.locationSize*z)*he,me)}else{if(ae.isInstancedBufferAttribute){for(let we=0;we<X.locationSize;we++)T(X.location+we,ae.meshPerAttribute);O.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let we=0;we<X.locationSize;we++)A(X.location+we);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let we=0;we<X.locationSize;we++)N(X.location+we,xe/X.locationSize,De,ce,xe*he,xe/X.locationSize*we*he,me)}}else if(oe!==void 0){const ce=oe[$];if(ce!==void 0)switch(ce.length){case 2:t.vertexAttrib2fv(X.location,ce);break;case 3:t.vertexAttrib3fv(X.location,ce);break;case 4:t.vertexAttrib4fv(X.location,ce);break;default:t.vertexAttrib1fv(X.location,ce)}}}}R()}function C(){I();for(const O in o){const B=o[O];for(const V in B){const G=B[V];for(const K in G)y(G[K].object),delete G[K];delete B[V]}delete o[O]}}function k(O){if(o[O.id]===void 0)return;const B=o[O.id];for(const V in B){const G=B[V];for(const K in G)y(G[K].object),delete G[K];delete B[V]}delete o[O.id]}function U(O){for(const B in o){const V=o[B];if(V[O.id]===void 0)continue;const G=V[O.id];for(const K in G)y(G[K].object),delete G[K];delete V[O.id]}}function I(){H(),u=!0,c!==l&&(c=l,m(c.object))}function H(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:I,resetDefaultState:H,dispose:C,releaseStatesOfGeometry:k,releaseStatesOfProgram:U,initAttributes:w,enableAttribute:A,disableUnusedAttributes:R}}function vbe(t,e,n,r){const i=r.isWebGL2;let a;function s(u){a=u}function o(u,f){t.drawArrays(a,u,f),n.update(f,a,1)}function l(u,f,g){if(g===0)return;let m,y;if(i)m=t,y="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),y="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[y](a,u,f,g),n.update(f,a,g)}function c(u,f,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let y=0;y<g;y++)this.render(u[y],f[y]);else{m.multiDrawArraysWEBGL(a,u,0,f,0,g);let y=0;for(let v=0;v<g;v++)y+=f[v];n.update(y,a,1)}}this.setMode=s,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function bbe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=s||e.has("WEBGL_draw_buffers"),u=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),x=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,A=s||e.has("OES_texture_float"),T=w&&A,R=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:y,maxAttributes:v,maxVertexUniforms:b,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:R}}function ybe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Su,o=new dn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=u(f,g,0)},this.setState=function(f,g,m){const y=f.clippingPlanes,v=f.clipIntersection,b=f.clipShadows,x=t.get(f);if(!i||y===null||y.length===0||a&&!b)a?u(null):c();else{const M=a?0:r,w=M*4;let A=x.clippingState||null;l.value=A,A=u(y,g,w,m);for(let T=0;T!==w;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(f,g,m,y){const v=f!==null?f.length:0;let b=null;if(v!==0){if(b=l.value,y!==!0||b===null){const x=m+v*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(b===null||b.length<x)&&(b=new Float32Array(x));for(let w=0,A=m;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(b,A),b[A+3]=s.constant}l.value=b,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,b}}function _be(t){let e=new WeakMap;function n(s,o){return o===R3?s.mapping=Zp:o===P3&&(s.mapping=Qp),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===R3||o===P3)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new Dxe(l.height/2);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",i),n(c.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class Sbe extends PW{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Mp=4,d5=[.125,.215,.35,.446,.526,.582],Zd=20,zT=new Sbe,f5=new Bt;let BT=null,HT=0,$T=0;const Vd=(1+Math.sqrt(5))/2,cp=1/Vd,h5=[new Te(1,1,1),new Te(-1,1,1),new Te(1,1,-1),new Te(-1,1,-1),new Te(0,Vd,cp),new Te(0,Vd,-cp),new Te(cp,0,Vd),new Te(-cp,0,Vd),new Te(Vd,cp,0),new Te(-Vd,cp,0)];class p5{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){BT=this._renderer.getRenderTarget(),HT=this._renderer.getActiveCubeFace(),$T=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=x5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=g5(),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(BT,HT,$T),e.scissorTest=!1,My(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zp||e.mapping===Qp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),BT=this._renderer.getRenderTarget(),HT=this._renderer.getActiveCubeFace(),$T=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:Fs,minFilter:Fs,generateMipmaps:!1,type:Jx,format:zs,colorSpace:xc,depthBuffer:!1},i=m5(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=m5(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=wbe(a)),this._blurMaterial=Mbe(a,e,n)}return i}_compileMaterial(e){const n=new _o(this._lodPlanes[0],e);this._renderer.compile(n,zT)}_sceneToCubeUV(e,n,r,i){const o=new ls(90,1,n,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,g=u.toneMapping;u.getClearColor(f5),u.toneMapping=Hu,u.autoClear=!1;const m=new TW({name:"PMREM.Background",side:za,depthWrite:!1,depthTest:!1}),y=new _o(new F0,m);let v=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,v=!0):(m.color.copy(f5),v=!0);for(let x=0;x<6;x++){const M=x%3;M===0?(o.up.set(0,l[x],0),o.lookAt(c[x],0,0)):M===1?(o.up.set(0,0,l[x]),o.lookAt(0,c[x],0)):(o.up.set(0,l[x],0),o.lookAt(0,0,c[x]));const w=this._cubeSize;My(i,M*w,x>2?w:0,w,w),u.setRenderTarget(i),v&&u.render(y,o),u.render(e,o)}y.geometry.dispose(),y.material.dispose(),u.toneMapping=g,u.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Zp||e.mapping===Qp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=x5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=g5());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new _o(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;My(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(s,zT)}_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]),s=h5[(i-1)%h5.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,f=new _o(this._lodPlanes[i],c),g=c.uniforms,m=this._sizeLods[r]-1,y=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Zd-1),v=a/y,b=isFinite(a)?1+Math.floor(u*v):Zd;b>Zd&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Zd}`);const x=[];let M=0;for(let N=0;N<Zd;++N){const j=N/v,C=Math.exp(-j*j/2);x.push(C),N===0?M+=C:N<b&&(M+=2*C)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=y,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Mp?i-w+Mp:0),R=4*(this._cubeSize-A);My(n,T,R,3*A,2*A),l.setRenderTarget(n),l.render(f,zT)}}function wbe(t){const e=[],n=[],r=[];let i=t;const a=t-Mp+1+d5.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);n.push(o);let l=1/o;s>t-Mp?l=d5[s-t+Mp-1]:s===0&&(l=0),r.push(l);const c=1/(o-2),u=-c,f=1+c,g=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,y=6,v=3,b=2,x=1,M=new Float32Array(v*y*m),w=new Float32Array(b*y*m),A=new Float32Array(x*y*m);for(let R=0;R<m;R++){const N=R%3*2/3-1,j=R>2?0:-1,C=[N,j,0,N+2/3,j,0,N+2/3,j+1,0,N,j,0,N+2/3,j+1,0,N,j+1,0];M.set(C,v*y*R),w.set(g,b*y*R);const k=[R,R,R,R,R,R];A.set(k,x*y*R)}const T=new oa;T.setAttribute("position",new hs(M,v)),T.setAttribute("uv",new hs(w,b)),T.setAttribute("faceIndex",new hs(A,x)),e.push(T),i>Mp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function m5(t,e,n){const r=new Pf(t,e,n);return r.texture.mapping=lw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function My(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Mbe(t,e,n){const r=new Float32Array(Zd),i=new Te(0,1,0);return new Ju({name:"SphericalGaussianBlur",defines:{n:Zd,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:gk(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:Bu,depthTest:!1,depthWrite:!1})}function g5(){return new Ju({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:gk(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:Bu,depthTest:!1,depthWrite:!1})}function x5(){return new Ju({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:gk(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:Bu,depthTest:!1,depthWrite:!1})}function gk(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function Ebe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===R3||l===P3,u=l===Zp||l===Qp;if(c||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new p5(t)),f=c?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(c&&f&&f.height>0||u&&f&&i(f)){n===null&&(n=new p5(t));const g=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",a),g.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function Abe(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 Tbe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const y in g.attributes)e.remove(g.attributes[y]);for(const y in g.morphAttributes){const v=g.morphAttributes[y];for(let b=0,x=v.length;b<x;b++)e.remove(v[b])}g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const y in g)e.update(g[y],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const y in m){const v=m[y];for(let b=0,x=v.length;b<x;b++)e.update(v[b],t.ARRAY_BUFFER)}}function c(f){const g=[],m=f.index,y=f.attributes.position;let v=0;if(m!==null){const M=m.array;v=m.version;for(let w=0,A=M.length;w<A;w+=3){const T=M[w+0],R=M[w+1],N=M[w+2];g.push(T,R,R,N,N,T)}}else if(y!==void 0){const M=y.array;v=y.version;for(let w=0,A=M.length/3-1;w<A;w+=3){const T=w+0,R=w+1,N=w+2;g.push(T,R,R,N,N,T)}}else return;const b=new(_W(g)?NW:CW)(g,1);b.version=v;const x=a.get(f);x&&e.remove(x),a.set(f,b)}function u(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:u}}function Cbe(t,e,n,r){const i=r.isWebGL2;let a;function s(m){a=m}let o,l;function c(m){o=m.type,l=m.bytesPerElement}function u(m,y){t.drawElements(a,y,o,m*l),n.update(y,a,1)}function f(m,y,v){if(v===0)return;let b,x;if(i)b=t,x="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[x](a,y,o,m*l,v),n.update(y,a,v)}function g(m,y,v){if(v===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let x=0;x<v;x++)this.render(m[x]/l,y[x]);else{b.multiDrawElementsWEBGL(a,y,0,o,m,0,v);let x=0;for(let M=0;M<v;M++)x+=y[M];n.update(x,a,1)}}this.setMode=s,this.setIndex=c,this.render=u,this.renderInstances=f,this.renderMultiDraw=g}function Nbe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function 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 Rbe(t,e){return t[0]-e[0]}function Pbe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function kbe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new Gn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,u,f){const g=c.morphTargetInfluences;if(e.isWebGL2===!0){const y=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,v=y!==void 0?y.length:0;let b=a.get(u);if(b===void 0||b.count!==v){let B=function(){H.dispose(),a.delete(u),u.removeEventListener("dispose",B)};var m=B;b!==void 0&&b.texture.dispose();const w=u.morphAttributes.position!==void 0,A=u.morphAttributes.normal!==void 0,T=u.morphAttributes.color!==void 0,R=u.morphAttributes.position||[],N=u.morphAttributes.normal||[],j=u.morphAttributes.color||[];let C=0;w===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let k=u.attributes.position.count*C,U=1;k>e.maxTextureSize&&(U=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const I=new Float32Array(k*U*4*v),H=new MW(I,k,U,v);H.type=nc,H.needsUpdate=!0;const O=C*4;for(let V=0;V<v;V++){const G=R[V],K=N[V],Y=j[V],oe=k*U*4*V;for(let $=0;$<G.count;$++){const X=$*O;w===!0&&(s.fromBufferAttribute(G,$),I[oe+X+0]=s.x,I[oe+X+1]=s.y,I[oe+X+2]=s.z,I[oe+X+3]=0),A===!0&&(s.fromBufferAttribute(K,$),I[oe+X+4]=s.x,I[oe+X+5]=s.y,I[oe+X+6]=s.z,I[oe+X+7]=0),T===!0&&(s.fromBufferAttribute(Y,$),I[oe+X+8]=s.x,I[oe+X+9]=s.y,I[oe+X+10]=s.z,I[oe+X+11]=Y.itemSize===4?s.w:1)}}b={count:v,texture:H,size:new qt(k,U)},a.set(u,b),u.addEventListener("dispose",B)}let x=0;for(let w=0;w<g.length;w++)x+=g[w];const M=u.morphTargetsRelative?1:1-x;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const y=g===void 0?0:g.length;let v=r[u.id];if(v===void 0||v.length!==y){v=[];for(let A=0;A<y;A++)v[A]=[A,0];r[u.id]=v}for(let A=0;A<y;A++){const T=v[A];T[0]=A,T[1]=g[A]}v.sort(Pbe);for(let A=0;A<8;A++)A<y&&v[A][1]?(o[A][0]=v[A][0],o[A][1]=v[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(Rbe);const b=u.morphAttributes.position,x=u.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const T=o[A],R=T[0],N=T[1];R!==Number.MAX_SAFE_INTEGER&&N?(b&&u.getAttribute("morphTarget"+A)!==b[R]&&u.setAttribute("morphTarget"+A,b[R]),x&&u.getAttribute("morphNormal"+A)!==x[R]&&u.setAttribute("morphNormal"+A,x[R]),i[A]=N,M+=N):(b&&u.hasAttribute("morphTarget"+A)===!0&&u.deleteAttribute("morphTarget"+A),x&&u.hasAttribute("morphNormal"+A)===!0&&u.deleteAttribute("morphNormal"+A),i[A]=0)}const w=u.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function Dbe(t,e,n,r){let i=new WeakMap;function a(l){const c=r.render.frame,u=l.geometry,f=e.get(l,u);if(i.get(f)!==c&&(e.update(f),i.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return f}function s(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}class OW extends Ba{constructor(e,n,r,i,a,s,o,l,c,u){if(u=u!==void 0?u:df,u!==df&&u!==Jp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===df&&(r=Ou),r===void 0&&u===Jp&&(r=uf),super(null,i,a,s,o,l,u,r,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Hi,this.minFilter=l!==void 0?l:Hi,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 LW=new Ba,IW=new OW(1,1);IW.compareFunction=bW;const jW=new MW,UW=new xxe,FW=new kW,v5=[],b5=[],y5=new Float32Array(16),_5=new Float32Array(9),S5=new Float32Array(4);function Em(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=v5[i];if(a===void 0&&(a=new Float32Array(i),v5[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function oi(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 li(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function dw(t,e){let n=b5[e];n===void 0&&(n=new Int32Array(e),b5[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Obe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Lbe(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(oi(n,e))return;t.uniform2fv(this.addr,e),li(n,e)}}function Ibe(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(oi(n,e))return;t.uniform3fv(this.addr,e),li(n,e)}}function jbe(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(oi(n,e))return;t.uniform4fv(this.addr,e),li(n,e)}}function Ube(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;S5.set(r),t.uniformMatrix2fv(this.addr,!1,S5),li(n,r)}}function Fbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;_5.set(r),t.uniformMatrix3fv(this.addr,!1,_5),li(n,r)}}function zbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;y5.set(r),t.uniformMatrix4fv(this.addr,!1,y5),li(n,r)}}function Bbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Hbe(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(oi(n,e))return;t.uniform2iv(this.addr,e),li(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.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(oi(n,e))return;t.uniform3iv(this.addr,e),li(n,e)}}function Vbe(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(oi(n,e))return;t.uniform4iv(this.addr,e),li(n,e)}}function Gbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Wbe(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(oi(n,e))return;t.uniform2uiv(this.addr,e),li(n,e)}}function qbe(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(oi(n,e))return;t.uniform3uiv(this.addr,e),li(n,e)}}function Xbe(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(oi(n,e))return;t.uniform4uiv(this.addr,e),li(n,e)}}function Kbe(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?IW:LW;n.setTexture2D(e||a,i)}function Ybe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||UW,i)}function Zbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||FW,i)}function Qbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||jW,i)}function Jbe(t){switch(t){case 5126:return Obe;case 35664:return Lbe;case 35665:return Ibe;case 35666:return jbe;case 35674:return Ube;case 35675:return Fbe;case 35676:return zbe;case 5124:case 35670:return Bbe;case 35667:case 35671:return Hbe;case 35668:case 35672:return $be;case 35669:case 35673:return Vbe;case 5125:return Gbe;case 36294:return Wbe;case 36295:return qbe;case 36296:return Xbe;case 35678:case 36198:case 36298:case 36306:case 35682:return Kbe;case 35679:case 36299:case 36307:return Ybe;case 35680:case 36300:case 36308:case 36293:return Zbe;case 36289:case 36303:case 36311:case 36292:return Qbe}}function eye(t,e){t.uniform1fv(this.addr,e)}function tye(t,e){const n=Em(e,this.size,2);t.uniform2fv(this.addr,n)}function nye(t,e){const n=Em(e,this.size,3);t.uniform3fv(this.addr,n)}function rye(t,e){const n=Em(e,this.size,4);t.uniform4fv(this.addr,n)}function iye(t,e){const n=Em(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function aye(t,e){const n=Em(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function sye(t,e){const n=Em(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function oye(t,e){t.uniform1iv(this.addr,e)}function lye(t,e){t.uniform2iv(this.addr,e)}function cye(t,e){t.uniform3iv(this.addr,e)}function uye(t,e){t.uniform4iv(this.addr,e)}function dye(t,e){t.uniform1uiv(this.addr,e)}function fye(t,e){t.uniform2uiv(this.addr,e)}function hye(t,e){t.uniform3uiv(this.addr,e)}function pye(t,e){t.uniform4uiv(this.addr,e)}function mye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||LW,a[s])}function gye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||UW,a[s])}function xye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||FW,a[s])}function vye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||jW,a[s])}function bye(t){switch(t){case 5126:return eye;case 35664:return tye;case 35665:return nye;case 35666:return rye;case 35674:return iye;case 35675:return aye;case 35676:return sye;case 5124:case 35670:return oye;case 35667:case 35671:return lye;case 35668:case 35672:return cye;case 35669:case 35673:return uye;case 5125:return dye;case 36294:return fye;case 36295:return hye;case 36296:return pye;case 35678:case 36198:case 36298:case 36306:case 35682:return mye;case 35679:case 36299:case 36307:return gye;case 35680:case 36300:case 36308:case 36293:return xye;case 36289:case 36303:case 36311:case 36292:return vye}}class yye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Jbe(n.type)}}class _ye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=bye(n.type)}}class Sye{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}}const VT=/(\w+)(\])?(\[|\.)?/g;function w5(t,e){t.seq.push(e),t.map[e.id]=e}function wye(t,e,n){const r=t.name,i=r.length;for(VT.lastIndex=0;;){const a=VT.exec(r),s=VT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===i){w5(n,c===void 0?new yye(o,t,e):new _ye(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Sye(o),w5(n,f)),n=f}}}class M_{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),s=e.getUniformLocation(n,a.name);wye(a,s,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,s=n.length;a!==s;++a){const o=n[a],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function M5(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Mye=37297;let Eye=0;function Aye(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  7343. `)}function Tye(t){const e=$n.getPrimaries($n.workingColorSpace),n=$n.getPrimaries(t);let r;switch(e===n?r="":e===r1&&n===n1?r="LinearDisplayP3ToLinearSRGB":e===n1&&n===r1&&(r="LinearSRGBToLinearDisplayP3"),t){case xc:case cw:return[r,"LinearTransferOETF"];case $i:case dk:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function E5(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 s=parseInt(a[1]);return n.toUpperCase()+`
  7344. `+i+`
  7345. `+Aye(t.getShaderSource(e),s)}else return i}function Cye(t,e){const n=Tye(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Nye(t,e){let n;switch(e){case Cge:n="Linear";break;case Nge:n="Reinhard";break;case Rge:n="OptimizedCineon";break;case Pge:n="ACESFilmic";break;case kge:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Rye(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(ox).join(`
  7346. `)}function Pye(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function kye(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function ox(t){return t!==""}function A5(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 T5(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Dye=/^[ \t]*#include +<([\w\d./]+)>/gm;function j3(t){return t.replace(Dye,Lye)}const Oye=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Lye(t,e){let n=rn[e];if(n===void 0){const r=Oye.get(e);if(r!==void 0)n=rn[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 j3(n)}const Iye=/#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 C5(t){return t.replace(Iye,jye)}function jye(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 N5(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function Uye(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===lW?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===nge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Gl&&(e="SHADOWMAP_TYPE_VSM"),e}function Fye(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Zp:case Qp:e="ENVMAP_TYPE_CUBE";break;case lw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function zye(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Qp:e="ENVMAP_MODE_REFRACTION";break}return e}function Bye(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case ck:e="ENVMAP_BLENDING_MULTIPLY";break;case Age:e="ENVMAP_BLENDING_MIX";break;case Tge:e="ENVMAP_BLENDING_ADD";break}return e}function Hye(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 $ye(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=Uye(n),c=Fye(n),u=zye(n),f=Bye(n),g=Hye(n),m=n.isWebGL2?"":Rye(n),y=Pye(a),v=i.createProgram();let b,x,M=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(ox).join(`
  7353. `),b.length>0&&(b+=`
  7354. `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(ox).join(`
  7355. `),x.length>0&&(x+=`
  7356. `)):(b=[N5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7357. `].filter(ox).join(`
  7358. `),x=[m,N5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hu?"#define TONE_MAPPING":"",n.toneMapping!==Hu?rn.tonemapping_pars_fragment:"",n.toneMapping!==Hu?Nye("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",rn.colorspace_pars_fragment,Cye("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(ox).join(`
  7360. `)),s=j3(s),s=A5(s,n),s=T5(s,n),o=j3(o),o=A5(o,n),o=T5(o,n),s=C5(s),o=C5(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  7361. `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+b,x=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===qz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===qz?"":"#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(`
  7364. `)+`
  7365. `+x);const w=M+b+s,A=M+x+o,T=M5(i,i.VERTEX_SHADER,w),R=M5(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,R),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(U){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v).trim(),H=i.getShaderInfoLog(T).trim(),O=i.getShaderInfoLog(R).trim();let B=!0,V=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(B=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,R);else{const G=E5(i,T,"vertex"),K=E5(i,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+I+`
  7367. `+G+`
  7368. `+K)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(H===""||O==="")&&(V=!1);V&&(U.diagnostics={runnable:B,programLog:I,vertexShader:{log:H,prefix:b},fragmentShader:{log:O,prefix:x}})}i.deleteShader(T),i.deleteShader(R),j=new M_(i,v),C=kye(i,v)}let j;this.getUniforms=function(){return j===void 0&&N(this),j};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(v,Mye)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Eye++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=R,this}let Vye=0;class Gye{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),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.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 Wye(e),n.set(e,r)),r}}class Wye{constructor(e){this.id=Vye++,this.code=e,this.usedTimes=0}}function qye(t,e,n,r,i,a,s){const o=new EW,l=new Gye,c=[],u=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const y={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(C){return C===0?"uv":`uv${C}`}function b(C,k,U,I,H){const O=I.fog,B=H.geometry,V=C.isMeshStandardMaterial?I.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||V),K=G&&G.mapping===lw?G.image.height:null,Y=y[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const oe=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,$=oe!==void 0?oe.length:0;let X=0;B.morphAttributes.position!==void 0&&(X=1),B.morphAttributes.normal!==void 0&&(X=2),B.morphAttributes.color!==void 0&&(X=3);let ae,ce,xe,te;if(Y){const ln=Ia[Y];ae=ln.vertexShader,ce=ln.fragmentShader}else ae=C.vertexShader,ce=C.fragmentShader,l.update(C),xe=l.getVertexShaderID(C),te=l.getFragmentShaderID(C);const ve=t.getRenderTarget(),De=H.isInstancedMesh===!0,he=H.isBatchedMesh===!0,me=!!C.map,we=!!C.matcap,se=!!G,st=!!C.aoMap,z=!!C.lightMap,q=!!C.bumpMap,ie=!!C.normalMap,Q=!!C.displacementMap,ee=!!C.emissiveMap,le=!!C.metalnessMap,Re=!!C.roughnessMap,Pe=C.anisotropy>0,ne=C.clearcoat>0,F=C.iridescence>0,L=C.sheen>0,Z=C.transmission>0,ge=Pe&&!!C.anisotropyMap,ye=ne&&!!C.clearcoatMap,pe=ne&&!!C.clearcoatNormalMap,Ze=ne&&!!C.clearcoatRoughnessMap,Ie=F&&!!C.iridescenceMap,Xe=F&&!!C.iridescenceThicknessMap,ot=L&&!!C.sheenColorMap,je=L&&!!C.sheenRoughnessMap,ke=!!C.specularMap,pt=!!C.specularColorMap,rt=!!C.specularIntensityMap,nt=Z&&!!C.transmissionMap,dt=Z&&!!C.thicknessMap,de=!!C.gradientMap,it=!!C.alphaMap,fe=C.alphaTest>0,Le=!!C.alphaHash,Ee=!!C.extensions,be=!!B.attributes.uv1,He=!!B.attributes.uv2,ut=!!B.attributes.uv3;let _t=Hu;return C.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(_t=t.toneMapping),{isWebGL2:u,shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ae,fragmentShader:ce,defines:C.defines,customVertexShaderID:xe,customFragmentShaderID:te,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:he,instancing:De,instancingColor:De&&H.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:xc,map:me,matcap:we,envMap:se,envMapMode:se&&G.mapping,envMapCubeUVHeight:K,aoMap:st,lightMap:z,bumpMap:q,normalMap:ie,displacementMap:g&&Q,emissiveMap:ee,normalMapObjectSpace:ie&&C.normalMapType===Vge,normalMapTangentSpace:ie&&C.normalMapType===vW,metalnessMap:le,roughnessMap:Re,anisotropy:Pe,anisotropyMap:ge,clearcoat:ne,clearcoatMap:ye,clearcoatNormalMap:pe,clearcoatRoughnessMap:Ze,iridescence:F,iridescenceMap:Ie,iridescenceThicknessMap:Xe,sheen:L,sheenColorMap:ot,sheenRoughnessMap:je,specularMap:ke,specularColorMap:pt,specularIntensityMap:rt,transmission:Z,transmissionMap:nt,thicknessMap:dt,gradientMap:de,opaque:C.transparent===!1&&C.blending===Dp,alphaMap:it,alphaTest:fe,alphaHash:Le,combine:C.combine,mapUv:me&&v(C.map.channel),aoMapUv:st&&v(C.aoMap.channel),lightMapUv:z&&v(C.lightMap.channel),bumpMapUv:q&&v(C.bumpMap.channel),normalMapUv:ie&&v(C.normalMap.channel),displacementMapUv:Q&&v(C.displacementMap.channel),emissiveMapUv:ee&&v(C.emissiveMap.channel),metalnessMapUv:le&&v(C.metalnessMap.channel),roughnessMapUv:Re&&v(C.roughnessMap.channel),anisotropyMapUv:ge&&v(C.anisotropyMap.channel),clearcoatMapUv:ye&&v(C.clearcoatMap.channel),clearcoatNormalMapUv:pe&&v(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ze&&v(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&v(C.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&v(C.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&v(C.sheenColorMap.channel),sheenRoughnessMapUv:je&&v(C.sheenRoughnessMap.channel),specularMapUv:ke&&v(C.specularMap.channel),specularColorMapUv:pt&&v(C.specularColorMap.channel),specularIntensityMapUv:rt&&v(C.specularIntensityMap.channel),transmissionMapUv:nt&&v(C.transmissionMap.channel),thicknessMapUv:dt&&v(C.thicknessMap.channel),alphaMapUv:it&&v(C.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(ie||Pe),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUv1s:be,vertexUv2s:He,vertexUv3s:ut,pointsUvs:H.isPoints===!0&&!!B.attributes.uv&&(me||it),fog:!!O,useFog:C.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:H.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:$,morphTextureStride:X,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,useLegacyLights:t._useLegacyLights,decodeVideoTexture:me&&C.map.isVideoTexture===!0&&$n.getTransfer(C.map.colorSpace)===rr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Yl,flipSided:C.side===za,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ee&&C.extensions.derivatives===!0,extensionFragDepth:Ee&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ee&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ee&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function x(C){const k=[];if(C.shaderID?k.push(C.shaderID):(k.push(C.customVertexShaderID),k.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)k.push(U),k.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(M(k,C),w(k,C),k.push(t.outputColorSpace)),k.push(C.customProgramCacheKey),k.join()}function M(C,k){C.push(k.precision),C.push(k.outputColorSpace),C.push(k.envMapMode),C.push(k.envMapCubeUVHeight),C.push(k.mapUv),C.push(k.alphaMapUv),C.push(k.lightMapUv),C.push(k.aoMapUv),C.push(k.bumpMapUv),C.push(k.normalMapUv),C.push(k.displacementMapUv),C.push(k.emissiveMapUv),C.push(k.metalnessMapUv),C.push(k.roughnessMapUv),C.push(k.anisotropyMapUv),C.push(k.clearcoatMapUv),C.push(k.clearcoatNormalMapUv),C.push(k.clearcoatRoughnessMapUv),C.push(k.iridescenceMapUv),C.push(k.iridescenceThicknessMapUv),C.push(k.sheenColorMapUv),C.push(k.sheenRoughnessMapUv),C.push(k.specularMapUv),C.push(k.specularColorMapUv),C.push(k.specularIntensityMapUv),C.push(k.transmissionMapUv),C.push(k.thicknessMapUv),C.push(k.combine),C.push(k.fogExp2),C.push(k.sizeAttenuation),C.push(k.morphTargetsCount),C.push(k.morphAttributeCount),C.push(k.numDirLights),C.push(k.numPointLights),C.push(k.numSpotLights),C.push(k.numSpotLightMaps),C.push(k.numHemiLights),C.push(k.numRectAreaLights),C.push(k.numDirLightShadows),C.push(k.numPointLightShadows),C.push(k.numSpotLightShadows),C.push(k.numSpotLightShadowsWithMaps),C.push(k.numLightProbes),C.push(k.shadowMapType),C.push(k.toneMapping),C.push(k.numClippingPlanes),C.push(k.numClipIntersection),C.push(k.depthPacking)}function w(C,k){o.disableAll(),k.isWebGL2&&o.enable(0),k.supportsVertexTextures&&o.enable(1),k.instancing&&o.enable(2),k.instancingColor&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),C.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.skinning&&o.enable(4),k.morphTargets&&o.enable(5),k.morphNormals&&o.enable(6),k.morphColors&&o.enable(7),k.premultipliedAlpha&&o.enable(8),k.shadowMapEnabled&&o.enable(9),k.useLegacyLights&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),C.push(o.mask)}function A(C){const k=y[C.type];let U;if(k){const I=Ia[k];U=pk.clone(I.uniforms)}else U=C.uniforms;return U}function T(C,k){let U;for(let I=0,H=c.length;I<H;I++){const O=c[I];if(O.cacheKey===k){U=O,++U.usedTimes;break}}return U===void 0&&(U=new $ye(t,k,C,a),c.push(U)),U}function R(C){if(--C.usedTimes===0){const k=c.indexOf(C);c[k]=c[c.length-1],c.pop(),C.destroy()}}function N(C){l.remove(C)}function j(){l.dispose()}return{getParameters:b,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:R,releaseShaderCache:N,programs:c,dispose:j}}function Xye(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,o){t.get(a)[s]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function Kye(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 R5(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 P5(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,y,v,b){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:g,material:m,groupOrder:y,renderOrder:f.renderOrder,z:v,group:b},t[e]=x):(x.id=f.id,x.object=f,x.geometry=g,x.material=m,x.groupOrder=y,x.renderOrder=f.renderOrder,x.z=v,x.group=b),e++,x}function o(f,g,m,y,v,b){const x=s(f,g,m,y,v,b);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(f,g,m,y,v,b){const x=s(f,g,m,y,v,b);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(f,g){n.length>1&&n.sort(f||Kye),r.length>1&&r.sort(g||R5),i.length>1&&i.sort(g||R5)}function u(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:l,finish:u,sort:c}}function Yye(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new P5,t.set(r,[s])):i>=a.length?(s=new P5,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function Zye(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Te,color:new Bt};break;case"SpotLight":n={position:new Te,direction:new Te,color:new Bt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Te,color:new Bt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Te,skyColor:new Bt,groundColor:new Bt};break;case"RectAreaLight":n={color:new Bt,position:new Te,halfWidth:new Te,halfHeight:new Te};break}return t[e.id]=n,n}}}function Qye(){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 qt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Jye=0;function e_e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function t_e(t,e){const n=new Zye,r=Qye(),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 u=0;u<9;u++)i.probe.push(new Te);const a=new Te,s=new Jn,o=new Jn;function l(u,f){let g=0,m=0,y=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let v=0,b=0,x=0,M=0,w=0,A=0,T=0,R=0,N=0,j=0,C=0;u.sort(e_e);const k=f===!0?Math.PI:1;for(let I=0,H=u.length;I<H;I++){const O=u[I],B=O.color,V=O.intensity,G=O.distance,K=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)g+=B.r*V*k,m+=B.g*V*k,y+=B.b*V*k;else if(O.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(O.sh.coefficients[Y],V);C++}else if(O.isDirectionalLight){const Y=n.get(O);if(Y.color.copy(O.color).multiplyScalar(O.intensity*k),O.castShadow){const oe=O.shadow,$=r.get(O);$.shadowBias=oe.bias,$.shadowNormalBias=oe.normalBias,$.shadowRadius=oe.radius,$.shadowMapSize=oe.mapSize,i.directionalShadow[v]=$,i.directionalShadowMap[v]=K,i.directionalShadowMatrix[v]=O.shadow.matrix,A++}i.directional[v]=Y,v++}else if(O.isSpotLight){const Y=n.get(O);Y.position.setFromMatrixPosition(O.matrixWorld),Y.color.copy(B).multiplyScalar(V*k),Y.distance=G,Y.coneCos=Math.cos(O.angle),Y.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),Y.decay=O.decay,i.spot[x]=Y;const oe=O.shadow;if(O.map&&(i.spotLightMap[N]=O.map,N++,oe.updateMatrices(O),O.castShadow&&j++),i.spotLightMatrix[x]=oe.matrix,O.castShadow){const $=r.get(O);$.shadowBias=oe.bias,$.shadowNormalBias=oe.normalBias,$.shadowRadius=oe.radius,$.shadowMapSize=oe.mapSize,i.spotShadow[x]=$,i.spotShadowMap[x]=K,R++}x++}else if(O.isRectAreaLight){const Y=n.get(O);Y.color.copy(B).multiplyScalar(V),Y.halfWidth.set(O.width*.5,0,0),Y.halfHeight.set(0,O.height*.5,0),i.rectArea[M]=Y,M++}else if(O.isPointLight){const Y=n.get(O);if(Y.color.copy(O.color).multiplyScalar(O.intensity*k),Y.distance=O.distance,Y.decay=O.decay,O.castShadow){const oe=O.shadow,$=r.get(O);$.shadowBias=oe.bias,$.shadowNormalBias=oe.normalBias,$.shadowRadius=oe.radius,$.shadowMapSize=oe.mapSize,$.shadowCameraNear=oe.camera.near,$.shadowCameraFar=oe.camera.far,i.pointShadow[b]=$,i.pointShadowMap[b]=K,i.pointShadowMatrix[b]=O.shadow.matrix,T++}i.point[b]=Y,b++}else if(O.isHemisphereLight){const Y=n.get(O);Y.skyColor.copy(O.color).multiplyScalar(V*k),Y.groundColor.copy(O.groundColor).multiplyScalar(V*k),i.hemi[w]=Y,w++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_FLOAT_1,i.rectAreaLTC2=bt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_HALF_1,i.rectAreaLTC2=bt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=y;const U=i.hash;(U.directionalLength!==v||U.pointLength!==b||U.spotLength!==x||U.rectAreaLength!==M||U.hemiLength!==w||U.numDirectionalShadows!==A||U.numPointShadows!==T||U.numSpotShadows!==R||U.numSpotMaps!==N||U.numLightProbes!==C)&&(i.directional.length=v,i.spot.length=x,i.rectArea.length=M,i.point.length=b,i.hemi.length=w,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=R,i.spotShadowMap.length=R,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=R+N-j,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=j,i.numLightProbes=C,U.directionalLength=v,U.pointLength=b,U.spotLength=x,U.rectAreaLength=M,U.hemiLength=w,U.numDirectionalShadows=A,U.numPointShadows=T,U.numSpotShadows=R,U.numSpotMaps=N,U.numLightProbes=C,i.version=Jye++)}function c(u,f){let g=0,m=0,y=0,v=0,b=0;const x=f.matrixWorldInverse;for(let M=0,w=u.length;M<w;M++){const A=u[M];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),g++}else if(A.isSpotLight){const T=i.spot[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),y++}else if(A.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(A.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),v++}else if(A.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),m++}else if(A.isHemisphereLight){const T=i.hemi[b];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(x),b++}}}return{setup:l,setupView:c,state:i}}function k5(t,e){const n=new t_e(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function o(f){i.push(f)}function l(f){n.setup(r,f)}function c(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function n_e(t,e){let n=new WeakMap;function r(a,s=0){const o=n.get(a);let l;return o===void 0?(l=new k5(t,e),n.set(a,[l])):s>=o.length?(l=new k5(t,e),o.push(l)):l=o[s],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class r_e extends Mm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Hge,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 i_e extends Mm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const a_e=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,s_e=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function o_e(t,e,n){let r=new uw;const i=new qt,a=new qt,s=new Gn,o=new r_e({depthPacking:$ge}),l=new i_e,c={},u=n.maxTextureSize,f={[Qu]:za,[za]:Qu,[Yl]:Yl},g=new Ju({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qt},radius:{value:4}},vertexShader:a_e,fragmentShader:s_e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const y=new oa;y.setAttribute("position",new hs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new _o(y,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=lW;let x=this.type;this.render=function(T,R,N){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||T.length===0)return;const j=t.getRenderTarget(),C=t.getActiveCubeFace(),k=t.getActiveMipmapLevel(),U=t.state;U.setBlending(Bu),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const I=x!==Gl&&this.type===Gl,H=x===Gl&&this.type!==Gl;for(let O=0,B=T.length;O<B;O++){const V=T[O],G=V.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",V,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const K=G.getFrameExtents();if(i.multiply(K),a.copy(G.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/K.x),i.x=a.x*K.x,G.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/K.y),i.y=a.y*K.y,G.mapSize.y=a.y)),G.map===null||I===!0||H===!0){const oe=this.type!==Gl?{minFilter:Hi,magFilter:Hi}:{};G.map!==null&&G.map.dispose(),G.map=new Pf(i.x,i.y,oe),G.map.texture.name=V.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const Y=G.getViewportCount();for(let oe=0;oe<Y;oe++){const $=G.getViewport(oe);s.set(a.x*$.x,a.y*$.y,a.x*$.z,a.y*$.w),U.viewport(s),G.updateMatrices(V,oe),r=G.getFrustum(),A(R,N,G.camera,V,this.type)}G.isPointLightShadow!==!0&&this.type===Gl&&M(G,N),G.needsUpdate=!1}x=this.type,b.needsUpdate=!1,t.setRenderTarget(j,C,k)};function M(T,R){const N=e.update(v);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Pf(i.x,i.y)),g.uniforms.shadow_pass.value=T.map.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(R,null,N,g,v,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(R,null,N,m,v,null)}function w(T,R,N,j){let C=null;const k=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(k!==void 0)C=k;else if(C=N.isPointLight===!0?l:o,t.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){const U=C.uuid,I=R.uuid;let H=c[U];H===void 0&&(H={},c[U]=H);let O=H[I];O===void 0&&(O=C.clone(),H[I]=O),C=O}if(C.visible=R.visible,C.wireframe=R.wireframe,j===Gl?C.side=R.shadowSide!==null?R.shadowSide:R.side:C.side=R.shadowSide!==null?R.shadowSide:f[R.side],C.alphaMap=R.alphaMap,C.alphaTest=R.alphaTest,C.map=R.map,C.clipShadows=R.clipShadows,C.clippingPlanes=R.clippingPlanes,C.clipIntersection=R.clipIntersection,C.displacementMap=R.displacementMap,C.displacementScale=R.displacementScale,C.displacementBias=R.displacementBias,C.wireframeLinewidth=R.wireframeLinewidth,C.linewidth=R.linewidth,N.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const U=t.properties.get(C);U.light=N}return C}function A(T,R,N,j,C){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&C===Gl)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const I=e.update(T),H=T.material;if(Array.isArray(H)){const O=I.groups;for(let B=0,V=O.length;B<V;B++){const G=O[B],K=H[G.materialIndex];if(K&&K.visible){const Y=w(T,K,j,C);T.onBeforeShadow(t,T,R,N,I,Y,G),t.renderBufferDirect(N,null,I,Y,T,G),T.onAfterShadow(t,T,R,N,I,Y,G)}}}else if(H.visible){const O=w(T,H,j,C);T.onBeforeShadow(t,T,R,N,I,O,null),t.renderBufferDirect(N,null,I,O,T,null),T.onAfterShadow(t,T,R,N,I,O,null)}}const U=T.children;for(let I=0,H=U.length;I<H;I++)A(U[I],R,N,j,C)}}function l_e(t,e,n){const r=n.isWebGL2;function i(){let fe=!1;const Le=new Gn;let Ee=null;const be=new Gn(0,0,0,0);return{setMask:function(He){Ee!==He&&!fe&&(t.colorMask(He,He,He,He),Ee=He)},setLocked:function(He){fe=He},setClear:function(He,ut,_t,Rt,ln){ln===!0&&(He*=Rt,ut*=Rt,_t*=Rt),Le.set(He,ut,_t,Rt),be.equals(Le)===!1&&(t.clearColor(He,ut,_t,Rt),be.copy(Le))},reset:function(){fe=!1,Ee=null,be.set(-1,0,0,0)}}}function a(){let fe=!1,Le=null,Ee=null,be=null;return{setTest:function(He){He?he(t.DEPTH_TEST):me(t.DEPTH_TEST)},setMask:function(He){Le!==He&&!fe&&(t.depthMask(He),Le=He)},setFunc:function(He){if(Ee!==He){switch(He){case bge:t.depthFunc(t.NEVER);break;case yge:t.depthFunc(t.ALWAYS);break;case _ge:t.depthFunc(t.LESS);break;case e1:t.depthFunc(t.LEQUAL);break;case Sge:t.depthFunc(t.EQUAL);break;case wge:t.depthFunc(t.GEQUAL);break;case Mge:t.depthFunc(t.GREATER);break;case Ege:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ee=He}},setLocked:function(He){fe=He},setClear:function(He){be!==He&&(t.clearDepth(He),be=He)},reset:function(){fe=!1,Le=null,Ee=null,be=null}}}function s(){let fe=!1,Le=null,Ee=null,be=null,He=null,ut=null,_t=null,Rt=null,ln=null;return{setTest:function(Dt){fe||(Dt?he(t.STENCIL_TEST):me(t.STENCIL_TEST))},setMask:function(Dt){Le!==Dt&&!fe&&(t.stencilMask(Dt),Le=Dt)},setFunc:function(Dt,Rn,qn){(Ee!==Dt||be!==Rn||He!==qn)&&(t.stencilFunc(Dt,Rn,qn),Ee=Dt,be=Rn,He=qn)},setOp:function(Dt,Rn,qn){(ut!==Dt||_t!==Rn||Rt!==qn)&&(t.stencilOp(Dt,Rn,qn),ut=Dt,_t=Rn,Rt=qn)},setLocked:function(Dt){fe=Dt},setClear:function(Dt){ln!==Dt&&(t.clearStencil(Dt),ln=Dt)},reset:function(){fe=!1,Le=null,Ee=null,be=null,He=null,ut=null,_t=null,Rt=null,ln=null}}}const o=new i,l=new a,c=new s,u=new WeakMap,f=new WeakMap;let g={},m={},y=new WeakMap,v=[],b=null,x=!1,M=null,w=null,A=null,T=null,R=null,N=null,j=null,C=new Bt(0,0,0),k=0,U=!1,I=null,H=null,O=null,B=null,V=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,Y=0;const oe=t.getParameter(t.VERSION);oe.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(oe)[1]),K=Y>=1):oe.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(oe)[1]),K=Y>=2);let $=null,X={};const ae=t.getParameter(t.SCISSOR_BOX),ce=t.getParameter(t.VIEWPORT),xe=new Gn().fromArray(ae),te=new Gn().fromArray(ce);function ve(fe,Le,Ee,be){const He=new Uint8Array(4),ut=t.createTexture();t.bindTexture(fe,ut),t.texParameteri(fe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(fe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let _t=0;_t<Ee;_t++)r&&(fe===t.TEXTURE_3D||fe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Le,0,t.RGBA,1,1,be,0,t.RGBA,t.UNSIGNED_BYTE,He):t.texImage2D(Le+_t,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,He);return ut}const De={};De[t.TEXTURE_2D]=ve(t.TEXTURE_2D,t.TEXTURE_2D,1),De[t.TEXTURE_CUBE_MAP]=ve(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(De[t.TEXTURE_2D_ARRAY]=ve(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),De[t.TEXTURE_3D]=ve(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),he(t.DEPTH_TEST),l.setFunc(e1),ee(!1),le(pz),he(t.CULL_FACE),ie(Bu);function he(fe){g[fe]!==!0&&(t.enable(fe),g[fe]=!0)}function me(fe){g[fe]!==!1&&(t.disable(fe),g[fe]=!1)}function we(fe,Le){return m[fe]!==Le?(t.bindFramebuffer(fe,Le),m[fe]=Le,r&&(fe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Le),fe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Le)),!0):!1}function se(fe,Le){let Ee=v,be=!1;if(fe)if(Ee=y.get(Le),Ee===void 0&&(Ee=[],y.set(Le,Ee)),fe.isWebGLMultipleRenderTargets){const He=fe.texture;if(Ee.length!==He.length||Ee[0]!==t.COLOR_ATTACHMENT0){for(let ut=0,_t=He.length;ut<_t;ut++)Ee[ut]=t.COLOR_ATTACHMENT0+ut;Ee.length=He.length,be=!0}}else Ee[0]!==t.COLOR_ATTACHMENT0&&(Ee[0]=t.COLOR_ATTACHMENT0,be=!0);else Ee[0]!==t.BACK&&(Ee[0]=t.BACK,be=!0);be&&(n.isWebGL2?t.drawBuffers(Ee):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ee))}function st(fe){return b!==fe?(t.useProgram(fe),b=fe,!0):!1}const z={[Yd]:t.FUNC_ADD,[ige]:t.FUNC_SUBTRACT,[age]:t.FUNC_REVERSE_SUBTRACT};if(r)z[vz]=t.MIN,z[bz]=t.MAX;else{const fe=e.get("EXT_blend_minmax");fe!==null&&(z[vz]=fe.MIN_EXT,z[bz]=fe.MAX_EXT)}const q={[sge]:t.ZERO,[oge]:t.ONE,[lge]:t.SRC_COLOR,[C3]:t.SRC_ALPHA,[pge]:t.SRC_ALPHA_SATURATE,[fge]:t.DST_COLOR,[uge]:t.DST_ALPHA,[cge]:t.ONE_MINUS_SRC_COLOR,[N3]:t.ONE_MINUS_SRC_ALPHA,[hge]:t.ONE_MINUS_DST_COLOR,[dge]:t.ONE_MINUS_DST_ALPHA,[mge]:t.CONSTANT_COLOR,[gge]:t.ONE_MINUS_CONSTANT_COLOR,[xge]:t.CONSTANT_ALPHA,[vge]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(fe,Le,Ee,be,He,ut,_t,Rt,ln,Dt){if(fe===Bu){x===!0&&(me(t.BLEND),x=!1);return}if(x===!1&&(he(t.BLEND),x=!0),fe!==rge){if(fe!==M||Dt!==U){if((w!==Yd||R!==Yd)&&(t.blendEquation(t.FUNC_ADD),w=Yd,R=Yd),Dt)switch(fe){case Dp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mz:t.blendFunc(t.ONE,t.ONE);break;case gz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case xz:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}else switch(fe){case Dp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mz:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case gz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case xz:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}A=null,T=null,N=null,j=null,C.set(0,0,0),k=0,M=fe,U=Dt}return}He=He||Le,ut=ut||Ee,_t=_t||be,(Le!==w||He!==R)&&(t.blendEquationSeparate(z[Le],z[He]),w=Le,R=He),(Ee!==A||be!==T||ut!==N||_t!==j)&&(t.blendFuncSeparate(q[Ee],q[be],q[ut],q[_t]),A=Ee,T=be,N=ut,j=_t),(Rt.equals(C)===!1||ln!==k)&&(t.blendColor(Rt.r,Rt.g,Rt.b,ln),C.copy(Rt),k=ln),M=fe,U=!1}function Q(fe,Le){fe.side===Yl?me(t.CULL_FACE):he(t.CULL_FACE);let Ee=fe.side===za;Le&&(Ee=!Ee),ee(Ee),fe.blending===Dp&&fe.transparent===!1?ie(Bu):ie(fe.blending,fe.blendEquation,fe.blendSrc,fe.blendDst,fe.blendEquationAlpha,fe.blendSrcAlpha,fe.blendDstAlpha,fe.blendColor,fe.blendAlpha,fe.premultipliedAlpha),l.setFunc(fe.depthFunc),l.setTest(fe.depthTest),l.setMask(fe.depthWrite),o.setMask(fe.colorWrite);const be=fe.stencilWrite;c.setTest(be),be&&(c.setMask(fe.stencilWriteMask),c.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),c.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),Pe(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):me(t.SAMPLE_ALPHA_TO_COVERAGE)}function ee(fe){I!==fe&&(fe?t.frontFace(t.CW):t.frontFace(t.CCW),I=fe)}function le(fe){fe!==ege?(he(t.CULL_FACE),fe!==H&&(fe===pz?t.cullFace(t.BACK):fe===tge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):me(t.CULL_FACE),H=fe}function Re(fe){fe!==O&&(K&&t.lineWidth(fe),O=fe)}function Pe(fe,Le,Ee){fe?(he(t.POLYGON_OFFSET_FILL),(B!==Le||V!==Ee)&&(t.polygonOffset(Le,Ee),B=Le,V=Ee)):me(t.POLYGON_OFFSET_FILL)}function ne(fe){fe?he(t.SCISSOR_TEST):me(t.SCISSOR_TEST)}function F(fe){fe===void 0&&(fe=t.TEXTURE0+G-1),$!==fe&&(t.activeTexture(fe),$=fe)}function L(fe,Le,Ee){Ee===void 0&&($===null?Ee=t.TEXTURE0+G-1:Ee=$);let be=X[Ee];be===void 0&&(be={type:void 0,texture:void 0},X[Ee]=be),(be.type!==fe||be.texture!==Le)&&($!==Ee&&(t.activeTexture(Ee),$=Ee),t.bindTexture(fe,Le||De[fe]),be.type=fe,be.texture=Le)}function Z(){const fe=X[$];fe!==void 0&&fe.type!==void 0&&(t.bindTexture(fe.type,null),fe.type=void 0,fe.texture=void 0)}function ge(){try{t.compressedTexImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ye(){try{t.compressedTexImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function pe(){try{t.texSubImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Ze(){try{t.texSubImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Ie(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Xe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ot(){try{t.texStorage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function je(){try{t.texStorage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ke(){try{t.texImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function pt(){try{t.texImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function rt(fe){xe.equals(fe)===!1&&(t.scissor(fe.x,fe.y,fe.z,fe.w),xe.copy(fe))}function nt(fe){te.equals(fe)===!1&&(t.viewport(fe.x,fe.y,fe.z,fe.w),te.copy(fe))}function dt(fe,Le){let Ee=f.get(Le);Ee===void 0&&(Ee=new WeakMap,f.set(Le,Ee));let be=Ee.get(fe);be===void 0&&(be=t.getUniformBlockIndex(Le,fe.name),Ee.set(fe,be))}function de(fe,Le){const be=f.get(Le).get(fe);u.get(Le)!==be&&(t.uniformBlockBinding(Le,be,fe.__bindingPointIndex),u.set(Le,be))}function it(){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),g={},$=null,X={},m={},y=new WeakMap,v=[],b=null,x=!1,M=null,w=null,A=null,T=null,R=null,N=null,j=null,C=new Bt(0,0,0),k=0,U=!1,I=null,H=null,O=null,B=null,V=null,xe.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:he,disable:me,bindFramebuffer:we,drawBuffers:se,useProgram:st,setBlending:ie,setMaterial:Q,setFlipSided:ee,setCullFace:le,setLineWidth:Re,setPolygonOffset:Pe,setScissorTest:ne,activeTexture:F,bindTexture:L,unbindTexture:Z,compressedTexImage2D:ge,compressedTexImage3D:ye,texImage2D:ke,texImage3D:pt,updateUBOMapping:dt,uniformBlockBinding:de,texStorage2D:ot,texStorage3D:je,texSubImage2D:pe,texSubImage3D:Ze,compressedTexSubImage2D:Ie,compressedTexSubImage3D:Xe,scissor:rt,viewport:nt,reset:it}}function c_e(t,e,n,r,i,a,s){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),y=new WeakMap;let v;const b=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(F,L){return x?new OffscreenCanvas(F,L):a1("canvas")}function w(F,L,Z,ge){let ye=1;if((F.width>ge||F.height>ge)&&(ye=ge/Math.max(F.width,F.height)),ye<1||L===!0)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap){const pe=L?i1:Math.floor,Ze=pe(ye*F.width),Ie=pe(ye*F.height);v===void 0&&(v=M(Ze,Ie));const Xe=Z?M(Ze,Ie):v;return Xe.width=Ze,Xe.height=Ie,Xe.getContext("2d").drawImage(F,0,0,Ze,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+F.width+"x"+F.height+") to ("+Ze+"x"+Ie+")."),Xe}else return"data"in F&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+F.width+"x"+F.height+")."),F;return F}function A(F){return I3(F.width)&&I3(F.height)}function T(F){return o?!1:F.wrapS!==mo||F.wrapT!==mo||F.minFilter!==Hi&&F.minFilter!==Fs}function R(F,L){return F.generateMipmaps&&L&&F.minFilter!==Hi&&F.minFilter!==Fs}function N(F){t.generateMipmap(F)}function j(F,L,Z,ge,ye=!1){if(o===!1)return L;if(F!==null){if(t[F]!==void 0)return t[F];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let pe=L;if(L===t.RED&&(Z===t.FLOAT&&(pe=t.R32F),Z===t.HALF_FLOAT&&(pe=t.R16F),Z===t.UNSIGNED_BYTE&&(pe=t.R8)),L===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(pe=t.R8UI),Z===t.UNSIGNED_SHORT&&(pe=t.R16UI),Z===t.UNSIGNED_INT&&(pe=t.R32UI),Z===t.BYTE&&(pe=t.R8I),Z===t.SHORT&&(pe=t.R16I),Z===t.INT&&(pe=t.R32I)),L===t.RG&&(Z===t.FLOAT&&(pe=t.RG32F),Z===t.HALF_FLOAT&&(pe=t.RG16F),Z===t.UNSIGNED_BYTE&&(pe=t.RG8)),L===t.RGBA){const Ze=ye?t1:$n.getTransfer(ge);Z===t.FLOAT&&(pe=t.RGBA32F),Z===t.HALF_FLOAT&&(pe=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(pe=Ze===rr?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(pe=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(pe=t.RGB5_A1)}return(pe===t.R16F||pe===t.R32F||pe===t.RG16F||pe===t.RG32F||pe===t.RGBA16F||pe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function C(F,L,Z){return R(F,Z)===!0||F.isFramebufferTexture&&F.minFilter!==Hi&&F.minFilter!==Fs?Math.log2(Math.max(L.width,L.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?L.mipmaps.length:1}function k(F){return F===Hi||F===yz||F===xT?t.NEAREST:t.LINEAR}function U(F){const L=F.target;L.removeEventListener("dispose",U),H(L),L.isVideoTexture&&y.delete(L)}function I(F){const L=F.target;L.removeEventListener("dispose",I),B(L)}function H(F){const L=r.get(F);if(L.__webglInit===void 0)return;const Z=F.source,ge=b.get(Z);if(ge){const ye=ge[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&O(F),Object.keys(ge).length===0&&b.delete(Z)}r.remove(F)}function O(F){const L=r.get(F);t.deleteTexture(L.__webglTexture);const Z=F.source,ge=b.get(Z);delete ge[L.__cacheKey],s.memory.textures--}function B(F){const L=F.texture,Z=r.get(F),ge=r.get(L);if(ge.__webglTexture!==void 0&&(t.deleteTexture(ge.__webglTexture),s.memory.textures--),F.depthTexture&&F.depthTexture.dispose(),F.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(Z.__webglFramebuffer[ye]))for(let pe=0;pe<Z.__webglFramebuffer[ye].length;pe++)t.deleteFramebuffer(Z.__webglFramebuffer[ye][pe]);else t.deleteFramebuffer(Z.__webglFramebuffer[ye]);Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer[ye])}else{if(Array.isArray(Z.__webglFramebuffer))for(let ye=0;ye<Z.__webglFramebuffer.length;ye++)t.deleteFramebuffer(Z.__webglFramebuffer[ye]);else t.deleteFramebuffer(Z.__webglFramebuffer);if(Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let ye=0;ye<Z.__webglColorRenderbuffer.length;ye++)Z.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(Z.__webglColorRenderbuffer[ye]);Z.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(F.isWebGLMultipleRenderTargets)for(let ye=0,pe=L.length;ye<pe;ye++){const Ze=r.get(L[ye]);Ze.__webglTexture&&(t.deleteTexture(Ze.__webglTexture),s.memory.textures--),r.remove(L[ye])}r.remove(L),r.remove(F)}let V=0;function G(){V=0}function K(){const F=V;return F>=l&&console.warn("THREE.WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+l),V+=1,F}function Y(F){const L=[];return L.push(F.wrapS),L.push(F.wrapT),L.push(F.wrapR||0),L.push(F.magFilter),L.push(F.minFilter),L.push(F.anisotropy),L.push(F.internalFormat),L.push(F.format),L.push(F.type),L.push(F.generateMipmaps),L.push(F.premultiplyAlpha),L.push(F.flipY),L.push(F.unpackAlignment),L.push(F.colorSpace),L.join()}function oe(F,L){const Z=r.get(F);if(F.isVideoTexture&&Pe(F),F.isRenderTargetTexture===!1&&F.version>0&&Z.__version!==F.version){const ge=F.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(Z,F,L);return}}n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+L)}function $(F,L){const Z=r.get(F);if(F.version>0&&Z.__version!==F.version){he(Z,F,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+L)}function X(F,L){const Z=r.get(F);if(F.version>0&&Z.__version!==F.version){he(Z,F,L);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+L)}function ae(F,L){const Z=r.get(F);if(F.version>0&&Z.__version!==F.version){me(Z,F,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+L)}const ce={[k3]:t.REPEAT,[mo]:t.CLAMP_TO_EDGE,[D3]:t.MIRRORED_REPEAT},xe={[Hi]:t.NEAREST,[yz]:t.NEAREST_MIPMAP_NEAREST,[xT]:t.NEAREST_MIPMAP_LINEAR,[Fs]:t.LINEAR,[Dge]:t.LINEAR_MIPMAP_NEAREST,[Qx]:t.LINEAR_MIPMAP_LINEAR},te={[Gge]:t.NEVER,[Zge]:t.ALWAYS,[Wge]:t.LESS,[bW]:t.LEQUAL,[qge]:t.EQUAL,[Yge]:t.GEQUAL,[Xge]:t.GREATER,[Kge]:t.NOTEQUAL};function ve(F,L,Z){if(Z?(t.texParameteri(F,t.TEXTURE_WRAP_S,ce[L.wrapS]),t.texParameteri(F,t.TEXTURE_WRAP_T,ce[L.wrapT]),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,ce[L.wrapR]),t.texParameteri(F,t.TEXTURE_MAG_FILTER,xe[L.magFilter]),t.texParameteri(F,t.TEXTURE_MIN_FILTER,xe[L.minFilter])):(t.texParameteri(F,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(F,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==mo||L.wrapT!==mo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(F,t.TEXTURE_MAG_FILTER,k(L.magFilter)),t.texParameteri(F,t.TEXTURE_MIN_FILTER,k(L.minFilter)),L.minFilter!==Hi&&L.minFilter!==Fs&&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(F,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(F,t.TEXTURE_COMPARE_FUNC,te[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ge=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Hi||L.minFilter!==xT&&L.minFilter!==Qx||L.type===nc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===Jx&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(F,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function De(F,L){let Z=!1;F.__webglInit===void 0&&(F.__webglInit=!0,L.addEventListener("dispose",U));const ge=L.source;let ye=b.get(ge);ye===void 0&&(ye={},b.set(ge,ye));const pe=Y(L);if(pe!==F.__cacheKey){ye[pe]===void 0&&(ye[pe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,Z=!0),ye[pe].usedTimes++;const Ze=ye[F.__cacheKey];Ze!==void 0&&(ye[F.__cacheKey].usedTimes--,Ze.usedTimes===0&&O(L)),F.__cacheKey=pe,F.__webglTexture=ye[pe].texture}return Z}function he(F,L,Z){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const ye=De(F,L),pe=L.source;n.bindTexture(ge,F.__webglTexture,t.TEXTURE0+Z);const Ze=r.get(pe);if(pe.version!==Ze.__version||ye===!0){n.activeTexture(t.TEXTURE0+Z);const Ie=$n.getPrimaries($n.workingColorSpace),Xe=L.colorSpace===Bs?null:$n.getPrimaries(L.colorSpace),ot=L.colorSpace===Bs||Ie===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,ot);const je=T(L)&&A(L.image)===!1;let ke=w(L.image,je,!1,u);ke=ne(L,ke);const pt=A(ke)||o,rt=a.convert(L.format,L.colorSpace);let nt=a.convert(L.type),dt=j(L.internalFormat,rt,nt,L.colorSpace,L.isVideoTexture);ve(ge,L,pt);let de;const it=L.mipmaps,fe=o&&L.isVideoTexture!==!0&&dt!==gW,Le=Ze.__version===void 0||ye===!0,Ee=C(L,ke,pt);if(L.isDepthTexture)dt=t.DEPTH_COMPONENT,o?L.type===nc?dt=t.DEPTH_COMPONENT32F:L.type===Ou?dt=t.DEPTH_COMPONENT24:L.type===uf?dt=t.DEPTH24_STENCIL8:dt=t.DEPTH_COMPONENT16:L.type===nc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===df&&dt===t.DEPTH_COMPONENT&&L.type!==uk&&L.type!==Ou&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Ou,nt=a.convert(L.type)),L.format===Jp&&dt===t.DEPTH_COMPONENT&&(dt=t.DEPTH_STENCIL,L.type!==uf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=uf,nt=a.convert(L.type))),Le&&(fe?n.texStorage2D(t.TEXTURE_2D,1,dt,ke.width,ke.height):n.texImage2D(t.TEXTURE_2D,0,dt,ke.width,ke.height,0,rt,nt,null));else if(L.isDataTexture)if(it.length>0&&pt){fe&&Le&&n.texStorage2D(t.TEXTURE_2D,Ee,dt,it[0].width,it[0].height);for(let be=0,He=it.length;be<He;be++)de=it[be],fe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,de.width,de.height,rt,nt,de.data):n.texImage2D(t.TEXTURE_2D,be,dt,de.width,de.height,0,rt,nt,de.data);L.generateMipmaps=!1}else fe?(Le&&n.texStorage2D(t.TEXTURE_2D,Ee,dt,ke.width,ke.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ke.width,ke.height,rt,nt,ke.data)):n.texImage2D(t.TEXTURE_2D,0,dt,ke.width,ke.height,0,rt,nt,ke.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){fe&&Le&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ee,dt,it[0].width,it[0].height,ke.depth);for(let be=0,He=it.length;be<He;be++)de=it[be],L.format!==zs?rt!==null?fe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,de.width,de.height,ke.depth,rt,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,be,dt,de.width,de.height,ke.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):fe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,de.width,de.height,ke.depth,rt,nt,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,be,dt,de.width,de.height,ke.depth,0,rt,nt,de.data)}else{fe&&Le&&n.texStorage2D(t.TEXTURE_2D,Ee,dt,it[0].width,it[0].height);for(let be=0,He=it.length;be<He;be++)de=it[be],L.format!==zs?rt!==null?fe?n.compressedTexSubImage2D(t.TEXTURE_2D,be,0,0,de.width,de.height,rt,de.data):n.compressedTexImage2D(t.TEXTURE_2D,be,dt,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):fe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,de.width,de.height,rt,nt,de.data):n.texImage2D(t.TEXTURE_2D,be,dt,de.width,de.height,0,rt,nt,de.data)}else if(L.isDataArrayTexture)fe?(Le&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ee,dt,ke.width,ke.height,ke.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ke.width,ke.height,ke.depth,rt,nt,ke.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,dt,ke.width,ke.height,ke.depth,0,rt,nt,ke.data);else if(L.isData3DTexture)fe?(Le&&n.texStorage3D(t.TEXTURE_3D,Ee,dt,ke.width,ke.height,ke.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ke.width,ke.height,ke.depth,rt,nt,ke.data)):n.texImage3D(t.TEXTURE_3D,0,dt,ke.width,ke.height,ke.depth,0,rt,nt,ke.data);else if(L.isFramebufferTexture){if(Le)if(fe)n.texStorage2D(t.TEXTURE_2D,Ee,dt,ke.width,ke.height);else{let be=ke.width,He=ke.height;for(let ut=0;ut<Ee;ut++)n.texImage2D(t.TEXTURE_2D,ut,dt,be,He,0,rt,nt,null),be>>=1,He>>=1}}else if(it.length>0&&pt){fe&&Le&&n.texStorage2D(t.TEXTURE_2D,Ee,dt,it[0].width,it[0].height);for(let be=0,He=it.length;be<He;be++)de=it[be],fe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,rt,nt,de):n.texImage2D(t.TEXTURE_2D,be,dt,rt,nt,de);L.generateMipmaps=!1}else fe?(Le&&n.texStorage2D(t.TEXTURE_2D,Ee,dt,ke.width,ke.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,rt,nt,ke)):n.texImage2D(t.TEXTURE_2D,0,dt,rt,nt,ke);R(L,pt)&&N(ge),Ze.__version=pe.version,L.onUpdate&&L.onUpdate(L)}F.__version=L.version}function me(F,L,Z){if(L.image.length!==6)return;const ge=De(F,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,F.__webglTexture,t.TEXTURE0+Z);const pe=r.get(ye);if(ye.version!==pe.__version||ge===!0){n.activeTexture(t.TEXTURE0+Z);const Ze=$n.getPrimaries($n.workingColorSpace),Ie=L.colorSpace===Bs?null:$n.getPrimaries(L.colorSpace),Xe=L.colorSpace===Bs||Ze===Ie?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 ot=L.isCompressedTexture||L.image[0].isCompressedTexture,je=L.image[0]&&L.image[0].isDataTexture,ke=[];for(let be=0;be<6;be++)!ot&&!je?ke[be]=w(L.image[be],!1,!0,c):ke[be]=je?L.image[be].image:L.image[be],ke[be]=ne(L,ke[be]);const pt=ke[0],rt=A(pt)||o,nt=a.convert(L.format,L.colorSpace),dt=a.convert(L.type),de=j(L.internalFormat,nt,dt,L.colorSpace),it=o&&L.isVideoTexture!==!0,fe=pe.__version===void 0||ge===!0;let Le=C(L,pt,rt);ve(t.TEXTURE_CUBE_MAP,L,rt);let Ee;if(ot){it&&fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Le,de,pt.width,pt.height);for(let be=0;be<6;be++){Ee=ke[be].mipmaps;for(let He=0;He<Ee.length;He++){const ut=Ee[He];L.format!==zs?nt!==null?it?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,0,0,ut.width,ut.height,nt,ut.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,de,ut.width,ut.height,0,ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,0,0,ut.width,ut.height,nt,dt,ut.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He,de,ut.width,ut.height,0,nt,dt,ut.data)}}}else{Ee=L.mipmaps,it&&fe&&(Ee.length>0&&Le++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Le,de,ke[0].width,ke[0].height));for(let be=0;be<6;be++)if(je){it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,ke[be].width,ke[be].height,nt,dt,ke[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,de,ke[be].width,ke[be].height,0,nt,dt,ke[be].data);for(let He=0;He<Ee.length;He++){const _t=Ee[He].image[be].image;it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,0,0,_t.width,_t.height,nt,dt,_t.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,de,_t.width,_t.height,0,nt,dt,_t.data)}}else{it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,nt,dt,ke[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,de,nt,dt,ke[be]);for(let He=0;He<Ee.length;He++){const ut=Ee[He];it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,0,0,nt,dt,ut.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,He+1,de,nt,dt,ut.image[be])}}}R(L,rt)&&N(t.TEXTURE_CUBE_MAP),pe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}F.__version=L.version}function we(F,L,Z,ge,ye,pe){const Ze=a.convert(Z.format,Z.colorSpace),Ie=a.convert(Z.type),Xe=j(Z.internalFormat,Ze,Ie,Z.colorSpace);if(!r.get(L).__hasExternalTextures){const je=Math.max(1,L.width>>pe),ke=Math.max(1,L.height>>pe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,pe,Xe,je,ke,L.depth,0,Ze,Ie,null):n.texImage2D(ye,pe,Xe,je,ke,0,Ze,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,F),Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,ye,r.get(Z).__webglTexture,0,le(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,ye,r.get(Z).__webglTexture,pe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function se(F,L,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,F),L.depthBuffer&&!L.stencilBuffer){let ge=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Z||Re(L)){const ye=L.depthTexture;ye&&ye.isDepthTexture&&(ye.type===nc?ge=t.DEPTH_COMPONENT32F:ye.type===Ou&&(ge=t.DEPTH_COMPONENT24));const pe=le(L);Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,pe,ge,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,pe,ge,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,F)}else if(L.depthBuffer&&L.stencilBuffer){const ge=le(L);Z&&Re(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,L.width,L.height):Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,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,F)}else{const ge=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ye=0;ye<ge.length;ye++){const pe=ge[ye],Ze=a.convert(pe.format,pe.colorSpace),Ie=a.convert(pe.type),Xe=j(pe.internalFormat,Ze,Ie,pe.colorSpace),ot=le(L);Z&&Re(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,Xe,L.width,L.height):Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ot,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function st(F,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,F),!(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),oe(L.depthTexture,0);const ge=r.get(L.depthTexture).__webglTexture,ye=le(L);if(L.depthTexture.format===df)Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0);else if(L.depthTexture.format===Jp)Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0);else throw new Error("Unknown depthTexture format")}function z(F){const L=r.get(F),Z=F.isWebGLCubeRenderTarget===!0;if(F.depthTexture&&!L.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");st(L.__webglFramebuffer,F)}else if(Z){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]=t.createRenderbuffer(),se(L.__webglDepthbuffer[ge],F,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),se(L.__webglDepthbuffer,F,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function q(F,L,Z){const ge=r.get(F);L!==void 0&&we(ge.__webglFramebuffer,F,F.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&z(F)}function ie(F){const L=F.texture,Z=r.get(F),ge=r.get(L);F.addEventListener("dispose",I),F.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,s.memory.textures++);const ye=F.isWebGLCubeRenderTarget===!0,pe=F.isWebGLMultipleRenderTargets===!0,Ze=A(F)||o;if(ye){Z.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer[Ie]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Z.__webglFramebuffer[Ie][Xe]=t.createFramebuffer()}else Z.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)Z.__webglFramebuffer[Ie]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if(pe)if(i.drawBuffers){const Ie=F.texture;for(let Xe=0,ot=Ie.length;Xe<ot;Xe++){const je=r.get(Ie[Xe]);je.__webglTexture===void 0&&(je.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&F.samples>0&&Re(F)===!1){const Ie=pe?L:[L];Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Xe=0;Xe<Ie.length;Xe++){const ot=Ie[Xe];Z.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[Xe]);const je=a.convert(ot.format,ot.colorSpace),ke=a.convert(ot.type),pt=j(ot.internalFormat,je,ke,ot.colorSpace,F.isXRRenderTarget===!0),rt=le(F);t.renderbufferStorageMultisample(t.RENDERBUFFER,rt,pt,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,Z.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),F.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),se(Z.__webglDepthRenderbuffer,F,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),ve(t.TEXTURE_CUBE_MAP,L,Ze);for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)we(Z.__webglFramebuffer[Ie][Xe],F,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Xe);else we(Z.__webglFramebuffer[Ie],F,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);R(L,Ze)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(pe){const Ie=F.texture;for(let Xe=0,ot=Ie.length;Xe<ot;Xe++){const je=Ie[Xe],ke=r.get(je);n.bindTexture(t.TEXTURE_2D,ke.__webglTexture),ve(t.TEXTURE_2D,je,Ze),we(Z.__webglFramebuffer,F,je,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),R(je,Ze)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(o?Ie=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ie,ge.__webglTexture),ve(Ie,L,Ze),o&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)we(Z.__webglFramebuffer[Xe],F,L,t.COLOR_ATTACHMENT0,Ie,Xe);else we(Z.__webglFramebuffer,F,L,t.COLOR_ATTACHMENT0,Ie,0);R(L,Ze)&&N(Ie),n.unbindTexture()}F.depthBuffer&&z(F)}function Q(F){const L=A(F)||o,Z=F.isWebGLMultipleRenderTargets===!0?F.texture:[F.texture];for(let ge=0,ye=Z.length;ge<ye;ge++){const pe=Z[ge];if(R(pe,L)){const Ze=F.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ie=r.get(pe).__webglTexture;n.bindTexture(Ze,Ie),N(Ze),n.unbindTexture()}}}function ee(F){if(o&&F.samples>0&&Re(F)===!1){const L=F.isWebGLMultipleRenderTargets?F.texture:[F.texture],Z=F.width,ge=F.height;let ye=t.COLOR_BUFFER_BIT;const pe=[],Ze=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=r.get(F),Xe=F.isWebGLMultipleRenderTargets===!0;if(Xe)for(let ot=0;ot<L.length;ot++)n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let ot=0;ot<L.length;ot++){pe.push(t.COLOR_ATTACHMENT0+ot),F.depthBuffer&&pe.push(Ze);const je=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(je===!1&&(F.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),F.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[ot]),je===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ze]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ze])),Xe){const ke=r.get(L[ot]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ke,0)}t.blitFramebuffer(0,0,Z,ge,0,0,Z,ge,ye,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,pe)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let ot=0;ot<L.length;ot++){n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[ot]);const je=r.get(L[ot]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function le(F){return Math.min(f,F.samples)}function Re(F){const L=r.get(F);return o&&F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Pe(F){const L=s.render.frame;y.get(F)!==L&&(y.set(F,L),F.update())}function ne(F,L){const Z=F.colorSpace,ge=F.format,ye=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||F.format===L3||Z!==xc&&Z!==Bs&&($n.getTransfer(Z)===rr?o===!1?e.has("EXT_sRGB")===!0&&ge===zs?(F.format=L3,F.minFilter=Fs,F.generateMipmaps=!1):L=SW.sRGBToLinear(L):(ge!==zs||ye!==$u)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),L}this.allocateTextureUnit=K,this.resetTextureUnits=G,this.setTexture2D=oe,this.setTexture2DArray=$,this.setTexture3D=X,this.setTextureCube=ae,this.rebindTextures=q,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=we,this.useMultisampledRTT=Re}function u_e(t,e,n){const r=n.isWebGL2;function i(a,s=Bs){let o;const l=$n.getTransfer(s);if(a===$u)return t.UNSIGNED_BYTE;if(a===dW)return t.UNSIGNED_SHORT_4_4_4_4;if(a===fW)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Oge)return t.BYTE;if(a===Lge)return t.SHORT;if(a===uk)return t.UNSIGNED_SHORT;if(a===uW)return t.INT;if(a===Ou)return t.UNSIGNED_INT;if(a===nc)return t.FLOAT;if(a===Jx)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===Ige)return t.ALPHA;if(a===zs)return t.RGBA;if(a===jge)return t.LUMINANCE;if(a===Uge)return t.LUMINANCE_ALPHA;if(a===df)return t.DEPTH_COMPONENT;if(a===Jp)return t.DEPTH_STENCIL;if(a===L3)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===Fge)return t.RED;if(a===hW)return t.RED_INTEGER;if(a===zge)return t.RG;if(a===pW)return t.RG_INTEGER;if(a===mW)return t.RGBA_INTEGER;if(a===vT||a===bT||a===yT||a===_T)if(l===rr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===vT)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===bT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===yT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===_T)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===vT)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===bT)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===yT)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===_T)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===_z||a===Sz||a===wz||a===Mz)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===_z)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Sz)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===wz)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Mz)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===gW)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===Ez||a===Az)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===Ez)return l===rr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===Az)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Tz||a===Cz||a===Nz||a===Rz||a===Pz||a===kz||a===Dz||a===Oz||a===Lz||a===Iz||a===jz||a===Uz||a===Fz||a===zz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===Tz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Cz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Nz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Rz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Pz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===kz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Dz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Oz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Lz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===Iz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===jz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Uz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Fz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===zz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===ST||a===Bz||a===Hz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===ST)return l===rr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===Bz)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===Hz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===Bge||a===$z||a===Vz||a===Gz)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===ST)return o.COMPRESSED_RED_RGTC1_EXT;if(a===$z)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Vz)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===Gz)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===uf?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class d_e extends ls{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class lx extends va{constructor(){super(),this.isGroup=!0,this.type="Group"}}const f_e={type:"move"};class GT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new lx,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 lx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Te,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Te),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new lx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Te,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Te),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const 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,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const v of e.hand.values()){const b=n.getJointPose(v,r),x=this._getHandJoint(c,v);b!==null&&(x.matrix.fromArray(b.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=b.radius),x.visible=b!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],g=u.position.distanceTo(f.position),m=.02,y=.005;c.inputState.pinching&&g>m+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-y&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(f_e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new lx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class h_e extends Xf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,f=null,g=null,m=null,y=null;const v=n.getContextAttributes();let b=null,x=null;const M=[],w=[],A=new qt;let T=null;const R=new ls;R.layers.enable(1),R.viewport=new Gn;const N=new ls;N.layers.enable(2),N.viewport=new Gn;const j=[R,N],C=new d_e;C.layers.enable(1),C.layers.enable(2);let k=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let ce=M[ae];return ce===void 0&&(ce=new GT,M[ae]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(ae){let ce=M[ae];return ce===void 0&&(ce=new GT,M[ae]=ce),ce.getGripSpace()},this.getHand=function(ae){let ce=M[ae];return ce===void 0&&(ce=new GT,M[ae]=ce),ce.getHandSpace()};function I(ae){const ce=w.indexOf(ae.inputSource);if(ce===-1)return;const xe=M[ce];xe!==void 0&&(xe.update(ae.inputSource,ae.frame,c||s),xe.dispatchEvent({type:ae.type,data:ae.inputSource}))}function H(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",O);for(let ae=0;ae<M.length;ae++){const ce=w[ae];ce!==null&&(w[ae]=null,M[ae].disconnect(ce))}k=null,U=null,e.setRenderTarget(b),m=null,g=null,f=null,i=null,x=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){a=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){o=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(ae){c=ae},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f},this.getFrame=function(){return y},this.getSession=function(){return i},this.setSession=async function(ae){if(i=ae,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",H),i.addEventListener("inputsourceschange",O),v.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ce={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,ce),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new Pf(m.framebufferWidth,m.framebufferHeight,{format:zs,type:$u,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ce=null,xe=null,te=null;v.depth&&(te=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ce=v.stencil?Jp:df,xe=v.stencil?uf:Ou);const ve={colorFormat:n.RGBA8,depthFormat:te,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(ve),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),x=new Pf(g.textureWidth,g.textureHeight,{format:zs,type:$u,depthTexture:new OW(g.textureWidth,g.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ce),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const De=e.properties.get(x);De.__ignoreDepthValues=g.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await i.requestReferenceSpace(o),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function O(ae){for(let ce=0;ce<ae.removed.length;ce++){const xe=ae.removed[ce],te=w.indexOf(xe);te>=0&&(w[te]=null,M[te].disconnect(xe))}for(let ce=0;ce<ae.added.length;ce++){const xe=ae.added[ce];let te=w.indexOf(xe);if(te===-1){for(let De=0;De<M.length;De++)if(De>=w.length){w.push(xe),te=De;break}else if(w[De]===null){w[De]=xe,te=De;break}if(te===-1)break}const ve=M[te];ve&&ve.connect(xe)}}const B=new Te,V=new Te;function G(ae,ce,xe){B.setFromMatrixPosition(ce.matrixWorld),V.setFromMatrixPosition(xe.matrixWorld);const te=B.distanceTo(V),ve=ce.projectionMatrix.elements,De=xe.projectionMatrix.elements,he=ve[14]/(ve[10]-1),me=ve[14]/(ve[10]+1),we=(ve[9]+1)/ve[5],se=(ve[9]-1)/ve[5],st=(ve[8]-1)/ve[0],z=(De[8]+1)/De[0],q=he*st,ie=he*z,Q=te/(-st+z),ee=Q*-st;ce.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(ee),ae.translateZ(Q),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert();const le=he+Q,Re=me+Q,Pe=q-ee,ne=ie+(te-ee),F=we*me/Re*le,L=se*me/Re*le;ae.projectionMatrix.makePerspective(Pe,ne,F,L,le,Re),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}function K(ae,ce){ce===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(ce.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(i===null)return;C.near=N.near=R.near=ae.near,C.far=N.far=R.far=ae.far,(k!==C.near||U!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),k=C.near,U=C.far);const ce=ae.parent,xe=C.cameras;K(C,ce);for(let te=0;te<xe.length;te++)K(xe[te],ce);xe.length===2?G(C,R,N):C.projectionMatrix.copy(R.projectionMatrix),Y(ae,C,ce)};function Y(ae,ce,xe){xe===null?ae.matrix.copy(ce.matrixWorld):(ae.matrix.copy(xe.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(ce.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(ce.projectionMatrix),ae.projectionMatrixInverse.copy(ce.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=t0*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ae){l=ae,g!==null&&(g.fixedFoveation=ae),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ae)};let oe=null;function $(ae,ce){if(u=ce.getViewerPose(c||s),y=ce,u!==null){const xe=u.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let te=!1;xe.length!==C.cameras.length&&(C.cameras.length=0,te=!0);for(let ve=0;ve<xe.length;ve++){const De=xe[ve];let he=null;if(m!==null)he=m.getViewport(De);else{const we=f.getViewSubImage(g,De);he=we.viewport,ve===0&&(e.setRenderTargetTextures(x,we.colorTexture,g.ignoreDepthValues?void 0:we.depthStencilTexture),e.setRenderTarget(x))}let me=j[ve];me===void 0&&(me=new ls,me.layers.enable(ve),me.viewport=new Gn,j[ve]=me),me.matrix.fromArray(De.transform.matrix),me.matrix.decompose(me.position,me.quaternion,me.scale),me.projectionMatrix.fromArray(De.projectionMatrix),me.projectionMatrixInverse.copy(me.projectionMatrix).invert(),me.viewport.set(he.x,he.y,he.width,he.height),ve===0&&(C.matrix.copy(me.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),te===!0&&C.cameras.push(me)}}for(let xe=0;xe<M.length;xe++){const te=w[xe],ve=M[xe];te!==null&&ve!==void 0&&ve.update(te,ce,c||s)}oe&&oe(ae,ce),ce.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ce}),y=null}const X=new DW;X.setAnimationLoop($),this.setAnimationLoop=function(ae){oe=ae},this.dispose=function(){}}}function p_e(t,e){function n(b,x){b.matrixAutoUpdate===!0&&b.updateMatrix(),x.value.copy(b.matrix)}function r(b,x){x.color.getRGB(b.fogColor.value,RW(t)),x.isFog?(b.fogNear.value=x.near,b.fogFar.value=x.far):x.isFogExp2&&(b.fogDensity.value=x.density)}function i(b,x,M,w,A){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(b,x):x.isMeshToonMaterial?(a(b,x),f(b,x)):x.isMeshPhongMaterial?(a(b,x),u(b,x)):x.isMeshStandardMaterial?(a(b,x),g(b,x),x.isMeshPhysicalMaterial&&m(b,x,A)):x.isMeshMatcapMaterial?(a(b,x),y(b,x)):x.isMeshDepthMaterial?a(b,x):x.isMeshDistanceMaterial?(a(b,x),v(b,x)):x.isMeshNormalMaterial?a(b,x):x.isLineBasicMaterial?(s(b,x),x.isLineDashedMaterial&&o(b,x)):x.isPointsMaterial?l(b,x,M,w):x.isSpriteMaterial?c(b,x):x.isShadowMaterial?(b.color.value.copy(x.color),b.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(b,x){b.opacity.value=x.opacity,x.color&&b.diffuse.value.copy(x.color),x.emissive&&b.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(b.map.value=x.map,n(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.bumpMap&&(b.bumpMap.value=x.bumpMap,n(x.bumpMap,b.bumpMapTransform),b.bumpScale.value=x.bumpScale,x.side===za&&(b.bumpScale.value*=-1)),x.normalMap&&(b.normalMap.value=x.normalMap,n(x.normalMap,b.normalMapTransform),b.normalScale.value.copy(x.normalScale),x.side===za&&b.normalScale.value.negate()),x.displacementMap&&(b.displacementMap.value=x.displacementMap,n(x.displacementMap,b.displacementMapTransform),b.displacementScale.value=x.displacementScale,b.displacementBias.value=x.displacementBias),x.emissiveMap&&(b.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,b.emissiveMapTransform)),x.specularMap&&(b.specularMap.value=x.specularMap,n(x.specularMap,b.specularMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest);const M=e.get(x).envMap;if(M&&(b.envMap.value=M,b.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=x.reflectivity,b.ior.value=x.ior,b.refractionRatio.value=x.refractionRatio),x.lightMap){b.lightMap.value=x.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=x.lightMapIntensity*w,n(x.lightMap,b.lightMapTransform)}x.aoMap&&(b.aoMap.value=x.aoMap,b.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,b.aoMapTransform))}function s(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,x.map&&(b.map.value=x.map,n(x.map,b.mapTransform))}function o(b,x){b.dashSize.value=x.dashSize,b.totalSize.value=x.dashSize+x.gapSize,b.scale.value=x.scale}function l(b,x,M,w){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.size.value=x.size*M,b.scale.value=w*.5,x.map&&(b.map.value=x.map,n(x.map,b.uvTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function c(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.rotation.value=x.rotation,x.map&&(b.map.value=x.map,n(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,n(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function u(b,x){b.specular.value.copy(x.specular),b.shininess.value=Math.max(x.shininess,1e-4)}function f(b,x){x.gradientMap&&(b.gradientMap.value=x.gradientMap)}function g(b,x){b.metalness.value=x.metalness,x.metalnessMap&&(b.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,b.metalnessMapTransform)),b.roughness.value=x.roughness,x.roughnessMap&&(b.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,b.roughnessMapTransform)),e.get(x).envMap&&(b.envMapIntensity.value=x.envMapIntensity)}function m(b,x,M){b.ior.value=x.ior,x.sheen>0&&(b.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),b.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(b.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,b.sheenColorMapTransform)),x.sheenRoughnessMap&&(b.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,b.sheenRoughnessMapTransform))),x.clearcoat>0&&(b.clearcoat.value=x.clearcoat,b.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(b.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,b.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(b.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===za&&b.clearcoatNormalScale.value.negate())),x.iridescence>0&&(b.iridescence.value=x.iridescence,b.iridescenceIOR.value=x.iridescenceIOR,b.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(b.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,b.iridescenceMapTransform)),x.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),x.transmission>0&&(b.transmission.value=x.transmission,b.transmissionSamplerMap.value=M.texture,b.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(b.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,b.transmissionMapTransform)),b.thickness.value=x.thickness,x.thicknessMap&&(b.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=x.attenuationDistance,b.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(b.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(b.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=x.specularIntensity,b.specularColor.value.copy(x.specularColor),x.specularColorMap&&(b.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,b.specularColorMapTransform)),x.specularIntensityMap&&(b.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,b.specularIntensityMapTransform))}function y(b,x){x.matcap&&(b.matcap.value=x.matcap)}function v(b,x){const M=e.get(x).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function m_e(t,e,n,r){let i={},a={},s=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(M,w){const A=w.program;r.uniformBlockBinding(M,A)}function c(M,w){let A=i[M.id];A===void 0&&(y(M),A=u(M),i[M.id]=A,M.addEventListener("dispose",b));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;a[M.id]!==R&&(g(M),a[M.id]=R)}function u(M){const w=f();M.__bindingPointIndex=w;const A=t.createBuffer(),T=M.__size,R=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,R),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let R=0,N=A.length;R<N;R++){const j=A[R];if(m(j,R,T)===!0){const C=j.__offset,k=Array.isArray(j.value)?j.value:[j.value];let U=0;for(let I=0;I<k.length;I++){const H=k[I],O=v(H);typeof H=="number"?(j.__data[0]=H,t.bufferSubData(t.UNIFORM_BUFFER,C+U,j.__data)):H.isMatrix3?(j.__data[0]=H.elements[0],j.__data[1]=H.elements[1],j.__data[2]=H.elements[2],j.__data[3]=H.elements[0],j.__data[4]=H.elements[3],j.__data[5]=H.elements[4],j.__data[6]=H.elements[5],j.__data[7]=H.elements[0],j.__data[8]=H.elements[6],j.__data[9]=H.elements[7],j.__data[10]=H.elements[8],j.__data[11]=H.elements[0]):(H.toArray(j.__data,U),U+=O.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,j.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,A){const T=M.value;if(A[w]===void 0){if(typeof T=="number")A[w]=T;else{const R=Array.isArray(T)?T:[T],N=[];for(let j=0;j<R.length;j++)N.push(R[j].clone());A[w]=N}return!0}else if(typeof T=="number"){if(A[w]!==T)return A[w]=T,!0}else{const R=Array.isArray(A[w])?A[w]:[A[w]],N=Array.isArray(T)?T:[T];for(let j=0;j<R.length;j++){const C=R[j];if(C.equals(N[j])===!1)return C.copy(N[j]),!0}}return!1}function y(M){const w=M.uniforms;let A=0;const T=16;let R=0;for(let N=0,j=w.length;N<j;N++){const C=w[N],k={boundary:0,storage:0},U=Array.isArray(C.value)?C.value:[C.value];for(let I=0,H=U.length;I<H;I++){const O=U[I],B=v(O);k.boundary+=B.boundary,k.storage+=B.storage}if(C.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=A,N>0){R=A%T;const I=T-R;R!==0&&I-k.boundary<0&&(A+=T-R,C.__offset=A)}A+=k.storage}return R=A%T,R>0&&(A+=T-R),M.__size=A,M.__cache={},this}function v(M){const w={boundary:0,storage:0};return typeof M=="number"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),w}function b(M){const w=M.target;w.removeEventListener("dispose",b);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:l,update:c,dispose:x}}class U3{constructor(e={}){const{canvas:n=fxe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const m=new Uint32Array(4),y=new Int32Array(4);let v=null,b=null;const x=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=$i,this._useLegacyLights=!1,this.toneMapping=Hu,this.toneMappingExposure=1;const w=this;let A=!1,T=0,R=0,N=null,j=-1,C=null;const k=new Gn,U=new Gn;let I=null;const H=new Bt(0);let O=0,B=n.width,V=n.height,G=1,K=null,Y=null;const oe=new Gn(0,0,B,V),$=new Gn(0,0,B,V);let X=!1;const ae=new uw;let ce=!1,xe=!1,te=null;const ve=new Jn,De=new qt,he=new Te,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function we(){return N===null?G:1}let se=r;function st(ue,Ue){for(let qe=0;qe<ue.length;qe++){const Ke=ue[qe],We=n.getContext(Ke,Ue);if(We!==null)return We}return null}try{const ue={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${ow}`),n.addEventListener("webglcontextlost",it,!1),n.addEventListener("webglcontextrestored",fe,!1),n.addEventListener("webglcontextcreationerror",Le,!1),se===null){const Ue=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ue.shift(),se=st(Ue,ue),se===null)throw st(Ue)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&se instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),se.getShaderPrecisionFormat===void 0&&(se.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ue){throw console.error("THREE.WebGLRenderer: "+ue.message),ue}let z,q,ie,Q,ee,le,Re,Pe,ne,F,L,Z,ge,ye,pe,Ze,Ie,Xe,ot,je,ke,pt,rt,nt;function dt(){z=new Abe(se),q=new bbe(se,z,e),z.init(q),pt=new u_e(se,z,q),ie=new l_e(se,z,q),Q=new Nbe(se),ee=new Xye,le=new c_e(se,z,ie,ee,q,pt,Q),Re=new _be(w),Pe=new Ebe(w),ne=new Ixe(se,q),rt=new xbe(se,z,ne,q),F=new Tbe(se,ne,Q,rt),L=new Dbe(se,F,ne,Q),ot=new kbe(se,q,le),Ze=new ybe(ee),Z=new qye(w,Re,Pe,z,q,rt,Ze),ge=new p_e(w,ee),ye=new Yye,pe=new n_e(z,q),Xe=new gbe(w,Re,Pe,ie,L,g,l),Ie=new o_e(w,L,q),nt=new m_e(se,Q,q,ie),je=new vbe(se,z,Q,q),ke=new Cbe(se,z,Q,q),Q.programs=Z.programs,w.capabilities=q,w.extensions=z,w.properties=ee,w.renderLists=ye,w.shadowMap=Ie,w.state=ie,w.info=Q}dt();const de=new h_e(w,se);this.xr=de,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){const ue=z.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=z.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(ue){ue!==void 0&&(G=ue,this.setSize(B,V,!1))},this.getSize=function(ue){return ue.set(B,V)},this.setSize=function(ue,Ue,qe=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=ue,V=Ue,n.width=Math.floor(ue*G),n.height=Math.floor(Ue*G),qe===!0&&(n.style.width=ue+"px",n.style.height=Ue+"px"),this.setViewport(0,0,ue,Ue)},this.getDrawingBufferSize=function(ue){return ue.set(B*G,V*G).floor()},this.setDrawingBufferSize=function(ue,Ue,qe){B=ue,V=Ue,G=qe,n.width=Math.floor(ue*qe),n.height=Math.floor(Ue*qe),this.setViewport(0,0,ue,Ue)},this.getCurrentViewport=function(ue){return ue.copy(k)},this.getViewport=function(ue){return ue.copy(oe)},this.setViewport=function(ue,Ue,qe,Ke){ue.isVector4?oe.set(ue.x,ue.y,ue.z,ue.w):oe.set(ue,Ue,qe,Ke),ie.viewport(k.copy(oe).multiplyScalar(G).floor())},this.getScissor=function(ue){return ue.copy($)},this.setScissor=function(ue,Ue,qe,Ke){ue.isVector4?$.set(ue.x,ue.y,ue.z,ue.w):$.set(ue,Ue,qe,Ke),ie.scissor(U.copy($).multiplyScalar(G).floor())},this.getScissorTest=function(){return X},this.setScissorTest=function(ue){ie.setScissorTest(X=ue)},this.setOpaqueSort=function(ue){K=ue},this.setTransparentSort=function(ue){Y=ue},this.getClearColor=function(ue){return ue.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(ue=!0,Ue=!0,qe=!0){let Ke=0;if(ue){let We=!1;if(N!==null){const St=N.texture.format;We=St===mW||St===pW||St===hW}if(We){const St=N.texture.type,J=St===$u||St===Ou||St===uk||St===uf||St===dW||St===fW,_e=Xe.getClearColor(),Ne=Xe.getClearAlpha(),Ce=_e.r,Me=_e.g,Qe=_e.b;J?(m[0]=Ce,m[1]=Me,m[2]=Qe,m[3]=Ne,se.clearBufferuiv(se.COLOR,0,m)):(y[0]=Ce,y[1]=Me,y[2]=Qe,y[3]=Ne,se.clearBufferiv(se.COLOR,0,y))}else Ke|=se.COLOR_BUFFER_BIT}Ue&&(Ke|=se.DEPTH_BUFFER_BIT),qe&&(Ke|=se.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),se.clear(Ke)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",it,!1),n.removeEventListener("webglcontextrestored",fe,!1),n.removeEventListener("webglcontextcreationerror",Le,!1),ye.dispose(),pe.dispose(),ee.dispose(),Re.dispose(),Pe.dispose(),L.dispose(),rt.dispose(),nt.dispose(),Z.dispose(),de.dispose(),de.removeEventListener("sessionstart",ln),de.removeEventListener("sessionend",Dt),te&&(te.dispose(),te=null),Rn.stop()};function it(ue){ue.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function fe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ue=Q.autoReset,Ue=Ie.enabled,qe=Ie.autoUpdate,Ke=Ie.needsUpdate,We=Ie.type;dt(),Q.autoReset=ue,Ie.enabled=Ue,Ie.autoUpdate=qe,Ie.needsUpdate=Ke,Ie.type=We}function Le(ue){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function Ee(ue){const Ue=ue.target;Ue.removeEventListener("dispose",Ee),be(Ue)}function be(ue){He(ue),ee.remove(ue)}function He(ue){const Ue=ee.get(ue).programs;Ue!==void 0&&(Ue.forEach(function(qe){Z.releaseProgram(qe)}),ue.isShaderMaterial&&Z.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,Ue,qe,Ke,We,St){Ue===null&&(Ue=me);const J=We.isMesh&&We.matrixWorld.determinant()<0,_e=Ar(ue,Ue,qe,Ke,We);ie.setMaterial(Ke,J);let Ne=qe.index,Ce=1;if(Ke.wireframe===!0){if(Ne=F.getWireframeAttribute(qe),Ne===void 0)return;Ce=2}const Me=qe.drawRange,Qe=qe.attributes.position;let ft=Me.start*Ce,vt=(Me.start+Me.count)*Ce;St!==null&&(ft=Math.max(ft,St.start*Ce),vt=Math.min(vt,(St.start+St.count)*Ce)),Ne!==null?(ft=Math.max(ft,0),vt=Math.min(vt,Ne.count)):Qe!=null&&(ft=Math.max(ft,0),vt=Math.min(vt,Qe.count));const xt=vt-ft;if(xt<0||xt===1/0)return;rt.setup(We,Ke,_e,qe,Ne);let Pt,Mt=je;if(Ne!==null&&(Pt=ne.get(Ne),Mt=ke,Mt.setIndex(Pt)),We.isMesh)Ke.wireframe===!0?(ie.setLineWidth(Ke.wireframeLinewidth*we()),Mt.setMode(se.LINES)):Mt.setMode(se.TRIANGLES);else if(We.isLine){let mt=Ke.linewidth;mt===void 0&&(mt=1),ie.setLineWidth(mt*we()),We.isLineSegments?Mt.setMode(se.LINES):We.isLineLoop?Mt.setMode(se.LINE_LOOP):Mt.setMode(se.LINE_STRIP)}else We.isPoints?Mt.setMode(se.POINTS):We.isSprite&&Mt.setMode(se.TRIANGLES);if(We.isBatchedMesh)Mt.renderMultiDraw(We._multiDrawStarts,We._multiDrawCounts,We._multiDrawCount);else if(We.isInstancedMesh)Mt.renderInstances(ft,xt,We.count);else if(qe.isInstancedBufferGeometry){const mt=qe._maxInstanceCount!==void 0?qe._maxInstanceCount:1/0,Gt=Math.min(qe.instanceCount,mt);Mt.renderInstances(ft,xt,Gt)}else Mt.render(ft,xt)};function ut(ue,Ue,qe){ue.transparent===!0&&ue.side===Yl&&ue.forceSinglePass===!1?(ue.side=za,ue.needsUpdate=!0,qi(ue,Ue,qe),ue.side=Qu,ue.needsUpdate=!0,qi(ue,Ue,qe),ue.side=Yl):qi(ue,Ue,qe)}this.compile=function(ue,Ue,qe=null){qe===null&&(qe=ue),b=pe.get(qe),b.init(),M.push(b),qe.traverseVisible(function(We){We.isLight&&We.layers.test(Ue.layers)&&(b.pushLight(We),We.castShadow&&b.pushShadow(We))}),ue!==qe&&ue.traverseVisible(function(We){We.isLight&&We.layers.test(Ue.layers)&&(b.pushLight(We),We.castShadow&&b.pushShadow(We))}),b.setupLights(w._useLegacyLights);const Ke=new Set;return ue.traverse(function(We){const St=We.material;if(St)if(Array.isArray(St))for(let J=0;J<St.length;J++){const _e=St[J];ut(_e,qe,We),Ke.add(_e)}else ut(St,qe,We),Ke.add(St)}),M.pop(),b=null,Ke},this.compileAsync=function(ue,Ue,qe=null){const Ke=this.compile(ue,Ue,qe);return new Promise(We=>{function St(){if(Ke.forEach(function(J){ee.get(J).currentProgram.isReady()&&Ke.delete(J)}),Ke.size===0){We(ue);return}setTimeout(St,10)}z.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let _t=null;function Rt(ue){_t&&_t(ue)}function ln(){Rn.stop()}function Dt(){Rn.start()}const Rn=new DW;Rn.setAnimationLoop(Rt),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(ue){_t=ue,de.setAnimationLoop(ue),ue===null?Rn.stop():Rn.start()},de.addEventListener("sessionstart",ln),de.addEventListener("sessionend",Dt),this.render=function(ue,Ue){if(Ue!==void 0&&Ue.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),Ue.parent===null&&Ue.matrixWorldAutoUpdate===!0&&Ue.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera(Ue),Ue=de.getCamera()),ue.isScene===!0&&ue.onBeforeRender(w,ue,Ue,N),b=pe.get(ue,M.length),b.init(),M.push(b),ve.multiplyMatrices(Ue.projectionMatrix,Ue.matrixWorldInverse),ae.setFromProjectionMatrix(ve),xe=this.localClippingEnabled,ce=Ze.init(this.clippingPlanes,xe),v=ye.get(ue,x.length),v.init(),x.push(v),qn(ue,Ue,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(K,Y),this.info.render.frame++,ce===!0&&Ze.beginShadows();const qe=b.state.shadowsArray;if(Ie.render(qe,ue,Ue),ce===!0&&Ze.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(v,ue),b.setupLights(w._useLegacyLights),Ue.isArrayCamera){const Ke=Ue.cameras;for(let We=0,St=Ke.length;We<St;We++){const J=Ke[We];pi(v,ue,J,J.viewport)}}else pi(v,ue,Ue);N!==null&&(le.updateMultisampleRenderTarget(N),le.updateRenderTargetMipmap(N)),ue.isScene===!0&&ue.onAfterRender(w,ue,Ue),rt.resetDefaultState(),j=-1,C=null,M.pop(),M.length>0?b=M[M.length-1]:b=null,x.pop(),x.length>0?v=x[x.length-1]:v=null};function qn(ue,Ue,qe,Ke){if(ue.visible===!1)return;if(ue.layers.test(Ue.layers)){if(ue.isGroup)qe=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(Ue);else if(ue.isLight)b.pushLight(ue),ue.castShadow&&b.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||ae.intersectsSprite(ue)){Ke&&he.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(ve);const J=L.update(ue),_e=ue.material;_e.visible&&v.push(ue,J,_e,qe,he.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||ae.intersectsObject(ue))){const J=L.update(ue),_e=ue.material;if(Ke&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),he.copy(ue.boundingSphere.center)):(J.boundingSphere===null&&J.computeBoundingSphere(),he.copy(J.boundingSphere.center)),he.applyMatrix4(ue.matrixWorld).applyMatrix4(ve)),Array.isArray(_e)){const Ne=J.groups;for(let Ce=0,Me=Ne.length;Ce<Me;Ce++){const Qe=Ne[Ce],ft=_e[Qe.materialIndex];ft&&ft.visible&&v.push(ue,J,ft,qe,he.z,Qe)}}else _e.visible&&v.push(ue,J,_e,qe,he.z,null)}}const St=ue.children;for(let J=0,_e=St.length;J<_e;J++)qn(St[J],Ue,qe,Ke)}function pi(ue,Ue,qe,Ke){const We=ue.opaque,St=ue.transmissive,J=ue.transparent;b.setupLightsView(qe),ce===!0&&Ze.setGlobalState(w.clippingPlanes,qe),St.length>0&&Zr(We,St,Ue,qe),Ke&&ie.viewport(k.copy(Ke)),We.length>0&&mi(We,Ue,qe),St.length>0&&mi(St,Ue,qe),J.length>0&&mi(J,Ue,qe),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function Zr(ue,Ue,qe,Ke){if((qe.isScene===!0?qe.overrideMaterial:null)!==null)return;const St=q.isWebGL2;te===null&&(te=new Pf(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")?Jx:$u,minFilter:Qx,samples:St?4:0})),w.getDrawingBufferSize(De),St?te.setSize(De.x,De.y):te.setSize(i1(De.x),i1(De.y));const J=w.getRenderTarget();w.setRenderTarget(te),w.getClearColor(H),O=w.getClearAlpha(),O<1&&w.setClearColor(16777215,.5),w.clear();const _e=w.toneMapping;w.toneMapping=Hu,mi(ue,qe,Ke),le.updateMultisampleRenderTarget(te),le.updateRenderTargetMipmap(te);let Ne=!1;for(let Ce=0,Me=Ue.length;Ce<Me;Ce++){const Qe=Ue[Ce],ft=Qe.object,vt=Qe.geometry,xt=Qe.material,Pt=Qe.group;if(xt.side===Yl&&ft.layers.test(Ke.layers)){const Mt=xt.side;xt.side=za,xt.needsUpdate=!0,Pi(ft,qe,Ke,vt,xt,Pt),xt.side=Mt,xt.needsUpdate=!0,Ne=!0}}Ne===!0&&(le.updateMultisampleRenderTarget(te),le.updateRenderTargetMipmap(te)),w.setRenderTarget(J),w.setClearColor(H,O),w.toneMapping=_e}function mi(ue,Ue,qe){const Ke=Ue.isScene===!0?Ue.overrideMaterial:null;for(let We=0,St=ue.length;We<St;We++){const J=ue[We],_e=J.object,Ne=J.geometry,Ce=Ke===null?J.material:Ke,Me=J.group;_e.layers.test(qe.layers)&&Pi(_e,Ue,qe,Ne,Ce,Me)}}function Pi(ue,Ue,qe,Ke,We,St){ue.onBeforeRender(w,Ue,qe,Ke,We,St),ue.modelViewMatrix.multiplyMatrices(qe.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),We.onBeforeRender(w,Ue,qe,Ke,ue,St),We.transparent===!0&&We.side===Yl&&We.forceSinglePass===!1?(We.side=za,We.needsUpdate=!0,w.renderBufferDirect(qe,Ue,Ke,We,ue,St),We.side=Qu,We.needsUpdate=!0,w.renderBufferDirect(qe,Ue,Ke,We,ue,St),We.side=Yl):w.renderBufferDirect(qe,Ue,Ke,We,ue,St),ue.onAfterRender(w,Ue,qe,Ke,We,St)}function qi(ue,Ue,qe){Ue.isScene!==!0&&(Ue=me);const Ke=ee.get(ue),We=b.state.lights,St=b.state.shadowsArray,J=We.state.version,_e=Z.getParameters(ue,We.state,St,Ue,qe),Ne=Z.getProgramCacheKey(_e);let Ce=Ke.programs;Ke.environment=ue.isMeshStandardMaterial?Ue.environment:null,Ke.fog=Ue.fog,Ke.envMap=(ue.isMeshStandardMaterial?Pe:Re).get(ue.envMap||Ke.environment),Ce===void 0&&(ue.addEventListener("dispose",Ee),Ce=new Map,Ke.programs=Ce);let Me=Ce.get(Ne);if(Me!==void 0){if(Ke.currentProgram===Me&&Ke.lightsStateVersion===J)return hr(ue,_e),Me}else _e.uniforms=Z.getUniforms(ue),ue.onBuild(qe,_e,w),ue.onBeforeCompile(_e,w),Me=Z.acquireProgram(_e,Ne),Ce.set(Ne,Me),Ke.uniforms=_e.uniforms;const Qe=Ke.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(Qe.clippingPlanes=Ze.uniform),hr(ue,_e),Ke.needsLights=Oc(ue),Ke.lightsStateVersion=J,Ke.needsLights&&(Qe.ambientLightColor.value=We.state.ambient,Qe.lightProbe.value=We.state.probe,Qe.directionalLights.value=We.state.directional,Qe.directionalLightShadows.value=We.state.directionalShadow,Qe.spotLights.value=We.state.spot,Qe.spotLightShadows.value=We.state.spotShadow,Qe.rectAreaLights.value=We.state.rectArea,Qe.ltc_1.value=We.state.rectAreaLTC1,Qe.ltc_2.value=We.state.rectAreaLTC2,Qe.pointLights.value=We.state.point,Qe.pointLightShadows.value=We.state.pointShadow,Qe.hemisphereLights.value=We.state.hemi,Qe.directionalShadowMap.value=We.state.directionalShadowMap,Qe.directionalShadowMatrix.value=We.state.directionalShadowMatrix,Qe.spotShadowMap.value=We.state.spotShadowMap,Qe.spotLightMatrix.value=We.state.spotLightMatrix,Qe.spotLightMap.value=We.state.spotLightMap,Qe.pointShadowMap.value=We.state.pointShadowMap,Qe.pointShadowMatrix.value=We.state.pointShadowMatrix),Ke.currentProgram=Me,Ke.uniformsList=null,Me}function Lr(ue){if(ue.uniformsList===null){const Ue=ue.currentProgram.getUniforms();ue.uniformsList=M_.seqWithValue(Ue.seq,ue.uniforms)}return ue.uniformsList}function hr(ue,Ue){const qe=ee.get(ue);qe.outputColorSpace=Ue.outputColorSpace,qe.batching=Ue.batching,qe.instancing=Ue.instancing,qe.instancingColor=Ue.instancingColor,qe.skinning=Ue.skinning,qe.morphTargets=Ue.morphTargets,qe.morphNormals=Ue.morphNormals,qe.morphColors=Ue.morphColors,qe.morphTargetsCount=Ue.morphTargetsCount,qe.numClippingPlanes=Ue.numClippingPlanes,qe.numIntersection=Ue.numClipIntersection,qe.vertexAlphas=Ue.vertexAlphas,qe.vertexTangents=Ue.vertexTangents,qe.toneMapping=Ue.toneMapping}function Ar(ue,Ue,qe,Ke,We){Ue.isScene!==!0&&(Ue=me),le.resetTextureUnits();const St=Ue.fog,J=Ke.isMeshStandardMaterial?Ue.environment:null,_e=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:xc,Ne=(Ke.isMeshStandardMaterial?Pe:Re).get(Ke.envMap||J),Ce=Ke.vertexColors===!0&&!!qe.attributes.color&&qe.attributes.color.itemSize===4,Me=!!qe.attributes.tangent&&(!!Ke.normalMap||Ke.anisotropy>0),Qe=!!qe.morphAttributes.position,ft=!!qe.morphAttributes.normal,vt=!!qe.morphAttributes.color;let xt=Hu;Ke.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(xt=w.toneMapping);const Pt=qe.morphAttributes.position||qe.morphAttributes.normal||qe.morphAttributes.color,Mt=Pt!==void 0?Pt.length:0,mt=ee.get(Ke),Gt=b.state.lights;if(ce===!0&&(xe===!0||ue!==C)){const Tr=ue===C&&Ke.id===j;Ze.setState(Ke,ue,Tr)}let Lt=!1;Ke.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Gt.state.version||mt.outputColorSpace!==_e||We.isBatchedMesh&&mt.batching===!1||!We.isBatchedMesh&&mt.batching===!0||We.isInstancedMesh&&mt.instancing===!1||!We.isInstancedMesh&&mt.instancing===!0||We.isSkinnedMesh&&mt.skinning===!1||!We.isSkinnedMesh&&mt.skinning===!0||We.isInstancedMesh&&mt.instancingColor===!0&&We.instanceColor===null||We.isInstancedMesh&&mt.instancingColor===!1&&We.instanceColor!==null||mt.envMap!==Ne||Ke.fog===!0&&mt.fog!==St||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Ze.numPlanes||mt.numIntersection!==Ze.numIntersection)||mt.vertexAlphas!==Ce||mt.vertexTangents!==Me||mt.morphTargets!==Qe||mt.morphNormals!==ft||mt.morphColors!==vt||mt.toneMapping!==xt||q.isWebGL2===!0&&mt.morphTargetsCount!==Mt)&&(Lt=!0):(Lt=!0,mt.__version=Ke.version);let en=mt.currentProgram;Lt===!0&&(en=qi(Ke,Ue,We));let un=!1,gn=!1,Ot=!1;const Xt=en.getUniforms(),Zt=mt.uniforms;if(ie.useProgram(en.program)&&(un=!0,gn=!0,Ot=!0),Ke.id!==j&&(j=Ke.id,gn=!0),un||C!==ue){Xt.setValue(se,"projectionMatrix",ue.projectionMatrix),Xt.setValue(se,"viewMatrix",ue.matrixWorldInverse);const Tr=Xt.map.cameraPosition;Tr!==void 0&&Tr.setValue(se,he.setFromMatrixPosition(ue.matrixWorld)),q.logarithmicDepthBuffer&&Xt.setValue(se,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&Xt.setValue(se,"isOrthographic",ue.isOrthographicCamera===!0),C!==ue&&(C=ue,gn=!0,Ot=!0)}if(We.isSkinnedMesh){Xt.setOptional(se,We,"bindMatrix"),Xt.setOptional(se,We,"bindMatrixInverse");const Tr=We.skeleton;Tr&&(q.floatVertexTextures?(Tr.boneTexture===null&&Tr.computeBoneTexture(),Xt.setValue(se,"boneTexture",Tr.boneTexture,le)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}We.isBatchedMesh&&(Xt.setOptional(se,We,"batchingTexture"),Xt.setValue(se,"batchingTexture",We._matricesTexture,le));const br=qe.morphAttributes;if((br.position!==void 0||br.normal!==void 0||br.color!==void 0&&q.isWebGL2===!0)&&ot.update(We,qe,en),(gn||mt.receiveShadow!==We.receiveShadow)&&(mt.receiveShadow=We.receiveShadow,Xt.setValue(se,"receiveShadow",We.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(Zt.envMap.value=Ne,Zt.flipEnvMap.value=Ne.isCubeTexture&&Ne.isRenderTargetTexture===!1?-1:1),gn&&(Xt.setValue(se,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&no(Zt,Ot),St&&Ke.fog===!0&&ge.refreshFogUniforms(Zt,St),ge.refreshMaterialUniforms(Zt,Ke,G,V,te),M_.upload(se,Lr(mt),Zt,le)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(M_.upload(se,Lr(mt),Zt,le),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&Xt.setValue(se,"center",We.center),Xt.setValue(se,"modelViewMatrix",We.modelViewMatrix),Xt.setValue(se,"normalMatrix",We.normalMatrix),Xt.setValue(se,"modelMatrix",We.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const Tr=Ke.uniformsGroups;for(let Nn=0,ro=Tr.length;Nn<ro;Nn++)if(q.isWebGL2){const Pn=Tr[Nn];nt.update(Pn,en),nt.bind(Pn,en)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return en}function no(ue,Ue){ue.ambientLightColor.needsUpdate=Ue,ue.lightProbe.needsUpdate=Ue,ue.directionalLights.needsUpdate=Ue,ue.directionalLightShadows.needsUpdate=Ue,ue.pointLights.needsUpdate=Ue,ue.pointLightShadows.needsUpdate=Ue,ue.spotLights.needsUpdate=Ue,ue.spotLightShadows.needsUpdate=Ue,ue.rectAreaLights.needsUpdate=Ue,ue.hemisphereLights.needsUpdate=Ue}function Oc(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(ue,Ue,qe){ee.get(ue.texture).__webglTexture=Ue,ee.get(ue.depthTexture).__webglTexture=qe;const Ke=ee.get(ue);Ke.__hasExternalTextures=!0,Ke.__hasExternalTextures&&(Ke.__autoAllocateDepthBuffer=qe===void 0,Ke.__autoAllocateDepthBuffer||z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Ke.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ue,Ue){const qe=ee.get(ue);qe.__webglFramebuffer=Ue,qe.__useDefaultFramebuffer=Ue===void 0},this.setRenderTarget=function(ue,Ue=0,qe=0){N=ue,T=Ue,R=qe;let Ke=!0,We=null,St=!1,J=!1;if(ue){const Ne=ee.get(ue);Ne.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(se.FRAMEBUFFER,null),Ke=!1):Ne.__webglFramebuffer===void 0?le.setupRenderTarget(ue):Ne.__hasExternalTextures&&le.rebindTextures(ue,ee.get(ue.texture).__webglTexture,ee.get(ue.depthTexture).__webglTexture);const Ce=ue.texture;(Ce.isData3DTexture||Ce.isDataArrayTexture||Ce.isCompressedArrayTexture)&&(J=!0);const Me=ee.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(Me[Ue])?We=Me[Ue][qe]:We=Me[Ue],St=!0):q.isWebGL2&&ue.samples>0&&le.useMultisampledRTT(ue)===!1?We=ee.get(ue).__webglMultisampledFramebuffer:Array.isArray(Me)?We=Me[qe]:We=Me,k.copy(ue.viewport),U.copy(ue.scissor),I=ue.scissorTest}else k.copy(oe).multiplyScalar(G).floor(),U.copy($).multiplyScalar(G).floor(),I=X;if(ie.bindFramebuffer(se.FRAMEBUFFER,We)&&q.drawBuffers&&Ke&&ie.drawBuffers(ue,We),ie.viewport(k),ie.scissor(U),ie.setScissorTest(I),St){const Ne=ee.get(ue.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Ne.__webglTexture,qe)}else if(J){const Ne=ee.get(ue.texture),Ce=Ue||0;se.framebufferTextureLayer(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,Ne.__webglTexture,qe||0,Ce)}j=-1},this.readRenderTargetPixels=function(ue,Ue,qe,Ke,We,St,J){if(!(ue&&ue.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=ee.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&J!==void 0&&(_e=_e[J]),_e){ie.bindFramebuffer(se.FRAMEBUFFER,_e);try{const Ne=ue.texture,Ce=Ne.format,Me=Ne.type;if(Ce!==zs&&pt.convert(Ce)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Qe=Me===Jx&&(z.has("EXT_color_buffer_half_float")||q.isWebGL2&&z.has("EXT_color_buffer_float"));if(Me!==$u&&pt.convert(Me)!==se.getParameter(se.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Me===nc&&(q.isWebGL2||z.has("OES_texture_float")||z.has("WEBGL_color_buffer_float")))&&!Qe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ue>=0&&Ue<=ue.width-Ke&&qe>=0&&qe<=ue.height-We&&se.readPixels(Ue,qe,Ke,We,pt.convert(Ce),pt.convert(Me),St)}finally{const Ne=N!==null?ee.get(N).__webglFramebuffer:null;ie.bindFramebuffer(se.FRAMEBUFFER,Ne)}}},this.copyFramebufferToTexture=function(ue,Ue,qe=0){const Ke=Math.pow(2,-qe),We=Math.floor(Ue.image.width*Ke),St=Math.floor(Ue.image.height*Ke);le.setTexture2D(Ue,0),se.copyTexSubImage2D(se.TEXTURE_2D,qe,0,0,ue.x,ue.y,We,St),ie.unbindTexture()},this.copyTextureToTexture=function(ue,Ue,qe,Ke=0){const We=Ue.image.width,St=Ue.image.height,J=pt.convert(qe.format),_e=pt.convert(qe.type);le.setTexture2D(qe,0),se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,qe.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,qe.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,qe.unpackAlignment),Ue.isDataTexture?se.texSubImage2D(se.TEXTURE_2D,Ke,ue.x,ue.y,We,St,J,_e,Ue.image.data):Ue.isCompressedTexture?se.compressedTexSubImage2D(se.TEXTURE_2D,Ke,ue.x,ue.y,Ue.mipmaps[0].width,Ue.mipmaps[0].height,J,Ue.mipmaps[0].data):se.texSubImage2D(se.TEXTURE_2D,Ke,ue.x,ue.y,J,_e,Ue.image),Ke===0&&qe.generateMipmaps&&se.generateMipmap(se.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(ue,Ue,qe,Ke,We=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const St=ue.max.x-ue.min.x+1,J=ue.max.y-ue.min.y+1,_e=ue.max.z-ue.min.z+1,Ne=pt.convert(Ke.format),Ce=pt.convert(Ke.type);let Me;if(Ke.isData3DTexture)le.setTexture3D(Ke,0),Me=se.TEXTURE_3D;else if(Ke.isDataArrayTexture)le.setTexture2DArray(Ke,0),Me=se.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}se.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,Ke.flipY),se.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ke.premultiplyAlpha),se.pixelStorei(se.UNPACK_ALIGNMENT,Ke.unpackAlignment);const Qe=se.getParameter(se.UNPACK_ROW_LENGTH),ft=se.getParameter(se.UNPACK_IMAGE_HEIGHT),vt=se.getParameter(se.UNPACK_SKIP_PIXELS),xt=se.getParameter(se.UNPACK_SKIP_ROWS),Pt=se.getParameter(se.UNPACK_SKIP_IMAGES),Mt=qe.isCompressedTexture?qe.mipmaps[0]:qe.image;se.pixelStorei(se.UNPACK_ROW_LENGTH,Mt.width),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,Mt.height),se.pixelStorei(se.UNPACK_SKIP_PIXELS,ue.min.x),se.pixelStorei(se.UNPACK_SKIP_ROWS,ue.min.y),se.pixelStorei(se.UNPACK_SKIP_IMAGES,ue.min.z),qe.isDataTexture||qe.isData3DTexture?se.texSubImage3D(Me,We,Ue.x,Ue.y,Ue.z,St,J,_e,Ne,Ce,Mt.data):qe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),se.compressedTexSubImage3D(Me,We,Ue.x,Ue.y,Ue.z,St,J,_e,Ne,Mt.data)):se.texSubImage3D(Me,We,Ue.x,Ue.y,Ue.z,St,J,_e,Ne,Ce,Mt),se.pixelStorei(se.UNPACK_ROW_LENGTH,Qe),se.pixelStorei(se.UNPACK_IMAGE_HEIGHT,ft),se.pixelStorei(se.UNPACK_SKIP_PIXELS,vt),se.pixelStorei(se.UNPACK_SKIP_ROWS,xt),se.pixelStorei(se.UNPACK_SKIP_IMAGES,Pt),We===0&&Ke.generateMipmaps&&se.generateMipmap(Me),ie.unbindTexture()},this.initTexture=function(ue){ue.isCubeTexture?le.setTextureCube(ue,0):ue.isData3DTexture?le.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?le.setTexture2DArray(ue,0):le.setTexture2D(ue,0),ie.unbindTexture()},this.resetState=function(){T=0,R=0,N=null,ie.reset(),rt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===dk?"display-p3":"srgb",n.unpackColorSpace=$n.workingColorSpace===cw?"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===$i?ff:xW}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ff?$i:xc}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class g_e extends U3{}g_e.prototype.isWebGL1Renderer=!0;class xk{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Bt(e),this.near=n,this.far=r}clone(){return new xk(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class x_e extends va{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 v_e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=O3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=cc()}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=cc()),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=cc()),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 da=new Te;class Lu{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++)da.fromBufferAttribute(this,n),da.applyMatrix4(e),this.setXYZ(n,da.x,da.y,da.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)da.fromBufferAttribute(this,n),da.applyNormalMatrix(e),this.setXYZ(n,da.x,da.y,da.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)da.fromBufferAttribute(this,n),da.transformDirection(e),this.setXYZ(n,da.x,da.y,da.z);return this}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=$o(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=$o(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=$o(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=$o(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),r=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),a=Hn(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 hs(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 Lu(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 b_e extends Ba{constructor(e=null,n=1,r=1,i,a,s,o,l,c=Hi,u=Hi,f,g){super(null,s,o,l,c,u,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function y_e(t,e){return t.z-e.z}function __e(t,e){return e.z-t.z}class S_e{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 up="batchId",mu=new Jn,D5=new Jn,w_e=new Jn,O5=new Jn,WT=new uw,Ey=new Ws,Bd=new Xo,Gg=new Te,qT=new S_e,Ji=new _o,Ay=[];function M_e(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 s=0;s<r;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class E_e extends _o{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new oa,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 b_e(n,e,e,zs,nc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:u,normalized:f}=l,g=new c.constructor(r*u),m=new l.constructor(g,u,f);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new hs(o,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(up,new hs(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(up))throw new Error(`BatchedMesh: Geometry cannot use attribute "${up}"`);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===up)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 Ws);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,mu),this.getBoundingBoxAt(i,Ey).applyMatrix4(mu),n.union(Ey))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xo);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,mu),this.getBoundingSphereAt(i,Bd).applyMatrix4(mu),n.union(Bd))}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 s=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(a=s[s.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 c=e.getIndex(),u=c!==null;if(u&&(r===-1?i.indexCount=c.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,g=this._active,m=this._matricesTexture,y=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,w_e.toArray(y,v*16),m.needsUpdate=!0,s.push(i),o.push({start:u?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ws,sphereInitialized:!1,sphere:new Xo});const b=this.geometry.getAttribute(up);for(let x=0;x<i.vertexCount;x++)b.setX(i.vertexStart+x,v);return b.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(i&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const m in r.attributes){if(m===up)continue;const y=n.getAttribute(m),v=r.getAttribute(m);M_e(y,v,l);const b=y.itemSize;for(let x=y.count,M=c;x<M;x++){const w=l+x;for(let A=0;A<b;A++)v.setComponent(w,A,0)}v.needsUpdate=!0}if(i){const m=o.indexStart;for(let y=0;y<s.count;y++)a.setX(m+y,l+s.getX(y));for(let y=s.count,v=o.indexCount;y<v;y++)a.setX(m+y,l);a.needsUpdate=!0}const u=this._bounds[e];n.boundingBox!==null?(u.box.copy(n.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,n.boundingSphere!==null?(u.sphere.copy(n.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?s.count:g.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,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const o=s.index,l=s.attributes.position,c=this._drawRanges[e];for(let u=c.start,f=c.start+c.count;u<f;u++){let g=u;o&&(g=o.getX(g)),a.expandByPoint(Gg.fromBufferAttribute(l,g))}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,s=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,Ey),Ey.getCenter(a.center);const o=s.index,l=s.attributes.position,c=this._drawRanges[e];let u=0;for(let f=c.start,g=c.start+c.count;f<g;f++){let m=f;o&&(m=o.getX(m)),Gg.fromBufferAttribute(l,m),u=Math.max(u,a.center.distanceToSquared(Gg))}a.radius=Math.sqrt(u),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||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,s=this._geometryCount,o=this.matrixWorld,l=this.geometry;Ji.material=this.material,Ji.geometry.index=l.index,Ji.geometry.attributes=l.attributes,Ji.geometry.boundingBox===null&&(Ji.geometry.boundingBox=new Ws),Ji.geometry.boundingSphere===null&&(Ji.geometry.boundingSphere=new Xo);for(let c=0;c<s;c++){if(!r[c]||!i[c])continue;const u=a[c];Ji.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Ji.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,Ji.geometry.boundingBox),this.getBoundingSphereAt(c,Ji.geometry.boundingSphere),Ji.raycast(e,Ay);for(let f=0,g=Ay.length;f<g;f++){const m=Ay[f];m.object=this,m.batchId=c,n.push(m)}Ay.length=0}Ji.material=null,Ji.geometry.index=null,Ji.geometry.attributes={},Ji.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 s=i.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,l=this._visibility,c=this._multiDrawStarts,u=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(O5.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),WT.setFromProjectionMatrix(O5,e.isWebGPURenderer?e0:Wo));let m=0;if(this.sortObjects){D5.copy(this.matrixWorld).invert(),Gg.setFromMatrixPosition(r.matrixWorld).applyMatrix4(D5);for(let b=0,x=l.length;b<x;b++)if(l[b]){this.getMatrixAt(b,mu),this.getBoundingSphereAt(b,Bd).applyMatrix4(mu);let M=!1;if(g&&(M=!WT.intersectsSphere(Bd)),!M){const w=Gg.distanceTo(Bd.center);qT.push(f[b],w)}}const y=qT.list,v=this.customSort;v===null?y.sort(a.transparent?__e:y_e):v.call(this,y,r);for(let b=0,x=y.length;b<x;b++){const M=y[b];c[m]=M.start*o,u[m]=M.count,m++}qT.reset()}else for(let y=0,v=l.length;y<v;y++)if(l[y]){let b=!1;if(g&&(this.getMatrixAt(y,mu),this.getBoundingSphereAt(y,Bd).applyMatrix4(mu),b=!WT.intersectsSphere(Bd)),!b){const x=f[y];c[m]=x.start*o,u[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class z0 extends Mm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Bt(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 L5=new Te,I5=new Te,j5=new Jn,XT=new hk,Ty=new Xo;class A_e extends va{constructor(e=new oa,n=new z0){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++)L5.fromBufferAttribute(n,i-1),I5.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=L5.distanceTo(I5);e.setAttribute("lineDistance",new Dr(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,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ty.copy(r.boundingSphere),Ty.applyMatrix4(i),Ty.radius+=a,e.ray.intersectsSphere(Ty)===!1)return;j5.copy(i).invert(),XT.copy(e.ray).applyMatrix4(j5);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Te,u=new Te,f=new Te,g=new Te,m=this.isLineSegments?2:1,y=r.index,b=r.attributes.position;if(y!==null){const x=Math.max(0,s.start),M=Math.min(y.count,s.start+s.count);for(let w=x,A=M-1;w<A;w+=m){const T=y.getX(w),R=y.getX(w+1);if(c.fromBufferAttribute(b,T),u.fromBufferAttribute(b,R),XT.distanceSqToSegment(c,u,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(g);j<e.near||j>e.far||n.push({distance:j,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,s.start),M=Math.min(b.count,s.start+s.count);for(let w=x,A=M-1;w<A;w+=m){if(c.fromBufferAttribute(b,w),u.fromBufferAttribute(b,w+1),XT.distanceSqToSegment(c,u,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(g);R<e.near||R>e.far||n.push({distance:R,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const U5=new Te,F5=new Te;class fw extends A_e{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)U5.fromBufferAttribute(n,i),F5.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+U5.distanceTo(F5);e.setAttribute("lineDistance",new Dr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class T_e extends oa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Te,a=new Te;if(e.index!==null){const s=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const f=l[c],g=f.start,m=f.count;for(let y=g,v=g+m;y<v;y+=3)for(let b=0;b<3;b++){const x=o.getX(y+b),M=o.getX(y+(b+1)%3);i.fromBufferAttribute(s,x),a.fromBufferAttribute(s,M),z5(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,l=s.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,f=3*o+(c+1)%3;i.fromBufferAttribute(s,u),a.fromBufferAttribute(s,f),z5(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Dr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function z5(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 C_e extends Mm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Bt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vW,this.normalScale=new qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ck,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 N_e extends z0{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 zW extends va{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Bt(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 KT=new Jn,B5=new Te,H5=new Te;class R_e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new qt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new uw,this._frameExtents=new qt(1,1),this._viewportCount=1,this._viewports=[new Gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;B5.setFromMatrixPosition(e.matrixWorld),n.position.copy(B5),H5.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(H5),n.updateMatrixWorld(),KT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(KT),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(KT)}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 $5=new Jn,Wg=new Te,YT=new Te;class P_e extends R_e{constructor(){super(new ls(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new qt(4,2),this._viewportCount=6,this._viewports=[new Gn(2,1,1,1),new Gn(0,1,1,1),new Gn(3,1,1,1),new Gn(1,1,1,1),new Gn(3,0,1,1),new Gn(1,0,1,1)],this._cubeDirections=[new Te(1,0,0),new Te(-1,0,0),new Te(0,0,1),new Te(0,0,-1),new Te(0,1,0),new Te(0,-1,0)],this._cubeUps=[new Te(0,1,0),new Te(0,1,0),new Te(0,1,0),new Te(0,1,0),new Te(0,0,1),new Te(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Wg.setFromMatrixPosition(e.matrixWorld),r.position.copy(Wg),YT.copy(r.position),YT.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(YT),r.updateMatrixWorld(),i.makeTranslation(-Wg.x,-Wg.y,-Wg.z),$5.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix($5)}}class k_e extends zW{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 P_e}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class D_e extends zW{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class O_e extends oa{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 F3 extends v_e{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 V5{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(Vi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const G5=new Te,Cy=new Te;class L_e{constructor(e=new Te,n=new Te){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){G5.subVectors(e,this.start),Cy.subVectors(this.end,this.start);const r=Cy.dot(Cy);let a=Cy.dot(G5)/r;return n&&(a=Vi(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 I_e extends fw{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 oa;i.setAttribute("position",new Dr(n,3)),i.setAttribute("color",new Dr(r,3));const a=new z0({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Bt,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:ow}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ow);class Ko{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"),Ko.nextNameID=Ko.nextNameID||0,this.$name.id=`lil-gui-name-${++Ko.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(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 j_e extends Ko{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 z3(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 U_e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:z3,toHexString:z3},n0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},F_e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=n0.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 n0.toHexString(i)}},z_e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=n0.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 n0.toHexString(i)}},B_e=[U_e,n0,F_e,z_e];function H_e(t){return B_e.find(e=>e.match(t))}class $_e extends Ko{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=H_e(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=z3(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 ZT extends Ko{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 V_e extends Ko{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let s=!1,o,l,c,u,f;const g=5,m=M=>{o=M.clientX,l=c=M.clientY,s=!0,u=this.getValue(),f=0,window.addEventListener("mousemove",y),window.addEventListener("mouseup",v)},y=M=>{if(s){const w=M.clientX-o,A=M.clientY-l;Math.abs(A)>g?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&v()}if(!s){const w=M.clientY-c;f-=w*this._step*this._arrowKeyMultiplier(M),u+f>this._max?f=this._max-u:u+f<this._min&&(f=this._min-u),this._snapClampSetValue(u+f)}c=M.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",v)},b=()=>{this._inputFocused=!0},x=()=>{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",m),this.$input.addEventListener("focus",b),this.$input.addEventListener("blur",x)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(x,M,w,A,T)=>(x-M)/(w-M)*(T-A)+A,n=x=>{const M=this.$slider.getBoundingClientRect();let w=e(x,M.left,M.right,this._min,this._max);this._snapClampSetValue(w)},r=x=>{this._setDraggingStyle(!0),n(x.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=x=>{n(x.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,o,l;const c=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),s=!1},u=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,l=x.touches[0].clientY,s=!0):c(x),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=x=>{if(s){const M=x.touches[0].clientX-o,w=x.touches[0].clientY-l;Math.abs(M)>Math.abs(w)?c(x):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else x.preventDefault(),n(x.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),y=400;let v;const b=x=>{if(Math.abs(x.deltaX)<Math.abs(x.deltaY)&&this._hasScrollBar)return;x.preventDefault();const w=this._normalizeMouseWheel(x)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(m,y)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",u,{passive:!1}),this.$slider.addEventListener("wheel",b,{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 G_e extends Ko{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 W_e extends Ko{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 q_e=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. 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");
  7811. }`;function X_e(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 W5=!1;class s1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:o=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{(c.code==="Enter"||c.code==="Space")&&(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!W5&&o&&(X_e(q_e),W5=!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=s}add(e,n,r,i,a){if(Object(r)===r)return new G_e(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new V_e(this,e,n,r,i,a);case"boolean":return new j_e(this,e,n);case"string":return new W_e(this,e,n);case"function":return new ZT(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,s)}addColor(e,n,r=1){return new $_e(this,e,n,r)}addFolder(e){const n=new s1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof ZT||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 ZT)){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 QT(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(c){try{l(r.next(c))}catch(u){a(u)}}function o(c){try{l(r.throw(c))}catch(u){a(u)}}function l(c){var u;c.done?i(c.value):(u=c.value,u instanceof n?u:new n((function(f){f(u)}))).then(s,o)}l((r=r.apply(t,[])).next())}))}class vk{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 vk(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 bk{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class q5 extends bk{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class gu extends bk{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class X5{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class o1{constructor(e){this.lines=[],this.preamble=new X5(-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(`
  7815. `);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,s]of Object.entries(i))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],s=n&&i[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((u=>u.trim())),l=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",c=this.parseParams(o.slice(2));switch(l){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new q5(e,l,c,s);case"t0":return new gu(e,l,s,0);case"t1":return new gu(e,l,s,1);case"t2":return new gu(e,l,s,2);case"t3":return new gu(e,l,s,3);case"t4":return new gu(e,l,s,4);case"t5":return new gu(e,l,s,5);case"t6":return new gu(e,l,s,6);case"t7":return new gu(e,l,s,7);default:return new bk(e,l,c,s)}}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 s=a[i-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof q5){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 s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new X5(this.layers.length,[],r,s))}}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 s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?r=vk.parse(a.slice(s+15).trim()):r&&(o==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}o1.prototype.parseGcode=o1.prototype.parseGCode;const K5={type:"change"},JT={type:"start"},Y5={type:"end"},Ny=new hk,Z5=new Su,K_e=Math.cos(70*yW.DEG2RAD);class Y_e extends Xf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Te,this.cursor=new Te,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Wh.ROTATE,MIDDLE:Wh.DOLLY,RIGHT:Wh.PAN},this.touches={ONE:qh.ROTATE,TWO:qh.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(q){q.addEventListener("keydown",we),this._domElementKeyEvents=q},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",we),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(K5),r.update(),a=i.NONE},this.update=(function(){const q=new Te,ie=new kf().setFromUnitVectors(e.up,new Te(0,1,0)),Q=ie.clone().invert(),ee=new Te,le=new kf,Re=new Te,Pe=2*Math.PI;return function(ne=null){const F=r.object.position;q.copy(F).sub(r.target),q.applyQuaternion(ie),o.setFromVector3(q),r.autoRotate&&a===i.NONE&&k((function(ye){return ye!==null?2*Math.PI/60*r.autoRotateSpeed*ye:2*Math.PI/60/60*r.autoRotateSpeed})(ne)),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let L=r.minAzimuthAngle,Z=r.maxAzimuthAngle;isFinite(L)&&isFinite(Z)&&(L<-Math.PI?L+=Pe:L>Math.PI&&(L-=Pe),Z<-Math.PI?Z+=Pe:Z>Math.PI&&(Z-=Pe),o.theta=L<=Z?Math.max(L,Math.min(Z,o.theta)):o.theta>(L+Z)/2?Math.max(L,o.theta):Math.min(Z,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(u,r.dampingFactor):r.target.add(u),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&R||r.object.isOrthographicCamera?o.radius=K(o.radius):o.radius=K(o.radius*c),q.setFromSpherical(o),q.applyQuaternion(Q),F.copy(r.target).add(q),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,u.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ge=!1;if(r.zoomToCursor&&R){let ye=null;if(r.object.isPerspectiveCamera){const pe=q.length();ye=K(pe*c);const Ze=pe-ye;r.object.position.addScaledVector(A,Ze),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const pe=new Te(T.x,T.y,0);pe.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ge=!0;const Ze=new Te(T.x,T.y,0);Ze.unproject(r.object),r.object.position.sub(Ze).add(pe),r.object.updateMatrixWorld(),ye=q.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;ye!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(ye).add(r.object.position):(Ny.origin.copy(r.object.position),Ny.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Ny.direction))<K_e?e.lookAt(r.target):(Z5.setFromNormalAndCoplanarPoint(r.object.up,r.target),Ny.intersectPlane(Z5,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ge=!0);return c=1,R=!1,!!(ge||ee.distanceToSquared(r.object.position)>s||8*(1-le.dot(r.object.quaternion))>s||Re.distanceToSquared(r.target)>0)&&(r.dispatchEvent(K5),ee.copy(r.object.position),le.copy(r.object.quaternion),Re.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",se),r.domElement.removeEventListener("pointerdown",ve),r.domElement.removeEventListener("pointercancel",he),r.domElement.removeEventListener("wheel",me),r.domElement.removeEventListener("pointermove",De),r.domElement.removeEventListener("pointerup",he),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",we),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 s=1e-6,o=new V5,l=new V5;let c=1;const u=new Te,f=new qt,g=new qt,m=new qt,y=new qt,v=new qt,b=new qt,x=new qt,M=new qt,w=new qt,A=new Te,T=new qt;let R=!1;const N=[],j={};function C(){return Math.pow(.95,r.zoomSpeed)}function k(q){l.theta-=q}function U(q){l.phi-=q}const I=(function(){const q=new Te;return function(ie,Q){q.setFromMatrixColumn(Q,0),q.multiplyScalar(-ie),u.add(q)}})(),H=(function(){const q=new Te;return function(ie,Q){r.screenSpacePanning===!0?q.setFromMatrixColumn(Q,1):(q.setFromMatrixColumn(Q,0),q.crossVectors(r.object.up,q)),q.multiplyScalar(ie),u.add(q)}})(),O=(function(){const q=new Te;return function(ie,Q){const ee=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;q.copy(le).sub(r.target);let Re=q.length();Re*=Math.tan(r.object.fov/2*Math.PI/180),I(2*ie*Re/ee.clientHeight,r.object.matrix),H(2*Q*Re/ee.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(I(ie*(r.object.right-r.object.left)/r.object.zoom/ee.clientWidth,r.object.matrix),H(Q*(r.object.top-r.object.bottom)/r.object.zoom/ee.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function B(q){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c/=q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(q){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c*=q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(q){if(!r.zoomToCursor)return;R=!0;const ie=r.domElement.getBoundingClientRect(),Q=q.clientX-ie.left,ee=q.clientY-ie.top,le=ie.width,Re=ie.height;T.x=Q/le*2-1,T.y=-ee/Re*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function K(q){return Math.max(r.minDistance,Math.min(r.maxDistance,q))}function Y(q){f.set(q.clientX,q.clientY)}function oe(q){y.set(q.clientX,q.clientY)}function $(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const q=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);f.set(q,ie)}}function X(){if(N.length===1)y.set(N[0].pageX,N[0].pageY);else{const q=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);y.set(q,ie)}}function ae(){const q=N[0].pageX-N[1].pageX,ie=N[0].pageY-N[1].pageY,Q=Math.sqrt(q*q+ie*ie);x.set(0,Q)}function ce(q){if(N.length==1)g.set(q.pageX,q.pageY);else{const Q=z(q),ee=.5*(q.pageX+Q.x),le=.5*(q.pageY+Q.y);g.set(ee,le)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ie=r.domElement;k(2*Math.PI*m.x/ie.clientHeight),U(2*Math.PI*m.y/ie.clientHeight),f.copy(g)}function xe(q){if(N.length===1)v.set(q.pageX,q.pageY);else{const ie=z(q),Q=.5*(q.pageX+ie.x),ee=.5*(q.pageY+ie.y);v.set(Q,ee)}b.subVectors(v,y).multiplyScalar(r.panSpeed),O(b.x,b.y),y.copy(v)}function te(q){const ie=z(q),Q=q.pageX-ie.x,ee=q.pageY-ie.y,le=Math.sqrt(Q*Q+ee*ee);M.set(0,le),w.set(0,Math.pow(M.y/x.y,r.zoomSpeed)),B(w.y),x.copy(M)}function ve(q){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(q.pointerId),r.domElement.addEventListener("pointermove",De),r.domElement.addEventListener("pointerup",he)),(function(ie){N.push(ie)})(q),q.pointerType==="touch"?(function(ie){switch(st(ie),N.length){case 1:switch(r.touches.ONE){case qh.ROTATE:if(r.enableRotate===!1)return;$(),a=i.TOUCH_ROTATE;break;case qh.PAN:if(r.enablePan===!1)return;X(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case qh.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ae(),r.enablePan&&X(),a=i.TOUCH_DOLLY_PAN;break;case qh.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ae(),r.enableRotate&&$(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(JT)})(q):(function(ie){let Q;switch(ie.button){case 0:Q=r.mouseButtons.LEFT;break;case 1:Q=r.mouseButtons.MIDDLE;break;case 2:Q=r.mouseButtons.RIGHT;break;default:Q=-1}switch(Q){case Wh.DOLLY:if(r.enableZoom===!1)return;(function(ee){G(ee),x.set(ee.clientX,ee.clientY)})(ie),a=i.DOLLY;break;case Wh.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;oe(ie),a=i.PAN}else{if(r.enableRotate===!1)return;Y(ie),a=i.ROTATE}break;case Wh.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;Y(ie),a=i.ROTATE}else{if(r.enablePan===!1)return;oe(ie),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(JT)})(q))}function De(q){r.enabled!==!1&&(q.pointerType==="touch"?(function(ie){switch(st(ie),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ce(ie),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;xe(ie),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(Q){r.enableZoom&&te(Q),r.enablePan&&xe(Q)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(Q){r.enableZoom&&te(Q),r.enableRotate&&ce(Q)})(ie),r.update();break;default:a=i.NONE}})(q):(function(ie){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(Q){g.set(Q.clientX,Q.clientY),m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ee=r.domElement;k(2*Math.PI*m.x/ee.clientHeight),U(2*Math.PI*m.y/ee.clientHeight),f.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(Q){M.set(Q.clientX,Q.clientY),w.subVectors(M,x),w.y>0?B(C()):w.y<0&&V(C()),x.copy(M),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(Q){v.set(Q.clientX,Q.clientY),b.subVectors(v,y).multiplyScalar(r.panSpeed),O(b.x,b.y),y.copy(v),r.update()})(ie)}})(q))}function he(q){(function(ie){delete j[ie.pointerId];for(let Q=0;Q<N.length;Q++)if(N[Q].pointerId==ie.pointerId)return void N.splice(Q,1)})(q),N.length===0&&(r.domElement.releasePointerCapture(q.pointerId),r.domElement.removeEventListener("pointermove",De),r.domElement.removeEventListener("pointerup",he)),r.dispatchEvent(Y5),a=i.NONE}function me(q){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(q.preventDefault(),r.dispatchEvent(JT),(function(ie){G(ie),ie.deltaY<0?V(C()):ie.deltaY>0&&B(C()),r.update()})(q),r.dispatchEvent(Y5))}function we(q){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let Q=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):O(0,r.keyPanSpeed),Q=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):O(0,-r.keyPanSpeed),Q=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?k(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):O(r.keyPanSpeed,0),Q=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?k(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):O(-r.keyPanSpeed,0),Q=!0}Q&&(ie.preventDefault(),r.update())})(q)}function se(q){r.enabled!==!1&&q.preventDefault()}function st(q){let ie=j[q.pointerId];ie===void 0&&(ie=new qt,j[q.pointerId]=ie),ie.set(q.pageX,q.pageY)}function z(q){const ie=q.pointerId===N[0].pointerId?N[1]:N[0];return j[ie.pointerId]}r.domElement.addEventListener("contextmenu",se),r.domElement.addEventListener("pointerdown",ve),r.domElement.addEventListener("pointercancel",he),r.domElement.addEventListener("wheel",me,{passive:!1}),this.update()}}bt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new qt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Ia.line={uniforms:pk.merge([bt.common,bt.fog,bt.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class BW extends Ju{constructor(e){super({type:"LineMaterial",uniforms:pk.clone(Ia.line.uniforms),vertexShader:Ia.line.vertexShader,fragmentShader:Ia.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const Q5=new Ws,Ry=new Te;class HW extends O_e{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Dr([-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 Dr([-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 F3(n,6,1);return this.setAttribute("instanceStart",new Lu(r,3,0)),this.setAttribute("instanceEnd",new Lu(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 F3(n,6,1);return this.setAttribute("instanceColorStart",new Lu(r,3,0)),this.setAttribute("instanceColorEnd",new Lu(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 T_e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ws);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Q5.setFromBufferAttribute(n),this.boundingBox.union(Q5))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xo),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Ry.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ry)),Ry.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Ry));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 J5=new Te,eB=new Te,ji=new Gn,Ui=new Gn,Oo=new Gn,e2=new Te,t2=new Jn,Fi=new L_e,tB=new Te,Py=new Ws,ky=new Xo,Lo=new Gn;let Io,Qd;function nB(t,e,n){return Lo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Lo.multiplyScalar(1/Lo.w),Lo.x=Qd/n.width,Lo.y=Qd/n.height,Lo.applyMatrix4(t.projectionMatrixInverse),Lo.multiplyScalar(1/Lo.w),Math.abs(Math.max(Lo.x,Lo.y))}class Z_e extends _o{constructor(e=new HW,n=new BW({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 s=0,o=0,l=n.count;s<l;s++,o+=2)J5.fromBufferAttribute(n,s),eB.fromBufferAttribute(r,s),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+J5.distanceTo(eB);const a=new F3(i,2,1);return e.setAttribute("instanceDistanceStart",new Lu(a,1,0)),e.setAttribute("instanceDistanceEnd",new Lu(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;Io=e.ray;const s=this.matrixWorld,o=this.geometry,l=this.material;let c,u;Qd=l.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),ky.copy(o.boundingSphere).applyMatrix4(s),r?c=.5*Qd:c=nB(i,Math.max(i.near,ky.distanceToPoint(Io.origin)),l.resolution),ky.radius+=c,Io.intersectsSphere(ky)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),Py.copy(o.boundingBox).applyMatrix4(s),r?u=.5*Qd:u=nB(i,Math.max(i.near,Py.distanceToPoint(Io.origin)),l.resolution),Py.expandByScalar(u),Io.intersectsBox(Py)!==!1&&(r?(function(f,g){const m=f.matrixWorld,y=f.geometry,v=y.attributes.instanceStart,b=y.attributes.instanceEnd;for(let x=0,M=Math.min(y.instanceCount,v.count);x<M;x++){Fi.start.fromBufferAttribute(v,x),Fi.end.fromBufferAttribute(b,x),Fi.applyMatrix4(m);const w=new Te,A=new Te;Io.distanceSqToSegment(Fi.start,Fi.end,A,w),A.distanceTo(w)<.5*Qd&&g.push({point:A,pointOnLine:w,distance:Io.origin.distanceTo(A),object:f,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(f,g,m){const y=g.projectionMatrix,v=f.material.resolution,b=f.matrixWorld,x=f.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,A=Math.min(x.instanceCount,M.count),T=-g.near;Io.at(1,Oo),Oo.w=1,Oo.applyMatrix4(g.matrixWorldInverse),Oo.applyMatrix4(y),Oo.multiplyScalar(1/Oo.w),Oo.x*=v.x/2,Oo.y*=v.y/2,Oo.z=0,e2.copy(Oo),t2.multiplyMatrices(g.matrixWorldInverse,b);for(let R=0,N=A;R<N;R++){if(ji.fromBufferAttribute(M,R),Ui.fromBufferAttribute(w,R),ji.w=1,Ui.w=1,ji.applyMatrix4(t2),Ui.applyMatrix4(t2),ji.z>T&&Ui.z>T)continue;if(ji.z>T){const I=ji.z-Ui.z,H=(ji.z-T)/I;ji.lerp(Ui,H)}else if(Ui.z>T){const I=Ui.z-ji.z,H=(Ui.z-T)/I;Ui.lerp(ji,H)}ji.applyMatrix4(y),Ui.applyMatrix4(y),ji.multiplyScalar(1/ji.w),Ui.multiplyScalar(1/Ui.w),ji.x*=v.x/2,ji.y*=v.y/2,Ui.x*=v.x/2,Ui.y*=v.y/2,Fi.start.copy(ji),Fi.start.z=0,Fi.end.copy(Ui),Fi.end.z=0;const j=Fi.closestPointToPointParameter(e2,!0);Fi.at(j,tB);const C=yW.lerp(ji.z,Ui.z,j),k=C>=-1&&C<=1,U=e2.distanceTo(tB)<.5*Qd;if(k&&U){Fi.start.fromBufferAttribute(M,R),Fi.end.fromBufferAttribute(w,R),Fi.start.applyMatrix4(b),Fi.end.applyMatrix4(b);const I=new Te,H=new Te;Io.distanceSqToSegment(Fi.start,Fi.end,H,I),m.push({point:H,pointOnLine:I,distance:Io.origin.distanceTo(H),object:f,face:null,faceIndex:R,uv:null,uv1:null})}}})(this,i,n)))}}class Q_e extends fw{constructor(e,n,r,i,a=4473924,s=8947848){a=new Bt(a),s=new Bt(s);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],c=[];let u=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){l.push(g,0,-1*r,g,0,r);const m=g===0?a:s;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?a:s;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}const f=new oa;f.setAttribute("position",new Dr(l,3)),f.setAttribute("color",new Dr(c,3)),super(f,new z0({vertexColors:!0,toneMapped:!1}))}}function J_e(t,e,n,r){const i=(function(s,o,l){s*=.5,o*=.5,l*=.5;const c=new oa,u=[];return u.push(-s,-o,-l,-s,o,-l,-s,o,-l,s,o,-l,s,o,-l,s,-o,-l,s,-o,-l,-s,-o,-l,-s,-o,l,-s,o,l,-s,o,l,s,o,l,s,o,l,s,-o,l,s,-o,l,-s,-o,l,-s,-o,-l,-s,-o,l,-s,o,-l,-s,o,l,s,o,-l,s,o,l,s,-o,-l,s,-o,l),c.setAttribute("position",new Dr(u,3)),c})(t,e,n),a=new fw(i,new N_e({color:new Bt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var yx=function(){var t=0,e=document.createElement("div");function n(u){return e.appendChild(u.dom),u}function r(u){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===u?"block":"none";t=u}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(u){u.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,s=0,o=n(new yx.Panel("FPS","#0ff","#002")),l=n(new yx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new yx.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){s++;var u=(performance||Date).now();if(l.update(u-i,200),u>=a+1e3&&(o.update(1e3*s/(u-a),100),a=u,s=0,c)){var f=performance.memory;c.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:r}};yx.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,u=2*s,f=3*s,g=15*s,m=74*s,y=30*s,v=document.createElement("canvas");v.width=o,v.height=l,v.style.cssText="width:80px;height:48px";var b=v.getContext("2d");return b.font="bold "+9*s+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,o,l),b.fillStyle=e,b.fillText(t,c,u),b.fillRect(f,g,m,y),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,g,m,y),{dom:v,update:function(x,M){r=Math.min(r,x),i=Math.max(i,x),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,o,g),b.fillStyle=e,b.fillText(a(x)+" "+t+" ("+a(r)+"-"+a(i)+")",c,u),b.drawImage(v,f+s,g,m-s,y,f,g,m-s,y),b.fillRect(f+m-s,g,s,y),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+m-s,g,s,a((1-x/M)*y))}}};var e1e=yx;class rB{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new s1,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 s1,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 t1e extends oa{constructor(e=[new Te],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 Te,s=new Te,o=new qt,l=[],c=[],u=[],f=[];function g(m){const[y,v,b]=(function(x){const M=e[x],w=new Te,A=new Te,T=new Te,R=new Te;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let N=Number.MAX_VALUE;const j=Math.abs(w.x),C=Math.abs(w.y),k=Math.abs(w.z);return j<=N&&(N=j,A.set(1,0,0)),C<=N&&(N=C,A.set(0,1,0)),k<=N&&A.set(0,0,1),R.crossVectors(w,A).normalize(),A.crossVectors(w,R),T.crossVectors(w,A),[M,A,T]})(m);for(let x=0;x<=i;x++){const M=x/i*Math.PI*2,w=Math.sin(M),A=-Math.cos(M);s.x=A*v.x+w*b.x,s.y=A*v.y+w*b.y,s.z=A*v.z+w*b.z,s.normalize(),c.push(s.x,s.y,s.z),a.x=y.x+n*s.x*.5,a.y=y.y+n*s.y*.5,a.z=y.z+r*s.z*.5,l.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)g(m);g(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let y=0;y<=i;y++)o.x=m/e.length,o.y=y/i,u.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let y=1;y<=i;y++){const v=(i+1)*(m-1)+(y-1),b=(i+1)*m+(y-1),x=(i+1)*m+y,M=(i+1)*(m-1)+y;f.push(v,b,M),f.push(b,x,M)}})()})(),this.setIndex(f),this.setAttribute("position",new Dr(l,3)),this.setAttribute("normal",new Dr(c,3)),this.setAttribute("uv",new Dr(u,2))}}class _x{static get initial(){const e=new _x;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const n2={h:0,s:0,l:0};class Lp{constructor(e){var n,r,i,a,s,o,l,c,u;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=_x.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Lp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Bt(14737632),this._travelColor=new Bt(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 o1(this.minLayerThreshold),this.scene=new x_e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Bt(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=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(c=e.extrusionWidth)!==null&&c!==void 0?c:this.extrusionWidth,this.devMode=(u=e.devMode)!==null&&u!==void 0?u:this.devMode,this.stats=this.devMode?new e1e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Bt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Bt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Bt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,y]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Bt(y)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+ow),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 U3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new U3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ls(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new xk(this._backgroundColor,g,f),this.resize(),this.controls=new Y_e(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 Bt(r)}else this._extrusionColor=new Bt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Lp.defaultExtrusionColor:this._extrusionColor instanceof Bt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Lp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Bt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Bt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Bt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Bt(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 I_e(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn("Volumetric rendering is experimental. It may not work as expected or change in the future.");const e=new D_e(13421772,.3*Math.PI),n=new k_e(16777215,Math.PI,void 0,.001);n.position.set(0,500,500),this.scene.add(e),this.scene.add(n)}}createGroup(e){const n=new lx;return n.name=e,n.quaternion.setFromEuler(new U0(-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=_x.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 QT(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,s,o,l,c;if(e>this.maxLayerIndex)return;const u=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:u.height};for(const g of u.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,y={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=m.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=m.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((c=m.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(y.x!=this.state.x||y.y!=this.state.y||y.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,y,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,y,v))}this.state.x=y.x,this.state.y=y.y,this.state.z=y.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(n2),a=new Bt().setHSL(n2.h,n2.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,l=e.extrusion.splice(-3),c=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...c,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...c,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new Q_e(this.buildVolume.x,10,this.buildVolume.y,10));const e=J_e(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 o1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=_x.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 s=i?e.extrusion:e.travel,o=n.x,l=n.y,c=n.z,u=r.x,f=r.y,g=r.z;let m=r.r,y=r.i,v=r.j;if(m){const B=u-o,V=f-l,G=Math.sqrt(Math.pow(B/2,2)+Math.pow(V/2,2));m=Math.max(m,G);const K=Math.pow(B,2)+Math.pow(V,2),Y=Math.pow(m,2)-K/4;let oe=Math.sqrt(Y/K);(a&&m<0||!a&&m>0)&&(oe=-oe),y=B/2+V*oe,v=V/2-B*oe}const b=o==u&&l==f,x=o+y,M=l+v,w=Math.sqrt(y*y+v*v),A=Math.atan2(-v,-y),T=Math.atan2(f-M,u-x);let R;b?R=2*Math.PI:(R=a?A-T:T-A,R<0&&(R+=2*Math.PI));let N=w*R/1.8;this.inches&&(N*=25),N<1&&(N=1);let j=R/N;j*=a?-1:1;const C=[];C.push({x:o,y:l,z:c});const k=(c-g)/N;let U=o,I=l,H=c,O=A;for(let B=0;B<N-1;B++)O+=j,U=x+w*Math.cos(O),I=M+w*Math.sin(O),H+=k,C.push({x:U,y:I,z:H});C.push({x:r.x,y:r.y,z:r.z});for(let B=0;B<C.length-1;B++)s.push(C[B].x,C[B].y,C[B].z,C[B+1].x,C[B+1].y,C[B+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new oa;i.setAttribute("position",new Dr(e,3)),this.disposables.push(i);const a=new z0({color:n});this.disposables.push(a);const s=new fw(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),l=new Te(o[0],o[1],o[2]),c=new Te(o[3],o[4],o[5]),u=new Te(o[6],o[7],o[8]);i.push(l),c.equals(u)||(i.push(c),a.push(i),i=[])}a.forEach((s=>{var o;const l=new t1e(s,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(l)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new HW;this.disposables.push(i);const a=new BW({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new Z_e(i,a);(r=this.group)===null||r===void 0||r.add(s)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>QT(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 C_e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),s=new E_e(r.length,a,void 0,i);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,r;return QT(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield i.read(),o+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const c=(l=a.value,new TextDecoder("utf-8").decode(l)),u=c.lastIndexOf(`
  8059. `),f=c.slice(0,u);this.parser.parseGCode(s+f),s=c.slice(u)}while(!a.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new rB(this):typeof this.devMode=="object"&&(this.devGui=new rB(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())}}Lp.defaultExtrusionColor=new Bt("hotpink");const n1e=function(t){return new Lp(t)};function r1e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(null),[c,u]=E.useState(!1),[f,g]=E.useState(0),[m,y]=E.useState(0);E.useEffect(()=>{if(!r.current)return;const x=r.current,M=n1e({canvas:x,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=M,s(!0),l(null),u(!1),fetch(t).then(async A=>{if(!A.ok)throw A.status===404&&(await A.json().catch(()=>({}))).detail?.includes("sliced")?(u(!0),new Error("not_sliced")):new Error("Failed to load G-code");return A.text()}).then(A=>{M.processGCode(A);const T=M.layers?.length||0;y(T),g(T),M.render(),s(!1)}).catch(A=>{l(A.message),s(!1)});const w=()=>{if(x.parentElement){const A=x.parentElement.getBoundingClientRect();x.width=A.width,x.height=A.height,M.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),M.dispose()}},[t,e]);const v=x=>{if(!i.current)return;const M=Math.max(1,Math.min(x,m));g(M),i.current.render()},b=x=>{v(parseInt(x.target.value,10))};return h.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[h.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[h.jsx("canvas",{ref:r,className:"w-full h-full"}),a&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsxs("div",{className:"text-center",children:[h.jsx(Ft,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),h.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsxs("div",{className:"text-center max-w-sm px-4",children:[h.jsx(Rse,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),h.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),h.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),o&&!c&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx("div",{className:"text-center text-red-400",children:h.jsx("p",{className:"text-sm",children:o})})})]}),!a&&!o&&!c&&m>0&&h.jsx("div",{className:"mt-4 px-2",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(u9,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),h.jsx("button",{onClick:()=>v(f-1),disabled:f<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:h.jsx(Af,{className:"w-4 h-4"})}),h.jsx("input",{type:"range",min:1,max:m,value:f,onChange:b,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),h.jsx("button",{onClick:()=>v(f+1),disabled:f>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:h.jsx(Wf,{className:"w-4 h-4"})}),h.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",m]})]})})]})}function i1e({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[a,s]=E.useState(null),[o,l]=E.useState(!0);E.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]),E.useEffect(()=>{Fe.getArchiveCapabilities(t).then(u=>{s(u),u.has_model?i("3d"):u.has_gcode&&i("gcode"),l(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const c=()=>{const u=e||"model",f=`${window.location.origin}${Fe.getArchiveForSlicer(t,u)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:u=>u.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ct,{variant:"secondary",size:"sm",onClick:c,children:[h.jsx(Qo,{className:"w-4 h-4"}),"Open in Slicer"]}),h.jsx(ct,{variant:"ghost",size:"sm",onClick:n,children:h.jsx(mn,{className:"w-5 h-5"})})]})]}),a&&h.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[h.jsxs("button",{onClick:()=>a.has_model&&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:[h.jsx(Hx,{className:"w-4 h-4"}),"3D Model",!a.has_model&&h.jsx("span",{className:"text-xs",children:"(not available)"})]}),h.jsxs("button",{onClick:()=>a.has_gcode&&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:[h.jsx(pse,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&h.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),h.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?h.jsx("div",{className:"w-full h-full flex items-center justify-center",children:h.jsx(Ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?h.jsx(Jme,{url:Fe.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?h.jsx(r1e,{gcodeUrl:Fe.getArchiveGcode(t),buildVolume:a.build_volume,className:"w-full h-full"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function a1e({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,a]=E.useState(null);E.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const{data:s,isLoading:o}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),l=yt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Fe.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),c=s?.filter(u=>u.is_active)||[];return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:h.jsx(Yt,{className:"w-full max-w-md",children:h.jsxs(on,{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),h.jsx(ct,{variant:"ghost",size:"sm",onClick:n,children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",h.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?h.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):h.jsx("div",{className:"space-y-2 mb-6",children:c.map(u=>h.jsxs("button",{onClick:()=>a(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===u.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[h.jsx("div",{className:`p-2 rounded-lg ${i===u.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:h.jsx(mc,{className:`w-5 h-5 ${i===u.id?"text-bambu-green":"text-bambu-gray"}`})}),h.jsxs("div",{className:"text-left",children:[h.jsx("p",{className:"text-white font-medium",children:u.name}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.model||"Unknown model"," • ",u.ip_address]})]})]},u.id))}),l.isError&&h.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:l.error.message||"Failed to start print"}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx(ct,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(ct,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):h.jsxs(h.Fragment,{children:[h.jsx(mc,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function s1e({onClose:t,initialFiles:e}){const n=In(),{showToast:r}=eo(),i=E.useRef(null),[a,s]=E.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,l]=E.useState(!1),[c,u]=E.useState(),[f,g]=E.useState(null);E.useEffect(()=>{const N=j=>{j.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:m}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),y=yt({mutationFn:N=>Fe.uploadArchivesBulk(N,c),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(j=>j.map(C=>{const k=N.results.find(I=>I.filename===C.file.name),U=N.errors.find(I=>I.filename===C.file.name);return k?{...C,status:"success",archiveId:k.id}:U?{...C,status:"error",error:U.error}:C})),N.failed===0?r(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?r(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):r(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{s(N=>N.map(j=>({...j,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=E.useCallback(N=>{N.preventDefault(),l(!0)},[]),b=E.useCallback(N=>{N.preventDefault(),l(!1)},[]),x=E.useCallback(N=>{N.preventDefault(),l(!1);const j=Array.from(N.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));j.length>0&&s(C=>[...C,...j.map(k=>({file:k,status:"pending"}))])},[]),M=E.useCallback(N=>{const j=Array.from(N.target.files||[]).filter(C=>C.name.endsWith(".3mf"));j.length>0&&s(C=>[...C,...j.map(k=>({file:k,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=E.useCallback(N=>{s(j=>j.filter((C,k)=>k!==N))},[]),A=()=>{if(a.length===0)return;const N=a.filter(j=>j.status==="pending");N.length!==0&&(s(j=>j.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),y.mutate(N.map(j=>j.file)))},T=a.filter(N=>N.status==="pending").length,R=y.isPending;return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx(Yt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:h.jsxs(on,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),h.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"p-4",children:h.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:b,onDrop:x,children:[h.jsx(Gx,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),h.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),h.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),h.jsx(ct,{variant:"secondary",onClick:()=>i.current?.click(),disabled:R,children:"Browse Files"}),h.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),h.jsxs("div",{className:"px-4 pb-4",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),h.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c||"",onChange:N=>u(N.target.value?Number(N.target.value):void 0),disabled:R,children:[h.jsx("option",{value:"",children:"No printer"}),m?.map(N=>h.jsx("option",{value:N.id,children:N.name},N.id))]})]}),a.length>0&&h.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:h.jsx("div",{className:"space-y-2",children:a.map((N,j)=>h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[h.jsx(s9,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),h.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),h.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&h.jsx("button",{onClick:()=>w(j),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:R,children:h.jsx(mn,{className:"w-4 h-4"})}),N.status==="uploading"&&h.jsx(Ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&h.jsx(ld,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-red-400",children:N.error}),h.jsx(od,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${j}`))})}),f&&h.jsx("div",{className:"px-4 pb-4",children:h.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:h.jsxs("p",{className:"text-sm text-white",children:[h.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&h.jsxs(h.Fragment,{children:[", ",h.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),h.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[h.jsx(ct,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&h.jsx(ct,{onClick:A,disabled:T===0||R,className:"flex-1",children:R?h.jsxs(h.Fragment,{children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Gx,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const o1e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function l1e({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const K=Y=>{Y.key==="Escape"&&e()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[e]);const r=In(),[i,a]=E.useState(t.print_name||""),[s,o]=E.useState(t.printer_id),[l,c]=E.useState(t.notes||""),[u,f]=E.useState(t.tags||""),[g,m]=E.useState(t.failure_reason||""),[y,v]=E.useState(t.photos||[]),[b,x]=E.useState(!1),[M,w]=E.useState(!1),A=E.useRef(null),T=E.useRef(null),R=E.useRef(null),{data:N}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:j}=Ut({queryKey:["archives"],queryFn:()=>Fe.getArchives(void 0,1e3,0),enabled:n.length===0}),C=n.length>0?n:[...new Set(j?.flatMap(K=>K.tags?.split(",").map(Y=>Y.trim())||[]).filter(Boolean)||[])].sort(),k=u.split(",").map(K=>K.trim()).filter(Boolean),U=C.filter(K=>!k.includes(K)),I=K=>{if(!k.includes(K)){const Y=[...k,K].join(", ");f(Y)}R.current!==null&&clearTimeout(R.current),A.current?.focus()},H=K=>{const Y=k.filter(oe=>oe!==K).join(", ");f(Y)},O=yt({mutationFn:K=>Fe.updateArchive(t.id,K),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),e()}}),B=async K=>{const Y=K.target.files?.[0];if(Y){x(!0);try{const oe=await Fe.uploadArchivePhoto(t.id,Y);v(oe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(oe){console.error("Failed to upload photo:",oe)}finally{x(!1),T.current&&(T.current.value="")}}},V=async K=>{try{const Y=await Fe.deleteArchivePhoto(t.id,K);v(Y.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Y){console.error("Failed to delete photo:",Y)}},G=K=>{K.preventDefault(),O.mutate({print_name:i||void 0,printer_id:s,notes:l||void 0,tags:u||void 0,failure_reason:t.status==="failed"&&g||void 0})};return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:K=>K.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:G,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.jsx("input",{type:"text",value:i,onChange:K=>a(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),h.jsxs("select",{value:s??"",onChange:K=>o(K.target.value?Number(K.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"",children:"No printer"}),N?.map(K=>h.jsx("option",{value:K.id,children:K.name},K.id))]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),h.jsx("textarea",{value:l,onChange:K=>c(K.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),k.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:k.map(K=>h.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[h.jsx(Vx,{className:"w-3 h-3"}),K,h.jsx("button",{type:"button",onClick:()=>H(K),className:"ml-0.5 text-bambu-gray hover:text-white",children:h.jsx(mn,{className:"w-3 h-3"})})]},K))}),h.jsxs("div",{className:"relative",children:[h.jsx("input",{ref:A,type:"text",value:u,onChange:K=>f(K.target.value),onFocus:()=>{R.current!==null&&clearTimeout(R.current),w(!0)},onBlur:()=>{R.current=window.setTimeout(()=>w(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:k.length>0?"Add more tags...":"Add tags..."}),M&&U.length>0&&h.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[h.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),h.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:U.map(K=>h.jsx("button",{type:"button",onClick:()=>I(K),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:K},K))})]})]})]}),t.status==="failed"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),h.jsxs("select",{value:g,onChange:K=>m(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"",children:"Select reason..."}),o1e.map(K=>h.jsx("option",{value:K,children:K},K))]})]}),h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[h.jsx($_,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),h.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[y.map(K=>h.jsxs("div",{className:"relative group",children:[h.jsx("img",{src:Fe.getArchivePhotoUrl(t.id,K),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),h.jsx("button",{type:"button",onClick:()=>V(K),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:h.jsx(aa,{className:"w-3 h-3 text-white"})})]},K)),h.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[h.jsx("input",{ref:T,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:B,className:"hidden",disabled:b}),b?h.jsx(Ft,{className:"w-6 h-6 text-bambu-gray animate-spin"}):h.jsx(Jo,{className:"w-6 h-6 text-bambu-gray"})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(ct,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(ct,{type:"submit",disabled:O.isPending,className:"flex-1",children:[h.jsx(I0,{className:"w-4 h-4"}),O.isPending?"Saving...":"Save"]})]})]})]})})}function c1e({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null);return E.useEffect(()=>{const a=l=>{i.current&&!i.current.contains(l.target)&&r()},s=l=>{l.key==="Escape"&&r()},o=()=>{r()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",s),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s),document.removeEventListener("scroll",o,!0)}},[r]),E.useEffect(()=>{if(i.current){const a=i.current.getBoundingClientRect(),s=window.innerWidth,o=window.innerHeight;let l=t,c=e;t+a.width>s&&(l=s-a.width-8),e+a.height>o&&(c=o-a.height-8),i.current.style.left=`${l}px`,i.current.style.top=`${c}px`}},[t,e]),h.jsx("div",{ref:i,className:"fixed z-50 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden",style:{left:t,top:e},children:n.map((a,s)=>a.divider?h.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},s):h.jsxs("button",{onClick:()=>{a.disabled||(a.onClick(),r())},disabled:a.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${a.disabled?"text-bambu-gray cursor-not-allowed":a.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[a.icon&&h.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:a.icon}),a.label]},s))})}function u1e({selectedIds:t,existingTags:e,onClose:n}){const r=In(),{showToast:i}=eo(),[a,s]=E.useState(""),[o,l]=E.useState(new Set),[c,u]=E.useState("add");E.useEffect(()=>{const v=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=yt({mutationFn:async()=>{const v=Array.from(o);return await Promise.all(t.map(async b=>{const x=await Fe.getArchive(b),M=x.tags?x.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let w;return c==="add"?w=[...new Set([...M,...v])]:w=M.filter(A=>!o.has(A)),Fe.updateArchive(b,{tags:w.join(", ")})})),{count:t.length,mode:c,tags:v}},onSuccess:({count:v,mode:b,tags:x})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${b==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:()=>{i("Failed to update tags","error")}}),g=v=>{l(b=>{const x=new Set(b);return x.has(v)?x.delete(v):x.add(v),x})},m=()=>{a.trim()&&!o.has(a.trim())&&(l(v=>new Set([...v,a.trim()])),s(""))},y=v=>{v.key==="Enter"&&(v.preventDefault(),m())};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx(Yt,{className:"w-full max-w-md",children:h.jsxs(on,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Vx,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-4 space-y-4",children:[h.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ct,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>u("add"),children:"Add Tags"}),h.jsx(ct,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>u("remove"),children:"Remove Tags"})]}),c==="add"&&h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>s(v.target.value),onKeyDown:y}),h.jsx(ct,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:h.jsx(Jo,{className:"w-4 h-4"})})]}),e.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),h.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>h.jsx("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),o.size>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(v=>h.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${c==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,h.jsx("button",{onClick:()=>g(v),className:"hover:opacity-70",children:h.jsx(mn,{className:"w-3 h-3"})})]},v))})]})]}),h.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[h.jsx(ct,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(ct,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Vx,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function d1e(t,e){return new Date(t,e+1,0).getDate()}function f1e(t,e){return new Date(t,e,1).getDay()}const h1e=["January","February","March","April","May","June","July","August","September","October","November","December"],p1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function m1e({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[a,s]=E.useState(n.getFullYear()),[o,l]=E.useState(null),c=E.useMemo(()=>{const x=new Map;return t.forEach(M=>{const w=new Date(M.completed_at||M.created_at),A=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=x.get(A)||[];T.push(M),x.set(A,T)}),x},[t]),u=d1e(a,r),f=f1e(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},m=()=>{r===11?(i(0),s(a+1)):i(r+1)},y=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let x=0;x<f;x++)v.push(null);for(let x=1;x<=u;x++)v.push(x);const b=o?c.get(o)||[]:[];return h.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[h.jsxs("div",{className:"flex-1",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Af,{className:"w-5 h-5 text-bambu-gray"})}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("h2",{className:"text-lg font-semibold text-white",children:[h1e[r]," ",a]}),h.jsx("button",{onClick:y,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),h.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Wf,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:p1e.map(x=>h.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),h.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((x,M)=>{if(x===null)return h.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,A=c.get(w)||[],T=A.length>0,R=x===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),N=w===o,j=A.filter(k=>k.status==="completed").length,C=A.filter(k=>k.status==="failed").length;return h.jsxs("button",{onClick:()=>l(N?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":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:[h.jsx("span",{className:`text-sm font-medium ${R&&!N?"text-bambu-green":""}`,children:x}),T&&h.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[h.jsx("div",{className:`w-2 h-2 rounded-full ${C>0&&j===0?"bg-red-400":C>0?"bg-yellow-400":"bg-green-400"}`}),h.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},x)})}),h.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a}).length}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="completed"}).length}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="failed"}).length}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),h.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?h.jsxs(h.Fragment,{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),b.length>0?h.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:b.map(x=>h.jsxs("button",{onClick:()=>e?.(x),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[x.thumbnail_path?h.jsx("img",{src:Fe.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):h.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:h.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&h.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>h.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):h.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):h.jsx("div",{className:"text-center py-8",children:h.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function g1e({archiveId:t,archiveName:e,onClose:n}){const r=Fe.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const a=s=>{s.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 h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-6 flex flex-col items-center",children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),h.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:h.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),h.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),h.jsxs(ct,{onClick:i,className:"w-full",children:[h.jsx(Ku,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function x1e({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=E.useState(0),[o,l]=E.useState(!1);if(E.useEffect(()=>{const m=y=>{y.key==="Escape"&&r(),y.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),y.key==="ArrowRight"&&s(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const c=n[a],u=Fe.getArchivePhotoUrl(t,c),f=()=>{const m=document.createElement("a");m.href=u,m.download=`${e}_photo_${a+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return h.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[h.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ct,{variant:"secondary",size:"sm",onClick:f,children:[h.jsx(Ku,{className:"w-4 h-4"}),"Download"]}),i&&h.jsx(ct,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:h.jsx(aa,{className:"w-4 h-4"})}),h.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-6 h-6"})})]})]}),h.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&h.jsx("button",{onClick:()=>s(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:h.jsx(Af,{className:"w-8 h-8 text-white"})}),h.jsx("img",{src:u,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&h.jsx("button",{onClick:()=>s(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:h.jsx(Wf,{className:"w-8 h-8 text-white"})})]}),n.length>1&&h.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,y)=>h.jsx("button",{onClick:()=>s(y),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${y===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:h.jsx("img",{src:Fe.getArchivePhotoUrl(t,m),alt:`Thumbnail ${y+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&h.jsx(ii,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(c),l(!1)},onCancel:()=>l(!1)})]})}function Bi(t){this.content=t}Bi.prototype={constructor:Bi,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 Bi(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 Bi(n)},addToStart:function(t,e){return new Bi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Bi(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 Bi(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=Bi.from(t),t.size?new Bi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Bi.from(t),t.size?new Bi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Bi.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}};Bi.from=function(t){if(t instanceof Bi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Bi(e)};function $W(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 s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=$W(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function VW(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 s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let c=0,u=Math.min(s.text.length,o.text.length);for(;c<u&&s.text[s.text.length-c-1]==o.text[o.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let c=VW(s.content,o.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class ht{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 s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;if(c>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let u=o+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let c=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=c},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 ht(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,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new ht(r,i)}cutByIndex(e,n){return e==n?ht.empty:e==0&&n==this.content.length?this:new ht(this.content.slice(e,n))}replaceChild(e,n){let 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 ht(i,a)}addToStart(e){return new ht([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ht(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return $W(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return VW(this,e,n,r)}findIndex(e){if(e==0)return Dy(0,e);if(e==this.size)return Dy(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?Dy(n+1,a):Dy(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 ht.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ht(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ht.empty;let n,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 ht(n||e,r)}static from(e){if(!e)return ht.empty;if(e instanceof ht)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ht([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ht.empty=new ht([],0);const r2={index:0,offset:0};function Dy(t,e){return r2.index=t,r2.offset=e,r2}function l1(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(!l1(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!l1(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Kn=class B3{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&&l1(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 B3.none;if(e instanceof B3)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Kn.none=[];class c1 extends Error{}class Et{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=WW(this.content,e+this.openStart,n);return r&&new Et(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Et(GW(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 Et.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 Et(ht.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 Et(e,r,i)}}Et.empty=new Et(ht.empty,0,0);function GW(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(GW(a.content,e-i-1,n-i-1)))}function WW(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=WW(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function v1e(t,e,n){if(n.openStart>t.depth)throw new c1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new c1("Inconsistent open depths");return qW(t,e,n,0)}function qW(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=qW(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return pf(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=b1e(n,t);return pf(a,KW(t,s,o,e,r))}else return pf(a,u1(t,e,r))}function XW(t,e){if(!e.type.compatibleContent(t.type))throw new c1("Cannot join "+e.type.name+" onto "+t.type.name)}function H3(t,e,n){let r=t.node(n);return XW(r,e.node(n)),r}function hf(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 Sx(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(hf(t.nodeAfter,r),a++));for(let o=a;o<s;o++)hf(i.child(o),r);e&&e.depth==n&&e.textOffset&&hf(e.nodeBefore,r)}function pf(t,e){return t.type.checkContent(e),t.copy(e)}function KW(t,e,n,r,i){let a=t.depth>i&&H3(t,e,i+1),s=r.depth>i&&H3(n,r,i+1),o=[];return Sx(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(XW(a,s),hf(pf(a,KW(t,e,n,r,i+1)),o)):(a&&hf(pf(a,u1(t,e,i+1)),o),Sx(e,n,i,o),s&&hf(pf(s,u1(n,r,i+1)),o)),Sx(r,null,i,o),new ht(o)}function u1(t,e,n){let r=[];if(Sx(null,t,n,r),t.depth>n){let i=H3(t,e,n+1);hf(pf(i,u1(t,e,n+1)),r)}return Sx(e,null,n,r),new ht(r)}function b1e(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(ht.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class r0{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 Kn.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].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 d1(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 s=e;;){let{index:o,offset:l}=s.content.findIndex(a),c=a-l;if(r.push(s,o,i+l),!c||(s=s.child(o),s.isText))break;a=c-1,i+=l+1}return new r0(n,r,a)}static resolveCached(e,n){let r=iB.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else iB.set(e,r=new y1e);let i=r.elts[r.i]=r0.resolve(e,n);return r.i=(r.i+1)%_1e,i}}class y1e{constructor(){this.elts=[],this.i=0}}const _1e=12,iB=new WeakMap;class d1{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 S1e=Object.create(null);let Vu=class $3{constructor(e,n,r,i=Kn.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||ht.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,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&&l1(this.attrs,n||e.defaultAttrs||S1e)&&Kn.sameSet(this.marks,r||Kn.none)}copy(e=null){return e==this.content?this:new $3(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new $3(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 Et.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),c=i.node(s).content.cut(i.pos-o,a.pos-o);return new Et(c,i.depth-s,a.depth-s)}replace(e,n,r){return v1e(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 r0.resolveCached(this,e)}resolveNoCache(e){return r0.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()+")"),YW(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=ht.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).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),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Kn.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Kn.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let 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=ht.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Vu.prototype.text=void 0;class f1 extends Vu{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):YW(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 f1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new f1(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 YW(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Df{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new w1e(e,n);if(r.next==null)return Df.empty;let i=ZW(r);r.next&&r.err("Unexpected trailing text");let a=R1e(N1e(i));return P1e(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(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return ht.from(o.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,o.concat(u));if(g)return g}}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 s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(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 s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
  8060. `)}}Df.empty=new Df(!0);class w1e{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 ZW(t){let e=[];do e.push(M1e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function M1e(t){let e=[];do e.push(E1e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E1e(t){let e=C1e(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=A1e(t,e);else break;return e}function aB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function A1e(t,e){let n=aB(t),r=n;return t.eat(",")&&(t.next!="}"?r=aB(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function T1e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function C1e(t){if(t.eat("(")){let e=ZW(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=T1e(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 N1e(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let c={term:l,to:o};return e[s].push(c),c}function i(s,o){s.forEach(l=>l.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(a(c,o)),[]);if(s.type=="seq")for(let l=0;;l++){let c=a(s.exprs[l],o);if(l==s.exprs.length-1)return c;i(c,o=n())}else if(s.type=="star"){let l=n();return r(o,l),i(a(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(a(s.expr,o),l),i(a(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let l=o;for(let c=0;c<s.min;c++){let u=n();i(a(s.expr,l),u),l=u}if(s.max==-1)i(a(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=n();r(l,u),i(a(s.expr,l),u),l=u}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function QW(t,e){return e-t}function sB(t,e){let n=[];return r(e),n.sort(QW);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:l}=a[s];!o&&n.indexOf(l)==-1&&r(l)}}}function R1e(t){let e=Object.create(null);return n(sB(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let u=0;u<i.length;u++)i[u][0]==o&&(c=i[u][1]);sB(t,l).forEach(u=>{c||i.push([o,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let a=e[r.join(",")]=new Df(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(QW);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function P1e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:l,next:c}=i.next[o];s.push(l.name),a&&!(l.isText||l.hasRequiredAttrs())&&(a=!1),r.indexOf(c)==-1&&r.push(c)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function JW(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 e7(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 t7(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 n7(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new D1e(t,r,e[r]);return n}let oB=class r7{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=n7(e,r.attrs),this.defaultAttrs=JW(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==Df.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:e7(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Vu(this,this.computeAttrs(e),ht.from(n),Kn.setFrom(r))}createChecked(e=null,n,r){return n=ht.from(n),this.checkContent(n),new Vu(this,this.computeAttrs(e),n,Kn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ht.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(ht.empty,!0);return a?new Vu(this,e,n.append(a),Kn.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){t7(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:Kn.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new r7(a,n,s));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 k1e(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 D1e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?k1e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class hw{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=n7(e,i.attrs),this.excluded=null;let a=JW(this.attrs);this.instance=a?new Kn(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Kn(this,e7(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new hw(a,i++,n,s)),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){t7(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class i7{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=Bi.from(e.nodes),n.marks=Bi.from(e.marks||{}),this.nodes=oB.compile(this.spec.nodes,this),this.marks=hw.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],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=Df.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?lB(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:lB(this,s.split(" "))}this.nodeFromJSON=i=>Vu.fromJSON(this,i),this.markFromJSON=i=>Kn.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 oB){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 f1(r,r.defaultAttrs,e,Kn.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function lB(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function O1e(t){return t.tag!=null}function L1e(t){return t.style!=null}let wx=class V3{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(O1e(i))this.tags.push(i);else if(L1e(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 uB(this,n,!1);return r.addAll(e,Kn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new uB(this,n,!0);return r.addAll(e,Kn.none,n.from,n.to),Et.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(U1e(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=dB(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=dB(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new V3(e,V3.schemaRules(e)))}};const a7={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},I1e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},s7={ol:!0,ul:!0},i0=1,G3=2,Mx=4;function cB(t,e,n){return e!=null?(e?i0:0)|(e==="full"?G3:0):t&&t.whitespace=="pre"?i0|G3:n&~Mx}class Oy{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=Kn.none,this.match=a||(s&Mx?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ht.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let 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&i0)){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=ht.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ht.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!a7.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class uB{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=cB(null,n.preserveWhitespace,0)|(r?Mx:0);i?a=new Oy(i.type,i.attrs,Kn.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new Oy(null,null,Kn.none,!0,null,s):a=new Oy(e.schema.topNodeType,null,Kn.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&G3?"full":this.localPreserveWS||(i.options&i0)>0,{schema:s}=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,`
  8061. `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));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 o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.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 s=e.nodeName.toLowerCase(),o;s7.hasOwnProperty(s)&&this.parser.normalizeLists&&j1e(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:I1e.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(a7.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),c=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(a),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8062. `),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],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(a,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(a=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.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(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+o)&&(i=c,a=l,!c.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],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 s=Kn.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):fB(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!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 s=this.top;s.match=s.match&&s.match.matchType(e);let o=cB(e,a,s.options);s.options&Mx&&s.content.length==0&&(o|=Mx);let l=Kn.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):fB(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Oy(e,n,l,i,null,o)),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|=i0)}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),s=(o,l)=>{for(;o>=0;o--){let c=n[o];if(c==""){if(o==n.length-1||o==0)continue;for(;l>=a;l--)if(s(o-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=a?r.node(l-a).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let 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 j1e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&s7.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function U1e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dB(t){let e={};for(let n in t)e[n]=t[n];return e}function fB(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let l=0;l<o.edgeCount;l++){let{type:c,next:u}=o.edge(l);if(c==e||a.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class Kf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=i2(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,l=0;for(;o<a.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(a[o][0])||c.type.spec.spanning===!1)break;o++,l++}for(;o<a.length;)i=a.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],u=this.serializeMark(c,s.isInline,n);u&&(a.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=E_(i2(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&&E_(i2(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return E_(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Kf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hB(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hB(e.marks)}}function hB(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function i2(t){return t.document||window.document}const pB=new WeakMap;function F1e(t){let e=pB.get(t);return e===void 0&&pB.set(t,e=z1e(t)),e}function z1e(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 E_(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=F1e(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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let g=f.indexOf(" ");g>0?l.setAttributeNS(f.slice(0,g),f.slice(g+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:y}=E_(t,g,n,r);if(l.appendChild(m),y){if(o)throw new RangeError("Multiple content holes");o=y}}}return{dom:l,contentDOM:o}}const o7=65535,l7=Math.pow(2,16);function B1e(t,e){return t+e*l7}function mB(t){return t&o7}function H1e(t){return(t-(t&o7))/l7}const c7=1,u7=2,A_=4,d7=8;class W3{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&d7)>0}get deletedBefore(){return(this.delInfo&(c7|A_))>0}get deletedAfter(){return(this.delInfo&(u7|A_))>0}get deletedAcross(){return(this.delInfo&A_)>0}}class cs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&cs.empty)return cs.empty}recover(e){let n=0,r=mB(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+H1e(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,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[o+a],u=this.ranges[o+s],f=l+c;if(e<=f){let g=c?e==l?-1:e==f?1:n:n,m=l+i+(g<0?0:u);if(r)return m;let y=e==(n<0?l:f)?null:B1e(o/3,e-l),v=e==l?u7:e==f?c7:A_;return(n<0?e!=l:e!=f)&&(v|=d7),new W3(m,v,y)}i+=u-c}return r?e+i:new W3(e+i,0,null)}touches(e,n){let r=0,i=mB(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[o+a],u=l+c;if(e<=u&&o==i*3)return!0;r+=this.ranges[o+s]-c}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 s=this.ranges[i],o=s-(this.inverted?a:0),l=s+(this.inverted?0:a),c=this.ranges[i+n],u=this.ranges[i+r];e(o,o+c,l,l+u),a+=u-c}}invert(){return new cs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?cs.empty:new cs(e<0?[0,-e,0]:[0,0,e])}}cs.empty=new cs([]);class a0{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 a0(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 a0;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 s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(a);if(l!=null&&l>a&&l<this.to){a=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new W3(e,i,null)}}const a2=Object.create(null);let la=class{getMap(){return cs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=a2[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 a2)throw new RangeError("Duplicate use of step JSON ID "+e);return a2[e]=n,n.prototype.jsonID=e,n}};class Vr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Vr(e,null)}static fail(e){return new Vr(null,e)}static fromReplace(e,n,r,i){try{return Vr.ok(e.replace(n,r,i))}catch(a){if(a instanceof c1)return Vr.fail(a.message);throw a}}}function yk(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(yk(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return ht.fromArray(r)}class Iu extends la{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 Et(yk(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Vr.fromReplace(e,this.from,this.to,a)}invert(){return new So(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 Iu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Iu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Iu(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 Iu(n.from,n.to,e.markFromJSON(n.mark))}}la.jsonID("addMark",Iu);class So extends la{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 Et(yk(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Vr.fromReplace(e,this.from,this.to,r)}invert(){return new Iu(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 So(n.pos,r.pos,this.mark)}merge(e){return e instanceof So&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new So(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 So(n.from,n.to,e.markFromJSON(n.mark))}}la.jsonID("removeMark",So);class ju extends la{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Vr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Vr.fromReplace(e,this.pos,this.pos+1,new Et(ht.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 ju(this.pos,n.marks[i]);return new ju(this.pos,this.mark)}}return new Of(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ju(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 ju(n.pos,e.markFromJSON(n.mark))}}la.jsonID("addNodeMark",ju);class Of extends la{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Vr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Vr.fromReplace(e,this.pos,this.pos+1,new Et(ht.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ju(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Of(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 Of(n.pos,e.markFromJSON(n.mark))}}la.jsonID("removeNodeMark",Of);class Ai extends la{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&q3(e,this.from,this.to)?Vr.fail("Structure replace would overwrite content"):Vr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new cs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ai(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 Ai(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ai)||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?Et.empty:new Et(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ai(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?Et.empty:new Et(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ai(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 Ai(n.from,n.to,Et.fromJSON(e,n.slice),!!n.structure)}}la.jsonID("replace",Ai);class Ci extends la{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(q3(e,this.from,this.gapFrom)||q3(e,this.gapTo,this.to)))return Vr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Vr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Vr.fromReplace(e,this.from,this.to,r):Vr.fail("Content does not fit in gap")}getMap(){return new cs([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 Ci(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 Ci(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 Ci(n.from,n.to,n.gapFrom,n.gapTo,Et.fromJSON(e,n.slice),n.insert,!!n.structure)}}la.jsonID("replaceAround",Ci);function q3(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 s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function $1e(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let g=Math.max(c,e),m=Math.min(c+l.nodeSize,n),y=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(y)||(s&&s.to==g&&s.mark.eq(f[v])?s.to=m:i.push(s=new So(g,m,f[v])));o&&o.to==g?o.to=m:a.push(o=new Iu(g,m,r))}}),i.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function V1e(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let l=null;if(r instanceof hw){let c=s.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(o+s.nodeSize,n);for(let u=0;u<l.length;u++){let f=l[u],g;for(let m=0;m<i.length;m++){let y=i[m];y.step==a-1&&f.eq(i[m].style)&&(g=y)}g?(g.to=c,g.step=a):i.push({style:f,from:Math.max(o,e),to:c,step:a})}}}),i.forEach(s=>t.step(new So(s.from,s.to,s.style)))}function _k(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<a.childCount;l++){let c=a.child(l),u=o+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new Ai(o,u,Et.empty));else{r=f;for(let g=0;g<c.marks.length;g++)n.allowsMarkType(c.marks[g].type)||t.step(new So(o,u,c.marks[g]));if(i&&c.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,y;for(;g=m.exec(c.text);)y||(y=new Et(ht.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ai(o+g.index,o+g.index+g[0].length,y))}}o=u}if(!r.validEnd){let l=r.fillBefore(ht.empty,!0);t.replace(o,o,new Et(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function G1e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Am(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,l,n))return r;if(r==0||s.type.spec.isolating||!G1e(s,o,l))break;o&&(i=1),l<s.childCount&&(a=1)}return null}function W1e(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),l=s,c=o,u=ht.empty,f=0;for(let y=a,v=!1;y>n;y--)v||r.index(y)>0?(v=!0,u=ht.from(r.node(y).copy(u)),f++):l--;let g=ht.empty,m=0;for(let y=a,v=!1;y>n;y--)v||i.after(y+1)<i.end(y)?(v=!0,g=ht.from(i.node(y).copy(g)),m++):c++;t.step(new Ci(l,c,s,o,new Et(u.append(g),f,m),u.size-f,!0))}function Sk(t,e,n=null,r=t){let i=q1e(t,e),a=i&&X1e(r,e);return a?i.map(gB).concat({type:e,attrs:n}).concat(a.map(gB)):null}function gB(t){return{type:t,attrs:null}}function q1e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function X1e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function K1e(t,e,n){let r=ht.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ht.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ci(i,a,i,a,new Et(r,0,0),n.length,!0))}function Y1e(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,(s,o)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&Z1e(t.doc,t.mapping.slice(a).map(o),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",y=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!y?c=!1:!m&&y&&(c=!0)}c===!1&&h7(t,s,o,a),_k(t,t.mapping.slice(a).map(o,1),r,void 0,c===null);let u=t.mapping.slice(a),f=u.map(o,1),g=u.map(o+s.nodeSize,1);return t.step(new Ci(f,g,f+1,g-1,new Et(ht.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&f7(t,s,o,a),!1}})}function f7(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function h7(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
  8063. `))}})}function Z1e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Q1e(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 s=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ci(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Et(ht.from(s),0,0),1,!0))}function uc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,s=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>a;c--,u--){let f=i.node(c),g=i.index(c);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(g,f.childCount),y=r&&r[u+1];y&&(m=m.replaceChild(0,y.type.create(y.attrs)));let v=r&&r[u]||f;if(!f.canReplace(g+1,f.childCount)||!v.type.validContent(m))return!1}let o=i.indexAfter(a),l=r&&r[0];return i.node(a).canReplaceWith(o,o,l?l.type:i.node(a+1).type)}function J1e(t,e,n=1,r){let i=t.doc.resolve(e),a=ht.empty,s=ht.empty;for(let o=i.depth,l=i.depth-n,c=n-1;o>l;o--,c--){a=ht.from(i.node(o).copy(a));let u=r&&r[c];s=ht.from(u?u.type.create(u.attrs,s):i.node(o).copy(s))}t.step(new Ai(e,e,new Et(a.append(s),n,n),!0))}function cd(t,e){let n=t.resolve(e),r=n.index();return p7(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function eSe(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),s=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function p7(t,e){return!!(t&&e&&!t.isLeaf&&eSe(t,e))}function pw(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,o=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),o++,s=r.node(i).maybeChild(o)):(a=r.node(i).maybeChild(o-1),s=r.node(i+1)),a&&!a.isTextblock&&p7(a,s)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function tSe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);h7(t,u.node(),u.before(),o)}s.inlineContent&&_k(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let l=t.mapping.slice(o),c=l.map(e-n);if(t.step(new Ai(c,l.map(e+n,-1),Et.empty,!0)),r===!0){let u=t.doc.resolve(c);f7(t,u.node(),u.before(),t.steps.length)}return t}function nSe(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 m7(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 s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(o>0?1:0),c=r.node(s),u=!1;if(a==1)u=c.canReplace(l,l,i);else{let f=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(l,l,f[0])}if(u)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function mw(t,e,n=e,r=Et.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return g7(i,a,r)?new Ai(e,n,r):new rSe(i,a,r).fit()}function g7(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class rSe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ht.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=ht.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,s=r.depth,o=i.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let l=new Et(a,s,o);return e>-1?new Ci(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ai(r.pos,i.pos,l):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=s2(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:c}=this.frontier[o],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(ht.from(s),!1)):a&&l.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:a,wrap:u};if(a&&c.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=s2(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Et(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=s2(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Et(cx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Et(cx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-e,c=0,u=[],{match:f,type:g}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)u.push(i.child(v));f=f.matchFragment(i)}let m=o.size+e-(s.content.size-s.openEnd);for(;c<o.childCount;){let v=o.child(c),b=f.matchType(v.type);if(!b)break;c++,(c>1||l==0||v.content.size)&&(f=b,u.push(x7(v.mark(g.allowedMarks(v.marks)),c==1?l:0,c==o.childCount?m:-1)))}let y=c==o.childCount;y||(m=-1),this.placed=ux(this.placed,n,ht.from(u)),this.frontier[n].match=f,y&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,b=o;v<m;v++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=y?e==0?Et.empty:new Et(cx(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new Et(cx(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!o2(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)),s=o2(e,n,i,r,a);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],u=o2(e,o,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ux(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=ux(this.placed,this.depth,ht.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ht.empty,!0);n.childCount&&(this.placed=ux(this.placed,this.frontier.length,n))}}function cx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(cx(t.firstChild.content,e-1,n)))}function ux(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ux(t.lastChild.content,e-1,n)))}function s2(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function x7(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,x7(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(ht.empty,!0)))),t.copy(r)}function o2(t,e,n,r,i){let a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=r.fillBefore(a.content,!0,s);return o&&!iSe(n,a.content,s)?o:null}function iSe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function aSe(t){return t.spec.defining||t.spec.definingForContent}function sSe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(g7(i,a,r))return t.step(new Ai(e,n,r));let s=b7(i,a);s[s.length-1]==0&&s.pop();let o=-(i.depth+1);s.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let y=i.node(g).type.spec;if(y.defining||y.definingAsContext||y.isolating)break;s.indexOf(g)>-1?o=g:i.before(g)==m&&s.splice(1,0,-g)}let l=s.indexOf(o),c=[],u=r.openStart;for(let g=r.content,m=0;;m++){let y=g.firstChild;if(c.push(y),m==r.openStart)break;g=y.content}for(let g=u-1;g>=0;g--){let m=c[g],y=aSe(m.type);if(y&&!m.sameMarkup(i.node(Math.abs(o)-1)))u=g;else if(y||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+u+1)%(r.openStart+1),y=c[m];if(y)for(let v=0;v<s.length;v++){let b=s[(v+l)%s.length],x=!0;b<0&&(x=!1,b=-b);let M=i.node(b-1),w=i.index(b-1);if(M.canReplaceWith(w,w,y.type,y.marks))return t.replace(i.before(b),x?a.after(b):n,new Et(v7(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let m=s[g];m<0||(e=i.before(m),n=a.after(m))}}function v7(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(v7(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(ht.empty,!0))}return t}function oSe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=nSe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Et(ht.from(r),0,0))}function lSe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=b7(r,i);for(let s=0;s<a.length;s++){let o=a[s],l=s==a.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function b7(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 Ip extends la{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 Vr.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 Vr.fromReplace(e,this.pos,this.pos+1,new Et(ht.from(i),0,n.isLeaf?0:1))}getMap(){return cs.empty}invert(e){return new Ip(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 Ip(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 Ip(n.pos,n.attr,n.value)}}la.jsonID("attr",Ip);class s0 extends la{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 Vr.ok(r)}getMap(){return cs.empty}invert(e){return new s0(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 s0(n.attr,n.value)}}la.jsonID("docAttr",s0);let tm=class extends Error{};tm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};tm.prototype=Object.create(Error.prototype);tm.prototype.constructor=tm;tm.prototype.name="TransformError";class y7{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new a0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new tm(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Et.empty){let i=mw(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Et(ht.from(r),0,0))}delete(e,n){return this.replace(e,n,Et.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return sSe(this,e,n,r),this}replaceRangeWith(e,n,r){return oSe(this,e,n,r),this}deleteRange(e,n){return lSe(this,e,n),this}lift(e,n){return W1e(this,e,n),this}join(e,n=1){return tSe(this,e,n),this}wrap(e,n){return K1e(this,e,n),this}setBlockType(e,n=e,r,i=null){return Y1e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Q1e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Ip(e,n,r)),this}setDocAttribute(e,n){return this.step(new s0(e,n)),this}addNodeMark(e,n){return this.step(new ju(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 Kn)n.isInSet(r.marks)&&this.step(new Of(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new Of(e,a)),i=a.removeFromSet(i);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return J1e(this,e,n,r),this}addMark(e,n,r){return $1e(this,e,n,r),this}removeMark(e,n,r){return V1e(this,e,n,r),this}clearIncompatible(e,n,r){return _k(this,e,n,r),this}}const l2=Object.create(null);class sn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cSe(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=Et.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:c}=s[o],u=e.mapping.slice(a);e.replaceRange(u.map(l.pos),u.map(c.pos),o?Et.empty:n),o==0&&bB(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:s,$to:o}=i[a],l=e.mapping.slice(r),c=l.map(s.pos),u=l.map(o.pos);a?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),bB(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Vt(e):xp(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 s=n<0?xp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):xp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ps(e.node(0))}static atStart(e){return xp(e,e,0,0,1)||new ps(e)}static atEnd(e){return xp(e,e,e.content.size,e.childCount,-1)||new ps(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=l2[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 l2)throw new RangeError("Duplicate use of selection JSON ID "+e);return l2[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Vt.between(this.$anchor,this.$head).getBookmark()}}sn.prototype.visible=!0;class cSe{constructor(e,n){this.$from=e,this.$to=n}}let xB=!1;function vB(t){!xB&&!t.parent.inlineContent&&(xB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Vt extends sn{constructor(e,n=e){vB(e),vB(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 sn.near(r);let i=e.resolve(n.map(this.anchor));return new Vt(i.parent.inlineContent?i:r,r)}replace(e,n=Et.empty){if(super.replace(e,n),n==Et.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Vt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new gw(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 Vt(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=sn.findFrom(n,r,!0)||sn.findFrom(n,-r,!0);if(a)n=a.$head;else return sn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(sn.findFrom(e,-r,!0)||sn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Vt(e,n)}}sn.jsonID("text",Vt);class gw{constructor(e,n){this.anchor=e,this.head=n}map(e){return new gw(e.map(this.anchor),e.map(this.head))}resolve(e){return Vt.between(e.resolve(this.anchor),e.resolve(this.head))}}class zt extends sn{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?sn.near(a):new zt(a)}content(){return new Et(ht.from(this.node),0,0)}eq(e){return e instanceof zt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new wk(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new zt(e.resolve(n.anchor))}static create(e,n){return new zt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}zt.prototype.visible=!1;sn.jsonID("node",zt);class wk{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new gw(r,r):new wk(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&zt.isSelectable(r)?new zt(n):sn.near(n)}}class ps extends sn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Et.empty){if(n==Et.empty){e.delete(0,e.doc.content.size);let r=sn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ps(e)}map(e){return new ps(e)}eq(e){return e instanceof ps}getBookmark(){return uSe}}sn.jsonID("all",ps);const uSe={map(){return this},resolve(t){return new ps(t)}};function xp(t,e,n,r,i,a=!1){if(e.inlineContent)return Vt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let o=e.child(s);if(o.isAtom){if(!a&&zt.isSelectable(o))return zt.create(t,n-(i<0?o.nodeSize:0))}else{let l=xp(t,o,n+i,i<0?o.childCount:0,i,a);if(l)return l}n+=o.nodeSize*i}return null}function bB(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ai||i instanceof Ci))return;let a=t.mapping.maps[r],s;a.forEach((o,l,c,u)=>{s==null&&(s=u)}),t.setSelection(sn.near(t.doc.resolve(s),n))}const yB=1,Ly=2,_B=4;class dSe extends y7{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|yB)&~Ly,this.storedMarks=null,this}get selectionSet(){return(this.updated&yB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ly,this}ensureMarks(e){return Kn.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ly)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ly,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)||Kn.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 s=this.doc.resolve(n);a=r==n?s.marks():s.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(sn.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|=_B,this}get scrolledIntoView(){return(this.updated&_B)>0}}function SB(t,e){return!e||!t?t:t.bind(e)}class dx{constructor(e,n,r){this.name=e,this.init=SB(n.init,r),this.apply=SB(n.apply,r)}}const fSe=[new dx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new dx("selection",{init(t,e){return t.selection||sn.atStart(e.doc)},apply(t){return t.selection}}),new dx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new dx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class c2{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fSe.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 dx(r.key,r.spec.state,r))})}}class Ep{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 s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,u=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),a=!0}i&&(i[s]={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 Ep(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 dSe(this)}static create(e){let n=new c2(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ep(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 c2(this.schema,e.plugins),r=n.fields,i=new Ep(n);for(let a=0;a<r.length;a++){let s=r[a].name;i[s]=this.hasOwnProperty(s)?this[s]: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 c2(e.schema,e.plugins),a=new Ep(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=Vu.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=sn.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=c.fromJSON.call(l,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function _7(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=_7(i,e,{})),n[r]=i}return n}class xr{constructor(e){this.spec=e,this.props={},e.props&&_7(e.props,this,this.props),this.key=e.key?e.key.key:S7("plugin")}getState(e){return e[this.key]}}const u2=Object.create(null);function S7(t){return t in u2?t+"$"+ ++u2[t]:(u2[t]=0,t+"$")}class ci{constructor(e="key"){this.key=S7(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Mk=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function w7(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const M7=(t,e,n)=>{let r=w7(t,n);if(!r)return!1;let i=Ek(r);if(!i){let s=r.blockRange(),o=s&&Am(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=i.nodeBefore;if(D7(t,i,e,-1))return!0;if(r.parent.content.size==0&&(nm(a,"end")||zt.isSelectable(a)))for(let s=r.depth;;s--){let o=mw(t.doc,r.before(s),r.after(s),Et.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(nm(a,"end")?sn.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):zt.create(l.doc,i.pos-a.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-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},hSe=(t,e,n)=>{let r=w7(t,n);if(!r)return!1;let i=Ek(r);return i?E7(t,i,e):!1},pSe=(t,e,n)=>{let r=T7(t,n);if(!r)return!1;let i=Ak(r);return i?E7(t,i,e):!1};function E7(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 u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,o=s,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let u=o.firstChild;if(!u)return!1;o=u}let c=mw(t.doc,a,l,Et.empty);if(!c||c.from!=a||c instanceof Ai&&c.slice.size>=l-a)return!1;if(n){let u=t.tr.step(c);u.setSelection(Vt.create(u.doc,a)),n(u.scrollIntoView())}return!0}function nm(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 A7=(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=Ek(r)}let s=a&&a.nodeBefore;return!s||!zt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(zt.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function Ek(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 T7(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const C7=(t,e,n)=>{let r=T7(t,n);if(!r)return!1;let i=Ak(r);if(!i)return!1;let a=i.nodeAfter;if(D7(t,i,e,1))return!0;if(r.parent.content.size==0&&(nm(a,"start")||zt.isSelectable(a))){let s=mw(t.doc,r.before(),r.after(),Et.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(nm(a,"start")?sn.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):zt.create(o.doc,o.mapping.map(i.pos))),e(o.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},N7=(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=Ak(r)}let s=a&&a.nodeAfter;return!s||!zt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(zt.create(t.doc,a.pos)).scrollIntoView()),!0)};function Ak(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 mSe=(t,e)=>{let n=t.selection,r=n instanceof zt,i;if(r){if(n.node.isTextblock||!cd(t.doc,n.from))return!1;i=n.from}else if(i=pw(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(zt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},gSe=(t,e)=>{let n=t.selection,r;if(n instanceof zt){if(n.node.isTextblock||!cd(t.doc,n.to))return!1;r=n.to}else if(r=pw(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},xSe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Am(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},R7=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8064. `).scrollIntoView()),!0)};function Tk(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 vSe=(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),s=Tk(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(sn.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},P7=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof ps||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Tk(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Vt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},k7=(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(uc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Am(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function bSe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof zt&&e.selection.node.isBlock)return!r.parentOffset||!uc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,o,l=!1,c=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),c=r.start(m)==r.pos-(r.depth-m),o=Tk(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(l&&o?{type:o}:null),s=m;break}else{if(m==1)return!1;a.unshift(null)}let u=e.tr;(e.selection instanceof Vt||e.selection instanceof ps)&&u.deleteSelection();let f=u.mapping.map(r.pos),g=uc(u.doc,f,a.length,a);if(g||(a[0]=o?{type:o}:null,g=uc(u.doc,f,a.length,a)),!g)return!1;if(u.split(f,a.length,a),!l&&c&&r.node(s).type!=o){let m=u.mapping.map(r.before(s)),y=u.doc.resolve(m);o&&r.node(s-1).canReplaceWith(y.index(),y.index()+1,o)&&u.setNodeMarkup(u.mapping.map(r.before(s)),o)}return n&&n(u.scrollIntoView()),!0}}const ySe=bSe(),_Se=(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(zt.create(t.doc,i))),!0)};function SSe(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||cd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function D7(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,o,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&SSe(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,y=ht.empty;for(let x=s.length-1;x>=0;x--)y=ht.from(s[x].create(null,y));y=ht.from(i.copy(y));let v=t.tr.step(new Ci(e.pos-1,m,e.pos,m,new Et(y,1,0),s.length,!0)),b=v.doc.resolve(m+2*s.length);b.nodeAfter&&b.nodeAfter.type==i.type&&cd(v.doc,b.pos)&&v.join(b.pos),n(v.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&l?null:sn.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),g=f&&Am(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(c&&nm(a,"start",!0)&&nm(i,"end")){let m=i,y=[];for(;y.push(m),!m.isTextblock;)m=m.lastChild;let v=a,b=1;for(;!v.isTextblock;v=v.firstChild)b++;if(m.canReplace(m.childCount,m.childCount,v.content)){if(n){let x=ht.empty;for(let w=y.length-1;w>=0;w--)x=ht.from(y[w].copy(x));let M=t.tr.step(new Ci(e.pos-y.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Et(x,y.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function O7(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(Vt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const wSe=O7(-1),MSe=O7(1);function ESe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),o=s&&Sk(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function wB(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];a.setBlockType(o,l,t,e)}r(a.scrollIntoView())}return!0}}function Ck(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Ck(Mk,M7,A7);Ck(Mk,C7,N7);Ck(R7,P7,k7,ySe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ASe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let o=r?n.tr:null;return TSe(o,s,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function TSe(t,e,n,r=null){let i=!1,a=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);a=new d1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new d1(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=Sk(a,n,r,e);return o?(t&&CSe(t,e,o,i,n),!0):!1}function CSe(t,e,n,r,i){let a=ht.empty;for(let u=n.length-1;u>=0;u--)a=ht.from(n[u].type.create(n[u].attrs,a));t.step(new Ci(e.start-(r?2:0),e.end,e.start,e.end,new Et(a,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let o=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,g=!0;u<f;u++,g=!1)!g&&uc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(u).nodeSize;return t}function NSe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?RSe(e,n,t,a):PSe(e,n,a):!0:!1}}function RSe(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Ci(a-1,s,a,s,new Et(ht.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new d1(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const o=Am(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(a,-1)-1);return cd(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function PSe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,y=n.endIndex-1,v=n.startIndex;y>v;y--)m-=i.child(y).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==i.childCount,c=a.node(-1),u=a.index(-1);if(!c.canReplace(u+(o?0:1),u+1,s.content.append(l?ht.empty:ht.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Ci(f-(o?1:0),g+(l?1:0),f+1,g-1,new Et((o?ht.empty:ht.from(i.copy(ht.empty))).append(l?ht.empty:ht.from(i.copy(ht.empty))),o?0:1,l?0:1),o?0:1)),e(r.scrollIntoView()),!0}function kSe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let o=a.parent,l=o.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==o.type,u=ht.from(c?t.create():null),f=new Et(ht.from(t.create(null,ht.from(o.type.create(null,u)))),c?3:1,0),g=a.start,m=a.end;n(e.tr.step(new Ci(g-(c?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const Gi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},rm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let X3=null;const ql=function(t,e,n){let r=X3||(X3=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},DSe=function(){X3=null},Lf=function(t,e,n,r){return n&&(MB(t,e,n,r,-1)||MB(t,e,n,r,1))},OSe=/^(img|br|input|textarea|hr)$/i;function MB(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Hs(t))){let s=t.parentNode;if(!s||s.nodeType!=1||B0(t)||OSe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Gi(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Hs(t):0}else return!1}}function Hs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function LSe(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=Hs(t)}else if(t.parentNode&&!B0(t))e=Gi(t),t=t.parentNode;else return null}}function ISe(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&&!B0(t))e=Gi(t)+1,t=t.parentNode;else return null}}function jSe(t,e,n){for(let r=e==0,i=e==Hs(t);r||i;){if(t==n)return!0;let a=Gi(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Hs(t)}}function B0(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 xw=function(t){return t.focusNode&&Lf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Jd(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function USe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function FSe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Hs(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Hs(r.startContainer),r.startOffset)}}}const rl=typeof navigator<"u"?navigator:null,EB=typeof document<"u"?document:null,ud=rl&&rl.userAgent||"",K3=/Edge\/(\d+)/.exec(ud),L7=/MSIE \d/.exec(ud),Y3=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ud),Ha=!!(L7||Y3||K3),Gu=L7?document.documentMode:Y3?+Y3[1]:K3?+K3[1]:0,qs=!Ha&&/gecko\/(\d+)/i.test(ud);qs&&+(/Firefox\/(\d+)/.exec(ud)||[0,0])[1];const Z3=!Ha&&/Chrome\/(\d+)/.exec(ud),ia=!!Z3,I7=Z3?+Z3[1]:0,_a=!Ha&&!!rl&&/Apple Computer/.test(rl.vendor),im=_a&&(/Mobile\/\w+/.test(ud)||!!rl&&rl.maxTouchPoints>2),Is=im||(rl?/Mac/.test(rl.platform):!1),zSe=rl?/Win/.test(rl.platform):!1,rc=/Android \d/.test(ud),H0=!!EB&&"webkitFontSmoothing"in EB.documentElement.style,BSe=H0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HSe(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 Bl(t,e){return typeof t=="number"?t:t[e]}function $Se(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 AB(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=rm(s);continue}let o=s,l=o==a.body,c=l?HSe(a):$Se(o),u=0,f=0;if(e.top<c.top+Bl(r,"top")?f=-(c.top-e.top+Bl(i,"top")):e.bottom>c.bottom-Bl(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Bl(i,"top")-c.top:e.bottom-c.bottom+Bl(i,"bottom")),e.left<c.left+Bl(r,"left")?u=-(c.left-e.left+Bl(i,"left")):e.right>c.right-Bl(r,"right")&&(u=e.right-c.right+Bl(i,"right")),u||f)if(l)a.defaultView.scrollBy(u,f);else{let m=o.scrollLeft,y=o.scrollTop;f&&(o.scrollTop+=f),u&&(o.scrollLeft+=u);let v=o.scrollLeft-m,b=o.scrollTop-y;e={left:e.left-v,top:e.top-b,right:e.right-v,bottom:e.bottom-b}}let g=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:rm(s)}}function VSe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,i=l.top;break}}return{refDOM:r,refTop:i,stack:j7(t.dom)}}function j7(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=rm(r));return e}function GSe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;U7(n,r==0?0:r-e)}function U7(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 dp=null;function WSe(t){if(t.setActive)return t.setActive();if(dp)return t.focus(dp);let e=j7(t);t.focus(dp==null?{get preventScroll(){return dp={preventScroll:!0},!0}}:void 0),dp||(dp=!1,U7(e,0))}function F7(t,e){let n,r=2e8,i,a=0,s=e.top,o=e.top,l,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let g;if(u.nodeType==1)g=u.getClientRects();else if(u.nodeType==3)g=ql(u).getClientRects();else continue;for(let m=0;m<g.length;m++){let y=g[m];if(y.top<=s&&y.bottom>=o){s=Math.max(y.bottom,s),o=Math.min(y.top,o);let v=y.left>e.left?y.left-e.left:y.right<e.left?e.left-y.right:0;if(v<r){n=u,r=v,i=v&&n.nodeType==3?{left:y.right<e.left?y.right:y.left,top:e.top}:e,u.nodeType==1&&v&&(a=f+(e.left>=(y.left+y.right)/2?1:0));continue}}else y.top>e.top&&!l&&y.left<=e.left&&y.right>=e.left&&(l=u,c={left:Math.max(y.left,Math.min(y.right,e.left)),top:y.top});!n&&(e.left>=y.right&&e.top>=y.top||e.left>=y.left&&e.top>=y.bottom)&&(a=f+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?qSe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:F7(n,i)}function qSe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=yu(r,1);if(a.top!=a.bottom&&Nk(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function Nk(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function XSe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function KSe(t,e,n){let{node:r,offset:i}=F7(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function YSe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function z7(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 s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let c=o[l];if(Nk(e,c))return z7(s,e,c)}}if((a=(a+1)%r)==i)break}return t}function ZSe(t,e){let n=t.dom.ownerDocument,r,i=0,a=FSe(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Nk(e,c)||(s=z7(t.dom,e,c),!s))return null}if(_a)for(let c=s;r&&c;c=rm(c))c.draggable&&(r=void 0);if(s=XSe(s,e),r){if(qs&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;H0&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=YSe(t,r,i,e))}o==null&&(o=KSe(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function TB(t){return t.top<t.bottom||t.left<t.right}function yu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(TB(r))return r}return Array.prototype.find.call(n,TB)||t.getBoundingClientRect()}const QSe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function B7(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=H0||qs;if(r.nodeType==3)if(s&&(QSe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=yu(ql(r,i,i),n);if(qs&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=yu(ql(r,i-1,i-1),-1);if(c.top==l.top){let u=yu(ql(r,i,i+1),-1);if(u.top!=l.top)return qg(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,qg(yu(ql(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Hs(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return d2(l.getBoundingClientRect(),!1)}if(a==null&&i<Hs(r)){let l=r.childNodes[i];if(l.nodeType==1)return d2(l.getBoundingClientRect(),!0)}return d2(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Hs(r))){let l=r.childNodes[i-1],c=l.nodeType==3?ql(l,Hs(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return qg(yu(c,1),!1)}if(a==null&&i<Hs(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?ql(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return qg(yu(c,-1),!0)}return qg(yu(r.nodeType==3?ql(r):r,-n),n>=0)}function qg(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 d2(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 H7(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 JSe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return H7(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=B7(t,i.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=ql(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const ewe=/[\u0590-\u08ac]/;function twe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,o=t.domSelection();return o?!ewe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:H7(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:y,focusOffset:v}=t.domSelectionRange(),b=y&&!m.contains(y.nodeType==1?y:y.parentNode)||l==y&&c==v;try{o.collapse(u,f),l&&(l!=u||c!=f)&&o.extend&&o.extend(l,c)}catch{}return g!=null&&(o.caretBidiLevel=g),b}):r.pos==r.start()||r.pos==r.end()}let CB=null,NB=null,RB=!1;function nwe(t,e,n){return CB==e&&NB==n?RB:(CB=e,NB=n,RB=n=="up"||n=="down"?JSe(t,e,n):twe(t,e,n))}const Xs=0,PB=1,nf=2,il=3;class $0{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Xs,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,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Gi(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),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==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 s=0;s<i.children.length;s++){let o=i.children[s];if(o.size){i=o;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 s=this.children[r],o=a+s.size;if(o>e||s instanceof V7){i=e-a;break}a=o}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 $7&&a.side>=0;r--);if(n<=0){let a,s=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Gi(a.dom)+1:0}}else{let a,s=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?Gi(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 s=r,o=0;;o++){let l=this.children[o],c=s+l.size;if(i==-1&&e<=c){let u=s+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Gi(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(c>n||o==this.children.length-1)){n=c;for(let u=o+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=Gi(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset: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),s=Math.max(e,n);for(let m=0,y=0;m<this.children.length;m++){let v=this.children[m],b=y+v.size;if(a>y&&s<b)return v.setSelection(e-y-v.border,n-y-v.border,r,i);y=b}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((qs||_a)&&e==n){let{node:m,offset:y}=o;if(m.nodeType==3){if(f=!!(y&&m.nodeValue[y-1]==`
  8065. `),f&&y==m.nodeValue.length)for(let v=m,b;v;v=v.parentNode){if(b=v.nextSibling){b.nodeName=="BR"&&(o=l={node:b.parentNode,offset:Gi(b)+1});break}let x=v.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let v=m.childNodes[y-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(qs&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&_a)&&Lf(o.node,o.offset,u.anchorNode,u.anchorOffset)&&Lf(l.node,l.offset,u.focusNode,u.focusOffset))return;let g=!1;if((c.extend||e==n)&&!(f&&qs)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let y=o;o=l,l=y}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+a.border,l=s-a.border;if(e>=o&&n<=l){this.dirty=e==r||n==s?nf:PB,e==o&&n==l&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=il:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?nf:il}r=s}this.dirty=nf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?nf:PB;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class $7 extends $0{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Xs&&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 rwe extends $0{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 If extends $0{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],s=a&&a(n,i,r);return(!s||!s.dom)&&(s=Kf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new If(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&il||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=il&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xs){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xs}}slice(e,n,r){let i=If.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=J3(a,n,s,r)),e>0&&(a=J3(a,0,e,r));for(let o=0;o<a.length;o++)a[o].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 Wu extends $0{constructor(e,n,r,i,a,s,o,l,c){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,a,s){let o=a.nodeViews[n.type.name],l,c=o&&o(n,a,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=Kf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let g=u;return u=q7(u,r,n),c?l=new iwe(e,n,r,i,u,f||null,g,c,a,s+1):n.isText?new vw(e,n,r,i,u,g,a):new Wu(e,n,r,i,u,f||null,g,a,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ht.empty)}return e}matchesNode(e,n,r){return this.dirty==Xs&&e.eq(this.node)&&h1(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,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,l=new swe(this,s&&s.node,e);cwe(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&l.syncToMarks(u==this.node.childCount?Kn.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,i)},(c,u,f,g)=>{l.syncToMarks(c.marks,r,e);let m;l.findNodeMatch(c,u,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(m=l.findIndexWithChild(a.node))>-1&&l.updateNodeAt(c,u,f,m,e)||l.updateNextNode(c,u,f,e,g,i)||l.addNode(c,u,f,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==nf)&&(s&&this.protectLocalComposition(e,s),G7(this.contentDOM,this.children,e),im&&uwe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Vt)||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 s=a.nodeValue,o=dwe(this.node.content,s,r-n,i-n);return o<0?null:{node:a,pos:o,text:s}}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 s=new rwe(this,a,n,i);e.input.compositionNodes.push(s),this.children=J3(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==il||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xs}updateOuterDeco(e){if(h1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=W7(this.dom,this.nodeDOM,Q3(this.outerDeco,this.node,n),Q3(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 kB(t,e,n,r,i){q7(r,e,t);let a=new Wu(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class vw extends Wu{constructor(e,n,r,i,a,s,o){super(e,n,r,i,a,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==il||this.dirty!=Xs&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xs||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=Xs,!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 vw(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=il)}get domAtom(){return!1}isText(e){return this.node.text==e}}class V7 extends $0{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xs&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class iwe extends Wu{constructor(e,n,r,i,a,s,o,l,c,u){super(e,n,r,i,a,s,o,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==il)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function G7(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=DB(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(s instanceof If){let l=r?r.previousSibling:t.lastChild;G7(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=DB(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ex=function(t){t&&(this.nodeName=t)};Ex.prototype=Object.create(null);const rf=[new Ex];function Q3(t,e,n){if(t.length==0)return rf;let r=n?rf[0]:new Ex,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new Ex(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&i.length==1&&i.push(r=new Ex(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return i}function W7(t,e,n,r){if(n==rf&&r==rf)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],o=n[a];if(a){let l;o&&o.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),o=rf[0]),i=l}awe(i,o||rf[0],s)}return i}function awe(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 q7(t,e,n){return W7(t,t,rf,Q3(e,n,t.nodeType!=1))}function h1(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 DB(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class swe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=owe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,s=Math.min(a,e.length);for(;i<s&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Xs,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[a])&&!this.isLocked(c.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=If.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let c=this.top.children[o];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==il&&s.dom==s.contentDOM&&(s.dirty=nf),s.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,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Wu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=a)return!1;let u=l.dom,f,g=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=il&&h1(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=nf,f.updateChildren(i,s+1),f.dirty=Xs),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!h1(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Wu.create(this.top,n,r,i,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,i,a){let s=Wu.create(this.top,e,n,r,i,a);s.contentDOM&&s.updateChildren(i,a+1),this.top.children.splice(this.index++,0,s),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 $7(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 If;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof vw)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_a||ia)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new V7(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 owe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let o;for(;;)if(r){let c=n.children[r-1];if(c instanceof If)n=c,r=c.children.length;else{o=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(i-1))break;--i,a.set(o,i),s.push(o)}}return{index:i,matched:a,matches:s.reverse()}}function lwe(t,e){return t.type.side-e.type.side}function cwe(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(a,u),c),a+=u.nodeSize}return}let s=0,o=[],l=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==a;){let b=i[s++];b.widget&&(u?(f||(f=[u])).push(b):u=b)}if(u)if(f){f.sort(lwe);for(let b=0;b<f.length;b++)n(f[b],c,!!l)}else n(u,c,!!l);let g,m;if(l)m=-1,g=l,l=null;else if(c<t.childCount)m=c,g=t.child(c++);else break;for(let b=0;b<o.length;b++)o[b].to<=a&&o.splice(b--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)o.push(i[s++]);let y=a+g.nodeSize;if(g.isText){let b=y;s<i.length&&i[s].from<b&&(b=i[s].from);for(let x=0;x<o.length;x++)o[x].to<b&&(b=o[x].to);b<y&&(l=g.cut(b-a),g=g.cut(0,b-a),y=b,m=-1)}else for(;s<i.length&&i[s].to<y;)s++;let v=g.isInline&&!g.isLeaf?o.filter(b=>!b.inline):o.slice();r(g,v,e.forChild(a,g),m),a=y}}function uwe(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 dwe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),o=a;if(a+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(a+=c.nodeSize,!c.isText)break;l+=c.text}if(a>=n){if(a>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let c=o<r?l.lastIndexOf(e,r-o-1):-1;if(c>=0&&c+e.length+o>=n)return o+c;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function J3(t,e,n,r,i){let a=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],c=o,u=o+=l.size;c>=n||u<=e?a.push(l):(c<e&&a.push(l.slice(0,e-c,r)),i&&(a.push(i),i=void 0),u>n&&a.push(l.slice(n-c,l.size,r)))}return a}function Rk(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,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),l,c;if(xw(n)){for(l=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&zt.isSelectable(f)&&i.parent&&!(f.isInline&&jSe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;c=new zt(s==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let m=0;m<n.rangeCount;m++){let y=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(y.startContainer,y.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(y.endContainer,y.endOffset,-1))}if(f<0)return null;[l,s]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;c=Pk(t,u,o,f)}return c}function X7(t){return t.editable?t.hasFocus():Y7(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function dc(t,e=!1){let n=t.state.selection;if(K7(t,n),!!X7(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ia){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Lf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)hwe(t);else{let{anchor:r,head:i}=n,a,s;OB&&!(n instanceof Vt)&&(n.$from.parent.inlineContent||(a=LB(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=LB(t,n.to))),t.docView.setSelection(r,i,t,e),OB&&(a&&IB(a),s&&IB(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fwe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const OB=_a||ia&&I7<63;function LB(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(_a&&i&&i.contentEditable=="false")return f2(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return f2(i);if(a)return f2(a)}}function f2(t){return t.contentEditable="true",_a&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function IB(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function fwe(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(()=>{(!X7(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function hwe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Gi(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ha&&Gu<=11&&(n.disabled=!0,n.disabled=!1)}function K7(t,e){if(e instanceof zt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(jB(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else jB(t)}function jB(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Pk(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Vt.between(e,n,r)}function UB(t){return t.editable&&!t.hasFocus()?!1:Y7(t)}function Y7(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 pwe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Lf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function eR(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&&sn.findFrom(a,e)}function wu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function FB(t,e,n){let r=t.state.selection;if(r instanceof Vt)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 s=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return wu(t,new Vt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=eR(t.state,e);return i&&i instanceof zt?wu(t,i):!1}else if(!(Is&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?zt.isSelectable(a)?wu(t,new zt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):H0?wu(t,new Vt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof zt&&r.node.isInline)return wu(t,new Vt(e>0?r.$to:r.$from));{let i=eR(t.state,e);return i?wu(t,i):!1}}}function p1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ax(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function fp(t,e){return e<0?mwe(t):gwe(t)}function mwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(qs&&n.nodeType==1&&r<p1(n)&&Ax(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Ax(o,-1))i=n,a=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(Z7(n))break;{let o=n.previousSibling;for(;o&&Ax(o,-1);)i=n.parentNode,a=Gi(o),o=o.previousSibling;if(o)n=o,r=p1(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?tR(t,n,r):i&&tR(t,i,a)}function gwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=p1(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Ax(o,1))a=n,s=++r;else break}else{if(Z7(n))break;{let o=n.nextSibling;for(;o&&Ax(o,1);)a=o.parentNode,s=Gi(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=p1(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&tR(t,a,s)}function Z7(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function xwe(t,e){for(;t&&e==t.childNodes.length&&!B0(t);)e=Gi(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 vwe(t,e){for(;t&&!e&&!B0(t);)e=Gi(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 tR(t,e,n){if(e.nodeType!=3){let a,s;(s=xwe(e,n))?(e=s,n=0):(a=vwe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xw(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&&dc(t)},50)}function zB(t,e){let n=t.state.doc.resolve(e);if(!(ia||zSe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>i.top&&s<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),s=(a.top+a.bottom)/2;if(s>i.top&&s<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 BB(t,e,n){let r=t.state.selection;if(r instanceof Vt&&!r.empty||n.indexOf("s")>-1||Is&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=eR(t.state,e);if(s&&s instanceof zt)return wu(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,o=r instanceof ps?sn.near(s,e):sn.findFrom(s,e);return o?wu(t,o):!1}return!1}function HB(t,e){if(!(t.state.selection instanceof Vt))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 s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function $B(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function bwe(t){if(!_a||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;$B(t,r,"true"),setTimeout(()=>$B(t,r,"false"),20)}return!1}function ywe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _we(t,e){let n=e.keyCode,r=ywe(e);if(n==8||Is&&n==72&&r=="c")return HB(t,-1)||fp(t,-1);if(n==46&&!e.shiftKey||Is&&n==68&&r=="c")return HB(t,1)||fp(t,1);if(n==13||n==27)return!0;if(n==37||Is&&n==66&&r=="c"){let i=n==37?zB(t,t.state.selection.from)=="ltr"?-1:1:-1;return FB(t,i,r)||fp(t,i)}else if(n==39||Is&&n==70&&r=="c"){let i=n==39?zB(t,t.state.selection.from)=="ltr"?1:-1:1;return FB(t,i,r)||fp(t,i)}else{if(n==38||Is&&n==80&&r=="c")return BB(t,-1,r)||fp(t,-1);if(n==40||Is&&n==78&&r=="c")return bwe(t)||BB(t,1,r)||fp(t,1);if(r==(Is?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function kk(t,e){t.someProp("transformCopied",m=>{e=m(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 m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||Kf.fromSchema(t.state.schema),o=rq(),l=o.createElement("div");l.appendChild(s.serializeFragment(r,{document:o}));let c=l.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=nq[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let y=o.createElement(u[m]);for(;l.firstChild;)y.appendChild(l.firstChild);l.appendChild(y),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8066. `);return{dom:l,text:g,slice:e}}function Q7(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return o=new Et(ht.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8067. `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:m}=t.state,y=Kf.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let b=s.appendChild(document.createElement("p"));v&&b.appendChild(y.serializeNode(m.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=Ewe(n),H0&&Awe(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||wx.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Swe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Twe(VB(o,+u[1],+u[2]),u[4]);else if(o=Et.maxOpen(wwe(o.content,i),!0),o.openStart||o.openEnd){let f=0,g=0;for(let m=o.content.firstChild;f<o.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=VB(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,l)}),o}const Swe=/^(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 wwe(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,s=[];if(t.forEach(o=>{if(!s)return;let l=i.findWrapping(o.type),c;if(!l)return s=null;if(c=s.length&&a.length&&eq(l,a,o,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=tq(s[s.length-1],a.length));let u=J7(o,l);s.push(u),i=i.matchType(u.type),a=l}}),s)return ht.from(s)}return t}function J7(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ht.from(t));return t}function eq(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=eq(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(ht.from(J7(n,t,i+1))))}}function tq(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,tq(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(ht.empty,!0);return t.copy(n.append(r))}function nR(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=nR(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(ht.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function VB(t,e,n){return e<t.openStart&&(t=new Et(nR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Et(nR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const nq={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 GB=null;function rq(){return GB||(GB=document.implementation.createHTMLDocument("title"))}let h2=null;function Mwe(t){let e=window.trustedTypes;return e?(h2||(h2=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),h2.createHTML(t)):t}function Ewe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=rq().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&nq[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=Mwe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function Awe(t){let e=t.querySelectorAll(ia?"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 Twe(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:s}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=ht.from(l.create(r[o+1],i)),a++,s++}return new Et(i,a,s)}const Sa={},wa={},Cwe={touchstart:!0,touchmove:!0};class Nwe{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Rwe(t){for(let e in Sa){let n=Sa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{kwe(t,r)&&!Dk(t,r)&&(t.editable||!(r.type in wa))&&n(t,r)},Cwe[e]?{passive:!0}:void 0)}_a&&t.dom.addEventListener("input",()=>null),rR(t)}function Uu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Pwe(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 rR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Dk(t,r))})}function Dk(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function kwe(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 Dwe(t,e){!Dk(t,e)&&Sa[e.type]&&(t.editable||!(e.type in wa))&&Sa[e.type](t,e)}wa.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!aq(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(rc&&ia&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),im&&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,Jd(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_we(t,n)?n.preventDefault():Uu(t,"key")};wa.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};wa.keypress=(t,e)=>{let n=e;if(aq(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Is&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Vt)||!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",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function bw(t){return{left:t.clientX,top:t.clientY}}function Owe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ok(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function jp(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 Lwe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&zt.isSelectable(r)?(jp(t,new zt(n)),!0):!1}function Iwe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof zt&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(zt.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(jp(t,zt.create(t.state.doc,i)),!0):!1}function jwe(t,e,n,r,i){return Ok(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?Iwe(t,n):Lwe(t,n))}function Uwe(t,e,n,r){return Ok(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Fwe(t,e,n,r){return Ok(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||zwe(t,n,r)}function zwe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(jp(t,Vt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)jp(t,Vt.create(r,o+1,o+1+s.content.size));else if(zt.isSelectable(s))jp(t,zt.create(r,o));else continue;return!0}}function Lk(t){return m1(t)}const iq=Is?"metaKey":"ctrlKey";Sa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Lk(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&Owe(n,t.input.lastClick)&&!n[iq]&&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 s=t.posAtCoords(bw(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Bwe(t,s,n,!!r)):(a=="doubleClick"?Uwe:Fwe)(t,s.pos,s.inside,n)?n.preventDefault():Uu(t,"pointer"))};class Bwe{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[iq],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);a=u.parent,s=u.depth?u.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||c instanceof zt&&c.from<=s&&c.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qs&&!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)),Uu(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(()=>dc(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(bw(e))),this.updateAllowDefault(e),this.allowDefault||!n?Uu(this.view,"pointer"):jwe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_a&&this.mightDrag&&!this.mightDrag.node.isAtom||ia&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(jp(this.view,sn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Uu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Uu(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)}}Sa.touchstart=t=>{t.input.lastTouch=Date.now(),Lk(t),Uu(t,"pointer")};Sa.touchmove=t=>{t.input.lastTouch=Date.now(),Uu(t,"pointer")};Sa.contextmenu=t=>Lk(t);function aq(t,e){return t.composing?!0:_a&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Hwe=rc?5e3:-1;wa.compositionstart=wa.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Vt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),m1(t,!0),t.markCursor=null;else if(m1(t,!e.selection.empty),qs&&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 s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}sq(t,Hwe)};wa.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,sq(t,20))};function sq(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>m1(t),e))}function oq(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Vwe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $we(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=LSe(e.focusNode,e.focusOffset),r=ISe(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 s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Vwe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function m1(t,e=!1){if(!(rc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),oq(t),e||t.docView&&t.docView.dirty){let n=Rk(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 Gwe(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 o0=Ha&&Gu<15||im&&BSe<604;Sa.copy=wa.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=o0?null:n.clipboardData,s=r.content(),{dom:o,text:l}=kk(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",l)):Gwe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Wwe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function qwe(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?l0(t,r.value,null,i,e):l0(t,r.textContent,r.innerHTML,i,e)},50)}function l0(t,e,n,r,i){let a=Q7(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,a||Et.empty)))return!0;if(!a)return!1;let s=Wwe(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function lq(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," "):""}wa.paste=(t,e)=>{let n=e;if(t.composing&&!rc)return;let r=o0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&l0(t,lq(r),r.getData("text/html"),i,n)?n.preventDefault():qwe(t,n)};class cq{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Xwe=Is?"altKey":"ctrlKey";function uq(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Xwe]}Sa.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(bw(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof zt?i.to-1:i.to))){if(r&&r.mightDrag)s=zt.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&&(s=zt.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=kk(t,o);(!n.dataTransfer.files.length||!ia||I7>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(o0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",o0||n.dataTransfer.setData("text/plain",c),t.dragging=new cq(u,uq(t,n),s)};Sa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};wa.dragover=wa.dragenter=(t,e)=>e.preventDefault();wa.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(bw(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",y=>{s=y(s,t,!1)}):s=Q7(t,lq(n.dataTransfer),o0?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(r&&uq(t,n));if(t.someProp("handleDrop",y=>y(t,n,s||Et.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let l=s?m7(t.state.doc,a.pos,s):a.pos;l==null&&(l=a.pos);let c=t.state.tr;if(o){let{node:y}=r;y?y.replace(c):c.deleteSelection()}let u=c.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=c.doc;if(f?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(g))return;let m=c.doc.resolve(u);if(f&&zt.isSelectable(s.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new zt(m));else{let y=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,M)=>y=M),c.setSelection(Pk(t,m,c.doc.resolve(y)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};Sa.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())&&dc(t)},20))};Sa.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)};Sa.beforeinput=(t,e)=>{if(ia&&rc&&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,Jd(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 wa)Sa[t]=wa[t];function c0(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class g1{constructor(e,n){this.toDOM=e,this.spec=n||mf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new ga(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof g1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&c0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class qu{constructor(e,n){this.attrs=e,this.spec=n||mf}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new ga(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof qu&&c0(this.attrs,e.attrs)&&c0(this.spec,e.spec)}static is(e){return e.type instanceof qu}destroy(){}}class Ik{constructor(e,n){this.attrs=e,this.spec=n||mf}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new ga(a.pos-r,s.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 Ik&&c0(this.attrs,e.attrs)&&c0(this.spec,e.spec)}destroy(){}}class ga{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ga(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 ga(e,e,new g1(n,r))}static inline(e,n,r,i){return new ga(e,n,new qu(r,i))}static node(e,n,r,i){return new ga(e,n,new Ik(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof qu}get widget(){return this.type instanceof g1}}const vp=[],mf={};class pr{constructor(e,n){this.local=e.length?e:vp,this.children=n.length?n:vp}static create(e,n){return n.length?x1(n,e,0,mf):ta}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 s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==ta||e.maps.length==0?this:this.mapInner(e,n,0,0,r||mf)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?Kwe(this.children,s||[],e,n,r,i,a):s?new pr(s.sort(gf),vp):ta}add(e,n){return n.length?this==ta?pr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,l)=>{let c=l+r,u;if(u=fq(n,o,c)){for(i||(i=this.children.slice());a<i.length&&i[a]<l;)a+=3;i[a]==l?i[a+2]=i[a+2].addInner(o,u,c+1):i.splice(a,0,l,l+o.nodeSize,x1(u,o,c+1,mf)),a+=3}});let s=dq(a?hq(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new pr(s.length?this.local.concat(s).sort(gf):this.local,i||this.children)}remove(e){return e.length==0||this==ta?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 s,o=r[a]+n,l=r[a+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>o&&f.to<l&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[a+2].removeInner(s,o+1);c!=ta?r[a+2]=c:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new pr(i,r):ta}forChild(e,n){if(this==ta)return this;if(n.isLeaf)return pr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<s&&l.to>a&&l.type instanceof qu){let c=Math.max(a,l.from)-a,u=Math.min(s,l.to)-a;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let o=new pr(i.sort(gf),vp);return r?new Ru([o,r]):o}return r||ta}eq(e){if(this==e)return!0;if(!(e instanceof pr)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return jk(this.localsInner(e))}localsInner(e){if(this==ta)return vp;if(e.inlineContent||!this.local.some(qu.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof qu||n.push(this.local[r]);return n}forEachSet(e){e(this)}}pr.empty=new pr([],[]);pr.removeOverlap=jk;const ta=pr.empty;class Ru{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,mf));return Ru.from(r)}forChild(e,n){if(n.isLeaf)return pr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=ta&&(a instanceof Ru?r=r.concat(a.members):r.push(a))}return Ru.from(r)}eq(e){if(!(e instanceof Ru)||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 s=0;s<a.length;s++)n.push(a[s])}}return n?jk(r?n:n.sort(gf)):vp}static from(e){switch(e.length){case 0:return ta;case 1:return e[0];default:return new Ru(e.every(n=>n instanceof pr)?e:e.reduce((n,r)=>n.concat(r instanceof pr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Kwe(t,e,n,r,i,a,s){let o=t.slice();for(let c=0,u=a;c<n.maps.length;c++){let f=0;n.maps[c].forEach((g,m,y,v)=>{let b=v-y-(m-g);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||g>M+u-f)continue;let w=o[x]+u-f;m>=w?o[x+1]=g<=w?-2:-1:g>=u&&b&&(o[x]+=b,o[x+1]+=b)}f+=b}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){l=!0,o[c+1]=-1;continue}let u=n.map(t[c]+a),f=u-i;if(f<0||f>=r.content.size){l=!0;continue}let g=n.map(t[c+1]+a,-1),m=g-i,{index:y,offset:v}=r.content.findIndex(f),b=r.maybeChild(y);if(b&&v==f&&v+b.nodeSize==m){let x=o[c+2].mapInner(n,b,u+1,t[c]+a+1,s);x!=ta?(o[c]=f,o[c+1]=m,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=Ywe(o,t,e,n,i,a,s),u=x1(c,r,0,s);e=u.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<u.children.length;f+=3){let m=u.children[f];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,u.children[f],u.children[f+1],u.children[f+2])}}return new pr(e.sort(gf),o)}function dq(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 ga(i.from+e,i.to+e,i.type))}return n}function Ywe(t,e,n,r,i,a,s){function o(l,c){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)o(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+a+1);return n}function fq(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function hq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function x1(t,e,n,r){let i=[],a=!1;e.forEach((o,l)=>{let c=fq(t,o,l+n);if(c){a=!0;let u=x1(c,o,n+l+1,r);u!=ta&&i.push(l,l+o.nodeSize,u)}});let s=dq(a?hq(t):t,-n).sort(gf);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new pr(s,i):ta}function gf(t,e){return t.from-e.from||t.to-e.to}function jk(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),WB(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),WB(e,i,r.copy(a.from,r.to)));break}}}return e}function WB(t,e,n){for(;e<t.length&&gf(n,t[e])>0;)e++;t.splice(e,0,n)}function p2(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ta&&e.push(r)}),t.cursorWrapper&&e.push(pr.create(t.state.doc,[t.cursorWrapper.deco])),Ru.from(e)}const Zwe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Qwe=Ha&&Gu<=11;class Jwe{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 eMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jwe,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]);Ha&&Gu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Qwe&&(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,Zwe)),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(UB(this.view)){if(this.suppressingSelectionUpdates)return dc(this.view);if(Ha&&Gu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Lf(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=rm(a))n.add(a);for(let a=e.anchorNode;a;a=rm(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)&&UB(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],l);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(o=!0))}if(qs&&l.length){let u=l.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,g]=u;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of u){let m=g.parentNode;m&&m.nodeName=="LI"&&(!f||rMe(e,f)!=m)&&g.remove()}}}let c=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xw(r)&&(c=Rk(e))&&c.eq(sn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,dc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),tMe(e)),this.handleDOMChange(a,s,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||dc(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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];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(Ha&&Gu<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:g}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let s=i&&i.parentNode==e.target?Gi(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),l=a&&a.parentNode==e.target?Gi(a):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:o,to:c}}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 qB=new WeakMap,XB=!1;function tMe(t){if(!qB.has(t)&&(qB.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=qs,XB)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."),XB=!0}}function KB(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Lf(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function nMe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return KB(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?KB(t,n):null}function rMe(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 iMe(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],xw(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ia&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let x=r.childNodes[b-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){a=b;break}if(!M||M.size)break}let f=t.state.doc,g=t.someProp("domParser")||wx.fromSchema(t.state.schema),m=f.resolve(s),y=null,v=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:aMe,context:m});if(c&&c[0].pos!=null){let b=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=b),y={anchor:b+s,head:x+s}}return{doc:v,sel:y,from:s,to:o}}function aMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(_a&&/^(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||_a&&/^(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 sMe=/^(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 oMe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=Rk(t,N);if(j&&!t.state.selection.eq(j)){if(ia&&rc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",k=>k(t,Jd(13,"Enter"))))return;let C=t.state.tr.setSelection(j);N=="pointer"?C.setMeta("pointer",!0):N=="key"&&C.scrollIntoView(),a&&C.setMeta("composition",a),t.dispatch(C)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,c=iMe(t,e,n),u=t.state.doc,f=u.slice(c.from,c.to),g,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,m="end"):(g=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let y=uMe(f.content,c.doc.content,c.from,g,m);if(y&&t.input.domChangeCount++,(im&&t.input.lastIOSEnter>Date.now()-225||rc)&&i.some(N=>N.nodeType==1&&!sMe.test(N.nodeName))&&(!y||y.endA>=y.endB)&&t.someProp("handleKeyDown",N=>N(t,Jd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!y)if(r&&l instanceof Vt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))y={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=YB(t,t.state.doc,c.sel);if(N&&!N.eq(t.state.selection)){let j=t.state.tr.setSelection(N);a&&j.setMeta("composition",a),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&y.start==y.endB&&t.state.selection instanceof Vt&&(y.start>t.state.selection.from&&y.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?y.start=t.state.selection.from:y.endA<t.state.selection.to&&y.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(y.endB+=t.state.selection.to-y.endA,y.endA=t.state.selection.to)),Ha&&Gu<=11&&y.endB==y.start+1&&y.endA==y.start&&y.start>c.from&&c.doc.textBetween(y.start-c.from-1,y.start-c.from+1)=="  "&&(y.start--,y.endA--,y.endB--);let v=c.doc.resolveNoCache(y.start-c.from),b=c.doc.resolveNoCache(y.endB-c.from),x=u.resolve(y.start),M=v.sameParent(b)&&v.parent.inlineContent&&x.end()>=y.endA;if((im&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!M&&v.pos<c.doc.content.size&&(!v.sameParent(b)||!v.parent.inlineContent)&&v.pos<b.pos&&!/\S/.test(c.doc.textBetween(v.pos,b.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Jd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>y.start&&cMe(u,y.start,y.endA,v,b)&&t.someProp("handleKeyDown",N=>N(t,Jd(8,"Backspace")))){rc&&ia&&t.domObserver.suppressSelectionUpdates();return}ia&&y.endB==y.start&&(t.input.lastChromeDelete=Date.now()),rc&&!M&&v.start()!=b.start()&&b.parentOffset==0&&v.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==y.endA&&(y.endB-=2,b=c.doc.resolveNoCache(y.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Jd(13,"Enter"))})},20));let w=y.start,A=y.endA,T=N=>{let j=N||t.state.tr.replace(w,A,c.doc.slice(y.start-c.from,y.endB-c.from));if(c.sel){let C=YB(t,j.doc,c.sel);C&&!(ia&&t.composing&&C.empty&&(y.start!=y.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==w||C.head==j.mapping.map(A)-1)||Ha&&C.empty&&C.head==w)&&j.setSelection(C)}return a&&j.setMeta("composition",a),j.scrollIntoView()},R;if(M)if(v.pos==b.pos){Ha&&Gu<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>dc(t),20));let N=T(t.state.tr.delete(w,A)),j=u.resolve(y.start).marksAcross(u.resolve(y.endA));j&&N.ensureMarks(j),t.dispatch(N)}else if(y.endA==y.endB&&(R=lMe(v.parent.content.cut(v.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,y.endA-x.start())))){let N=T(t.state.tr);R.type=="add"?N.addMark(w,A,R.mark):N.removeMark(w,A,R.mark),t.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==b.index()-(b.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,b.parentOffset),j=()=>T(t.state.tr.insertText(N,w,A));t.someProp("handleTextInput",C=>C(t,w,A,N,j))||t.dispatch(j())}else t.dispatch(T());else t.dispatch(T())}function YB(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Pk(t,e.resolve(n.anchor),e.resolve(n.head))}function lMe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,l;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)a=n[u].removeFromSet(a);if(i.length==1&&a.length==0)o=i[0],s="add",l=u=>u.mark(o.addToSet(u.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",l=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(ht.from(c).eq(t))return{mark:o,type:s}}function cMe(t,e,n,r,i){if(n-e<=i.pos-r.pos||m2(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(m2(a,!0,!0));return!s.parent.isTextblock||s.pos>n||m2(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function m2(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 uMe(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,a-Math.min(s,o));r-=s+l-a}if(s<a&&t.size<e.size){let l=r<=a&&r>=s?a-r:0;a-=l,a&&a<e.size&&ZB(e.textBetween(a-1,a+1))&&(a+=l?1:-1),o=a+(o-s),s=a}else if(o<a){let l=r<=a&&r>=o?a-r:0;a-=l,a&&a<t.size&&ZB(t.textBetween(a-1,a+1))&&(a+=l?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function ZB(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 pq{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 Nwe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(nH),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=eH(this),JB(this),this.nodeViews=tH(this),this.docView=kB(this.state.doc,QB(this),p2(this),this.dom,this),this.domObserver=new eMe(this,(r,i,a,s)=>oMe(this,r,i,a,s)),this.domObserver.start(),Rwe(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&&rR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nH),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,s=!1;e.storedMarks&&this.composing&&(oq(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=tH(this);fMe(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&rR(this),this.editable=eH(this),JB(this);let l=p2(this),c=QB(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(i.selection))&&(s=!0);let g=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&VSe(this);if(s){this.domObserver.stop();let m=f&&(Ha||ia)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&dMe(i.selection,e.selection);if(f){let y=ia?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$we(this)),(a||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=kB(e.doc,c,l,this.dom,this)),y&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&pwe(this))?dc(this,m):(K7(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():g&&GSe(g)}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 zt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&AB(this,n.getBoundingClientRect(),e)}else AB(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 cq(e.slice,e.move,i<0?void 0:zt.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 s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ha){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&&WSe(this.dom),dc(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 ZSe(this,e)}coordsAtPos(e,n=1){return B7(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 nwe(this,n||this.state,e)}pasteHTML(e,n){return l0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return l0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return kk(this,e)}destroy(){this.docView&&(Pwe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],p2(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,DSe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Dwe(this,e)}domSelectionRange(){let e=this.domSelection();return e?_a&&this.root.nodeType===11&&USe(this.dom.ownerDocument)==this.dom&&nMe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}pq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function QB(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let 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"),[ga.node(0,t.state.doc.content.size,e)]}function JB(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:ga.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function eH(t){return!t.someProp("editable",e=>e(t.state)===!1)}function dMe(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 tH(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 fMe(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 nH(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 ed={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:"'"},v1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},hMe=typeof navigator<"u"&&/Mac/.test(navigator.platform),pMe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wi=0;Wi<10;Wi++)ed[48+Wi]=ed[96+Wi]=String(Wi);for(var Wi=1;Wi<=24;Wi++)ed[Wi+111]="F"+Wi;for(var Wi=65;Wi<=90;Wi++)ed[Wi]=String.fromCharCode(Wi+32),v1[Wi]=String.fromCharCode(Wi);for(var g2 in ed)v1.hasOwnProperty(g2)||(v1[g2]=ed[g2]);function mMe(t){var e=hMe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||pMe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?v1:ed)[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 gMe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xMe=typeof navigator<"u"&&/Win/.test(navigator.platform);function vMe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))gMe?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function bMe(t){let e=Object.create(null);for(let n in t)e[vMe(n)]=t[n];return e}function x2(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 yMe(t){return new xr({props:{handleKeyDown:mq(t)}})}function mq(t){let e=bMe(t);return function(n,r){let i=mMe(r),a,s=e[x2(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[x2(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(xMe&&r.ctrlKey&&r.altKey)&&(a=ed[r.keyCode])&&a!=i){let o=e[x2(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var _Me=Object.defineProperty,Uk=(t,e)=>{for(var n in e)_Me(t,n,{get:e[n],enumerable:!0})};function yw(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 _w=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(([s,o])=>[s,(...c)=>{const u=o(...c)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}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,s=[],o=!!t,l=t||i.tr,c=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(l),s.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...y)=>{const v=this.buildProps(l,e),b=g(...y)(v);return s.push(b),u}])),run:c};return u}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(([o,l])=>[o,(...c)=>l(...c)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:yw({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(([o,l])=>[o,(...c)=>l(...c)(s)]))}};return s}},gq={};Uk(gq,{blur:()=>SMe,clearContent:()=>wMe,clearNodes:()=>MMe,command:()=>EMe,createParagraphNear:()=>AMe,cut:()=>TMe,deleteCurrentNode:()=>CMe,deleteNode:()=>NMe,deleteRange:()=>RMe,deleteSelection:()=>PMe,enter:()=>kMe,exitCode:()=>DMe,extendMarkRange:()=>OMe,first:()=>LMe,focus:()=>jMe,forEach:()=>UMe,insertContent:()=>FMe,insertContentAt:()=>HMe,joinBackward:()=>GMe,joinDown:()=>VMe,joinForward:()=>WMe,joinItemBackward:()=>qMe,joinItemForward:()=>XMe,joinTextblockBackward:()=>KMe,joinTextblockForward:()=>YMe,joinUp:()=>$Me,keyboardShortcut:()=>QMe,lift:()=>JMe,liftEmptyBlock:()=>eEe,liftListItem:()=>tEe,newlineInCode:()=>nEe,resetAttributes:()=>rEe,scrollIntoView:()=>iEe,selectAll:()=>aEe,selectNodeBackward:()=>sEe,selectNodeForward:()=>oEe,selectParentNode:()=>lEe,selectTextblockEnd:()=>cEe,selectTextblockStart:()=>uEe,setContent:()=>dEe,setMark:()=>NEe,setMeta:()=>REe,setNode:()=>PEe,setNodeSelection:()=>kEe,setTextDirection:()=>DEe,setTextSelection:()=>OEe,sinkListItem:()=>LEe,splitBlock:()=>IEe,splitListItem:()=>jEe,toggleList:()=>UEe,toggleMark:()=>FEe,toggleNode:()=>zEe,toggleWrap:()=>BEe,undoInputRule:()=>HEe,unsetAllMarks:()=>$Ee,unsetMark:()=>VEe,unsetTextDirection:()=>GEe,updateAttributes:()=>WEe,wrapIn:()=>qEe,wrapInList:()=>XEe});var SMe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),wMe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),MMe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,l)=>{if(o.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(l)),g=c.resolve(u.map(l+o.nodeSize)),m=f.blockRange(g);if(!m)return;const y=Am(m);if(o.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,v)}(y||y===0)&&e.lift(m,y)})}),!0},EMe=t=>e=>t(e),AMe=()=>({state:t,dispatch:e})=>P7(t,e),TMe=(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 s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new Vt(r.doc.resolve(Math.max(s-1,0)))),!0},CMe=()=>({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 o=i.before(a),l=i.after(a);t.delete(o,l).scrollIntoView()}return!0}return!1};function Kr(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 NMe=t=>({tr:e,state:n,dispatch:r})=>{const i=Kr(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const l=a.before(s),c=a.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},RMe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},PMe=()=>({state:t,dispatch:e})=>Mk(t,e),kMe=()=>({commands:t})=>t.keyboardShortcut("Enter"),DMe=()=>({state:t,dispatch:e})=>vSe(t,e);function Fk(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function b1(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Fk(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function xq(t,e,n={}){return t.find(r=>r.type===e&&b1(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function rH(t,e,n={}){return!!xq(t,e,n)}function zk(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!xq([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,l=s+1,c=o+i.node.nodeSize;for(;s>0&&rH([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&rH([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function Ac(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var OMe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Ac(t,r.schema),{doc:s,selection:o}=n,{$from:l,from:c,to:u}=o;if(i){const f=zk(l,a,e);if(f&&f.from<=c&&f.to>=u){const g=Vt.create(s,f.from,f.to);n.setSelection(g)}}return!0},LMe=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 vq(t){return t instanceof Vt}function af(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function bq(t,e=null){if(!e)return null;const n=sn.atStart(t),r=sn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Vt.create(t,af(0,i,a),af(t.content.size,i,a)):Vt.create(t,af(e,i,a),af(e,i,a))}function IMe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Bk(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var jMe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(Bk()||IMe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!vq(n.state.selection))return s(),!0;const o=bq(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return a&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},UMe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),FMe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),yq=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&&yq(r)}return t};function Iy(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 yq(n)}function u0(t,e,n){if(t instanceof Vu||t instanceof ht)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 ht.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),u0("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const l=new i7({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,o=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?wx.fromSchema(l).parseSlice(Iy(t),n.parseOptions):wx.fromSchema(l).parse(Iy(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=wx.fromSchema(e);return n.slice?a.parseSlice(Iy(t),n.parseOptions).content:a.parse(Iy(t),n.parseOptions)}return u0("",e,n)}function zMe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ai||i instanceof Ci))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,l,c,u)=>{s===0&&(s=u)}),t.setSelection(sn.near(t.doc.resolve(s),n))}var BMe=t=>!("type"in t),HMe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=b=>{a.emit("contentError",{editor:a,error:b,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{u0(e,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(b){l(b)}try{o=u0(e,a.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(b){return l(b),!1}let{from:u,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((BMe(o)?o:[o]).forEach(b=>{b.check(),g=g?b.isText&&b.marks.length===0:!1,m=m?b.isBlock:!1}),u===f&&m){const{parent:b}=r.doc.resolve(u);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(u-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(b=>b.text||"").join("");else if(e instanceof ht){let b="";e.forEach(x=>{x.text&&(b+=x.text)}),v=b}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,u,f)}else{v=o;const b=r.doc.resolve(u),x=b.node(),M=b.parentOffset===0,w=x.isText||x.isTextblock,A=x.content.size>0;M&&w&&A&&(u=Math.max(0,u-1)),r.replaceWith(u,f,v)}n.updateSelection&&zMe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:v})}return!0},$Me=()=>({state:t,dispatch:e})=>mSe(t,e),VMe=()=>({state:t,dispatch:e})=>gSe(t,e),GMe=()=>({state:t,dispatch:e})=>M7(t,e),WMe=()=>({state:t,dispatch:e})=>C7(t,e),qMe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pw(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},XMe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pw(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},KMe=()=>({state:t,dispatch:e})=>hSe(t,e),YMe=()=>({state:t,dispatch:e})=>pSe(t,e);function _q(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ZMe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))Bk()||_q()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var QMe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=ZMe(t).split(/-(?!$)/),s=a.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,o))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function td(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?Kr(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const m=Math.max(r,g),y=Math.min(i,g+f.nodeSize);o.push({node:f,from:m,to:y})});const l=i-r,c=o.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>b1(f.node.attrs,n,{strict:!1}));return a?!!c.length:c.reduce((f,g)=>f+g.to-g.from,0)>=l}var JMe=(t,e={})=>({state:n,dispatch:r})=>{const i=Kr(t,n.schema);return td(n,i,e)?xSe(n,r):!1},eEe=()=>({state:t,dispatch:e})=>k7(t,e),tEe=t=>({state:e,dispatch:n})=>{const r=Kr(t,e.schema);return NSe(r)(e,n)},nEe=()=>({state:t,dispatch:e})=>R7(t,e);function Sw(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function iH(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 rEe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=Sw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=Kr(t,r.schema)),o==="mark"&&(s=Ac(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,f)=>{a&&a===u.type&&(l=!0,i&&n.setNodeMarkup(f,void 0,iH(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(g=>{s===g.type&&(l=!0,i&&n.addMark(f,f+u.nodeSize,s.create(iH(g.attrs,e))))})})}),l},iEe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),aEe=()=>({tr:t,dispatch:e})=>{if(e){const n=new ps(t.doc);t.setSelection(n)}return!0},sEe=()=>({state:t,dispatch:e})=>A7(t,e),oEe=()=>({state:t,dispatch:e})=>N7(t,e),lEe=()=>({state:t,dispatch:e})=>_Se(t,e),cEe=()=>({state:t,dispatch:e})=>MSe(t,e),uEe=()=>({state:t,dispatch:e})=>wSe(t,e);function iR(t,e,n={},r={}){return u0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var dEe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:l}=a;if(r.preserveWhitespace!=="full"){const c=iR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Sq(t,e){const n=Ac(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const o=s.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function wq(t,e){const n=new y7(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function fEe(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 hEe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function pEe(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 ww(t){return e=>pEe(e.$from,t)}function jt(t,e,n){return t.config[e]===void 0&&t.parent?jt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?jt(t.parent,e,n):null}):t.config[e]}function Hk(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=jt(e,"addExtensions",n);return r?[e,...Hk(r())]:e}).flat(10)}function $k(t,e){const n=Kf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Mq(t){return typeof t=="function"}function On(t,e=void 0,...n){return Mq(t)?e?t.bind(e)(...n):t(...n):t}function mEe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function am(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 Eq(t){const e=[],{nodeExtensions:n,markExtensions:r}=am(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},l=jt(s,"addGlobalAttributes",o);if(!l)return;l().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([g,m])=>{e.push({type:f,name:g,attribute:{...a,...m}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},l=jt(s,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([u,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:u,attribute:g})})}),e}function Er(...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 o=a?String(a).split(" "):[],l=r[i]?r[i].split(" "):[],c=o.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){const o=a?a.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[f,g]=u.split(":").map(m=>m.trim());c.set(f,g)}),o.forEach(u=>{const[f,g]=u.split(":").map(m=>m.trim());c.set(f,g)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=a}),r},{})}function y1(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)=>Er(n,r),{})}function gEe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function aH(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,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):gEe(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function sH(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&mEe(n)?!1:n!=null))}function oH(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 xEe(t,e){var n;const r=Eq(t),{nodeExtensions:i,markExtensions:a}=am(t),s=(n=i.find(c=>jt(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(c=>{const u=r.filter(x=>x.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((x,M)=>{const w=jt(M,"extendNodeSchema",f);return{...x,...w?w(c):{}}},{}),m=sH({...g,content:On(jt(c,"content",f)),marks:On(jt(c,"marks",f)),group:On(jt(c,"group",f)),inline:On(jt(c,"inline",f)),atom:On(jt(c,"atom",f)),selectable:On(jt(c,"selectable",f)),draggable:On(jt(c,"draggable",f)),code:On(jt(c,"code",f)),whitespace:On(jt(c,"whitespace",f)),linebreakReplacement:On(jt(c,"linebreakReplacement",f)),defining:On(jt(c,"defining",f)),isolating:On(jt(c,"isolating",f)),attrs:Object.fromEntries(u.map(oH))}),y=On(jt(c,"parseHTML",f));y&&(m.parseDOM=y.map(x=>aH(x,u)));const v=jt(c,"renderHTML",f);v&&(m.toDOM=x=>v({node:x,HTMLAttributes:y1(x,u)}));const b=jt(c,"renderText",f);return b&&(m.toText=b),[c.name,m]})),l=Object.fromEntries(a.map(c=>{const u=r.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((b,x)=>{const M=jt(x,"extendMarkSchema",f);return{...b,...M?M(c):{}}},{}),m=sH({...g,inclusive:On(jt(c,"inclusive",f)),excludes:On(jt(c,"excludes",f)),group:On(jt(c,"group",f)),spanning:On(jt(c,"spanning",f)),code:On(jt(c,"code",f)),attrs:Object.fromEntries(u.map(oH))}),y=On(jt(c,"parseHTML",f));y&&(m.parseDOM=y.map(b=>aH(b,u)));const v=jt(c,"renderHTML",f);return v&&(m.toDOM=b=>v({mark:b,HTMLAttributes:y1(b,u)})),[c.name,m]}));return new i7({topNode:s,nodes:o,marks:l})}function vEe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Vk(t){return t.sort((n,r)=>{const i=jt(n,"priority")||100,a=jt(r,"priority")||100;return i>a?-1:i<a?1:0})}function Aq(t){const e=Vk(Hk(t)),n=vEe(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 Tq(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8068. `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(l,c,u,f)=>{var g;l.isBlock&&c>r&&(o+=a);const m=s?.[l.type.name];if(m)return u&&(o+=m({node:l,pos:c,parent:u,index:f,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,c)-c,i-c))}),o}function bEe(t,e){const n={from:0,to:t.content.size};return Tq(t,n,e)}function Cq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function yEe(t,e){const n=Kr(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function Nq(t,e){const n=Sw(typeof e=="string"?e:e.name,t.schema);return n==="node"?yEe(t,e):n==="mark"?Sq(t,e):{}}function _Ee(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 SEe(t){const e=_Ee(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==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 Rq(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,l)=>{s.push({from:o,to:l})});else{const{from:o,to:l}=n[a];if(o===void 0||l===void 0)return;s.push({from:o,to:l})}s.forEach(({from:o,to:l})=>{const c=e.slice(a).map(o,-1),u=e.slice(a).map(l),f=e.invert().map(c,-1),g=e.invert().map(u);r.push({oldRange:{from:f,to:g},newRange:{from:c,to:u}})})}),SEe(r)}function Gk(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=zk(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var wEe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function v2(t,e){return e.nodes[t]||e.marks[t]||null}function T_(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 MEe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var l,c;const u=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-a))}),n};function aR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Ac(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>b1(f.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const m=f.pos,y=g.pos;t.doc.nodesBetween(m,y,(v,b)=>{if(!v.isText&&!v.marks.length)return;const x=Math.max(m,b),M=Math.min(y,b+v.nodeSize),w=M-x;s+=w,o.push(...v.marks.map(A=>({mark:A,from:x,to:M})))})}),s===0)return!1;const l=o.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>b1(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),c=o.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(l>0?l+c:l)>=s}function EEe(t,e,n={}){if(!e)return td(t,null,n)||aR(t,null,n);const r=Sw(e,t.schema);return r==="node"?td(t,e,n):r==="mark"?aR(t,e,n):!1}var AEe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=ww(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},TEe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function lH(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function cH(t,e){const{nodeExtensions:n}=am(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=On(jt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Mw(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&&(Mw(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Pq(t){return t instanceof zt}function CEe(t,e,n){var r;const{selection:i}=e;let a=null;if(vq(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(c=>c.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:l})=>{let c=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(u,f,g)=>{if(c)return!1;if(u.isInline){const m=!g||g.type.allowsMarkType(n),y=!!n.isInSet(u.marks)||!u.marks.some(v=>v.type.excludes(n));c=m&&y}return!c}),c})}var NEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=Ac(t,r.schema);if(i)if(s){const c=Sq(r,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(g,m)=>{const y=Math.max(m,u),v=Math.min(m+g.nodeSize,f);g.marks.find(x=>x.type===l)?g.marks.forEach(x=>{l===x.type&&n.addMark(y,v,l.create({...x.attrs,...e}))}):n.addMark(y,v,l.create(e))})});return CEe(r,n,l)},REe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),PEe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Kr(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>wB(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>wB(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},kEe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=af(t,0,r.content.size),a=zt.create(r,i);e.setSelection(a)}return!0},DEe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},OEe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Vt.atStart(r).from,o=Vt.atEnd(r).to,l=af(i,s,o),c=af(a,s,o),u=Vt.create(r,l,c);e.setSelection(u)}return!0},LEe=t=>({state:e,dispatch:n})=>{const r=Kr(t,e.schema);return kSe(r)(e,n)};function uH(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 IEe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:l}=a,c=i.extensionManager.attributes,u=T_(c,o.node().type.name,o.node().attrs);if(a instanceof zt&&a.node.isBlock)return!o.parentOffset||!uc(s,o.pos)?!1:(r&&(t&&uH(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:fEe(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:u}]:void 0,y=uc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!y&&uc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(y=!0,m=g?[{type:g,attrs:u}]:void 0),r){if(y&&(a instanceof Vt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const v=e.mapping.map(o.before()),b=e.doc.resolve(v);o.node(-1).canReplaceWith(b.index(),b.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&uH(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return y},jEe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=Kr(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==o)return!1;const g=a.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let x=ht.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let j=l.depth-M;j>=l.depth-3;j-=1)x=ht.from(l.node(j).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...T_(g,l.node().type.name,l.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;x=x.append(ht.from(o.createAndFill(null,T)||void 0));const R=l.before(l.depth-(M-1));n.replace(R,l.after(-w),new Et(x,4-M,0));let N=-1;n.doc.nodesBetween(R,n.doc.content.size,(j,C)=>{if(N>-1)return!1;j.isTextblock&&j.content.size===0&&(N=C+1)}),N>-1&&n.setSelection(Vt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,y={...T_(g,f.type.name,f.attrs),...e},v={...T_(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const b=m?[{type:o,attrs:y},{type:m,attrs:v}]:[{type:o,attrs:y}];if(!uc(n.doc,l.pos,2))return!1;if(i){const{selection:x,storedMarks:M}=r,{splittableMarks:w}=a.extensionManager,A=M||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,b).scrollIntoView(),!A||!i)return!0;const T=A.filter(R=>w.includes(R.type.name));n.ensureMarks(T)}return!0},b2=(t,e)=>{const n=ww(s=>s.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&&cd(t.doc,n.pos)&&t.join(n.pos),!0},y2=(t,e)=>{const n=ww(s=>s.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&&cd(t.doc,r)&&t.join(r),!0},UEe=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:l,commands:c,can:u})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=Kr(t,s.schema),y=Kr(e,s.schema),{selection:v,storedMarks:b}=s,{$from:x,$to:M}=v,w=x.blockRange(M),A=b||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const T=ww(R=>cH(R.type.name,f))(v);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===m)return c.liftListItem(y);if(cH(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return l().command(()=>(a.setNodeMarkup(T.pos,m),!0)).command(()=>b2(a,m)).command(()=>y2(a,m)).run()}return!n||!A||!o?l().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>b2(a,m)).command(()=>y2(a,m)).run():l().command(()=>{const R=u().wrapInList(m,r),N=A.filter(j=>g.includes(j.type.name));return a.ensureMarks(N),R?!0:c.clearNodes()}).wrapInList(m,r).command(()=>b2(a,m)).command(()=>y2(a,m)).run()},FEe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Ac(t,r.schema);return aR(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},zEe=(t,e,n={})=>({state:r,commands:i})=>{const a=Kr(t,r.schema),s=Kr(e,r.schema),o=td(r,a,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(s,l):i.setNode(a,{...l,...n})},BEe=(t,e={})=>({state:n,commands:r})=>{const i=Kr(t,n.schema);return td(n,i,e)?r.lift(i):r.wrapIn(i,e)},HEe=()=>({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 s=t.tr,o=a.transform;for(let l=o.steps.length-1;l>=0;l-=1)s.step(o.steps[l].invert(o.docs[l]));if(a.text){const l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1},$Ee=()=>({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},VEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Ac(t,r.schema),{$from:c,empty:u,ranges:f}=o;if(!i)return!0;if(u&&s){let{from:g,to:m}=o;const y=(a=c.marks().find(b=>b.type===l))==null?void 0:a.attrs,v=zk(c,l,y);v&&(g=v.from,m=v.to),n.removeMark(g,m,l)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},GEe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,l)=>{if(o.isText)return;const c={...o.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},WEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=Sw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=Kr(t,r.schema)),o==="mark"&&(s=Ac(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;let g,m,y,v;n.selection.empty?r.doc.nodesBetween(u,f,(b,x)=>{a&&a===b.type&&(l=!0,y=Math.max(x,u),v=Math.min(x+b.nodeSize,f),g=x,m=b)}):r.doc.nodesBetween(u,f,(b,x)=>{x<u&&a&&a===b.type&&(l=!0,y=Math.max(x,u),v=Math.min(x+b.nodeSize,f),g=x,m=b),x>=u&&x<=f&&(a&&a===b.type&&(l=!0,i&&n.setNodeMarkup(x,void 0,{...b.attrs,...e})),s&&b.marks.length&&b.marks.forEach(M=>{if(s===M.type&&(l=!0,i)){const w=Math.max(x,u),A=Math.min(x+b.nodeSize,f);n.addMark(w,A,s.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(b=>{s===b.type&&i&&n.addMark(y,v,s.create({...b.attrs,...e}))}))}),l},qEe=(t,e={})=>({state:n,dispatch:r})=>{const i=Kr(t,n.schema);return ESe(i,e)(n,r)},XEe=(t,e={})=>({state:n,dispatch:r})=>{const i=Kr(t,n.schema);return ASe(i,e)(n,r)},KEe=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}},Ew=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},YEe=(t,e)=>{if(Fk(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 jy(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let u=!1;const f=MEe(c)+a;return s.forEach(g=>{if(u)return;const m=YEe(f,g.find);if(!m)return;const y=l.state.tr,v=yw({state:l.state,transaction:y}),b={from:r-(m[0].length-a.length),to:i},{commands:x,chain:M,can:w}=new _w({editor:n,state:v});g.handler({state:v,range:b,match:m,commands:x,chain:M,can:w})===null||!y.steps.length||(g.undoable&&y.setMeta(o,{transform:y,from:r,to:i,text:a}),l.dispatch(y),u=!0)}),u}function ZEe(t){const{editor:e,rules:n}=t,r=new xr({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=$k(ht.from(u),s.schema);const{from:f}=l,g=f+u.length;jy({editor:e,from:f,to:g,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return jy({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&jy({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:s}=i.state.selection;return s?jy({editor:e,from:s.pos,to:s.pos,text:`
  8069. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function QEe(t){return Object.prototype.toString.call(t).slice(8,-1)}function Uy(t){return QEe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function kq(t,e){const n={...t};return Uy(t)&&Uy(e)&&Object.keys(e).forEach(r=>{Uy(e[r])&&Uy(t[r])?n[r]=kq(t[r],e[r]):n[r]=e[r]}),n}var Wk=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...On(jt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...On(jt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>kq(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}},dd=class Dq extends Wk{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Dq(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;const l=s.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),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 JEe(t){return typeof t=="number"}var eAe=class{constructor(t){this.find=t.find,this.handler=t.handler}},tAe=(t,e,n)=>{if(Fk(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 nAe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:l,chain:c,can:u}=new _w({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,y)=>{var v,b,x,M,w;if((b=(v=m.type)==null?void 0:v.spec)!=null&&b.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(w=(M=(x=m.content)==null?void 0:x.size)!=null?M:m.nodeSize)!=null?w:0,T=Math.max(r,y),R=Math.min(i,y+A);if(T>=R)return;const N=m.isText?m.text||"":m.textBetween(T-y,R-y,void 0,"");tAe(N,a.find,s).forEach(C=>{if(C.index===void 0)return;const k=T+C.index+1,U=k+C[0].length,I={from:n.tr.mapping.map(k),to:n.tr.mapping.map(U)},H=a.handler({state:n,range:I,match:C,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:o});f.push(H)})}),f.every(m=>m!==null)}var Fy=null,rAe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function iAe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:u,from:f,to:g,rule:m,pasteEvt:y})=>{const v=u.tr,b=yw({state:u,transaction:v});if(!(!nAe({editor:e,state:b,from:Math.max(f-1,0),to:g.b-1,rule:m,pasteEvent:y,dropEvent:o})||!v.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(u=>new xr({view(f){const g=y=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(y.target)?f.dom.parentElement:null,r&&(Fy=e)},m=()=>{Fy&&(Fy=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,o=g,!a){const m=Fy;m?.isEditable&&setTimeout(()=>{const y=m.state.selection;y&&m.commands.deleteRange({from:y.from,to:y.to})},10)}return!1},paste:(f,g)=>{var m;const y=(m=g.clipboardData)==null?void 0:m.getData("text/html");return s=g,i=!!y?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,m)=>{const y=f[0],v=y.getMeta("uiEvent")==="paste"&&!i,b=y.getMeta("uiEvent")==="drop"&&!a,x=y.getMeta("applyPasteRules"),M=!!x;if(!v&&!b&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=$k(ht.from(T),m.schema);const{from:R}=x,N=R+T.length,j=rAe(T);return l({rule:u,state:m,from:R,to:{b:N},pasteEvt:j})}const w=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!JEe(w)||!A||w===A.b))return l({rule:u,state:m,from:w,to:A,pasteEvt:s})}}))}var Aw=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Aq(t),this.schema=xEe(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:v2(e.name,this.schema)},r=jt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Vk([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:v2(r.name,this.schema)},a=[],s=jt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&jt(r,"exitable",i)&&(o.ArrowRight=()=>dd.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([m,y])=>[m,()=>y({editor:t})]));o={...o,...g}}const l=yMe(o);a.push(l);const c=jt(r,"addInputRules",i);if(lH(r,t.options.enableInputRules)&&c){const g=c();if(g&&g.length){const m=ZEe({editor:t,rules:g}),y=Array.isArray(m)?m:[m];a.push(...y)}}const u=jt(r,"addPasteRules",i);if(lH(r,t.options.enablePasteRules)&&u){const g=u();if(g&&g.length){const m=iAe({editor:t,rules:g});a.push(...m)}}const f=jt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return Eq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=am(this.extensions);return Object.fromEntries(e.filter(n=>!!jt(n,"addNodeView")).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:Kr(n.name,this.schema)},a=jt(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(l,c,u,f,g)=>{const m=y1(l,r);return s({node:l,view:c,getPos:u,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=am(this.extensions);return Object.fromEntries(e.filter(n=>!!jt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ac(n.name,this.schema)},a=jt(n,"addMarkView",i);if(!a)return[];const s=(o,l,c)=>{const u=y1(o,r);return a()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:f=>{bAe(o,t,f)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:v2(e.name,this.schema)};e.type==="mark"&&((n=On(jt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=jt(e,"onBeforeCreate",r),a=jt(e,"onCreate",r),s=jt(e,"onUpdate",r),o=jt(e,"onSelectionUpdate",r),l=jt(e,"onTransaction",r),c=jt(e,"onFocus",r),u=jt(e,"onBlur",r),f=jt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};Aw.resolve=Aq;Aw.sort=Vk;Aw.flatten=Hk;var aAe={};Uk(aAe,{ClipboardTextSerializer:()=>Lq,Commands:()=>Iq,Delete:()=>jq,Drop:()=>Uq,Editable:()=>Fq,FocusEvents:()=>Bq,Keymap:()=>Hq,Paste:()=>$q,Tabindex:()=>Vq,TextDirection:()=>Gq,focusEventsPluginKey:()=>zq});var Wn=class Oq extends Wk{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Oq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Lq=Wn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new xr({key:new ci("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(u=>u.$from.pos)),o=Math.max(...a.map(u=>u.$to.pos)),l=Cq(n);return Tq(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Iq=Wn.create({name:"commands",addCommands(){return{...gq}}}),jq=Wn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,l,c;if((c=(l=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?c:t.getMeta("y-sync$"))return;const u=wq(t.before,[t,...e]);Rq(u).forEach(m=>{u.mapping.mapResult(m.oldRange.from).deletedAfter&&u.mapping.mapResult(m.oldRange.to).deletedBefore&&u.before.nodesBetween(m.oldRange.from,m.oldRange.to,(y,v)=>{const b=v+y.nodeSize-2,x=m.oldRange.from<=v&&b<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:y,from:v,to:b,newFrom:u.mapping.map(v),newTo:u.mapping.map(b),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:u})})});const g=u.mapping;u.steps.forEach((m,y)=>{var v,b;if(m instanceof So){const x=g.slice(y).map(m.from,-1),M=g.slice(y).map(m.to),w=g.invert().map(x,-1),A=g.invert().map(M),T=(v=u.doc.nodeAt(x-1))==null?void 0:v.marks.some(N=>N.eq(m.mark)),R=(b=u.doc.nodeAt(M))==null?void 0:b.marks.some(N=>N.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:w,to:A},newRange:{from:x,to:M},partial:!!(R||T),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),Uq=Wn.create({name:"drop",addProseMirrorPlugins(){return[new xr({key:new ci("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Fq=Wn.create({name:"editable",addProseMirrorPlugins(){return[new xr({key:new ci("editable"),props:{editable:()=>this.editor.options.editable}})]}}),zq=new ci("focusEvents"),Bq=Wn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new xr({key:zq,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}}}})]}}),Hq=Wn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:l,doc:c}=o,{empty:u,$anchor:f}=l,{pos:g,parent:m}=f,y=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,v=y.parent.type.spec.isolating,b=f.pos-f.parentOffset,x=v&&y.parent.childCount===1?b===f.pos:sn.atStart(c).from===g;return!u||!m.type.isTextblock||m.textContent.length||!x||x&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},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 Bk()||_q()?a:i},addProseMirrorPlugins(){return[new xr({key:new ci("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,l=sn.atStart(e.doc).from,c=sn.atEnd(e.doc).to;if(a||!(s===l&&o===c)||!Mw(n.doc))return;const g=n.tr,m=yw({state:n,transaction:g}),{commands:y}=new _w({editor:this.editor,state:m});if(y.clearNodes(),!!g.steps.length)return g}})]}}),$q=Wn.create({name:"paste",addProseMirrorPlugins(){return[new xr({key:new ci("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Vq=Wn.create({name:"tabindex",addProseMirrorPlugins(){return[new xr({key:new ci("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Gq=Wn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=am(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 xr({key:new ci("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),sAe=class bp{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 bp(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 bp(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 bp(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,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const l=new bp(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new bp(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const l=s[o];if(a[l]!==n[l])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(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.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)}},oAe=`.ProseMirror {
  8070. position: relative;
  8071. }
  8072. .ProseMirror {
  8073. word-wrap: break-word;
  8074. white-space: pre-wrap;
  8075. white-space: break-spaces;
  8076. -webkit-font-variant-ligatures: none;
  8077. font-variant-ligatures: none;
  8078. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8079. }
  8080. .ProseMirror [contenteditable="false"] {
  8081. white-space: normal;
  8082. }
  8083. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8084. white-space: pre-wrap;
  8085. }
  8086. .ProseMirror pre {
  8087. white-space: pre-wrap;
  8088. }
  8089. img.ProseMirror-separator {
  8090. display: inline !important;
  8091. border: none !important;
  8092. margin: 0 !important;
  8093. width: 0 !important;
  8094. height: 0 !important;
  8095. }
  8096. .ProseMirror-gapcursor {
  8097. display: none;
  8098. pointer-events: none;
  8099. position: absolute;
  8100. margin: 0;
  8101. }
  8102. .ProseMirror-gapcursor:after {
  8103. content: "";
  8104. display: block;
  8105. position: absolute;
  8106. top: -2px;
  8107. width: 20px;
  8108. border-top: 1px solid black;
  8109. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8110. }
  8111. @keyframes ProseMirror-cursor-blink {
  8112. to {
  8113. visibility: hidden;
  8114. }
  8115. }
  8116. .ProseMirror-hideselection *::selection {
  8117. background: transparent;
  8118. }
  8119. .ProseMirror-hideselection *::-moz-selection {
  8120. background: transparent;
  8121. }
  8122. .ProseMirror-hideselection * {
  8123. caret-color: transparent;
  8124. }
  8125. .ProseMirror-focused .ProseMirror-gapcursor {
  8126. display: block;
  8127. }`;function lAe(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 cAe=class extends KEe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=bq(e,this.options.autofocus);this.editorState=Ep.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=lAe(oAe,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=Mq(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(s=>!s.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?[Fq,Lq.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Iq,Bq,Hq,Vq,Uq,$q,jq,Gq.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 Aw(r,this)}createCommandManager(){this.commandManager=new _w({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=iR(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=iR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new pq(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});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 s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),o=s?.getMeta("focus"),l=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Nq(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return EEe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return $k(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8128. `,textSerializers:n={}}=t||{};return bEe(this.state.doc,{blockSeparator:e,textSerializers:{...Cq(this.schema),...n}})}get isEmpty(){return Mw(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 sAe(e,this)}get $doc(){return this.$pos(0)}};function sm(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=On(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],o=r[0];if(s){const l=o.search(/\S/),c=n.from+o.indexOf(s),u=c+s.length;if(Gk(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(v=>v===t.type&&v!==m.mark.type)).filter(m=>m.to>c).length)return null;u<n.to&&a.delete(u,n.to),c>n.from&&a.delete(n.from+l,c);const g=n.from+l+s.length;a.addMark(n.from+l,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Wq(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=On(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let o=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>o?u=o:o=u+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(u,o,l)}else if(r[0]){const c=t.type.isInline?s:s-1;a.insert(c,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function sR(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=On(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 om(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=On(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Sk(l,t.type,a);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,y=g||f.$to.parentOffset&&f.$from.marks();if(y){const v=y.filter(b=>m.includes(b.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&cd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)},undoable:t.undoable})}var uAe=t=>"touches"in t,dAe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,l=s.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,uAe(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"),s=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),o?i=this.startHeight+n:l&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&l>this.maxSize.height&&(l=this.maxSize.height,o=l*this.aspectRatio),{width:o,height:l}}applyAspectRatio(t,e,n){const 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 fAe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof zt){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 hAe={};Uk(hAe,{createAtomBlockMarkdownSpec:()=>pAe,createBlockMarkdownSpec:()=>mAe,createInlineMarkdownSpec:()=>vAe,parseAttributes:()=>qk,parseIndentedBlocks:()=>oR,renderNestedMarkdownContent:()=>Kk,serializeAttributes:()=>Xk});function qk(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,c,u])=>{var f;const g=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[g];m&&(e[c]=m.slice(1,-1))});const l=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 l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Xk(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 pAe(t){const{nodeName:e,name:n,parseAttributes:r=qk,serializeAttributes:i=Xk,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,l=n||e,c=u=>{if(!o)return u;const f={};return o.forEach(g=>{g in u&&(f[g]=u[g])}),f};return{parseMarkdown:(u,f)=>{const g={...a,...u.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(f=u.match(g))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(u,f,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),y=u.match(m);if(!y)return;const v=y[1]||"",b=r(v);if(!s.find(M=>!(M in b)))return{type:e,raw:y[0],attributes:b}}},renderMarkdown:u=>{const f=c(u.attrs||{}),g=i(f),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function mAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=qk,serializeAttributes:a=Xk,defaultAttributes:s={},content:o="block",allowedAttributes:l}=t,c=n||e,u=f=>{if(!l)return f;const g={};return l.forEach(m=>{m in f&&(g[m]=f[m])}),g};return{parseMarkdown:(f,g)=>{let m;if(r){const v=r(f);m=typeof v=="string"?[{type:"text",text:v}]:v}else o==="block"?m=g.parseChildren(f.tokens||[]):m=g.parseInline(f.tokens||[]);const y={...s,...f.attributes};return g.createNode(e,y,m)},markdownTokenizer:{name:e,level:"block",start(f){var g;const m=new RegExp(`^:::${c}`,"m"),y=(g=f.match(m))==null?void 0:g.index;return y!==void 0?y:-1},tokenize(f,g,m){var y;const v=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(v);if(!b)return;const[x,M=""]=b,w=i(M);let A=1;const T=x.length;let R="";const N=/^:::([\w-]*)(\s.*)?/gm,j=f.slice(T);for(N.lastIndex=0;;){const C=N.exec(j);if(C===null)break;const k=C.index,U=C[1];if(!((y=C[2])!=null&&y.endsWith(":::"))){if(U)A+=1;else if(A-=1,A===0){const I=j.slice(0,k);R=I.trim();const H=f.slice(0,T+k+C[0].length);let O=[];if(R)if(o==="block")for(O=m.blockTokens(I),O.forEach(B=>{B.text&&(!B.tokens||B.tokens.length===0)&&(B.tokens=m.inlineTokens(B.text))});O.length>0;){const B=O[O.length-1];if(B.type==="paragraph"&&(!B.text||B.text.trim()===""))O.pop();else break}else O=m.inlineTokens(R);return{type:e,raw:H,attributes:w,content:R,tokens:O}}}}}},renderMarkdown:(f,g)=>{const m=u(f.attrs||{}),y=a(m),v=y?` {${y}}`:"",b=g.renderChildren(f.content||[],`
  8129. `);return`:::${c}${v}
  8130. ${b}
  8131. :::`}}}function gAe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,s]=r;e[i]=a||s,r=n.exec(t)}return e}function xAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function vAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=gAe,serializeAttributes:a=xAe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,u=g=>{if(!l)return g;const m={};return l.forEach(y=>{y in g&&(m[y]=g[y])}),m},f=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const y={...s,...g.attributes};if(o)return m.createNode(e,y);const v=r?r(g):g.content||"";return v?m.createNode(e,y,[m.createTextNode(v)]):m.createNode(e,y,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),y=g.match(m),v=y?.index;return v!==void 0?v:-1},tokenize(g,m,y){const v=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=g.match(v);if(!b)return;let x="",M="";if(o){const[,A]=b;M=A}else{const[,A,T]=b;M=A,x=T||""}const w=i(M.trim());return{type:e,raw:b[0],content:x.trim(),attributes:w}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const y=u(g.attrs||{}),v=a(y),b=v?` ${v}`:"";return o?`[${c}${b}]`:`[${c}${b}]${m}[/${c}]`}}}function oR(t,e,n){var r,i,a,s;const o=t.split(`
  8132. `),l=[];let c="",u=0;const f=e.baseIndentSize||2;for(;u<o.length;){const g=o[u],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){u+=1,c=`${c}${g}
  8133. `;continue}else return}const y=e.extractItemData(m),{indentLevel:v,mainContent:b}=y;c=`${c}${g}
  8134. `;const x=[b];for(u+=1;u<o.length;){const T=o[u];if(T.trim()===""){const N=o.slice(u+1).findIndex(k=>k.trim()!=="");if(N===-1)break;if((((i=(r=o[u+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){x.push(T),c=`${c}${T}
  8135. `,u+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)x.push(T),c=`${c}${T}
  8136. `,u+=1;else break}let M;const w=x.slice(1);if(w.length>0){const T=w.map(R=>R.slice(v+f)).join(`
  8137. `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const A=e.createToken(y,M);l.push(A)}if(l.length!==0)return{items:l,raw:c}}function Kk(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),l=[`${i}${o}`];return s&&s.length>0&&s.forEach(c=>{const u=e.renderChildren([c]);if(u){const f=u.split(`
  8138. `).map(g=>g?e.indent(g):"").join(`
  8139. `);l.push(f)}}),l.join(`
  8140. `)}function bAe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,l)=>{const c=a.mapping.map(l),u=a.mapping.map(l)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==s)return!1;f=m}),!f)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});a.removeMark(c,u,t.type),a.addMark(c,u,m)}}),a.docChanged&&e.view.dispatch(a)}var Va=class qq extends Wk{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new qq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function jf(t){return new eAe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=On(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];let c=n.to;if(o){const u=l.search(/\S/),f=n.from+l.indexOf(o),g=f+o.length;if(Gk(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(b=>b===t.type&&b!==y.mark.type)).filter(y=>y.to>f).length)return null;g<n.to&&s.delete(g,n.to),f>n.from&&s.delete(n.from+u,f),c=n.from+u+o.length,s.addMark(n.from+u,c,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var _2,dH;function yAe(){return dH||(dH=1,_2=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var s=a[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),_2}var _Ae=yAe();const SAe=Js(_Ae);var S2={exports:{}},w2={};var fH;function wAe(){if(fH)return w2;fH=1;var t=xm(),e=AG();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return w2.useSyncExternalStoreWithSelector=function(c,u,f,g,m){var y=a(null);if(y.current===null){var v={hasValue:!1,value:null};y.current=v}else v=y.current;y=o(function(){function x(R){if(!M){if(M=!0,w=R,R=g(R),m!==void 0&&v.hasValue){var N=v.value;if(m(N,R))return A=N}return A=R}if(N=A,r(w,R))return N;var j=g(R);return m!==void 0&&m(N,j)?(w=R,N):(w=R,A=j)}var M=!1,w,A,T=f===void 0?null:f;return[function(){return x(u())},T===null?void 0:function(){return x(T())}]},[u,f,g,m]);var b=i(c,y[0],y[1]);return s(function(){v.hasValue=!0,v.value=b},[b]),l(b),b},w2}var hH;function MAe(){return hH||(hH=1,S2.exports=wAe()),S2.exports}var Xq=MAe(),EAe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},AAe=({contentComponent:t})=>{const e=RP.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return h.jsx(h.Fragment,{children:Object.values(e)})};function TAe(){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]:Gie.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 CAe=class extends ur.Component{constructor(t){var e;super(t),this.editorContentRef=ur.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=TAe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return h.jsxs(h.Fragment,{children:[h.jsx("div",{ref:EAe(e,this.editorContentRef),...n}),t?.contentComponent&&h.jsx(AAe,{contentComponent:t.contentComponent})]})}},NAe=E.forwardRef((t,e)=>{const n=ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ur.createElement(CAe,{key:n,innerRef:e,...t})}),RAe=ur.memo(NAe),PAe=typeof window<"u"?E.useLayoutEffect:E.useEffect,kAe=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 DAe(t){var e;const[n]=E.useState(()=>new kAe(t.editor)),r=Xq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:SAe);return PAe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var OAe=!1,lR=typeof window>"u",LAe=lR||!!(typeof window<"u"&&window.next),IAe=class Kq{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?lR||LAe?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 cAe(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 s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Kq.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 jAe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new IAe(n)),i=RP.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),DAe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var UAe=E.createContext({editor:null});UAe.Consumer;var FAe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),zAe=()=>E.useContext(FAe);ur.forwardRef((t,e)=>{const{onDragStart:n}=zAe(),r=t.as||"div";return h.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ur.createContext({markViewContentRef:()=>{}});var _1=(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]},BAe=/^\s*>\s$/,HAe=Va.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return _1("blockquote",{...Er(this.options.HTMLAttributes,t),children:_1("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 o=e.renderChildren([i]).split(`
  8141. `).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(o.join(`
  8142. `))}),r.join(`
  8143. ${n}
  8144. `)},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[om({find:BAe,type:this.type})]}}),$Ae=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VAe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,GAe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,WAe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qAe=dd.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 _1("strong",{...Er(this.options.HTMLAttributes,t),children:_1("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[sm({find:$Ae,type:this.type}),sm({find:GAe,type:this.type})]},addPasteRules(){return[jf({find:VAe,type:this.type}),jf({find:WAe,type:this.type})]}}),XAe=/(^|[^`])`([^`]+)`(?!`)$/,KAe=/(^|[^`])`([^`]+)`(?!`)/g,YAe=dd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Er(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[sm({find:XAe,type:this.type})]},addPasteRules(){return[jf({find:KAe,type:this.type})]}}),M2=4,ZAe=/^```([a-z]+)?[\s\n]$/,QAe=/^~~~([a-z]+)?[\s\n]$/,JAe=Va.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:M2,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Er(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(`
  8145. `):r=`\`\`\`${i}
  8146. \`\`\``,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:M2,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8147. `,`
  8148. `).split(`
  8149. `).map(y=>o+y).join(`
  8150. `);return l.replaceWith(c,u,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:M2,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var l;const{pos:c}=a,u=a.start(),f=a.end(),m=r.doc.textBetween(u,f,`
  8151. `,`
  8152. `).split(`
  8153. `);let y=0,v=0;const b=c-u;for(let R=0;R<m.length;R+=1){if(v+m[R].length>=b){y=R;break}v+=m[R].length+1}const M=((l=m[y].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let A=u;for(let R=0;R<y;R+=1)A+=m[R].length+1;return o.delete(A,A+w),c-A<=w&&o.setSelection(Vt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:c}=i,g=r.doc.textBetween(l,c,`
  8154. `,`
  8155. `).split(`
  8156. `).map(m=>{var y;const v=((y=m.match(/^ */))==null?void 0:y[0])||"",b=Math.min(v.length,n);return m.slice(b)}).join(`
  8157. `);return o.replaceWith(l,c,r.schema.text(g)),!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,s=r.parent.textContent.endsWith(`
  8158. `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.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 o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:c})=>(c.setSelection(sn.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[sR({find:ZAe,type:this.type,getAttributes:t=>({language:t[1]})}),sR({find:QAe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xr({key:new ci("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:s,schema:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
  8159. `));return s.replaceSelectionWith(this.type.create({language:a},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Vt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),eTe=Va.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8160. `):""}),tTe=Va.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",Er(this.options.HTMLAttributes,t)]},renderText(){return`
  8161. `},renderMarkdown:()=>`
  8162. `,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:s}=this.options,{splittableMarks:o}=r.extensionManager,l=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&s){const f=l.filter(g=>o.includes(g.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),nTe=Va.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]}`,Er(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=>sR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),rTe=Va.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Er(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!fAe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Pq(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:l}=s.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?s.setSelection(Vt.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(zt.create(s.doc,l.pos)):s.setSelection(Vt.create(s.doc,l.pos));else{const u=a.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,f=u?.create();f&&(s.insert(c,f),s.setSelection(Vt.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Wq({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),iTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,aTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,sTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,oTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lTe=dd.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",Er(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[sm({find:iTe,type:this.type}),sm({find:sTe,type:this.type})]},addPasteRules(){return[jf({find:aTe,type:this.type}),jf({find:oTe,type:this.type})]}});const cTe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",uTe="ελ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",cR="numeric",uR="ascii",dR="alpha",Tx="asciinumeric",fx="alphanumeric",fR="domain",Yq="emoji",dTe="scheme",fTe="slashscheme",E2="whitespace";function hTe(t,e){return t in e||(e[t]=[]),e[t]}function sf(t,e,n){e[cR]&&(e[Tx]=!0,e[fx]=!0),e[uR]&&(e[Tx]=!0,e[dR]=!0),e[Tx]&&(e[fx]=!0),e[dR]&&(e[fx]=!0),e[fx]&&(e[fR]=!0),e[Yq]&&(e[fR]=!0);for(const r in e){const i=hTe(r,n);i.indexOf(t)<0&&i.push(t)}}function pTe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ja(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ja.groups={};ja.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||ja.groups;let i;return e&&e.j?i=e:(i=new ja(e),n&&r&&sf(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 s=0;s<a-1;s++)i=i.tt(t[s]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||ja.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,o=i.go(t);if(o?(s=new ja,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new ja,a){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(pTe(s.t,r),n);sf(a,l,r)}else n&&sf(a,n,r);s.t=a}return i.j[t]=s,s}};const tn=(t,e,n,r,i)=>t.ta(e,n,r,i),Sr=(t,e,n,r,i)=>t.tr(e,n,r,i),pH=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),Wl="WORD",hR="UWORD",Zq="ASCIINUMERICAL",Qq="ALPHANUMERICAL",d0="LOCALHOST",pR="TLD",mR="UTLD",C_="SCHEME",yp="SLASH_SCHEME",Yk="NUM",gR="WS",Zk="NL",Cx="OPENBRACE",Nx="CLOSEBRACE",S1="OPENBRACKET",w1="CLOSEBRACKET",M1="OPENPAREN",E1="CLOSEPAREN",A1="OPENANGLEBRACKET",T1="CLOSEANGLEBRACKET",C1="FULLWIDTHLEFTPAREN",N1="FULLWIDTHRIGHTPAREN",R1="LEFTCORNERBRACKET",P1="RIGHTCORNERBRACKET",k1="LEFTWHITECORNERBRACKET",D1="RIGHTWHITECORNERBRACKET",O1="FULLWIDTHLESSTHAN",L1="FULLWIDTHGREATERTHAN",I1="AMPERSAND",j1="APOSTROPHE",U1="ASTERISK",Mu="AT",F1="BACKSLASH",z1="BACKTICK",B1="CARET",Pu="COLON",Qk="COMMA",H1="DOLLAR",Uo="DOT",$1="EQUALS",Jk="EXCLAMATION",ks="HYPHEN",Rx="PERCENT",V1="PIPE",G1="PLUS",W1="POUND",Px="QUERY",eD="QUOTE",Jq="FULLWIDTHMIDDLEDOT",tD="SEMI",Fo="SLASH",kx="TILDE",q1="UNDERSCORE",eX="EMOJI",X1="SYM";var tX=Object.freeze({__proto__:null,ALPHANUMERICAL:Qq,AMPERSAND:I1,APOSTROPHE:j1,ASCIINUMERICAL:Zq,ASTERISK:U1,AT:Mu,BACKSLASH:F1,BACKTICK:z1,CARET:B1,CLOSEANGLEBRACKET:T1,CLOSEBRACE:Nx,CLOSEBRACKET:w1,CLOSEPAREN:E1,COLON:Pu,COMMA:Qk,DOLLAR:H1,DOT:Uo,EMOJI:eX,EQUALS:$1,EXCLAMATION:Jk,FULLWIDTHGREATERTHAN:L1,FULLWIDTHLEFTPAREN:C1,FULLWIDTHLESSTHAN:O1,FULLWIDTHMIDDLEDOT:Jq,FULLWIDTHRIGHTPAREN:N1,HYPHEN:ks,LEFTCORNERBRACKET:R1,LEFTWHITECORNERBRACKET:k1,LOCALHOST:d0,NL:Zk,NUM:Yk,OPENANGLEBRACKET:A1,OPENBRACE:Cx,OPENBRACKET:S1,OPENPAREN:M1,PERCENT:Rx,PIPE:V1,PLUS:G1,POUND:W1,QUERY:Px,QUOTE:eD,RIGHTCORNERBRACKET:P1,RIGHTWHITECORNERBRACKET:D1,SCHEME:C_,SEMI:tD,SLASH:Fo,SLASH_SCHEME:yp,SYM:X1,TILDE:kx,TLD:pR,UNDERSCORE:q1,UTLD:mR,UWORD:hR,WORD:Wl,WS:gR});const Hl=/[a-z]/,Xg=new RegExp("\\p{L}","u"),A2=new RegExp("\\p{Emoji}","u"),$l=/\d/,T2=/\s/,mH="\r",C2=`
  8163. `,mTe="️",gTe="‍",N2="";let zy=null,By=null;function xTe(t=[]){const e={};ja.groups=e;const n=new ja;zy==null&&(zy=gH(cTe)),By==null&&(By=gH(uTe)),gt(n,"'",j1),gt(n,"{",Cx),gt(n,"}",Nx),gt(n,"[",S1),gt(n,"]",w1),gt(n,"(",M1),gt(n,")",E1),gt(n,"<",A1),gt(n,">",T1),gt(n,"(",C1),gt(n,")",N1),gt(n,"「",R1),gt(n,"」",P1),gt(n,"『",k1),gt(n,"』",D1),gt(n,"<",O1),gt(n,">",L1),gt(n,"&",I1),gt(n,"*",U1),gt(n,"@",Mu),gt(n,"`",z1),gt(n,"^",B1),gt(n,":",Pu),gt(n,",",Qk),gt(n,"$",H1),gt(n,".",Uo),gt(n,"=",$1),gt(n,"!",Jk),gt(n,"-",ks),gt(n,"%",Rx),gt(n,"|",V1),gt(n,"+",G1),gt(n,"#",W1),gt(n,"?",Px),gt(n,'"',eD),gt(n,"/",Fo),gt(n,";",tD),gt(n,"~",kx),gt(n,"_",q1),gt(n,"\\",F1),gt(n,"・",Jq);const r=Sr(n,$l,Yk,{[cR]:!0});Sr(r,$l,r);const i=Sr(r,Hl,Zq,{[Tx]:!0}),a=Sr(r,Xg,Qq,{[fx]:!0}),s=Sr(n,Hl,Wl,{[uR]:!0});Sr(s,$l,i),Sr(s,Hl,s),Sr(i,$l,i),Sr(i,Hl,i);const o=Sr(n,Xg,hR,{[dR]:!0});Sr(o,Hl),Sr(o,$l,a),Sr(o,Xg,o),Sr(a,$l,a),Sr(a,Hl),Sr(a,Xg,a);const l=gt(n,C2,Zk,{[E2]:!0}),c=gt(n,mH,gR,{[E2]:!0}),u=Sr(n,T2,gR,{[E2]:!0});gt(n,N2,u),gt(c,C2,l),gt(c,N2,u),Sr(c,T2,u),gt(u,mH),gt(u,C2),Sr(u,T2,u),gt(u,N2,u);const f=Sr(n,A2,eX,{[Yq]:!0});gt(f,"#"),Sr(f,A2,f),gt(f,mTe,f);const g=gt(f,gTe);gt(g,"#"),Sr(g,A2,f);const m=[[Hl,s],[$l,i]],y=[[Hl,null],[Xg,o],[$l,a]];for(let v=0;v<zy.length;v++)xu(n,zy[v],pR,Wl,m);for(let v=0;v<By.length;v++)xu(n,By[v],mR,hR,y);sf(pR,{tld:!0,ascii:!0},e),sf(mR,{utld:!0,alpha:!0},e),xu(n,"file",C_,Wl,m),xu(n,"mailto",C_,Wl,m),xu(n,"http",yp,Wl,m),xu(n,"https",yp,Wl,m),xu(n,"ftp",yp,Wl,m),xu(n,"ftps",yp,Wl,m),sf(C_,{scheme:!0,ascii:!0},e),sf(yp,{slashscheme:!0,ascii:!0},e),t=t.sort((v,b)=>v[0]>b[0]?1:-1);for(let v=0;v<t.length;v++){const b=t[v][0],M=t[v][1]?{[dTe]:!0}:{[fTe]:!0};b.indexOf("-")>=0?M[fR]=!0:Hl.test(b)?$l.test(b)?M[Tx]=!0:M[uR]=!0:M[cR]=!0,pH(n,b,b,M)}return pH(n,"localhost",d0,{ascii:!0}),n.jd=new ja(X1),{start:n,tokens:Object.assign({groups:e},tX)}}function nX(t,e){const n=vTe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let o=t,l=null,c=0,u=null,f=-1,g=-1;for(;s<r&&(l=o.go(n[s]));)o=l,o.accepts()?(f=0,g=0,u=o):f>=0&&(f+=n[s].length,g++),c+=n[s].length,a+=n[s].length,s++;a-=f,s-=g,c-=f,i.push({t:u.t,v:e.slice(a-c,a),s:a-c,e:a})}return i}function vTe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,s=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function xu(t,e,n,r,i){let a;const s=e.length;for(let o=0;o<s-1;o++){const l=e[o];t.j[l]?a=t.j[l]:(a=new ja(r),a.jr=i.slice(),t.j[l]=a),t=a}return a=new ja(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function gH(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 s=parseInt(t.substring(r,r+a),10);s>0;s--)n.pop();r+=a}else n.push(t[r]),r++}return e}const f0={defaultProtocol:"http",events:null,format:xH,formatHref:xH,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function nD(t,e=null){let n=Object.assign({},f0);t&&(n=Object.assign(n,t instanceof nD?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}nD.prototype={o:f0,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]:f0[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 xH(t){return t}function rX(t,e){this.t="token",this.v=t,this.tk=e}rX.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=f0.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),s={},o=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,o&&(s.class=o),l&&(s.target=l),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:a,eventListeners:f}}};function Tw(t,e){class n extends rX{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 vH=Tw("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),bH=Tw("text"),bTe=Tw("nl"),Hy=Tw("url",{isLink:!0,toHref(t=f0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==d0&&t[1].t===Pu}}),Cs=t=>new ja(t);function yTe({groups:t}){const e=t.domain.concat([I1,U1,Mu,F1,z1,B1,H1,$1,ks,Yk,Rx,V1,G1,W1,Fo,X1,kx,q1]),n=[j1,Pu,Qk,Uo,Jk,Rx,Px,eD,tD,A1,T1,Cx,Nx,w1,S1,M1,E1,C1,N1,R1,P1,k1,D1,O1,L1],r=[I1,j1,U1,F1,z1,B1,H1,$1,ks,Cx,Nx,Rx,V1,G1,W1,Px,Fo,X1,kx,q1],i=Cs(),a=gt(i,kx);tn(a,r,a),tn(a,t.domain,a);const s=Cs(),o=Cs(),l=Cs();tn(i,t.domain,s),tn(i,t.scheme,o),tn(i,t.slashscheme,l),tn(s,r,a),tn(s,t.domain,s);const c=gt(s,Mu);gt(a,Mu,c),gt(o,Mu,c),gt(l,Mu,c);const u=gt(a,Uo);tn(u,r,a),tn(u,t.domain,a);const f=Cs();tn(c,t.domain,f),tn(f,t.domain,f);const g=gt(f,Uo);tn(g,t.domain,f);const m=Cs(vH);tn(g,t.tld,m),tn(g,t.utld,m),gt(c,d0,m);const y=gt(f,ks);gt(y,ks,y),tn(y,t.domain,f),tn(m,t.domain,f),gt(m,Uo,g),gt(m,ks,y);const v=gt(m,Pu);tn(v,t.numeric,vH);const b=gt(s,ks),x=gt(s,Uo);gt(b,ks,b),tn(b,t.domain,s),tn(x,r,a),tn(x,t.domain,s);const M=Cs(Hy);tn(x,t.tld,M),tn(x,t.utld,M),tn(M,t.domain,s),tn(M,r,a),gt(M,Uo,x),gt(M,ks,b),gt(M,Mu,c);const w=gt(M,Pu),A=Cs(Hy);tn(w,t.numeric,A);const T=Cs(Hy),R=Cs();tn(T,e,T),tn(T,n,R),tn(R,e,T),tn(R,n,R),gt(M,Fo,T),gt(A,Fo,T);const N=gt(o,Pu),j=gt(l,Pu),C=gt(j,Fo),k=gt(C,Fo);tn(o,t.domain,s),gt(o,Uo,x),gt(o,ks,b),tn(l,t.domain,s),gt(l,Uo,x),gt(l,ks,b),tn(N,t.domain,T),gt(N,Fo,T),gt(N,Px,T),tn(k,t.domain,T),tn(k,e,T),gt(k,Fo,T);const U=[[Cx,Nx],[S1,w1],[M1,E1],[A1,T1],[C1,N1],[R1,P1],[k1,D1],[O1,L1]];for(let I=0;I<U.length;I++){const[H,O]=U[I],B=gt(T,H);gt(R,H,B),gt(B,O,T);const V=Cs(Hy);tn(B,e,V);const G=Cs();tn(B,n),tn(V,e,V),tn(V,n,G),tn(G,e,V),tn(G,n,G),gt(V,O,T),gt(G,O,T)}return gt(i,d0,M),gt(i,Zk,bTe),{start:i,tokens:tX}}function _Te(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let o=t,l=null,c=null,u=0,f=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||o.go(n[i].t));)l=null,o=c,o.accepts()?(g=0,f=o):g>=0&&g++,i++,u++;if(g<0)i-=u,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(R2(bH,e,s)),s=[]),i-=g,u-=g;const m=f.t,y=n.slice(i-u,i);a.push(R2(m,e,y))}}return s.length>0&&a.push(R2(bH,e,s)),a}function R2(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 STe=typeof console<"u"&&console&&console.warn||(()=>{}),wTe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ir={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function MTe(){return ja.groups={},ir.scanner=null,ir.parser=null,ir.tokenQueue=[],ir.pluginQueue=[],ir.customSchemes=[],ir.initialized=!1,ir}function yH(t,e=!1){if(ir.initialized&&STe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${wTe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8164. 1. Must only contain digits, lowercase ASCII letters or "-"
  8165. 2. Cannot start or end with "-"
  8166. 3. "-" cannot repeat`);ir.customSchemes.push([t,e])}function ETe(){ir.scanner=xTe(ir.customSchemes);for(let t=0;t<ir.tokenQueue.length;t++)ir.tokenQueue[t][1]({scanner:ir.scanner});ir.parser=yTe(ir.scanner.tokens);for(let t=0;t<ir.pluginQueue.length;t++)ir.pluginQueue[t][1]({scanner:ir.scanner,parser:ir.parser});return ir.initialized=!0,ir}function rD(t){return ir.initialized||ETe(),_Te(ir.parser.start,t,nX(ir.scanner.start,t))}rD.scan=nX;function iX(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 nD(n),i=rD(t),a=[];for(let s=0;s<i.length;s++){const o=i[s];o.isLink&&(!e||o.t===e)&&r.check(o)&&a.push(o.toFormattedObject(r))}return a}var iD="[\0-   ᠎ -\u2029  ]",ATe=new RegExp(iD),TTe=new RegExp(`${iD}$`),CTe=new RegExp(iD,"g");function NTe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function RTe(t){return new xr({key:new ci("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),a=e.some(c=>c.getMeta("preventAutolink"));if(!i||a)return;const{tr:s}=r,o=wq(n.doc,[...e]);if(Rq(o).forEach(({newRange:c})=>{const u=hEe(r.doc,c,m=>m.isTextblock);let f,g;if(u.length>1)f=u[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const m=r.doc.textBetween(c.from,c.to," "," ");if(!TTe.test(m))return;f=u[0],g=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&g){const m=g.split(ATe).filter(Boolean);if(m.length<=0)return!1;const y=m[m.length-1],v=f.pos+g.lastIndexOf(y);if(!y)return!1;const b=rD(y).map(x=>x.toObject(t.defaultProtocol));if(!NTe(b))return!1;b.filter(x=>x.isLink).map(x=>({...x,from:v+x.start+1,to:v+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{Gk(x.from,x.to,r.doc).some(M=>M.mark.type===t.type)||s.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!s.steps.length)return s}})}function PTe(t){return new xr({key:new ci("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let u=r.target;const f=[];for(;u.nodeName!=="DIV";)f.push(u),u=u.parentNode;s=f.find(g=>g.nodeName==="A")}if(!s)return!1;const o=Nq(e.state,t.type.name),l=(i=s?.href)!=null?i:o.href,c=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&l?(window.open(l,c),!0):!1}}})}function kTe(t){return new xr({key:new ci("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=iX(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||i!==void 0&&!i(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Hd(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(CTe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var aX=dd.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"){yH(t);return}yH(t.scheme,t.optionalSlashes)})},onDestroy(){MTe()},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)=>!!Hd(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Hd(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=>!!Hd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Er(this.options.HTMLAttributes,t),0]:["a",Er(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=>!!Hd(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=>!!Hd(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[jf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=iX(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!Hd(s,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(RTe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Hd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(PTe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(kTe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),DTe=aX,OTe=Object.defineProperty,LTe=(t,e)=>{for(var n in e)OTe(t,n,{get:e[n],enumerable:!0})},ITe="listItem",_H="textStyle",SH=/^\s*([-+*])\s$/,sX=Va.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",Er(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,`
  8167. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ITe,this.editor.getAttributes(_H)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=om({find:SH,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=om({find:SH,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(_H),editor:this.editor})),[t]}}),oX=Va.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Er(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 s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Kk(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),jTe={};LTe(jTe,{findListItemPos:()=>V0,getNextListDepth:()=>aD,handleBackspace:()=>xR,handleDelete:()=>vR,hasListBefore:()=>lX,hasListItemAfter:()=>UTe,hasListItemBefore:()=>cX,listItemHasSubList:()=>uX,nextListIsDeeper:()=>dX,nextListIsHigher:()=>fX});var V0=(t,e)=>{const{$from:n}=e.selection,r=Kr(t,e.schema);let i=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)i=n.node(a),i.type===r?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},aD=(t,e)=>{const n=V0(t,e);if(!n)return!1;const[,r]=wEe(e,t,n.$pos.pos+4);return r},lX=(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))},cX=(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)},uX=(t,e,n)=>{if(!n)return!1;const r=Kr(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},xR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!td(t.state,e)&&lX(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),c=[];l.node().descendants((g,m)=>{g.type.name===e&&c.push({node:g,pos:m})});const u=c.at(-1);if(!u)return!1;const f=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!td(t.state,e)||!TEe(t.state))return!1;const r=V0(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=uX(e,t.state,a);return cX(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},dX=(t,e)=>{const n=aD(t,e),r=V0(t,e);return!r||!n?!1:n>r.depth},fX=(t,e)=>{const n=aD(t,e),r=V0(t,e);return!r||!n?!1:n<r.depth},vR=(t,e)=>{if(!td(t.state,e)||!AEe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:dX(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():fX(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},UTe=(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)},hX=Wn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&vR(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&&vR(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&&xR(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&&xR(t,n,r)&&(e=!0)}),e}}}}),wH=/^(\s*)(\d+)\.\s+(.*)$/,FTe=/^\s/;function zTe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(wH);if(!a)break;const[,s,o,l]=a,c=s.length;let u=l,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(wH))break;if(m.trim()==="")g.push(m),u+=`
  8168. `,f+=1;else if(m.match(FTe))g.push(m),u+=`
  8169. ${m.slice(c+2)}`,f+=1;else break}e.push({indent:c,number:parseInt(o,10),content:u.trim(),raw:g.join(`
  8170. `)}),r=f,n=f}return[e,r]}function pX(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
  8171. `),l=((r=o[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=o.slice(1).join(`
  8172. `).trim();if(u){const m=n.blockTokens(u);c.push(...m)}let f=a+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const m=Math.min(...g.map(v=>v.indent)),y=pX(g,m,n);c.push({type:"list",ordered:!0,start:g[0].number,items:y,raw:g.map(v=>v.raw).join(`
  8173. `)})}i.push({type:"list_item",raw:s.raw,tokens:c}),a=f}else a+=1}return i}function BTe(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 HTe="listItem",MH="textStyle",EH=/^(\d+)\.\s$/,mX=Va.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",Er(this.options.HTMLAttributes,n),0]:["ol",Er(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?BTe(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,`
  8174. `):"",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(`
  8175. `),[a,s]=zTe(i);if(a.length===0)return;const o=pX(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
  8176. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(HTe,this.editor.getAttributes(MH)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=om({find:EH,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=om({find:EH,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(MH)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),$Te=/^\s*(\[([( |x])?\])\s$/,VTe=Va.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",Er(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 Kk(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"),s=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),c=u=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,u,o.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",u=>u.preventDefault()),o.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const y=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...y?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),i.append(a,l),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)}),{dom:i,contentDOM:l,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,o.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[om({find:$Te,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),GTe=Va.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",Er(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,`
  8177. `):"",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 s=oR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=oR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser: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()}}});Wn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(sX.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(oX.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(hX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(mX.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(VTe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(GTe.configure(this.options.taskList)),t}});var WTe=Va.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Er(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qTe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,XTe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,KTe=dd.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",Er(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[sm({find:qTe,type:this.type})]},addPasteRules(){return[jf({find:XTe,type:this.type})]}}),YTe=Va.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),gX=dd.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",Er(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()}}}),ZTe=gX;function QTe(t={}){return new xr({view(e){return new JTe(e,t)}})}class JTe{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=s=>{this[i](s)};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(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let y=m.getBoundingClientRect(),v=f?y.bottom:y.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*o;r={left:y.left,right:y.right,top:v-b,bottom:v+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),g=f.width/l.offsetWidth,m=f.height/l.offsetHeight;c=f.left-l.scrollLeft*g,u=f.top-l.scrollTop*m}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),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 s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=m7(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Mr extends sn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Mr.valid(r)?new Mr(r):sn.near(r)}content(){return Et.empty}eq(e){return e instanceof Mr&&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 Mr(e.resolve(n.pos))}getBookmark(){return new sD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!e2e(e)||!t2e(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&&Mr.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Mr.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!zt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Mr.valid(o))return o}return null}}}Mr.prototype.visible=!1;Mr.findFrom=Mr.findGapCursorFrom;sn.jsonID("gapcursor",Mr);class sD{constructor(e){this.pos=e}map(e){return new sD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Mr.valid(n)?new Mr(n):sn.near(n)}}function xX(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function e2e(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||xX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function t2e(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||xX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function n2e(){return new xr({props:{decorations:s2e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Mr.valid(n)?new Mr(n):null},handleClick:i2e,handleKeyDown:r2e,handleDOMEvents:{beforeinput:a2e}}})}const r2e=mq({ArrowLeft:$y("horiz",-1),ArrowRight:$y("horiz",1),ArrowUp:$y("vert",-1),ArrowDown:$y("vert",1)});function $y(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Vt){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let c=Mr.findGapCursorFrom(o,e,l);return c?(i&&i(r.tr.setSelection(new Mr(c))),!0):!1}}function i2e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Mr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&zt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Mr(r))),!0)}function a2e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Mr))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=ht.empty;for(let s=r.length-1;s>=0;s--)i=ht.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Et(i,0,0));return a.setSelection(Vt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function s2e(t){if(!(t.selection instanceof Mr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pr.create(t.doc,[ga.widget(t.selection.head,e,{key:"gapcursor"})])}var K1=200,Ni=function(){};Ni.prototype.append=function(e){return e.length?(e=Ni.from(e),!this.length&&e||e.length<K1&&this.leafAppend(e)||this.length<K1&&e.leafPrepend(this)||this.appendInner(e)):this};Ni.prototype.prepend=function(e){return e.length?Ni.from(e).append(this):this};Ni.prototype.appendInner=function(e){return new o2e(this,e)};Ni.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ni.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ni.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ni.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)};Ni.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Ni.from=function(e){return e instanceof Ni?e:e&&e.length?new vX(e):Ni.empty};var vX=(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,s,o){for(var l=a;l<s;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var l=a-1;l>=s;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=K1)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=K1)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})(Ni);Ni.empty=new vX([]);var o2e=(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,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!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})(Ni);const l2e=500;class go{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 s=e.tr,o,l,c=[],u=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,u.push(f);return}if(i){u.push(new zo(f.map));let m=f.step.map(i.slice(a)),y;m&&s.maybeStep(m).doc&&(y=s.mapping.maps[s.mapping.maps.length-1],c.push(new zo(y,void 0,void 0,c.length+u.length))),a--,y&&i.appendMap(y,a)}else s.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(a)):f.selection,l=new go(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),g=new zo(e.mapping.maps[u],f,n),m;(m=l&&l.merge(g))&&(g=m,u?a.pop():o=o.slice(0,o.length-1)),a.push(g),n&&(s++,n=void 0),i||(l=g)}let c=s-r.depth;return c>u2e&&(o=c2e(o,c),s-=c),new go(o.append(a),s)}remapping(e,n){let r=new a0;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new go(this.items.append(e.map(n=>new zo(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=a.getMirror(--l);if(m==null)return;s=Math.min(s,m);let y=a.maps[m];if(g.step){let v=e.steps[m].invert(e.docs[m]),b=g.selection&&g.selection.map(a.slice(l+1,m));b&&o++,r.push(new zo(y,v,b))}else r.push(new zo(y))},i);let c=[];for(let g=n;g<s;g++)c.push(new zo(a.maps[g]));let u=this.items.slice(0,i).append(c).append(r),f=new go(u,o);return f.emptyItemCount()>l2e&&(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((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&a++;let f=new zo(c.invert(),l,u),g,m=i.length-1;(g=i.length&&i[m].merge(f))?i[m]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new go(Ni.from(i.reverse()),a)}}go.empty=new go(Ni.empty,0);function c2e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class zo{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 zo(n.getMap().invert(),n,this.selection)}}}class Eu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const u2e=20;function d2e(t,e,n,r){let i=n.getMeta(xf),a;if(i)return i.historyState;n.getMeta(p2e)&&(t=new Eu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(xf))return s.getMeta(xf).redo?new Eu(t.done.addTransform(n,void 0,r,N_(e)),t.undone,AH(n.mapping.maps),t.prevTime,t.prevComposition):new Eu(t.done,t.undone.addTransform(n,void 0,r,N_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!f2e(n,t.prevRanges)),c=s?P2(t.prevRanges,n.mapping):AH(n.mapping.maps);return new Eu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,N_(e)),go.empty,c,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Eu(t.done.rebased(n,a),t.undone.rebased(n,a),P2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Eu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),P2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function f2e(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 AH(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function P2(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 h2e(t,e,n){let r=N_(e),i=xf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),l=new Eu(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(xf,{redo:n,historyState:l})}let k2=!1,TH=null;function N_(t){let e=t.plugins;if(TH!=e){k2=!1,TH=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){k2=!0;break}}return k2}const xf=new ci("history"),p2e=new ci("closeHistory");function m2e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xr({key:xf,state:{init(){return new Eu(go.empty,go.empty,null,0,-1)},apply(e,n,r){return d2e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?yX:r=="historyRedo"?_X:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function bX(t,e){return(n,r)=>{let i=xf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=h2e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const yX=bX(!1,!0),_X=bX(!0,!0);Wn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const 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 xr({key:new ci("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 s=a-i,o=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(o,l);return t=!0,c}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 o=e.selection.$head.pos,l=a-r,c=o-l,u=o;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var g2e=Wn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[QTe(this.options)]}});Wn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new xr({key:new ci("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return pr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(ga.node(c,c+l.nodeSize,{class:this.options.className}))}),pr.create(t,a)}}})]}});var x2e=Wn.create({name:"gapCursor",addProseMirrorPlugins(){return[n2e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=On(jt(t,"allowGapCursor",n)))!=null?e:null}}});Wn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new xr({key:new ci("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((s,o)=>{const l=r>=o&&r<=o+s.nodeSize,c=!s.isLeaf&&Mw(s);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];a&&u.push(this.options.emptyEditorClass);const f=ga.node(o,o+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:l}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),pr.create(t,i)}}})]}});Wn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new xr({key:new ci("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Pq(n.selection)||t.view.dragging?null:pr.create(n.doc,[ga.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function CH({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var v2e=Wn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ci(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 xr({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:l,schema:c}=s,u=e.getState(s),f=o.content.size,g=c.nodes[n];if(u)return l.insert(f,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!CH({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!CH({node:s,types:r})}}})]}}),b2e=Wn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>yX(t,e),redo:()=>({state:t,dispatch:e})=>_X(t,e)}},addProseMirrorPlugins(){return[m2e(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()}}}),y2e=Wn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(qAe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(HAe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(sX.configure(this.options.bulletList)),this.options.code!==!1&&i.push(YAe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(JAe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(eTe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(g2e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(x2e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(tTe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(nTe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(b2e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(rTe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(lTe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(oX.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(hX.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(aX.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(mX.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(WTe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(KTe.configure(this.options.strike)),this.options.text!==!1&&i.push(YTe.configure(this.options.text)),this.options.underline!==!1&&i.push(gX.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(v2e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),_2e=y2e,S2e=Wn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),w2e=S2e,M2e=20,SX=(t,e=0)=>{const n=[];return!t.children.length||e>M2e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...SX(r,e+1))}),n},E2e=t=>{if(!t.children.length)return;const e=SX(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),s=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},wX=dd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&E2e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Er(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}}}}),A2e=Wn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const 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 s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),MX=Wn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const 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 s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),T2e=Wn.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),C2e=Wn.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),N2e=Wn.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Wn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(A2e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(MX.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(T2e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(C2e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(N2e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(wX.configure(this.options.textStyle)),t}});var R2e=MX,P2e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,k2e=Va.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",Er(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,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",c=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return c?`![${l}](${o} "${c}")`:`![${l}](${o})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([u,f])=>{if(f!=null)switch(u){case"width":case"height":break;default:o.setAttribute(u,f);break}}),o.src=s.src;const l=new dAe({element:o,node:i,getPos:a,onResize:(u,f)=>{o.style.width=`${u}px`,o.style.height=`${f}px`},onCommit:(u,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:u,height:f}).run()},onUpdate:(u,f,g)=>u.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",o.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Wq({find:P2e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),D2e=k2e;function NH({content:t,onChange:e,placeholder:n}){const r=jAe({extensions:[_2e.configure({heading:!1,codeBlock:!1,code:!1}),ZTe,DTe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),w2e.configure({types:["paragraph"]}),wX,R2e,D2e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:s,isActive:o=!1,children:l,title:c})=>h.jsx("button",{type:"button",onClick:s,title:c,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return h.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[h.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[h.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:h.jsx(Hae,{className:"w-4 h-4"})}),h.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:h.jsx(Zse,{className:"w-4 h-4"})}),h.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:h.jsx(Sle,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:h.jsx(d9,{className:"w-4 h-4"})}),h.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:h.jsx(doe,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:h.jsx(xle,{className:"w-4 h-4"})}),h.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:h.jsx(hle,{className:"w-4 h-4"})}),h.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:h.jsx(mle,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:h.jsx(coe,{className:"w-4 h-4"})}),r.isActive("link")&&h.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:h.jsx(Mle,{className:"w-4 h-4"})})]}),h.jsx(RAe,{editor:r})]})}function O2e({archiveId:t,archiveName:e,onClose:n}){const r=In(),[i,a]=E.useState(!1),[s,o]=E.useState(null),[l,c]=E.useState({}),{data:u,isLoading:f,error:g}=Ut({queryKey:["archive-project-page",t],queryFn:()=>Fe.getArchiveProjectPage(t)}),m=yt({mutationFn:T=>Fe.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),c({})}});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&(s!==null?o(null):i?x():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const y=[...u?.model_pictures||[],...u?.profile_pictures||[]],v=()=>{c({title:u?.title||"",description:u?.description||"",designer:u?.designer||"",license:u?.license||"",profile_title:u?.profile_title||"",profile_description:u?.profile_description||""}),a(!0)},b=()=>{m.mutate(l)},x=()=>{a(!1),c({})},M=T=>{const R=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(T,"text/html"),j=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const k=C,U=k.tagName.toLowerCase();if(!R.includes(U))return Array.from(k.childNodes).map(j).join("");let I="";if(U==="a"&&k.getAttribute("href")){const O=k.getAttribute("href");O?.toLowerCase().startsWith("http")&&(I=` href="${O}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const O=k.getAttribute("src");if(!O?.toLowerCase().startsWith("http"))return"";I=` src="${O}" style="max-width: 100%; height: auto;"`}const H=Array.from(k.childNodes).map(j).join("");return["br","img"].includes(U)?`<${U}${I} />`:`<${U}${I}>${H}</${U}>`}return""};return Array.from(N.body.childNodes).map(j).join("")},w=u&&(u.title||u.description||u.designer||u.profile_title||y.length>0),A=T=>{T.target===T.currentTarget&&n()};return h.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(Sp,{className:"w-5 h-5 text-bambu-green"}),h.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&h.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&h.jsxs(ct,{variant:"ghost",size:"sm",onClick:v,children:[h.jsx(VP,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&h.jsxs(h.Fragment,{children:[h.jsx(ct,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),h.jsxs(ct,{variant:"primary",size:"sm",onClick:b,disabled:m.isPending,children:[h.jsx(I0,{className:"w-4 h-4 mr-1"}),"Save"]})]}),h.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(mn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&h.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),u&&!w&&h.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[h.jsx(Sp,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),h.jsx("p",{children:"No project page data found in this 3MF file."}),h.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),u&&w&&h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"space-y-4",children:[i?h.jsx("input",{type:"text",value:l.title||"",onChange:T=>c({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):u.title&&h.jsx("h3",{className:"text-xl font-semibold text-white",children:u.title}),h.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(nF,{className:"w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",value:l.designer||"",onChange:T=>c({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.designer&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(nF,{className:"w-4 h-4"}),h.jsx("span",{children:u.designer}),u.designer_user_id&&h.jsx("a",{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:h.jsx(Qo,{className:"w-3 h-3"})})]}),u.creation_date&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(Zo,{className:"w-4 h-4"}),h.jsx("span",{children:u.creation_date})]}),i?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Sp,{className:"w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",value:l.license||"",onChange:T=>c({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.license&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(Sp,{className:"w-4 h-4"}),h.jsx("span",{children:u.license})]}),u.origin&&h.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:u.origin})]})]}),(u.description||i)&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?h.jsx(NH,{content:l.description||"",onChange:T=>c({...l,description:T}),placeholder:"Enter description..."}):h.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.description||"")}})]}),(u.profile_title||u.profile_description||i)&&h.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?h.jsxs("div",{className:"space-y-2",children:[h.jsx("input",{type:"text",value:l.profile_title||"",onChange:T=>c({...l,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),h.jsx(NH,{content:l.profile_description||"",onChange:T=>c({...l,profile_description:T}),placeholder:"Profile description..."})]}):h.jsxs(h.Fragment,{children:[u.profile_title&&h.jsx("p",{className:"text-white font-medium",children:u.profile_title}),u.profile_description&&h.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.profile_description)}}),u.profile_user_name&&h.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",u.profile_user_name]})]})]}),y.length>0&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[h.jsx(JS,{className:"w-4 h-4"}),"Images (",y.length,")"]}),h.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:y.map((T,R)=>h.jsx("button",{onClick:()=>o(R),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:h.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),u.design_model_id&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("a",{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[h.jsx(Qo,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&y[s]&&h.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[h.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:h.jsx(Af,{className:"w-6 h-6 text-white"})}),h.jsx("img",{src:y[s].url,alt:y[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),h.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(y.length-1,s+1))},disabled:s===y.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:h.jsx(Wf,{className:"w-6 h-6 text-white"})}),h.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:h.jsx(mn,{className:"w-6 h-6 text-white"})}),h.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",y.length]})]})]})}const L2e=[.25,.5,.75,1,1.5,2,3,4];function I2e({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(.5),[c,u]=E.useState(0),[f,g]=E.useState(0);E.useEffect(()=>{const w=i.current;w&&(w.playbackRate=o)},[o]),E.useEffect(()=>{const w=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),E.useEffect(()=>{const w=i.current;if(!w)return;const A=()=>u(w.currentTime),T=()=>g(w.duration),R=()=>s(!0),N=()=>s(!1);return w.addEventListener("timeupdate",A),w.addEventListener("durationchange",T),w.addEventListener("play",R),w.addEventListener("pause",N),()=>{w.removeEventListener("timeupdate",A),w.removeEventListener("durationchange",T),w.removeEventListener("play",R),w.removeEventListener("pause",N)}},[]);const m=()=>{const w=i.current;w&&(a?w.pause():w.play())},y=w=>{const A=i.current;A&&(A.currentTime=parseFloat(w.target.value))},v=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},b=()=>{const w=i.current;w&&(w.currentTime=Math.min(f,w.currentTime+5))},x=w=>{const A=Math.floor(w/60),T=Math.floor(w%60);return`${A}:${T.toString().padStart(2,"0")}`},M=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:h.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[h.jsx(Np,{className:"w-5 h-5 text-bambu-green"}),e]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(ct,{variant:"secondary",size:"sm",onClick:M,children:[h.jsx(Ku,{className:"w-4 h-4"}),"Download"]}),h.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:h.jsx(mn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),h.jsxs("div",{className:"p-4",children:[h.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),h.jsxs("div",{className:"mt-4 space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),h.jsx("input",{type:"range",min:0,max:f||100,value:c,onChange:y,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8178. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8179. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8180. [&::-webkit-slider-thumb]:cursor-pointer`}),h.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(f)})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:h.jsx(Zoe,{className:"w-5 h-5 text-bambu-gray"})}),h.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?h.jsx(h9,{className:"w-5 h-5 text-white"}):h.jsx(ew,{className:"w-5 h-5 text-white"})}),h.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:h.jsx(x9,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),h.jsx("div",{className:"flex gap-1",children:L2e.map(w=>h.jsxs("button",{onClick:()=>l(w),className:`px-2 py-1 text-xs rounded transition-colors ${o===w?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[w,"x"]},w))})]})]})]})]})]})})}function j2e({archiveId:t,archiveName:e,onClose:n}){const r=In(),{showToast:i}=eo(),[a,s]=E.useState(null),[o,l]=E.useState("asap"),[c,u]=E.useState(""),[f,g]=E.useState(!1),[m,y]=E.useState(!1),{data:v}=Ut({queryKey:["printers"],queryFn:()=>Fe.getPrinters()});E.useEffect(()=>{v?.length===1&&!a&&s(v[0].id)},[v,a]),E.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const b=yt({mutationFn:w=>Fe.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),x=w=>{if(w.preventDefault(),!a){i("Please select a printer","error");return}const A={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&c&&(A.scheduled_time=new Date(c).toISOString()),b.mutate(A)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsx(Yt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:h.jsxs(on,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Zo,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),h.jsx("p",{className:"text-white font-medium truncate",children:e})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?h.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[h.jsx(od,{className:"w-4 h-4"}),"No printers configured"]}):h.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:w=>s(w.target.value?Number(w.target.value):null),required:!0,children:[h.jsx("option",{value:"",children:"Select printer..."}),v?.map(w=>h.jsx("option",{value:w.id,children:w.name},w.id))]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[h.jsx(ba,{className:"w-4 h-4"}),"ASAP (when idle)"]}),h.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[h.jsx(Zo,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),h.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>u(w.target.value),min:M(),required:!0})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>y(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[h.jsx(tw,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(ct,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(ct,{type:"submit",className:"flex-1",disabled:b.isPending||!a||v?.length===0,children:b.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function bR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Kg(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function RH(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function U2e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i}){const a=In(),{showToast:s}=eo(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,g]=E.useState(!1),[m,y]=E.useState(!1),[v,b]=E.useState(!1),[x,M]=E.useState(!1),[w,A]=E.useState([]),[T,R]=E.useState(!1),[N,j]=E.useState(!1),[C,k]=E.useState(!1),[U,I]=E.useState(!1),[H,O]=E.useState(!1),[B,V]=E.useState(null),G=E.useRef(null),K=yt({mutationFn:te=>Fe.uploadSource3mf(t.id,te),onSuccess:te=>{a.invalidateQueries({queryKey:["archives"]}),s(`Source 3MF attached: ${te.filename}`)},onError:te=>{s(te.message||"Failed to upload source 3MF","error")}}),Y=yt({mutationFn:()=>Fe.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Source 3MF removed")},onError:te=>{s(te.message||"Failed to remove source 3MF","error")}}),oe=yt({mutationFn:()=>Fe.scanArchiveTimelapse(t.id),onSuccess:te=>{te.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${te.filename}`)):te.status==="exists"?s("Timelapse already attached"):te.status==="not_found"&&te.available_files&&te.available_files.length>0?(A(te.available_files),M(!0)):s(te.message||"No matching timelapse found","warning")},onError:te=>{s(te.message||"Failed to scan for timelapse","error")}}),$=yt({mutationFn:te=>Fe.selectArchiveTimelapse(t.id,te),onSuccess:te=>{a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${te.filename}`),M(!1),A([])},onError:te=>{s(te.message||"Failed to attach timelapse","error")}}),X=yt({mutationFn:()=>Fe.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Archive deleted")},onError:()=>{s("Failed to delete archive","error")}}),ae=yt({mutationFn:()=>Fe.toggleFavorite(t.id),onSuccess:te=>{a.invalidateQueries({queryKey:["archives"]}),s(te.is_favorite?"Added to favorites":"Removed from favorites")}}),ce=te=>{te.preventDefault(),V({x:te.clientX,y:te.clientY})},xe=[{label:"Print",icon:h.jsx(mc,{className:"w-4 h-4"}),onClick:()=>u(!0)},{label:"Schedule",icon:h.jsx(Zo,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:"Open in Bambu Studio",icon:h.jsx(Qo,{className:"w-4 h-4"}),onClick:()=>{const te=t.print_name||t.filename||"model",ve=`${window.location.origin}${Fe.getArchiveForSlicer(t.id,te)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{label:"View on MakerWorld",icon:h.jsx(V_,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:h.jsx(Hx,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:h.jsx(Np,{className:"w-4 h-4"}),onClick:()=>b(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:h.jsx(Voe,{className:"w-4 h-4"}),onClick:()=>oe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||oe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:h.jsx(ZU,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const te=document.createElement("a");te.href=Fe.getSource3mfDownloadUrl(t.id),te.download=`${t.print_name||t.filename}_source.3mf`,te.click()}else G.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:h.jsx(Gx,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},{label:"Remove Source 3MF",icon:h.jsx(aa,{className:"w-4 h-4"}),onClick:()=>O(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:h.jsx(Ku,{className:"w-4 h-4"}),onClick:()=>{const te=document.createElement("a");te.href=Fe.getArchiveDownload(t.id),te.download=`${t.print_name||t.filename}.3mf`,te.click()}},{label:"Copy Download Link",icon:h.jsx(LN,{className:"w-4 h-4"}),onClick:()=>{const te=`${window.location.origin}${Fe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(te).then(()=>{s("Link copied to clipboard")}).catch(()=>{s("Failed to copy link","error")})}},{label:"QR Code",icon:h.jsx(Loe,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:h.jsx($_,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:h.jsx(Sp,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:h.jsx($x,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ae.mutate()},{label:"Edit",icon:h.jsx(eF,{className:"w-4 h-4"}),onClick:()=>y(!0)},{label:n?"Deselect":"Select",icon:n?h.jsx(X_,{className:"w-4 h-4"}):h.jsx($p,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:h.jsx(aa,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return h.jsxs(Yt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:ce,onClick:i?()=>r(t.id):void 0,children:[i&&h.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:te=>{te.stopPropagation(),r(t.id)},children:n?h.jsx(X_,{className:"w-5 h-5 text-bambu-green"}):h.jsx($p,{className:"w-5 h-5 text-white"})}),h.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?h.jsx("img",{src:Fe.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center",children:h.jsx(JS,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),h.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:te=>{te.stopPropagation(),ae.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:h.jsx($x,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&h.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&h.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[h.jsx(LN,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&h.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:te=>{te.stopPropagation();const ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",De=`${window.location.origin}${Fe.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(De)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:h.jsx(ZU,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&h.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:te=>{te.stopPropagation(),b(!0)},title:"View timelapse",children:h.jsx(Np,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&h.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:te=>{te.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[h.jsx($_,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&h.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),h.jsxs(on,{className:"p-4 flex-1 flex flex-col",children:[h.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),h.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),h.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Kg(t.print_time_seconds||0)}
  8181. Actual: ${Kg(t.actual_time_seconds||0)}
  8182. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Kg(t.actual_time_seconds)}`:`Estimated: ${Kg(t.print_time_seconds||0)}`,children:[h.jsx(ba,{className:"w-3 h-3"}),Kg(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&h.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[h.jsx(W_,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[h.jsx(u9,{className:"w-3 h-3"}),t.total_layers&&h.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&h.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&h.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&h.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[h.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&h.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((te,ve)=>h.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:te},title:te},ve))})]})]}),(t.tags||t.notes)&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&h.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:h.jsx(ale,{className:"w-3 h-3"})}),t.tags?.split(",").map((te,ve)=>h.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:te.trim()},ve))]}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[h.jsx("span",{children:RH(t.created_at)}),h.jsx("span",{children:bR(t.file_size)})]}),h.jsxs("div",{className:"flex gap-1 mt-3",children:[h.jsxs(ct,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>u(!0),children:[h.jsx(mc,{className:"w-3 h-3 flex-shrink-0"}),h.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),h.jsx(ct,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const te=t.print_name||t.filename||"model",ve=`${window.location.origin}${Fe.getArchiveForSlicer(t.id,te)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:h.jsx(Qo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(ct,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:h.jsx(V_,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),h.jsx(ct,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:h.jsx(Hx,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(ct,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const te=document.createElement("a");te.href=Fe.getArchiveDownload(t.id),te.download=`${t.print_name||t.filename}.3mf`,te.click()},title:"Download",children:h.jsx(Ku,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(ct,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:h.jsx(eF,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(ct,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"Delete",children:h.jsx(aa,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),m&&h.jsx(l1e,{archive:t,onClose:()=>y(!1)}),o&&h.jsx(i1e,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&h.jsx(a1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>u(!1),onSuccess:()=>{}}),f&&h.jsx(ii,{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:()=>{X.mutate(),g(!1)},onCancel:()=>g(!1)}),H&&h.jsx(ii,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Y.mutate(),O(!1)},onCancel:()=>O(!1)}),B&&h.jsx(c1e,{x:B.x,y:B.y,items:xe,onClose:()=>V(null)}),v&&t.timelapse_path&&h.jsx(I2e,{src:Fe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>b(!1)}),x&&w.length>0&&h.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),h.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),h.jsx("button",{onClick:()=>{M(!1),A([])},className:"text-gray-400 hover:text-white p-1",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(te=>h.jsxs("button",{onClick:()=>$.mutate(te.name),disabled:$.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[h.jsx(Np,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-white font-medium truncate",children:te.name}),h.jsxs("p",{className:"text-sm text-gray-400",children:[bR(te.size),te.mtime&&` • ${RH(te.mtime)}`]})]})]},te.name))}),h.jsx("div",{className:"p-4 border-t border-gray-700",children:h.jsx(ct,{variant:"secondary",onClick:()=>{M(!1),A([])},className:"w-full",children:"Cancel"})})]})}),T&&h.jsx(g1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),N&&t.photos&&t.photos.length>0&&h.jsx(x1e,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async te=>{try{await Fe.deleteArchivePhoto(t.id,te),a.invalidateQueries({queryKey:["archives"]}),s("Photo deleted")}catch{s("Failed to delete photo","error")}}}),C&&h.jsx(O2e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>k(!1)}),U&&h.jsx(j2e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),h.jsx("input",{ref:G,type:"file",accept:".3mf",className:"hidden",onChange:te=>{const ve=te.target.files?.[0];ve&&K.mutate(ve),te.target.value=""}})]})}const F2e=[{id:"all",label:"All Archives",icon:h.jsx(Ise,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:h.jsx(ba,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:h.jsx(Zo,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:h.jsx(Zo,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:h.jsx($x,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:h.jsx(od,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:h.jsx(LN,{className:"w-4 h-4"})}];function z2e(){const t=In(),{showToast:e}=eo(),n=E.useRef(null),[r,i]=E.useState(""),[a,s]=E.useState(null),[o,l]=E.useState(null),[c,u]=E.useState(new Set),[f,g]=E.useState("or"),[m,y]=E.useState(!1),[v,b]=E.useState(null),[x,M]=E.useState(!1),[w,A]=E.useState([]),[T,R]=E.useState(!1),[N,j]=E.useState(new Set),[C,k]=E.useState(!1),[U,I]=E.useState(!1),[H,O]=E.useState(!1),[B,V]=E.useState("grid"),[G,K]=E.useState("date-desc"),[Y,oe]=E.useState("all"),{data:$,isLoading:X}=Ut({queryKey:["archives",a],queryFn:()=>Fe.getArchives(a||void 0)}),{data:ae}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),ce=yt({mutationFn:async ne=>(await Promise.all(ne.map(F=>Fe.deleteArchive(F))),ne.length),onSuccess:ne=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${ne} archive${ne!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),xe=new Map(ae?.map(ne=>[ne.id,ne.name])||[]),te=[...new Set($?.flatMap(ne=>ne.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ve=[...new Set($?.flatMap(ne=>ne.filament_color?.split(",")||[]).filter(Boolean)||[])],De=[...new Set($?.flatMap(ne=>ne.tags?.split(",").map(F=>F.trim())||[]).filter(Boolean)||[])].sort(),he=$?.filter(ne=>{const F=new Date,L=new Date(ne.created_at);let Z=!0;switch(Y){case"recent":Z=F.getTime()-L.getTime()<1440*60*1e3;break;case"this-week":Z=F.getTime()-L.getTime()<10080*60*1e3;break;case"this-month":Z=L.getMonth()===F.getMonth()&&L.getFullYear()===F.getFullYear();break;case"favorites":Z=ne.is_favorite===!0;break;case"failed":Z=ne.status==="failed";break;case"duplicates":Z=ne.duplicate_count>0;break}const ge=(ne.print_name||ne.filename).toLowerCase().includes(r.toLowerCase()),ye=!o||ne.filament_type?.split(", ").includes(o),pe=ne.filament_color?.split(",")||[],Ze=c.size===0||(f==="or"?pe.some(je=>c.has(je)):[...c].every(je=>pe.includes(je))),Ie=Y==="favorites"||!m||ne.is_favorite,Xe=ne.tags?.split(",").map(je=>je.trim())||[],ot=!v||Xe.includes(v);return Z&&ge&&ye&&Ze&&Ie&&ot}).sort((ne,F)=>{switch(G){case"date-desc":return new Date(F.created_at).getTime()-new Date(ne.created_at).getTime();case"date-asc":return new Date(ne.created_at).getTime()-new Date(F.created_at).getTime();case"name-asc":return(ne.print_name||ne.filename).localeCompare(F.print_name||F.filename);case"name-desc":return(F.print_name||F.filename).localeCompare(ne.print_name||ne.filename);case"size-desc":return F.file_size-ne.file_size;case"size-asc":return ne.file_size-F.file_size;default:return 0}}),me=C||N.size>0,we=ne=>{j(F=>{const L=new Set(F);return L.has(ne)?L.delete(ne):L.add(ne),L})},se=()=>{he&&j(new Set(he.map(ne=>ne.id)))},st=()=>{j(new Set),k(!1)},z=ne=>{u(F=>{const L=new Set(F);return L.has(ne)?L.delete(ne):L.add(ne),L})},q=()=>{u(new Set)},ie=()=>{i(""),s(null),l(null),y(!1),b(null)},Q=r||a||o||m||v,ee=E.useCallback(ne=>{ne.preventDefault(),ne.dataTransfer.types.includes("Files")&&R(!0)},[]),le=E.useCallback(ne=>{ne.preventDefault(),ne.currentTarget===ne.target&&R(!1)},[]),Re=E.useCallback(ne=>{ne.preventDefault(),R(!1);const F=Array.from(ne.dataTransfer.files).filter(L=>L.name.endsWith(".3mf"));F.length>0?(A(F),M(!0)):ne.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Pe=E.useCallback(ne=>{const F=ne.target;if(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable){ne.key==="Escape"&&F.blur();return}switch(ne.key){case"/":ne.preventDefault(),n.current?.focus();break;case"u":case"U":!ne.metaKey&&!ne.ctrlKey&&(ne.preventDefault(),M(!0));break;case"Escape":me&&st();break}},[me]);return E.useEffect(()=>(document.addEventListener("keydown",Pe),()=>document.removeEventListener("keydown",Pe)),[Pe]),h.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:ee,onDragLeave:le,onDrop:Re,children:[T&&h.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:h.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[h.jsx(Gx,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),h.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),h.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),me&&h.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[h.jsxs("span",{className:"text-white font-medium",children:[N.size," selected"]}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsx(ct,{variant:"secondary",size:"sm",onClick:se,children:"Select All"}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:st,children:[h.jsx(mn,{className:"w-4 h-4"}),"Clear"]}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>O(!0),children:[h.jsx(Vx,{className:"w-4 h-4"}),"Tags"]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>{const ne=Array.from(N);Promise.all(ne.map(F=>Fe.toggleFavorite(F))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ne.length} archive${ne.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[h.jsx($x,{className:"w-4 h-4"}),"Favorite"]}),h.jsxs(ct,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>I(!0),children:[h.jsx(aa,{className:"w-4 h-4"}),"Delete"]})]}),h.jsxs("div",{className:"flex items-center justify-between mb-8",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),h.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Y,onChange:ne=>oe(ne.target.value),children:F2e.map(ne=>h.jsx("option",{value:ne.id,children:ne.label},ne.id))})]}),h.jsxs("p",{className:"text-bambu-gray",children:[he?.length||0," of ",$?.length||0," prints"]})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[!me&&h.jsxs(ct,{variant:"secondary",onClick:()=>k(!0),children:[h.jsx(X_,{className:"w-4 h-4"}),"Select"]}),h.jsxs(ct,{onClick:()=>M(!0),children:[h.jsx(Gx,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),h.jsx(Yt,{className:"mb-6",children:h.jsxs(on,{className:"py-4",children:[h.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[h.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[h.jsx(q_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{ref:n,type:"text",placeholder:"Search archives... (press /)",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ne=>i(ne.target.value)})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(zse,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:ne=>s(ne.target.value?Number(ne.target.value):null),children:[h.jsx("option",{value:"",children:"All Printers"}),ae?.map(ne=>h.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(W_,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:ne=>l(ne.target.value||null),children:[h.jsx("option",{value:"",children:"All Materials"}),te.map(ne=>h.jsx("option",{value:ne,children:ne},ne))]})]}),h.jsxs("button",{onClick:()=>y(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[h.jsx($x,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),h.jsx("span",{className:"text-sm",children:"Favorites"})]}),De.length>0&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Vx,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v||"",onChange:ne=>b(ne.target.value||null),children:[h.jsx("option",{value:"",children:"All Tags"}),De.map(ne=>h.jsx("option",{value:ne,children:ne},ne))]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(jae,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:G,onChange:ne=>K(ne.target.value),children:[h.jsx("option",{value:"date-desc",children:"Newest first"}),h.jsx("option",{value:"date-asc",children:"Oldest first"}),h.jsx("option",{value:"name-asc",children:"Name A-Z"}),h.jsx("option",{value:"name-desc",children:"Name Z-A"}),h.jsx("option",{value:"size-desc",children:"Largest first"}),h.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),h.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[h.jsx("button",{className:`p-2 ${B==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("grid"),title:"Grid view",children:h.jsx(roe,{className:"w-4 h-4"})}),h.jsx("button",{className:`p-2 ${B==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("list"),title:"List view",children:h.jsx(d9,{className:"w-4 h-4"})}),h.jsx("button",{className:`p-2 ${B==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("calendar"),title:"Calendar view",children:h.jsx(qae,{className:"w-4 h-4"})})]}),Q&&h.jsxs(ct,{variant:"ghost",size:"sm",onClick:ie,className:"text-bambu-gray hover:text-white",children:[h.jsx(mn,{className:"w-4 h-4"}),"Reset"]})]}),ve.length>0&&h.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&h.jsx("button",{onClick:()=>g(ne=>ne==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),h.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ve.map(ne=>h.jsx("button",{onClick:()=>z(ne),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(ne)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ne},title:ne},ne))}),c.size>0&&h.jsxs("button",{onClick:q,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[h.jsx(mn,{className:"w-3 h-3"}),"Clear"]})]})]})}),X?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):he?.length===0?h.jsx(Yt,{children:h.jsxs(on,{className:"text-center py-12",children:[h.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),h.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):B==="calendar"?h.jsx(Yt,{className:"p-6",children:h.jsx(m1e,{archives:he||[],onArchiveClick:ne=>{i(ne.print_name||ne.filename),V("grid")}})}):B==="grid"?h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:he?.map(ne=>h.jsx(U2e,{archive:ne,printerName:ne.printer_id?xe.get(ne.printer_id)||"Unknown":"No Printer",isSelected:N.has(ne.id),onSelect:we,selectionMode:me},ne.id))}):B==="list"?h.jsx(Yt,{children:h.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[h.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[h.jsx("div",{className:"col-span-1"}),h.jsx("div",{className:"col-span-4",children:"Name"}),h.jsx("div",{className:"col-span-2",children:"Printer"}),h.jsx("div",{className:"col-span-2",children:"Date"}),h.jsx("div",{className:"col-span-1",children:"Size"}),h.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),he?.map(ne=>h.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${N.has(ne.id)?"bg-bambu-green/10":""}`,children:[h.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[me&&h.jsx("button",{onClick:()=>we(ne.id),children:N.has(ne.id)?h.jsx(X_,{className:"w-4 h-4 text-bambu-green"}):h.jsx($p,{className:"w-4 h-4 text-bambu-gray"})}),ne.thumbnail_path?h.jsx("img",{src:Fe.getArchiveThumbnail(ne.id),alt:"",className:"w-10 h-10 object-cover rounded"}):h.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:h.jsx(JS,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),h.jsxs("div",{className:"col-span-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("p",{className:"text-white text-sm truncate",children:ne.print_name||ne.filename}),ne.timelapse_path&&h.jsx("span",{title:"Has timelapse",children:h.jsx(Np,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ne.filament_type&&h.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:ne.filament_type}),ne.filament_color&&h.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ne.filament_color.split(",").map((F,L)=>h.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:F},title:F},L))})]})]}),h.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ne.printer_id?xe.get(ne.printer_id)||"Unknown":"No Printer"}),h.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ne.created_at).toLocaleDateString()}),h.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:bR(ne.file_size)}),h.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>{const F=ne.print_name||ne.filename||"model",L=`${window.location.origin}${Fe.getArchiveForSlicer(ne.id,F)}`;window.location.href=`bambustudioopen://${encodeURIComponent(L)}`},title:"Open in Slicer",children:h.jsx(Qo,{className:"w-4 h-4"})}),ne.makerworld_url&&h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>window.open(ne.makerworld_url,"_blank"),title:"MakerWorld",children:h.jsx(V_,{className:"w-4 h-4"})}),h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>{const F=document.createElement("a");F.href=Fe.getArchiveDownload(ne.id),F.download=`${ne.print_name||ne.filename}.3mf`,F.click()},title:"Download",children:h.jsx(Ku,{className:"w-4 h-4"})})]})]},ne.id))]})}):null,x&&h.jsx(s1e,{onClose:()=>{M(!1),A([])},initialFiles:w}),U&&h.jsx(ii,{title:"Delete Archives",message:`Are you sure you want to delete ${N.size} archive${N.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${N.size}`,variant:"danger",onConfirm:()=>{ce.mutate(Array.from(N)),I(!1)},onCancel:()=>I(!1)}),H&&h.jsx(u1e,{selectedIds:Array.from(N),existingTags:De,onClose:()=>O(!1)})]})}function B2e(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime();return r<-6e4?"Overdue":r<0?"Now":r<6e4?"In less than a minute":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)} hours`:e.toLocaleString()}function H2e({status:t}){const e={pending:{icon:ba,color:"text-yellow-400 bg-yellow-400/10",label:"Pending"},printing:{icon:ew,color:"text-blue-400 bg-blue-400/10",label:"Printing"},completed:{icon:ld,color:"text-green-400 bg-green-400/10",label:"Completed"},failed:{icon:L0,color:"text-red-400 bg-red-400/10",label:"Failed"},skipped:{icon:x9,color:"text-orange-400 bg-orange-400/10",label:"Skipped"},cancelled:{icon:mn,color:"text-gray-400 bg-gray-400/10",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return h.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium ${r}`,children:[h.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function D2({item:t,onCancel:e,onRemove:n,onStop:r}){const[i,a]=E.useState(!1),[s,o]=E.useState(!1),[l,c]=E.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-4 p-4 bg-bambu-dark-secondary rounded-lg",children:[t.status==="pending"&&h.jsx($P,{className:"w-5 h-5 text-bambu-gray cursor-grab"}),h.jsx("div",{className:"w-16 h-16 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?h.jsx("img",{src:Fe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:h.jsx(Zo,{className:"w-6 h-6"})})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),h.jsx(ZS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:h.jsx(Qo,{className:"w-3.5 h-3.5"})})]}),h.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-bambu-gray",children:[h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(mc,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(ba,{className:"w-3.5 h-3.5"}),B2e(t.scheduled_time)]})]}),t.require_previous_success&&h.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Requires previous print to succeed"}),t.auto_off_after&&h.jsxs("p",{className:"text-xs text-blue-400 mt-1 flex items-center gap-1",children:[h.jsx(tw,{className:"w-3 h-3"}),"Will power off when done"]}),t.error_message&&h.jsxs("p",{className:"text-xs text-red-400 mt-1 flex items-center gap-1",children:[h.jsx(od,{className:"w-3 h-3"}),t.error_message]})]}),h.jsx(H2e,{status:t.status}),h.jsxs("div",{className:"flex items-center gap-2",children:[t.status==="printing"&&h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Stop Print",className:"text-red-400 hover:text-red-300",children:h.jsx(cse,{className:"w-4 h-4"})}),t.status==="pending"&&h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>a(!0),title:"Cancel",children:h.jsx(mn,{className:"w-4 h-4"})}),["completed","failed","skipped","cancelled"].includes(t.status)&&h.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>o(!0),title:"Remove",children:h.jsx(aa,{className:"w-4 h-4"})})]})]}),i&&h.jsx(ii,{title:"Cancel Scheduled Print",message:`Are you sure you want to cancel "${t.archive_name||"this print"}"? It will be removed from the queue.`,confirmText:"Cancel Print",variant:"danger",onConfirm:()=>{e(t.id),a(!1)},onCancel:()=>a(!1)}),s&&h.jsx(ii,{title:"Remove from History",message:`Are you sure you want to remove "${t.archive_name||"this item"}" from the queue history?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{n(t.id),o(!1)},onCancel:()=>o(!1)}),l&&h.jsx(ii,{title:"Stop Print",message:`Are you sure you want to stop the current print "${t.archive_name||"this print"}"? This will cancel the print job on the printer.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{r(t.id),c(!1)},onCancel:()=>c(!1)})]})}function $2e(){const t=In(),{showToast:e}=eo(),[n,r]=E.useState(null),[i,a]=E.useState(""),{data:s,isLoading:o}=Ut({queryKey:["queue",n,i],queryFn:()=>Fe.getQueue(n||void 0,i||void 0),refetchInterval:1e4}),{data:l}=Ut({queryKey:["printers"],queryFn:()=>Fe.getPrinters()}),c=yt({mutationFn:v=>Fe.cancelQueueItem(v),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),u=yt({mutationFn:v=>Fe.removeFromQueue(v),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),f=yt({mutationFn:v=>Fe.stopQueueItem(v),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),g=s?.filter(v=>v.status==="pending")||[],m=s?.filter(v=>v.status==="printing")||[],y=s?.filter(v=>["completed","failed","skipped","cancelled"].includes(v.status))||[];return h.jsxs("div",{className:"p-8",children:[h.jsx("div",{className:"flex items-center justify-between mb-6",children:h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Print Queue"}),h.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage print jobs"})]})}),h.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:v=>r(v.target.value?Number(v.target.value):null),children:[h.jsx("option",{value:"",children:"All Printers"}),l?.map(v=>h.jsx("option",{value:v.id,children:v.name},v.id))]}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:v=>a(v.target.value),children:[h.jsx("option",{value:"",children:"All Status"}),h.jsx("option",{value:"pending",children:"Pending"}),h.jsx("option",{value:"printing",children:"Printing"}),h.jsx("option",{value:"completed",children:"Completed"}),h.jsx("option",{value:"failed",children:"Failed"}),h.jsx("option",{value:"skipped",children:"Skipped"}),h.jsx("option",{value:"cancelled",children:"Cancelled"})]})]}),o?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):s?.length===0?h.jsxs(Yt,{className:"p-12 text-center",children:[h.jsx(Zo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No prints scheduled"}),h.jsx("p",{className:"text-bambu-gray",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu.'})]}):h.jsxs("div",{className:"space-y-6",children:[m.length>0&&h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[h.jsx(ew,{className:"w-5 h-5 text-blue-400"}),"Currently Printing"]}),h.jsx("div",{className:"space-y-2",children:m.map(v=>h.jsx(D2,{item:v,onCancel:b=>c.mutate(b),onRemove:b=>u.mutate(b),onStop:b=>f.mutate(b)},v.id))})]}),g.length>0&&h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[h.jsx(ba,{className:"w-5 h-5 text-yellow-400"}),"Queued (",g.length,")"]}),h.jsx("div",{className:"space-y-2",children:g.map(v=>h.jsx(D2,{item:v,onCancel:b=>c.mutate(b),onRemove:b=>u.mutate(b),onStop:b=>f.mutate(b)},v.id))})]}),y.length>0&&h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[h.jsx(ld,{className:"w-5 h-5 text-bambu-gray"}),"History (",y.length,")"]}),h.jsx("div",{className:"space-y-2",children:y.slice(0,10).map(v=>h.jsx(D2,{item:v,onCancel:b=>c.mutate(b),onRemove:b=>u.mutate(b),onStop:b=>f.mutate(b)},v.id))})]})]})]})}function V2e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=E.useMemo(()=>{const l={};t.forEach(x=>{const M=x.split("T")[0];l[M]=(l[M]||0)+1});const c=new Date,u=new Date(c);u.setMonth(u.getMonth()-e),u.setDate(u.getDate()-u.getDay());const f=[],g=[];let m=[],y=-1;const v=new Date(u);let b=0;for(;v<=c;)v.getDay()===0&&m.length>0&&(f.push(m),m=[],b++),v.getMonth()!==y&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:b}),y=v.getMonth()),m.push(new Date(v)),v.setDate(v.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:g,printCounts:l}},[t,e]),a=Math.max(1,...Object.values(i)),s=l=>{if(l===0)return"bg-bambu-dark";const c=l/a;return c<=.25?"bg-bambu-green/30":c<=.5?"bg-bambu-green/50":c<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return h.jsxs("div",{className:"overflow-x-auto",children:[h.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:c},u)=>h.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:u===0?0:`${(c-(r[u-1]?.weekIndex||0))*14-24}px`},children:l},u))}),h.jsxs("div",{className:"flex gap-0.5",children:[h.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>h.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:c%2===1?"visible":"hidden"},children:l},l))}),n.map((l,c)=>h.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(u=>{const f=l.find(v=>v.getDay()===u);if(!f)return h.jsx("div",{className:"w-3 h-3"},u);const g=f.toISOString().split("T")[0],m=i[g]||0,y=g===new Date().toISOString().split("T")[0];return h.jsx("div",{className:`w-3 h-3 rounded-sm ${s(m)} ${y?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},u)})},c))]}),h.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[h.jsx("span",{children:"Less"}),h.jsxs("div",{className:"flex gap-0.5",children:[h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),h.jsx("span",{children:"More"})]})]})}function EX(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=EX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function An(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=EX(t))&&(r&&(r+=" "),r+=e);return r}var G2e=["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 oD(t){if(typeof t!="string")return!1;var e=G2e;return e.includes(t)}var W2e=["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"],q2e=new Set(W2e);function AX(t){return typeof t!="string"?!1:q2e.has(t)}function TX(t){return typeof t=="string"&&t.startsWith("data-")}function $a(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AX(n)||TX(n))&&(e[n]=t[n]);return e}function Uf(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return $a(e)}return typeof t=="object"&&!Array.isArray(t)?$a(t):null}function Ma(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AX(n)||TX(n)||oD(n))&&(e[n]=t[n]);return e}function X2e(t){return t==null?null:E.isValidElement(t)?Ma(t.props):typeof t=="object"&&!Array.isArray(t)?Ma(t):null}var K2e=["children","width","height","viewBox","className","style","title","desc"];function yR(){return yR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yR.apply(null,arguments)}function Y2e(t,e){if(t==null)return{};var n,r,i=Z2e(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 Z2e(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 lD=E.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:o,title:l,desc:c}=t,u=Y2e(t,K2e),f=a||{width:r,height:i,x:0,y:0},g=An("recharts-surface",s);return E.createElement("svg",yR({},Ma(u),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),E.createElement("title",null,l),E.createElement("desc",null,c),n)}),Q2e=["children","className"];function _R(){return _R=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_R.apply(null,arguments)}function J2e(t,e){if(t==null)return{};var n,r,i=eCe(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 eCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Or=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=J2e(t,Q2e),a=An("recharts-layer",r);return E.createElement("g",_R({className:a},Ma(i),{ref:e}),n)}),CX=E.createContext(null),tCe=()=>E.useContext(CX);function Qn(t){return function(){return t}}const NX=Math.cos,Y1=Math.sin,Co=Math.sqrt,Z1=Math.PI,Cw=2*Z1,SR=Math.PI,wR=2*SR,Gd=1e-6,nCe=wR-Gd;function RX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function rCe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return RX;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 iCe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?RX:rCe(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,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}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 s=this._x1,o=this._y1,l=r-e,c=i-n,u=s-e,f=o-n,g=u*u+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>Gd)if(!(Math.abs(f*l-c*u)>Gd)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-s,y=i-o,v=l*l+c*c,b=m*m+y*y,x=Math.sqrt(v),M=Math.sqrt(g),w=a*Math.tan((SR-Math.acos((v+g-b)/(2*x*M)))/2),A=w/M,T=w/x;Math.abs(A-1)>Gd&&this._append`L${e+A*u},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*m>u*y)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),c=e+o,u=n+l,f=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>Gd||Math.abs(this._y1-u)>Gd)&&this._append`L${c},${u}`,r&&(g<0&&(g=g%wR+wR),g>nCe?this._append`A${r},${r},0,1,${f},${e-o},${n-l}A${r},${r},0,1,${f},${this._x1=c},${this._y1=u}`:g>Gd&&this._append`A${r},${r},0,${+(g>=SR)},${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 cD(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 iCe(e)}function uD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function PX(t){this._context=t}PX.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 Nw(t){return new PX(t)}function kX(t){return t[0]}function DX(t){return t[1]}function OX(t,e){var n=Qn(!0),r=null,i=Nw,a=null,s=cD(o);t=typeof t=="function"?t:t===void 0?kX:Qn(t),e=typeof e=="function"?e:e===void 0?DX:Qn(e);function o(l){var c,u=(l=uD(l)).length,f,g=!1,m;for(r==null&&(a=i(m=s())),c=0;c<=u;++c)!(c<u&&n(f=l[c],c,l))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,c,l),+e(f,c,l));if(m)return a=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Qn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Qn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Qn(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(a=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=a=null:a=i(r=l),o):r},o}function Vy(t,e,n){var r=null,i=Qn(!0),a=null,s=Nw,o=null,l=cD(c);t=typeof t=="function"?t:t===void 0?kX:Qn(+t),e=typeof e=="function"?e:Qn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?DX:Qn(+n);function c(f){var g,m,y,v=(f=uD(f)).length,b,x=!1,M,w=new Array(v),A=new Array(v);for(a==null&&(o=s(M=l())),g=0;g<=v;++g){if(!(g<v&&i(b=f[g],g,f))===x)if(x=!x)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),y=g-1;y>=m;--y)o.point(w[y],A[y]);o.lineEnd(),o.areaEnd()}x&&(w[g]=+t(b,g,f),A[g]=+e(b,g,f),o.point(r?+r(b,g,f):w[g],n?+n(b,g,f):A[g]))}if(M)return o=null,M+""||null}function u(){return OX().defined(i).curve(s).context(a)}return c.x=function(f){return arguments.length?(t=typeof f=="function"?f:Qn(+f),r=null,c):t},c.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Qn(+f),c):t},c.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Qn(+f),c):r},c.y=function(f){return arguments.length?(e=typeof f=="function"?f:Qn(+f),n=null,c):e},c.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Qn(+f),c):e},c.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Qn(+f),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(r).y(e)},c.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Qn(!!f),c):i},c.curve=function(f){return arguments.length?(s=f,a!=null&&(o=s(a)),c):s},c.context=function(f){return arguments.length?(f==null?a=o=null:o=s(a=f),c):a},c}class LX{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 aCe(t){return new LX(t,!0)}function sCe(t){return new LX(t,!1)}const dD={draw(t,e){const n=Co(e/Z1);t.moveTo(n,0),t.arc(0,0,n,0,Cw)}},oCe={draw(t,e){const n=Co(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},IX=Co(1/3),lCe=IX*2,cCe={draw(t,e){const n=Co(e/lCe),r=n*IX;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},uCe={draw(t,e){const n=Co(e),r=-n/2;t.rect(r,r,n,n)}},dCe=.8908130915292852,jX=Y1(Z1/10)/Y1(7*Z1/10),fCe=Y1(Cw/10)*jX,hCe=-NX(Cw/10)*jX,pCe={draw(t,e){const n=Co(e*dCe),r=fCe*n,i=hCe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=Cw*a/5,o=NX(s),l=Y1(s);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},O2=Co(3),mCe={draw(t,e){const n=-Co(e/(O2*3));t.moveTo(0,n*2),t.lineTo(-O2*n,-n),t.lineTo(O2*n,-n),t.closePath()}},Ns=-.5,Rs=Co(3)/2,MR=1/Co(12),gCe=(MR/2+1)*3,xCe={draw(t,e){const n=Co(e/gCe),r=n/2,i=n*MR,a=r,s=n*MR+n,o=-a,l=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(o,l),t.lineTo(Ns*r-Rs*i,Rs*r+Ns*i),t.lineTo(Ns*a-Rs*s,Rs*a+Ns*s),t.lineTo(Ns*o-Rs*l,Rs*o+Ns*l),t.lineTo(Ns*r+Rs*i,Ns*i-Rs*r),t.lineTo(Ns*a+Rs*s,Ns*s-Rs*a),t.lineTo(Ns*o+Rs*l,Ns*l-Rs*o),t.closePath()}};function vCe(t,e){let n=null,r=cD(i);t=typeof t=="function"?t:Qn(t||dD),e=typeof e=="function"?e:Qn(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:Qn(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Qn(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Q1(){}function J1(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 UX(t){this._context=t}UX.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:J1(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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function bCe(t){return new UX(t)}function FX(t){this._context=t}FX.prototype={areaStart:Q1,areaEnd:Q1,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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function yCe(t){return new FX(t)}function zX(t){this._context=t}zX.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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function _Ce(t){return new zX(t)}function BX(t){this._context=t}BX.prototype={areaStart:Q1,areaEnd:Q1,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 SCe(t){return new BX(t)}function PH(t){return t<0?-1:1}function kH(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),o=(a*i+s*r)/(r+i);return(PH(a)+PH(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function DH(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function L2(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,o=(a-r)/3;t._context.bezierCurveTo(r+o,i+o*e,a-o,s-o*n,a,s)}function eS(t){this._context=t}eS.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:L2(this,this._t0,DH(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,L2(this,DH(this,n=kH(this,t,e)),n);break;default:L2(this,this._t0,n=kH(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function HX(t){this._context=new $X(t)}(HX.prototype=Object.create(eS.prototype)).point=function(t,e){eS.prototype.point.call(this,e,t)};function $X(t){this._context=t}$X.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 wCe(t){return new eS(t)}function MCe(t){return new HX(t)}function VX(t){this._context=t}VX.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=OH(t),i=OH(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function OH(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),s=new Array(n);for(i[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,s[e]-=r*s[e-1];for(i[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(s[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 ECe(t){return new VX(t)}function Rw(t,e){this._context=t,this._t=e}Rw.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 ACe(t){return new Rw(t,.5)}function TCe(t){return new Rw(t,0)}function CCe(t){return new Rw(t,1)}function lm(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,o=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<o;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function ER(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function NCe(t,e){return t[e]}function RCe(t){const e=[];return e.key=t,e}function PCe(){var t=Qn([]),e=ER,n=lm,r=NCe;function i(a){var s=Array.from(t.apply(this,arguments),RCe),o,l=s.length,c=-1,u;for(const f of a)for(o=0,++c;o<l;++o)(s[o][c]=[0,+r(f,s[o].key,c,a)]).data=f;for(o=0,u=uD(e(s));o<l;++o)s[u[o]].index=o;return n(s,u),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Qn(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Qn(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?ER:typeof a=="function"?a:Qn(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??lm,i):n},i}function kCe(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,s;i<a;++i){for(s=n=0;n<r;++n)s+=t[n][i][1]||0;if(s)for(n=0;n<r;++n)t[n][i][1]/=s}lm(t,e)}}function DCe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,o=0;s<i;++s)o+=t[s][n][1]||0;r[n][1]+=r[n][0]=-o/2}lm(t,e)}}function OCe(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var o=0,l=0,c=0;o<s;++o){for(var u=t[e[o]],f=u[r][1]||0,g=u[r-1][1]||0,m=(f-g)/2,y=0;y<o;++y){var v=t[e[y]],b=v[r][1]||0,x=v[r-1][1]||0;m+=b-x}l+=f,c+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=c/l)}i[r-1][1]+=i[r-1][0]=n,lm(t,e)}}var I2={},j2={},LH;function LCe(){return LH||(LH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(j2)),j2}var U2={},IH;function GX(){return IH||(IH=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})(U2)),U2}var F2={},jH;function fD(){return jH||(jH=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})(F2)),F2}var z2={},B2={},UH;function ICe(){return UH||(UH=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})(B2)),B2}var FH;function hD(){return FH||(FH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ICe(),n=fD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let o=0,l="",c="",u=!1;for(i.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const f=i[o];c?f==="\\"&&o+1<s?(o++,l+=i[o]):f===c?c="":l+=f:u?f==='"'||f==="'"?c=f:f==="]"?(u=!1,a.push(l),l=""):l+=f:f==="["?(u=!0,l&&(a.push(l),l="")):f==="."?l&&(a.push(l),l=""):l+=f,o++}return l&&a.push(l),a}t.toPath=r})(z2)),z2}var zH;function pD(){return zH||(zH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LCe(),n=GX(),r=fD(),i=hD();function a(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?n.isDeepKey(l)?a(o,i.toPath(l),c):c:u}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const u=o[l];return u===void 0?c:u}default:{if(Array.isArray(l))return s(o,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?c:u}}}function s(o,l,c){if(l.length===0)return c;let u=o;for(let f=0;f<l.length;f++){if(u==null||e.isUnsafeProperty(l[f]))return c;u=u[l[f]]}return u===void 0?c:u}t.get=a})(I2)),I2}var H2,BH;function jCe(){return BH||(BH=1,H2=pD().get),H2}var UCe=jCe();const Ff=Js(UCe);var Ti=t=>t===0?0:t>0?1:-1,Ys=t=>typeof t=="number"&&t!=+t,vc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,At=t=>(typeof t=="number"||t instanceof Number)&&!Ys(t),al=t=>At(t)||typeof t=="string",FCe=0,h0=t=>{var e=++FCe;return"".concat(t||"").concat(e)},sa=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(!At(e)&&typeof e!="string")return r;var a;if(vc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return Ys(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},WX=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function sr(t,e,n){return At(t)&&At(e)?t+n*(e-t):e}function qX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Ff(r,e))===n)}var gr=t=>t===null||typeof t>"u",G0=t=>gr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function zCe(t){return t!=null}function W0(){}var BCe=["type","size","sizeType"];function AR(){return AR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},AR.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 $H(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){HCe(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 HCe(t,e,n){return(e=$Ce(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ce(t){var e=VCe(t,"string");return typeof e=="symbol"?e:e+""}function VCe(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 GCe(t,e){if(t==null)return{};var n,r,i=WCe(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 WCe(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 XX={symbolCircle:dD,symbolCross:oCe,symbolDiamond:cCe,symbolSquare:uCe,symbolStar:pCe,symbolTriangle:mCe,symbolWye:xCe},qCe=Math.PI/180,XCe=t=>{var e="symbol".concat(G0(t));return XX[e]||dD},KCe=(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*qCe;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}},YCe=(t,e)=>{XX["symbol".concat(G0(t))]=e},mD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=GCe(t,BCe),a=$H($H({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var g=XCe(s),m=vCe().type(g).size(KCe(n,r,s)),y=m();if(y!==null)return y},{className:l,cx:c,cy:u}=a,f=Ma(a);return At(c)&&At(u)&&At(n)?E.createElement("path",AR({},f,{className:An("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(u,")"),d:o()})):null};mD.registerSymbol=YCe;var KX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,gD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{oD(i)&&(r[i]=(a=>n[i](n,a)))}),r},ZCe=(t,e,n)=>r=>(t(e,n,r),null),q0=(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];oD(i)&&typeof a=="function"&&(r||(r={}),r[i]=ZCe(a,e,n))}),r};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 QCe(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){JCe(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 JCe(t,e,n){return(e=eNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eNe(t){var e=tNe(t,"string");return typeof e=="symbol"?e:e+""}function tNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 Yr(t,e){var n=QCe({},t),r=e,i=Object.keys(e),a=i.reduce((s,o)=>(s[o]===void 0&&r[o]!==void 0&&(s[o]=r[o]),s),n);return a}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)}function GH(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 nNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GH(Object(n),!0).forEach(function(r){rNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rNe(t,e,n){return(e=iNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iNe(t){var e=aNe(t,"string");return typeof e=="symbol"?e:e+""}function aNe(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 Ds=32,sNe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function oNe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Ds/2,a=Ds/6,s=Ds/3,o=e.inactive?r:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var c;return E.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(c=e.payload)===null||c===void 0?void 0:c.strokeDasharray,x1:0,y1:i,x2:Ds,y2:i,className:"recharts-legend-icon"})}if(l==="line")return E.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(s,`
  8183. A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
  8184. H`).concat(Ds,"M").concat(2*s,",").concat(i,`
  8185. A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(l==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Ds/8,"h").concat(Ds,"v").concat(Ds*3/4,"h").concat(-Ds,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var u=nNe({},e);return delete u.legendIcon,E.cloneElement(e.legendIcon,u)}return E.createElement(mD,{fill:o,cx:i,cy:i,size:Ds,sizeType:"diameter",type:l})}function lNe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Ds,height:Ds},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((u,f)=>{var g=u.formatter||i,m=An({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:u.inactive});if(u.type==="none")return null;var y=u.inactive?a:u.color,v=g?g(u.value,u,f):u.value;return E.createElement("li",tS({className:m,style:l,key:"legend-item-".concat(f)},q0(t,u,f)),E.createElement(lD,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(v," legend icon")},E.createElement(oNe,{data:u,iconType:s,inactiveColor:a})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:y}},v))})}var cNe=t=>{var e=Yr(t,sNe),{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 E.createElement("ul",{className:"recharts-default-legend",style:a},E.createElement(lNe,tS({},e,{payload:n})))},$2={},V2={},WH;function uNe(){return WH||(WH=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 s=n[a],o=r(s);i.has(o)||i.set(o,s)}return Array.from(i.values())}t.uniqBy=e})(V2)),V2}var G2={},qH;function YX(){return qH||(qH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(G2)),G2}var W2={},q2={},X2={},XH;function dNe(){return XH||(XH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(X2)),X2}var KH;function xD(){return KH||(KH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dNe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(q2)),q2}var K2={},YH;function fNe(){return YH||(YH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(K2)),K2}var ZH;function hNe(){return ZH||(ZH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xD(),n=fNe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(W2)),W2}var Y2={},Z2={},QH;function pNe(){return QH||(QH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(Z2)),Z2}var Q2={},J2={},eC={},tC={},JH;function ZX(){return JH||(JH=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})(tC)),tC}var nC={},e8;function QX(){return e8||(e8=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})(nC)),nC}var rC={},t8;function JX(){return t8||(t8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.eq=e})(rC)),rC}var n8;function mNe(){return n8||(n8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZX(),n=QX(),r=JX();function i(u,f,g){return typeof g!="function"?i(u,f,()=>{}):a(u,f,function m(y,v,b,x,M,w){const A=g(y,v,b,x,M,w);return A!==void 0?!!A:a(y,v,m,w)},new Map)}function a(u,f,g,m){if(f===u)return!0;switch(typeof f){case"object":return s(u,f,g,m);case"function":return Object.keys(f).length>0?a(u,{...f},g,m):r.eq(u,f);default:return e.isObject(u)?typeof f=="string"?f==="":!0:r.eq(u,f)}}function s(u,f,g,m){if(f==null)return!0;if(Array.isArray(f))return l(u,f,g,m);if(f instanceof Map)return o(u,f,g,m);if(f instanceof Set)return c(u,f,g,m);const y=Object.keys(f);if(u==null)return y.length===0;if(y.length===0)return!0;if(m?.has(f))return m.get(f)===u;m?.set(f,u);try{for(let v=0;v<y.length;v++){const b=y[v];if(!n.isPrimitive(u)&&!(b in u)||f[b]===void 0&&u[b]!==void 0||f[b]===null&&u[b]!==null||!g(u[b],f[b],b,u,f,m))return!1}return!0}finally{m?.delete(f)}}function o(u,f,g,m){if(f.size===0)return!0;if(!(u instanceof Map))return!1;for(const[y,v]of f.entries()){const b=u.get(y);if(g(b,v,y,u,f,m)===!1)return!1}return!0}function l(u,f,g,m){if(f.length===0)return!0;if(!Array.isArray(u))return!1;const y=new Set;for(let v=0;v<f.length;v++){const b=f[v];let x=!1;for(let M=0;M<u.length;M++){if(y.has(M))continue;const w=u[M];let A=!1;if(g(w,b,v,u,f,m)&&(A=!0),A){y.add(M),x=!0;break}}if(!x)return!1}return!0}function c(u,f,g,m){return f.size===0?!0:u instanceof Set?l([...u],[...f],g,m):!1}t.isMatchWith=i,t.isSetMatch=c})(eC)),eC}var r8;function eK(){return r8||(r8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mNe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(J2)),J2}var iC={},aC={},sC={},i8;function gNe(){return i8||(i8=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})(sC)),sC}var oC={},a8;function tK(){return a8||(a8=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})(oC)),oC}var lC={},s8;function nK(){return s8||(s8=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]",s="[object Symbol]",o="[object Date]",l="[object Map]",c="[object Set]",u="[object Array]",f="[object Function]",g="[object ArrayBuffer]",m="[object Object]",y="[object Error]",v="[object DataView]",b="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",R="[object Int16Array]",N="[object Int32Array]",j="[object BigInt64Array]",C="[object Float32Array]",k="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=u,t.bigInt64ArrayTag=j,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=o,t.errorTag=y,t.float32ArrayTag=C,t.float64ArrayTag=k,t.functionTag=f,t.int16ArrayTag=R,t.int32ArrayTag=N,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=x})(lC)),lC}var cC={},o8;function xNe(){return o8||(o8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(cC)),cC}var l8;function rK(){return l8||(l8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gNe(),n=tK(),r=nK(),i=QX(),a=xNe();function s(u,f){return o(u,void 0,u,new Map,f)}function o(u,f,g,m=new Map,y=void 0){const v=y?.(u,f,g,m);if(v!==void 0)return v;if(i.isPrimitive(u))return u;if(m.has(u))return m.get(u);if(Array.isArray(u)){const b=new Array(u.length);m.set(u,b);for(let x=0;x<u.length;x++)b[x]=o(u[x],x,g,m,y);return Object.hasOwn(u,"index")&&(b.index=u.index),Object.hasOwn(u,"input")&&(b.input=u.input),b}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const b=new RegExp(u.source,u.flags);return b.lastIndex=u.lastIndex,b}if(u instanceof Map){const b=new Map;m.set(u,b);for(const[x,M]of u)b.set(x,o(M,x,g,m,y));return b}if(u instanceof Set){const b=new Set;m.set(u,b);for(const x of u)b.add(o(x,void 0,g,m,y));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(u))return u.subarray();if(a.isTypedArray(u)){const b=new(Object.getPrototypeOf(u)).constructor(u.length);m.set(u,b);for(let x=0;x<u.length;x++)b[x]=o(u[x],x,g,m,y);return b}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const b=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return m.set(u,b),l(b,u,g,m,y),b}if(typeof File<"u"&&u instanceof File){const b=new File([u],u.name,{type:u.type});return m.set(u,b),l(b,u,g,m,y),b}if(typeof Blob<"u"&&u instanceof Blob){const b=new Blob([u],{type:u.type});return m.set(u,b),l(b,u,g,m,y),b}if(u instanceof Error){const b=new u.constructor;return m.set(u,b),b.message=u.message,b.name=u.name,b.stack=u.stack,b.cause=u.cause,l(b,u,g,m,y),b}if(u instanceof Boolean){const b=new Boolean(u.valueOf());return m.set(u,b),l(b,u,g,m,y),b}if(u instanceof Number){const b=new Number(u.valueOf());return m.set(u,b),l(b,u,g,m,y),b}if(u instanceof String){const b=new String(u.valueOf());return m.set(u,b),l(b,u,g,m,y),b}if(typeof u=="object"&&c(u)){const b=Object.create(Object.getPrototypeOf(u));return m.set(u,b),l(b,u,g,m,y),b}return u}function l(u,f,g=u,m,y){const v=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<v.length;b++){const x=v[b],M=Object.getOwnPropertyDescriptor(u,x);(M==null||M.writable)&&(u[x]=o(f[x],x,g,m,y))}}function c(u){switch(n.getTag(u)){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=s,t.cloneDeepWithImpl=o,t.copyProperties=l})(aC)),aC}var c8;function vNe(){return c8||(c8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(iC)),iC}var u8;function bNe(){return u8||(u8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eK(),n=vNe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(Q2)),Q2}var uC={},dC={},fC={},d8;function yNe(){return d8||(d8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rK(),n=nK();function r(i,a){return e.cloneDeepWith(i,(s,o,l,c)=>{const u=a?.(s,o,l,c);if(u!==void 0)return u;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(fC)),fC}var f8;function _Ne(){return f8||(f8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yNe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(dC)),dC}var hC={},pC={},h8;function iK(){return h8||(h8=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})(pC)),pC}var mC={},p8;function SNe(){return p8||(p8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(mC)),mC}var m8;function wNe(){return m8||(m8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GX(),n=iK(),r=SNe(),i=hD();function a(s,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?l=i.toPath(o):l=[o],l.length===0)return!1;let c=s;for(let u=0;u<l.length;u++){const f=l[u];if((c==null||!Object.hasOwn(c,f))&&!((Array.isArray(c)||r.isArguments(c))&&n.isIndex(f)&&f<c.length))return!1;c=c[f]}return!0}t.has=a})(hC)),hC}var g8;function MNe(){return g8||(g8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eK(),n=fD(),r=_Ne(),i=pD(),a=wNe();function s(o,l){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return l=r.cloneDeep(l),function(c){const u=i.get(c,o);return u===void 0?a.has(c,o):l===void 0?u===void 0:e.isMatch(u,l)}}t.matchesProperty=s})(uC)),uC}var x8;function ENe(){return x8||(x8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YX(),n=pNe(),r=bNe(),i=MNe();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?i.matchesProperty(s[0],s[1]):r.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(Y2)),Y2}var v8;function ANe(){return v8||(v8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uNe(),n=YX(),r=hNe(),i=ENe();function a(s,o=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(o)):[]}t.uniqBy=a})($2)),$2}var gC,b8;function TNe(){return b8||(b8=1,gC=ANe().uniqBy),gC}var CNe=TNe();const y8=Js(CNe);function aK(t,e,n){return e===!0?y8(t,n):typeof e=="function"?y8(t,e):t}var vD=E.createContext(null),NNe=t=>t,er=()=>{var t=E.useContext(vD);return t?t.store.dispatch:NNe},R_=()=>{},RNe=()=>R_,PNe=(t,e)=>t===e;function Tt(t){var e=E.useContext(vD);return Xq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:RNe,e?e.store.getState:R_,e?e.store.getState:R_,e?t:R_,PNe)}function kNe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function DNe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function ONe(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 _8=t=>Array.isArray(t)?t:[t];function LNe(t){const e=Array.isArray(t[0])?t[0]:t;return ONe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function INe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var jNe=class{constructor(t){this.value=t}deref(){return this.value}},UNe=typeof WeakRef<"u"?WeakRef:jNe,FNe=0,S8=1;function Gy(){return{s:FNe,v:void 0,o:null,p:null}}function sK(t,e={}){let n=Gy();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let o=n;const{length:l}=arguments;for(let f=0,g=l;f<g;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let y=o.o;y===null&&(o.o=y=new WeakMap);const v=y.get(m);v===void 0?(o=Gy(),y.set(m,o)):o=v}else{let y=o.p;y===null&&(o.p=y=new Map);const v=y.get(m);v===void 0?(o=Gy(),y.set(m,o)):o=v}}const c=o;let u;if(o.s===S8)u=o.v;else if(u=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,u)&&(u=f,a!==0&&a--),i=typeof u=="object"&&u!==null||typeof u=="function"?new UNe(u):u}return c.s=S8,c.v=u,u}return s.clearCache=()=>{n=Gy(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function zNe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,o,l={},c=i.pop();typeof c=="object"&&(l=c,c=i.pop()),kNe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:f,memoizeOptions:g=[],argsMemoize:m=sK,argsMemoizeOptions:y=[]}=u,v=_8(g),b=_8(y),x=LNe(i),M=f(function(){return a++,c.apply(null,arguments)},...v),w=m(function(){s++;const T=INe(x,arguments);return o=M.apply(null,T),o},...b);return Object.assign(w,{resultFunc:c,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var $e=zNe(sK),BNe=Object.assign((t,e=$e)=>{DNe(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((s,o,l)=>(s[n[l]]=o,s),{}))},{withTypes:()=>BNe}),xC={},vC={},bC={},w8;function HNe(){return w8||(w8=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 s=e(r),o=e(i);if(s===o&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(bC)),bC}var yC={},_C={},M8;function oK(){return M8||(M8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(_C)),_C}var E8;function $Ne(){return E8||(E8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,s){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))||s!=null&&Object.hasOwn(s,a)}t.isKey=i})(yC)),yC}var A8;function VNe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HNe(),n=$Ne(),r=hD();function i(a,s,o,l){if(a==null)return[];o=l?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const c=(m,y)=>{let v=m;for(let b=0;b<y.length&&v!=null;++b)v=v[y[b]];return v},u=(m,y)=>y==null||m==null?y:typeof m=="object"&&"key"in m?Object.hasOwn(y,m.key)?y[m.key]:c(y,m.path):typeof m=="function"?m(y):Array.isArray(m)?c(y,m):typeof y=="object"?y[m]:y,f=s.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return a.map(m=>({original:m,criteria:f.map(y=>u(y,m))})).slice().sort((m,y)=>{for(let v=0;v<f.length;v++){const b=e.compareValues(m.criteria[v],y.criteria[v],o[v]);if(b!==0)return b}return 0}).map(m=>m.original)}t.orderBy=i})(vC)),vC}var SC={},T8;function GNe(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(o,l)=>{for(let c=0;c<o.length;c++){const u=o[c];Array.isArray(u)&&l<a?s(u,l+1):i.push(u)}};return s(n,0),i}t.flatten=e})(SC)),SC}var wC={},C8;function lK(){return C8||(C8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iK(),n=xD(),r=ZX(),i=JX();function a(s,o,l){return r.isObject(l)&&(typeof o=="number"&&n.isArrayLike(l)&&e.isIndex(o)&&o<l.length||typeof o=="string"&&o in l)?i.eq(l[o],s):!1}t.isIterateeCall=a})(wC)),wC}var N8;function WNe(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VNe(),n=GNe(),r=lK();function i(a,...s){const o=s.length;return o>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(xC)),xC}var MC,R8;function qNe(){return R8||(R8=1,MC=WNe().sortBy),MC}var XNe=qNe();const Pw=Js(XNe);var cK=t=>t.legend.settings,KNe=t=>t.legend.size,YNe=t=>t.legend.payload,ZNe=$e([YNe,cK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Pw(r,n):r});function QNe(){return Tt(ZNe)}var Wy=1;function uK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),r=E.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>Wy||Math.abs(s.left-e.left)>Wy||Math.abs(s.top-e.top)>Wy||Math.abs(s.width-e.width)>Wy)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function zi(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 JNe=typeof Symbol=="function"&&Symbol.observable||"@@observable",P8=JNe,EC=()=>Math.random().toString(36).substring(7).split("").join("."),e3e={INIT:`@@redux/INIT${EC()}`,REPLACE:`@@redux/REPLACE${EC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${EC()}`},nS=e3e;function bD(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 dK(t,e,n){if(typeof t!="function")throw new Error(zi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(zi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(zi(1));return n(dK)(t,e)}let r=t,i=e,a=new Map,s=a,o=0,l=!1;function c(){s===a&&(s=new Map,a.forEach((b,x)=>{s.set(x,b)}))}function u(){if(l)throw new Error(zi(3));return i}function f(b){if(typeof b!="function")throw new Error(zi(4));if(l)throw new Error(zi(5));let x=!0;c();const M=o++;return s.set(M,b),function(){if(x){if(l)throw new Error(zi(6));x=!1,c(),s.delete(M),a=null}}}function g(b){if(!bD(b))throw new Error(zi(7));if(typeof b.type>"u")throw new Error(zi(8));if(typeof b.type!="string")throw new Error(zi(17));if(l)throw new Error(zi(9));try{l=!0,i=r(i,b)}finally{l=!1}return(a=s).forEach(M=>{M()}),b}function m(b){if(typeof b!="function")throw new Error(zi(10));r=b,g({type:nS.REPLACE})}function y(){const b=f;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(zi(11));function M(){const A=x;A.next&&A.next(u())}return M(),{unsubscribe:b(M)}},[P8](){return this}}}return g({type:nS.INIT}),{dispatch:g,subscribe:f,getState:u,replaceReducer:m,[P8]:y}}function t3e(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:nS.INIT})>"u")throw new Error(zi(12));if(typeof n(void 0,{type:nS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(zi(13))})}function fK(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;try{t3e(n)}catch(a){i=a}return function(s={},o){if(i)throw i;let l=!1;const c={};for(let u=0;u<r.length;u++){const f=r[u],g=n[f],m=s[f],y=g(m,o);if(typeof y>"u")throw o&&o.type,new Error(zi(14));c[f]=y,l=l||y!==m}return l=l||r.length!==Object.keys(s).length,l?c:s}}function rS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function n3e(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(zi(15))};const s={getState:i.getState,dispatch:(l,...c)=>a(l,...c)},o=t.map(l=>l(s));return a=rS(...o)(i.dispatch),{...i,dispatch:a}}}function hK(t){return bD(t)&&"type"in t&&typeof t.type=="string"}var pK=Symbol.for("immer-nothing"),k8=Symbol.for("immer-draftable"),Ea=Symbol.for("immer-state");function xo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ds=Object,cm=ds.getPrototypeOf,iS="constructor",kw="prototype",TR="configurable",aS="enumerable",P_="writable",p0="value",bc=t=>!!t&&!!t[Ea];function Eo(t){return t?mK(t)||Dw(t)||!!t[k8]||!!t[iS]?.[k8]||Ow(t)||Lw(t):!1}var r3e=ds[kw][iS].toString(),D8=new WeakMap;function mK(t){if(!t||!yD(t))return!1;const e=cm(t);if(e===null||e===ds[kw])return!0;const n=ds.hasOwnProperty.call(e,iS)&&e[iS];if(n===Object)return!0;if(!_p(n))return!1;let r=D8.get(n);return r===void 0&&(r=Function.toString.call(n),D8.set(n,r)),r===r3e}function X0(t,e,n=!0){K0(t)===0?(n?Reflect.ownKeys(t):ds.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function K0(t){const e=t[Ea];return e?e.type_:Dw(t)?1:Ow(t)?2:Lw(t)?3:0}var O8=(t,e,n=K0(t))=>n===2?t.has(e):ds[kw].hasOwnProperty.call(t,e),CR=(t,e,n=K0(t))=>n===2?t.get(e):t[e],sS=(t,e,n,r=K0(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function i3e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Dw=Array.isArray,Ow=t=>t instanceof Map,Lw=t=>t instanceof Set,yD=t=>typeof t=="object",_p=t=>typeof t=="function",AC=t=>typeof t=="boolean",Kl=t=>t.copy_||t.base_,_D=t=>t.modified_?t.copy_:t.base_;function NR(t,e){if(Ow(t))return new Map(t);if(Lw(t))return new Set(t);if(Dw(t))return Array[kw].slice.call(t);const n=mK(t);if(e===!0||e==="class_only"&&!n){const r=ds.getOwnPropertyDescriptors(t);delete r[Ea];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[P_]===!1&&(o[P_]=!0,o[TR]=!0),(o.get||o.set)&&(r[s]={[TR]:!0,[P_]:!0,[aS]:o[aS],[p0]:t[s]})}return ds.create(cm(t),r)}else{const r=cm(t);if(r!==null&&n)return{...t};const i=ds.create(r);return ds.assign(i,t)}}function SD(t,e=!1){return Iw(t)||bc(t)||!Eo(t)||(K0(t)>1&&ds.defineProperties(t,{set:qy,add:qy,clear:qy,delete:qy}),ds.freeze(t),e&&X0(t,(n,r)=>{SD(r,!0)},!1)),t}function a3e(){xo(2)}var qy={[p0]:a3e};function Iw(t){return t===null||!yD(t)?!0:ds.isFrozen(t)}var oS="MapSet",RR="Patches",gK={};function um(t){const e=gK[t];return e||xo(0,t),e}var s3e=t=>!!gK[t],m0,xK=()=>m0,o3e=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:s3e(oS)?um(oS):void 0});function L8(t,e){e&&(t.patchPlugin_=um(RR),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function PR(t){kR(t),t.drafts_.forEach(l3e),t.drafts_=null}function kR(t){t===m0&&(m0=t.parent_)}var I8=t=>m0=o3e(m0,t);function l3e(t){const e=t[Ea];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function j8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ea].modified_&&(PR(e),xo(4)),Eo(t)&&(t=U8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ea].base_,t,e)}else t=U8(e,n);return c3e(e,t,!0),PR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pK?t:void 0}function U8(t,e){if(Iw(e))return e;const n=e[Ea];if(!n)return wD(e,t.handledSet_,t);if(!jw(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);yK(n,t)}return n.copy_}function c3e(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&SD(e,n)}function vK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var jw=(t,e)=>t.scope_===e,u3e=[];function bK(t,e,n,r){const i=Kl(t),a=t.type_;if(r!==void 0&&CR(i,r,a)===e){sS(i,r,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;X0(i,(l,c)=>{if(bc(c)){const u=o.get(c)||[];u.push(l),o.set(c,u)}})}const s=t.draftLocations_.get(e)??u3e;for(const o of s)sS(i,o,n,a)}function d3e(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!jw(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=_D(a);bK(t,a.draft_??a,s,n),yK(a,i)})}function yK(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}vK(t)}}function f3e(t,e,n){const{scope_:r}=t;if(bc(n)){const i=n[Ea];jw(i,r)&&i.callbacks_.push(function(){k_(t);const s=_D(i);bK(t,n,s,e)})}else Eo(n)&&t.callbacks_.push(function(){const a=Kl(t);CR(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&wD(CR(t.copy_,e,t.type_),r.handledSet_,r)})}function wD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||bc(t)||e.has(t)||!Eo(t)||Iw(t)||(e.add(t),X0(t,(r,i)=>{if(bc(i)){const a=i[Ea];if(jw(a,n)){const s=_D(a);sS(t,r,s,t.type_),vK(a)}}else Eo(i)&&wD(i,e,n)})),t}function h3e(t,e){const n=Dw(t),r={type_:n?1:0,scope_:e?e.scope_:xK(),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=MD;n&&(i=[r],a=g0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var MD={get(t,e){if(e===Ea)return t;const n=Kl(t);if(!O8(n,e,t.type_))return p3e(t,n,e);const r=n[e];if(t.finalized_||!Eo(r))return r;if(r===TC(t.base_,e)){k_(t);const i=t.type_===1?+e:e,a=OR(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Kl(t)},ownKeys(t){return Reflect.ownKeys(Kl(t))},set(t,e,n){const r=_K(Kl(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=TC(Kl(t),e),a=i?.[Ea];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(i3e(n,i)&&(n!==void 0||O8(t.base_,e,t.type_)))return!0;k_(t),DR(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),f3e(t,e,n)),!0},deleteProperty(t,e){return k_(t),TC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),DR(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Kl(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[P_]:!0,[TR]:t.type_!==1||e!=="length",[aS]:r[aS],[p0]:n[e]}},defineProperty(){xo(11)},getPrototypeOf(t){return cm(t.base_)},setPrototypeOf(){xo(12)}},g0={};X0(MD,(t,e)=>{g0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});g0.deleteProperty=function(t,e){return g0.set.call(this,t,e,void 0)};g0.set=function(t,e,n){return MD.set.call(this,t[0],e,n,t[0])};function TC(t,e){const n=t[Ea];return(n?Kl(n):t)[e]}function p3e(t,e,n){const r=_K(e,n);return r?p0 in r?r[p0]:r.get?.call(t.draft_):void 0}function _K(t,e){if(!(e in t))return;let n=cm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=cm(n)}}function DR(t){t.modified_||(t.modified_=!0,t.parent_&&DR(t.parent_))}function k_(t){t.copy_||(t.assigned_=new Map,t.copy_=NR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var m3e=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(_p(n)&&!_p(r)){const s=r;r=n;const o=this;return function(c=s,...u){return o.produce(c,f=>r.call(this,f,...u))}}_p(r)||xo(6),i!==void 0&&!_p(i)&&xo(7);let a;if(Eo(n)){const s=I8(this),o=OR(s,n,void 0);let l=!0;try{a=r(o),l=!1}finally{l?PR(s):kR(s)}return L8(s,i),j8(a,s)}else if(!n||!yD(n)){if(a=r(n),a===void 0&&(a=n),a===pK&&(a=void 0),this.autoFreeze_&&SD(a,!0),i){const s=[],o=[];um(RR).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),i(s,o)}return a}else xo(1,n)},this.produceWithPatches=(n,r)=>{if(_p(n))return(o,...l)=>this.produceWithPatches(o,c=>n(c,...l));let i,a;return[this.produce(n,r,(o,l)=>{i=o,a=l}),i,a]},AC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),AC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),AC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Eo(e)||xo(8),bc(e)&&(e=Mo(e));const n=I8(this),r=OR(n,e,void 0);return r[Ea].isManual_=!0,kR(n),r}finishDraft(e,n){const r=e&&e[Ea];(!r||!r.isManual_)&&xo(9);const{scope_:i}=r;return L8(i,n),j8(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=um(RR).applyPatches_;return bc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function OR(t,e,n,r){const[i,a]=Ow(e)?um(oS).proxyMap_(e,n):Lw(e)?um(oS).proxySet_(e,n):h3e(e,n);return(n?.scope_??xK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?d3e(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:c}=l;a.modified_&&c&&c.generatePatches_(a,[],l)}),i}function Mo(t){return bc(t)||xo(10,t),SK(t)}function SK(t){if(!Eo(t)||Iw(t))return t;const e=t[Ea];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=NR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=NR(t,!0);return X0(n,(i,a)=>{sS(n,i,SK(a))},r),e&&(e.finalized_=!1),n}var g3e=new m3e,wK=g3e.produce;function MK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var x3e=MK(),v3e=MK,b3e=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?rS:rS.apply(null,arguments)};function Zs(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(ms(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=>hK(r)&&r.type===t,n}var EK=class hx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,hx.prototype)}static get[Symbol.species](){return hx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new hx(...e[0].concat(this)):new hx(...e.concat(this))}};function F8(t){return Eo(t)?wK(t,()=>{}):t}function Xy(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function y3e(t){return typeof t=="boolean"}var _3e=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new EK;return n&&(y3e(n)?s.push(x3e):s.push(v3e(n.extraArgument))),s},AK="RTK_autoBatch",cr=()=>t=>({payload:t,meta:{[AK]:!0}}),z8=t=>e=>{setTimeout(e,t)},TK=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:z8(10):t.type==="callback"?t.queueNotification:z8(t.timeout),c=()=>{s=!1,a&&(a=!1,o.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){const f=()=>i&&u(),g=r.subscribe(f);return o.add(u),()=>{g(),o.delete(u)}},dispatch(u){try{return i=!u?.meta?.[AK],a=!i,a&&(s||(s=!0,l(c))),r.dispatch(u)}finally{i=!0}}})},S3e=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new EK(t);return r&&i.push(TK(typeof r=="object"?r:void 0)),i};function w3e(t){const e=_3e(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(bD(n))o=fK(n);else throw new Error(ms(1));let l;typeof r=="function"?l=r(e):l=e();let c=rS;i&&(c=b3e({trace:!1,...typeof i=="object"&&i}));const u=n3e(...l),f=S3e(u);let g=typeof s=="function"?s(f):f();const m=c(...g);return dK(o,a,m)}function CK(t){const e={},n=[];let r;const i={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(ms(28));if(o in e)throw new Error(ms(29));return e[o]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function M3e(t){return typeof t=="function"}function E3e(t,e){let[n,r,i]=CK(e),a;if(M3e(t))a=()=>F8(t());else{const o=F8(t);a=()=>o}function s(o=a(),l){let c=[n[l.type],...r.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[i]),c.reduce((u,f)=>{if(f)if(bc(u)){const m=f(u,l);return m===void 0?u:m}else{if(Eo(u))return wK(u,g=>f(g,l));{const g=f(u,l);if(g===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return u},o)}return s.getInitialState=a,s}var A3e="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",T3e=(t=21)=>{let e="",n=t;for(;n--;)e+=A3e[Math.random()*64|0];return e},C3e=Symbol.for("rtk-slice-createasyncthunk");function N3e(t,e){return`${t}/${e}`}function R3e({creators:t}={}){const e=t?.asyncThunk?.[C3e];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(ms(11));const s=(typeof r.reducers=="function"?r.reducers(k3e()):r.reducers)||{},o=Object.keys(s),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,A){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(ms(12));if(T in l.sliceCaseReducersByType)throw new Error(ms(13));return l.sliceCaseReducersByType[T]=A,c},addMatcher(w,A){return l.sliceMatchers.push({matcher:w,reducer:A}),c},exposeAction(w,A){return l.actionCreators[w]=A,c},exposeCaseReducer(w,A){return l.sliceCaseReducersByName[w]=A,c}};o.forEach(w=>{const A=s[w],T={reducerName:w,type:N3e(i,w),createNotation:typeof r.reducers=="function"};O3e(A)?I3e(T,A,c,e):D3e(T,A,c)});function u(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?CK(r.extraReducers):[r.extraReducers],R={...w,...l.sliceCaseReducersByType};return E3e(r.initialState,N=>{for(let j in R)N.addCase(j,R[j]);for(let j of l.sliceMatchers)N.addMatcher(j.matcher,j.reducer);for(let j of A)N.addMatcher(j.matcher,j.reducer);T&&N.addDefaultCase(T)})}const f=w=>w,g=new Map,m=new WeakMap;let y;function v(w,A){return y||(y=u()),y(w,A)}function b(){return y||(y=u()),y.getInitialState()}function x(w,A=!1){function T(N){let j=N[w];return typeof j>"u"&&A&&(j=Xy(m,T,b)),j}function R(N=f){const j=Xy(g,A,()=>new WeakMap);return Xy(j,N,()=>{const C={};for(const[k,U]of Object.entries(r.selectors??{}))C[k]=P3e(U,N,()=>Xy(m,N,b),A);return C})}return{reducerPath:w,getSelectors:R,get selectors(){return R(T)},selectSlice:T}}const M={name:i,reducer:v,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:b,...x(a),injectInto(w,{reducerPath:A,...T}={}){const R=A??a;return w.inject({reducerPath:R,reducer:v},T),{...M,...x(R,!0)}}};return M}}function P3e(t,e,n,r){function i(a,...s){let o=e(a);return typeof o>"u"&&r&&(o=n()),t(o,...s)}return i.unwrapped=t,i}var Ga=R3e();function k3e(){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 D3e({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!L3e(r))throw new Error(ms(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?Zs(t,s):Zs(t))}function O3e(t){return t._reducerDefinitionType==="asyncThunk"}function L3e(t){return t._reducerDefinitionType==="reducerWithPrepare"}function I3e({type:t,reducerName:e},n,r,i){if(!i)throw new Error(ms(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:l,settled:c,options:u}=n,f=i(t,a,u);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),o&&r.addCase(f.pending,o),l&&r.addCase(f.rejected,l),c&&r.addMatcher(f.settled,c),r.exposeCaseReducer(e,{fulfilled:s||Ky,pending:o||Ky,rejected:l||Ky,settled:c||Ky})}function Ky(){}var j3e="task",NK="listener",RK="completed",ED="cancelled",U3e=`task-${ED}`,F3e=`task-${RK}`,LR=`${NK}-${ED}`,z3e=`${NK}-${RK}`,Uw=class{constructor(t){this.code=t,this.message=`${j3e} ${ED} (reason: ${t})`}name="TaskAbortError";message},AD=(t,e)=>{if(typeof t!="function")throw new TypeError(ms(32))},lS=()=>{},PK=(t,e=lS)=>(t.catch(e),t),kK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),vf=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},bf=t=>{if(t.aborted){const{reason:e}=t;throw new Uw(e)}};function DK(t,e){let n=lS;return new Promise((r,i)=>{const a=()=>i(new Uw(t.reason));if(t.aborted){a();return}n=kK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=lS})}var B3e=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Uw?"cancelled":"rejected",error:n}}finally{e?.()}},cS=t=>e=>PK(DK(t,e).then(n=>(bf(t),n))),OK=t=>{const e=cS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Up}=Object,B8={},Fw="listenerMiddleware",H3e=(t,e)=>{const n=r=>kK(t,()=>vf(r,t.reason));return(r,i)=>{AD(r);const a=new AbortController;n(a);const s=B3e(async()=>{bf(t),bf(a.signal);const o=await r({pause:cS(a.signal),delay:OK(a.signal),signal:a.signal});return bf(a.signal),o},()=>vf(a,F3e));return i?.autoJoin&&e.push(s.catch(lS)),{result:cS(t)(s),cancel(){vf(a,U3e)}}}},$3e=(t,e)=>{const n=async(r,i)=>{bf(e);let a=()=>{};const o=[new Promise((l,c)=>{let u=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),l([f,g.getState(),g.getOriginalState()])}});a=()=>{u(),c()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await DK(e,Promise.race(o));return bf(e),l}finally{a()}};return(r,i)=>PK(n(r,i))},LK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Zs(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ms(21));return AD(a),{predicate:i,type:e,effect:a}},IK=Up(t=>{const{type:e,predicate:n,effect:r}=LK(t);return{id:T3e(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ms(22))}}},{withTypes:()=>IK}),H8=(t,e)=>{const{type:n,effect:r,predicate:i}=LK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},IR=t=>{t.pending.forEach(e=>{vf(e,LR)})},V3e=(t,e)=>()=>{for(const n of e.keys())IR(n);t.clear()},$8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},jK=Up(Zs(`${Fw}/add`),{withTypes:()=>jK}),G3e=Zs(`${Fw}/removeAll`),UK=Up(Zs(`${Fw}/remove`),{withTypes:()=>UK}),W3e=(...t)=>{console.error(`${Fw}/error`,...t)},Y0=(t={})=>{const e=new Map,n=new Map,r=m=>{const y=n.get(m)??0;n.set(m,y+1)},i=m=>{const y=n.get(m)??1;y===1?n.delete(m):n.set(m,y-1)},{extra:a,onError:s=W3e}=t;AD(s);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),y=>{m.unsubscribe(),y?.cancelActive&&IR(m)}),l=m=>{const y=H8(e,m)??IK(m);return o(y)};Up(l,{withTypes:()=>l});const c=m=>{const y=H8(e,m);return y&&(y.unsubscribe(),m.cancelActive&&IR(y)),!!y};Up(c,{withTypes:()=>c});const u=async(m,y,v,b)=>{const x=new AbortController,M=$3e(l,x.signal),w=[];try{m.pending.add(x),r(m),await Promise.resolve(m.effect(y,Up({},v,{getOriginalState:b,condition:(A,T)=>M(A,T).then(Boolean),take:M,delay:OK(x.signal),pause:cS(x.signal),extra:a,signal:x.signal,fork:H3e(x.signal,w),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,R)=>{A!==x&&(vf(A,LR),R.delete(A))})},cancel:()=>{vf(x,LR),m.pending.delete(x)},throwIfCancelled:()=>{bf(x.signal)}})))}catch(A){A instanceof Uw||$8(s,A,{raisedBy:"effect"})}finally{await Promise.all(w),vf(x,z3e),i(m),m.pending.delete(x)}},f=V3e(e,n);return{middleware:m=>y=>v=>{if(!hK(v))return y(v);if(jK.match(v))return l(v.payload);if(G3e.match(v)){f();return}if(UK.match(v))return c(v.payload);let b=m.getState();const x=()=>{if(b===B8)throw new Error(ms(23));return b};let M;try{if(M=y(v),e.size>0){const w=m.getState(),A=Array.from(e.values());for(const T of A){let R=!1;try{R=T.predicate(v,w,b)}catch(N){R=!1,$8(s,N,{raisedBy:"predicate"})}R&&u(T,v,m,x)}}}finally{b=B8}return M},startListening:l,stopListening:c,clearListeners:f}};function ms(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 q3e={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},FK=Ga({name:"chartLayout",initialState:q3e,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:X3e,setLayout:K3e,setChartSize:Y3e,setScale:Z3e}=FK.actions,Q3e=FK.reducer;function zK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function V8(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 Ap(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V8(Object(n),!0).forEach(function(r){J3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function J3e(t,e,n){return(e=eRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eRe(t){var e=tRe(t,"string");return typeof e=="symbol"?e:e+""}function tRe(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 Yn(t,e,n){return gr(t)||gr(e)?n:al(e)?Ff(t,e,n):typeof e=="function"?e(t):n}var nRe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&At(t[a]))return Ap(Ap({},t),{},{[a]:t[a]+(r||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&At(t[s]))return Ap(Ap({},t),{},{[s]:t[s]+(i||0)})}return t},Tc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",BK=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,a,s=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(a=!0),o.coordinate));return i||s.push(e),a||s.push(n),s},HK=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:u,ticks:f,niceTicks:g,axisType:m}=t;if(!s)return null;var y=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/y:0;if(v=m==="angleAxis"&&a&&a.length>=2?Ti(a[0]-a[1])*2*v:v,f||g){var b=(f||g||[]).map((x,M)=>{var w=r?r.indexOf(x):x;return{coordinate:s(w)+v,value:x,offset:v,index:M}});return b.filter(x=>!Ys(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:s(x)+v,value:x,index:M,offset:v})):s.ticks&&u!=null?s.ticks(u).map((x,M)=>({coordinate:s(x)+v,value:x,offset:v,index:M})):s.domain().map((x,M)=>({coordinate:s(x)+v,value:r?r[x]:x,index:M,offset:v}))},G8=1e-4,rRe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-G8,a=Math.max(r[0],r[1])+G8,s=t(e[0]),o=t(e[n-1]);(s<i||s>a||o<i||o>a)&&t.domain([e[0],e[n-1]])}},iRe=(t,e)=>{if(!e||e.length!==2||!At(e[0])||!At(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(!At(t[0])||t[0]<n)&&(i[0]=n),(!At(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},aRe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,s=0;s<e;++s){var o=Ys(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},sRe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var s=Ys(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=i,t[a][n][1]=i+s,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},oRe={sign:aRe,expand:kCe,none:lm,silhouette:DCe,wiggle:OCe,positive:sRe},lRe=(t,e,n)=>{var r=oRe[n],i=PCe().keys(e).value((a,s)=>Number(Yn(a,s,0))).order(ER).offset(r);return i(t)};function $K(t){return t==null?void 0:String(t)}function W8(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!gr(i[e.dataKey])){var o=qX(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var l=Yn(i,gr(s)?e.dataKey:s);return gr(l)?null:e.scale(l)}var q8=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var o=Yn(a,e.dataKey,e.scale.domain()[s]);return gr(o)?null:e.scale(o)-i/2+r},cRe=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]},uRe=t=>{var e=t.flat(2).filter(At);return[Math.min(...e),Math.max(...e)]},dRe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],fRe=(t,e,n)=>{if(t!=null)return dRe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,o=s.reduce((l,c)=>{var u=zK(c,e,n),f=uRe(u);return[Math.min(l[0],f[0]),Math.max(l[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},X8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,K8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,dm=(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=Pw(e,u=>u.coordinate),a=1/0,s=1,o=i.length;s<o;s++){var l=i[s],c=i[s-1];a=Math.min((l.coordinate||0)-(c.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function Y8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Ap(Ap({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Tm(t,e){if(t)return String(t);if(typeof e=="string")return e}var hRe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},pRe=(t,e)=>e==="centric"?t.angle:t.radius,Cc=t=>t.layout.width,Nc=t=>t.layout.height,mRe=t=>t.layout.scale,VK=t=>t.layout.margin,zw=$e(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),Bw=$e(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),GK="data-recharts-item-index",WK="data-recharts-item-data-key",Z0=60;function Z8(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 Yy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z8(Object(n),!0).forEach(function(r){gRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gRe(t,e,n){return(e=xRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xRe(t){var e=vRe(t,"string");return typeof e=="symbol"?e:e+""}function vRe(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 bRe=t=>t.brush.height;function yRe(t){var e=Bw(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Z0;return n+i}return n},0)}function _Re(t){var e=Bw(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Z0;return n+i}return n},0)}function SRe(t){var e=zw(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function wRe(t){var e=zw(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ui=$e([Cc,Nc,VK,bRe,yRe,_Re,SRe,wRe,cK,KNe],(t,e,n,r,i,a,s,o,l,c)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},g=Yy(Yy({},f),u),m=g.bottom;g.bottom+=r,g=nRe(g,l,c);var y=t-g.left-g.right,v=e-g.top-g.bottom;return Yy(Yy({brushBottom:m},g),{},{width:Math.max(y,0),height:Math.max(v,0)})}),MRe=$e(ui,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),TD=$e(Cc,Nc,(t,e)=>({x:0,y:0,width:t,height:e})),ERe=E.createContext(null),ca=()=>E.useContext(ERe)!=null,Hw=t=>t.brush,$w=$e([Hw,ui,VK],(t,e,n)=>({height:t.height,x:At(t.x)?t.x:e.left,y:At(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:At(t.width)?t.width:e.width})),CC={},NC={},RC={},Q8;function ARe(){return Q8||(Q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,o=null;const l=a!=null&&a.includes("leading"),c=a==null||a.includes("trailing"),u=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{c&&u(),v()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},y=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{y(),s=void 0,o=null},b=()=>{u()},x=function(...M){if(i?.aborted)return;s=this,o=M;const w=g==null;m(),l&&w&&u()};return x.schedule=m,x.cancel=v,x.flush=b,i?.addEventListener("abort",v,{once:!0}),x}t.debounce=e})(RC)),RC}var J8;function TRe(){return J8||(J8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ARe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:l}=a,c=Array(2);s&&(c[0]="leading"),o&&(c[1]="trailing");let u,f=null;const g=e.debounce(function(...v){u=r.apply(this,v),f=null},i,{edges:c}),m=function(...v){return l!=null&&(f===null&&(f=Date.now()),Date.now()-f>=l)?(u=r.apply(this,v),f=Date.now(),g.cancel(),g.schedule(),u):(g.apply(this,v),u)},y=()=>(g.flush(),u);return m.cancel=g.cancel,m.flush=y,m}t.debounce=n})(NC)),NC}var e6;function CRe(){return e6||(e6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TRe();function n(r,i=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:o})}t.throttle=n})(CC)),CC}var PC,t6;function NRe(){return t6||(t6=1,PC=CRe().throttle),PC}var RRe=NRe();const PRe=Js(RRe);var uS=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 s=0;console.warn(n.replace(/%s/g,()=>i[s++]))}},qK=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,o=vc(r)?t:Number(r),l=vc(i)?e:Number(i);return a&&a>0&&(o?l=o/a:l&&(o=l*a),s&&l!=null&&l>s&&(l=s)),{calculatedWidth:o,calculatedHeight:l}},kRe={width:0,height:0,overflow:"visible"},DRe={width:0,overflowX:"visible"},ORe={height:0,overflowY:"visible"},LRe={},IRe=t=>{var{width:e,height:n}=t,r=vc(e),i=vc(n);return r&&i?kRe:r?DRe:i?ORe:LRe};function jRe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function or(t){return Number.isFinite(t)}function sl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function jR(){return jR=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},jR.apply(null,arguments)}function n6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function r6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n6(Object(n),!0).forEach(function(r){URe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function URe(t,e,n){return(e=FRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FRe(t){var e=zRe(t,"string");return typeof e=="symbol"?e:e+""}function zRe(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 XK=E.createContext({width:-1,height:-1});function BRe(t){return sl(t.width)&&sl(t.height)}function KK(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return BRe(i)?E.createElement(XK.Provider,{value:i},e):null}var CD=()=>E.useContext(XK),HRe=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:o,maxHeight:l,children:c,debounce:u=0,id:f,className:g,onResize:m,style:y={}}=t,v=E.useRef(null),b=E.useRef();b.current=m,E.useImperativeHandle(e,()=>v.current);var[x,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),w=E.useCallback((j,C)=>{M(k=>{var U=Math.round(j),I=Math.round(C);return k.containerWidth===U&&k.containerHeight===I?k:{containerWidth:U,containerHeight:I}})},[]);E.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return W0;var j=I=>{var H,{width:O,height:B}=I[0].contentRect;w(O,B),(H=b.current)===null||H===void 0||H.call(b,O,B)};u>0&&(j=PRe(j,u,{trailing:!0,leading:!1}));var C=new ResizeObserver(j),{width:k,height:U}=v.current.getBoundingClientRect();return w(k,U),C.observe(v.current),()=>{C.disconnect()}},[w,u]);var{containerWidth:A,containerHeight:T}=x;uS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:R,calculatedHeight:N}=qK(A,T,{width:i,height:a,aspect:n,maxHeight:l});return uS(R!=null&&R>0||N!=null&&N>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8186. please check the style of container, or the props width(%s) and height(%s),
  8187. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8188. height and width.`,R,N,i,a,s,o,n),E.createElement("div",{id:f?"".concat(f):void 0,className:An("recharts-responsive-container",g),style:r6(r6({},y),{},{width:i,height:a,minWidth:s,minHeight:o,maxHeight:l}),ref:v},E.createElement("div",{style:IRe({width:i,height:a})},E.createElement(KK,{width:R,height:N},c)))}),kC=E.forwardRef((t,e)=>{var n=CD();if(sl(n.width)&&sl(n.height))return t.children;var{width:r,height:i}=jRe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=qK(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return At(a)&&At(s)?E.createElement(KK,{width:a,height:s},t.children):E.createElement(HRe,jR({},t,{width:r,height:i,ref:e}))});function YK(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 Vw=()=>{var t,e=ca(),n=Tt(MRe),r=Tt($w),i=(t=Tt(Hw))===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}},$Re={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZK=()=>{var t;return(t=Tt(ui))!==null&&t!==void 0?t:$Re},ND=()=>Tt(Cc),RD=()=>Tt(Nc),VRe=()=>Tt(t=>t.layout.margin),Sn=t=>t.layout.layoutType,Cm=()=>Tt(Sn),GRe=()=>{var t=Cm();if(t==="horizontal"||t==="vertical")return t},WRe=()=>{var t=Cm();return t!==void 0},Gw=t=>{var e=er(),n=ca(),{width:r,height:i}=t,a=CD(),s=r,o=i;return a&&(s=a.width>0?a.width:r,o=a.height>0?a.height:i),E.useEffect(()=>{!n&&sl(s)&&sl(o)&&e(Y3e({width:s,height:o}))},[e,n,s,o]),null},QK=Symbol.for("immer-nothing"),i6=Symbol.for("immer-draftable"),xs=Symbol.for("immer-state");function vo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var x0=Object.getPrototypeOf;function fm(t){return!!t&&!!t[xs]}function zf(t){return t?JK(t)||Array.isArray(t)||!!t[i6]||!!t.constructor?.[i6]||Q0(t)||qw(t):!1}var qRe=Object.prototype.constructor.toString(),a6=new WeakMap;function JK(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=a6.get(n);return r===void 0&&(r=Function.toString.call(n),a6.set(n,r)),r===qRe}function dS(t,e,n=!0){Ww(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 Ww(t){const e=t[xs];return e?e.type_:Array.isArray(t)?1:Q0(t)?2:qw(t)?3:0}function UR(t,e){return Ww(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function eY(t,e,n){const r=Ww(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function XRe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Q0(t){return t instanceof Map}function qw(t){return t instanceof Set}function Wd(t){return t.copy_||t.base_}function FR(t,e){if(Q0(t))return new Map(t);if(qw(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=JK(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 s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(x0(t),r)}else{const r=x0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function PD(t,e=!1){return Xw(t)||fm(t)||!zf(t)||(Ww(t)>1&&Object.defineProperties(t,{set:Zy,add:Zy,clear:Zy,delete:Zy}),Object.freeze(t),e&&Object.values(t).forEach(n=>PD(n,!0))),t}function KRe(){vo(2)}var Zy={value:KRe};function Xw(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var YRe={};function Bf(t){const e=YRe[t];return e||vo(0,t),e}var v0;function tY(){return v0}function ZRe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function s6(t,e){e&&(Bf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function zR(t){BR(t),t.drafts_.forEach(QRe),t.drafts_=null}function BR(t){t===v0&&(v0=t.parent_)}function o6(t){return v0=ZRe(v0,t)}function QRe(t){const e=t[xs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function l6(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[xs].modified_&&(zR(e),vo(4)),zf(t)&&(t=fS(e,t),e.parent_||hS(e,t)),e.patches_&&Bf("Patches").generateReplacementPatches_(n[xs].base_,t,e.patches_,e.inversePatches_)):t=fS(e,n,[]),zR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==QK?t:void 0}function fS(t,e,n){if(Xw(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[xs];if(!i)return dS(e,(a,s)=>c6(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return hS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),dS(s,(l,c)=>c6(t,i,a,l,c,n,o),r),hS(t,a,!1),n&&t.patches_&&Bf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function c6(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const o=Xw(i);if(!(o&&!s)){if(fm(i)){const l=a&&e&&e.type_!==3&&!UR(e.assigned_,r)?a.concat(r):void 0,c=fS(t,i,l);if(eY(n,r,c),fm(c))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(zf(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;fS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Q0(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&hS(t,i)}}}function hS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&PD(e,n)}function JRe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:tY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=kD;n&&(i=[r],a=b0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var kD={get(t,e){if(e===xs)return t;const n=Wd(t);if(!UR(n,e))return ePe(t,n,e);const r=n[e];return t.finalized_||!zf(r)?r:r===DC(t.base_,e)?(OC(t),t.copy_[e]=$R(r,t)):r},has(t,e){return e in Wd(t)},ownKeys(t){return Reflect.ownKeys(Wd(t))},set(t,e,n){const r=nY(Wd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=DC(Wd(t),e),a=i?.[xs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(XRe(n,i)&&(n!==void 0||UR(t.base_,e)))return!0;OC(t),HR(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 DC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,OC(t),HR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Wd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){vo(11)},getPrototypeOf(t){return x0(t.base_)},setPrototypeOf(){vo(12)}},b0={};dS(kD,(t,e)=>{b0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});b0.deleteProperty=function(t,e){return b0.set.call(this,t,e,void 0)};b0.set=function(t,e,n){return kD.set.call(this,t[0],e,n,t[0])};function DC(t,e){const n=t[xs];return(n?Wd(n):t)[e]}function ePe(t,e,n){const r=nY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function nY(t,e){if(!(e in t))return;let n=x0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=x0(n)}}function HR(t){t.modified_||(t.modified_=!0,t.parent_&&HR(t.parent_))}function OC(t){t.copy_||(t.copy_=FR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var tPe=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 s=this;return function(l=a,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&vo(6),r!==void 0&&typeof r!="function"&&vo(7);let i;if(zf(e)){const a=o6(this),s=$R(e,void 0);let o=!0;try{i=n(s),o=!1}finally{o?zR(a):BR(a)}return s6(a,r),l6(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===QK&&(i=void 0),this.autoFreeze_&&PD(i,!0),r){const a=[],s=[];Bf("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else vo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,l=>e(l,...o));let r,i;return[this.produce(e,n,(s,o)=>{r=s,i=o}),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){zf(t)||vo(8),fm(t)&&(t=nPe(t));const e=o6(this),n=$R(t,void 0);return n[xs].isManual_=!0,BR(e),n}finishDraft(t,e){const n=t&&t[xs];(!n||!n.isManual_)&&vo(9);const{scope_:r}=n;return s6(r,e),l6(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=Bf("Patches").applyPatches_;return fm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function $R(t,e){const n=Q0(t)?Bf("MapSet").proxyMap_(t,e):qw(t)?Bf("MapSet").proxySet_(t,e):JRe(t,e);return(e?e.scope_:tY()).drafts_.push(n),n}function nPe(t){return fm(t)||vo(10,t),rY(t)}function rY(t){if(!zf(t)||Xw(t))return t;const e=t[xs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=FR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=FR(t,!0);return dS(n,(i,a)=>{eY(n,i,rY(a))},r),e&&(e.finalized_=!1),n}var rPe=new tPe;rPe.produce;var iPe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},iY=Ga({name:"legend",initialState:iPe,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:cr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Mo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:cr()},removeLegendPayload:{reducer(t,e){var n=Mo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:cr()}}}),{setLegendSize:u6,setLegendSettings:aPe,addLegendPayload:aY,replaceLegendPayload:sY,removeLegendPayload:oY}=iY.actions,sPe=iY.reducer,oPe=["contextPayload"];function VR(){return VR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},VR.apply(null,arguments)}function d6(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 hm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d6(Object(n),!0).forEach(function(r){lPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lPe(t,e,n){return(e=cPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cPe(t){var e=uPe(t,"string");return typeof e=="symbol"?e:e+""}function uPe(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 dPe(t,e){if(t==null)return{};var n,r,i=fPe(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 fPe(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 hPe(t){return t.value}function pPe(t){var{contextPayload:e}=t,n=dPe(t,oPe),r=aK(e,t.payloadUniqBy,hPe),i=hm(hm({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(cNe,i)}function mPe(t,e,n,r,i,a){var{layout:s,align:o,verticalAlign:l}=e,c,u;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?c={left:((r||0)-a.width)/2}:c=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?u={top:((i||0)-a.height)/2}:u=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),hm(hm({},c),u)}function gPe(t){var e=er();return E.useEffect(()=>{e(aPe(t))},[e,t]),null}function xPe(t){var e=er();return E.useEffect(()=>(e(u6(t)),()=>{e(u6({width:0,height:0}))}),[e,t]),null}function vPe(t,e,n,r){return t==="vertical"&&At(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var bPe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function lY(t){var e=Yr(t,bPe),n=QNe(),r=tCe(),i=VRe(),{width:a,height:s,wrapperStyle:o,portal:l}=e,[c,u]=uK([n]),f=ND(),g=RD();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),y=vPe(e.layout,s,a,m),v=l?o:hm(hm({position:"absolute",width:y?.width||a||"auto",height:y?.height||s||"auto"},mPe(o,e,i,f,g,c)),o),b=l??r;if(b==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:u},E.createElement(gPe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&E.createElement(xPe,{width:c.width,height:c.height}),E.createElement(pPe,VR({},e,y,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return Jl.createPortal(x,b)}lY.displayName="Legend";function GR(){return GR=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},GR.apply(null,arguments)}function f6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f6(Object(n),!0).forEach(function(r){yPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yPe(t,e,n){return(e=_Pe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Pe(t){var e=SPe(t,"string");return typeof e=="symbol"?e:e+""}function SPe(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 wPe(t){return Array.isArray(t)&&al(t[0])&&al(t[1])?t.join(" ~ "):t}var MPe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:o,wrapperClassName:l,labelClassName:c,label:u,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(a&&a.length){var T={padding:0,margin:0},R=(o?Pw(a,o):a).map((N,j)=>{if(N.type==="none")return null;var C=N.formatter||s||wPe,{value:k,name:U}=N,I=k,H=U;if(C){var O=C(k,U,N,j,a);if(Array.isArray(O))[I,H]=O;else if(O!=null)I=O;else return null}var B=LC({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:B},al(H)?E.createElement("span",{className:"recharts-tooltip-item-name"},H):null,al(H)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},I),E.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:T},R)}return null},y=LC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=LC({margin:0},i),b=!gr(u),x=b?u:"",M=An("recharts-default-tooltip",l),w=An("recharts-tooltip-label",c);b&&f&&a!==void 0&&a!==null&&(x=f(u,a));var A=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",GR({className:M,style:y},A),E.createElement("p",{className:w,style:v},E.isValidElement(x)?x:"".concat(x)),m())},Yg="recharts-tooltip-wrapper",EPe={visibility:"hidden"};function APe(t){var{coordinate:e,translateX:n,translateY:r}=t;return An(Yg,{["".concat(Yg,"-right")]:At(n)&&e&&At(e.x)&&n>=e.x,["".concat(Yg,"-left")]:At(n)&&e&&At(e.x)&&n<e.x,["".concat(Yg,"-bottom")]:At(r)&&e&&At(e.y)&&r>=e.y,["".concat(Yg,"-top")]:At(r)&&e&&At(e.y)&&r<e.y})}function h6(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:o,viewBox:l,viewBoxDimension:c}=t;if(a&&At(a[r]))return a[r];var u=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return s[r]?u:f;var g=l[r];if(g==null)return 0;if(s[r]){var m=u,y=g;return m<y?Math.max(f,g):Math.max(u,g)}if(c==null)return 0;var v=f+o,b=g+c;return v>b?Math.max(u,g):Math.max(f,g)}function TPe(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 CPe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:l}=t,c,u,f;return s.height>0&&s.width>0&&n?(u=h6({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=h6({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),c=TPe({translateX:u,translateY:f,useTranslate3d:o})):c=EPe,{cssProperties:c,cssClasses:APe({translateX:u,translateY:f,coordinate:n})}}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 Qy(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){WR(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 WR(t,e,n){return(e=NPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NPe(t){var e=RPe(t,"string");return typeof e=="symbol"?e:e+""}function RPe(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 PPe extends E.PureComponent{constructor(){super(...arguments),WR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),WR(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:s,hasPayload:o,isAnimationActive:l,offset:c,position:u,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:y,lastBoundingBox:v,innerRef:b,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=CPe({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:c,position:u,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:m}),A=x?{}:Qy(Qy({transition:l&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=Qy(Qy({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},y);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:b},a)}}var cY=()=>{var t;return(t=Tt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function qR(){return qR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qR.apply(null,arguments)}function m6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m6(Object(n),!0).forEach(function(r){kPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kPe(t,e,n){return(e=DPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DPe(t){var e=OPe(t,"string");return typeof e=="symbol"?e:e+""}function OPe(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 x6={curveBasisClosed:yCe,curveBasisOpen:_Ce,curveBasis:bCe,curveBumpX:aCe,curveBumpY:sCe,curveLinearClosed:SCe,curveLinear:Nw,curveMonotoneX:wCe,curveMonotoneY:MCe,curveNatural:ECe,curveStep:ACe,curveStepAfter:CCe,curveStepBefore:TCe},pS=t=>or(t.x)&&or(t.y),v6=t=>t.base!=null&&pS(t.base)&&pS(t),Zg=t=>t.x,Qg=t=>t.y,LPe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(G0(t));return(n==="curveMonotone"||n==="curveBump")&&e?x6["".concat(n).concat(e==="vertical"?"Y":"X")]:x6[n]||Nw},IPe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=LPe(e,i),o=a?n.filter(pS):n,l;if(Array.isArray(r)){var c=n.map((m,y)=>g6(g6({},m),{},{base:r[y]}));i==="vertical"?l=Vy().y(Qg).x1(Zg).x0(m=>m.base.x):l=Vy().x(Zg).y1(Qg).y0(m=>m.base.y);var u=l.defined(v6).curve(s),f=a?c.filter(v6):c;return u(f)}i==="vertical"&&At(r)?l=Vy().y(Qg).x1(Zg).x0(r):At(r)?l=Vy().x(Zg).y1(Qg).y0(r):l=OX().x(Zg).y(Qg);var g=l.defined(pS).curve(s);return g(o)},Fp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?IPe(t):r;return E.createElement("path",qR({},$a(t),gD(t),{className:An("recharts-curve",e),d:a===null?void 0:a,ref:i}))},jPe=["x","y","top","left","width","height","className"];function XR(){return XR=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},XR.apply(null,arguments)}function b6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function UPe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b6(Object(n),!0).forEach(function(r){FPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FPe(t,e,n){return(e=zPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zPe(t){var e=BPe(t,"string");return typeof e=="symbol"?e:e+""}function BPe(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 HPe(t,e){if(t==null)return{};var n,r,i=$Pe(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 $Pe(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 VPe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),GPe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:o}=t,l=HPe(t,jPe),c=UPe({x:e,y:n,top:r,left:i,width:a,height:s},l);return!At(e)||!At(n)||!At(a)||!At(s)||!At(r)||!At(i)?null:E.createElement("path",XR({},Ma(c),{className:An("recharts-cross",o),d:VPe(e,n,a,s,r,i)}))};function WPe(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 y6(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 _6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y6(Object(n),!0).forEach(function(r){qPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qPe(t,e,n){return(e=XPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XPe(t){var e=KPe(t,"string");return typeof e=="symbol"?e:e+""}function KPe(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 YPe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uY=(t,e,n)=>t.map(r=>"".concat(YPe(r)," ").concat(e,"ms ").concat(n)).join(","),ZPe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),y0=(t,e)=>Object.keys(e).reduce((n,r)=>_6(_6({},n),{},{[r]:t(r,e[r])}),{});function S6(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 ti(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(r){QPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QPe(t,e,n){return(e=JPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JPe(t){var e=eke(t,"string");return typeof e=="symbol"?e:e+""}function eke(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 mS=(t,e,n)=>t+(e-t)*n,KR=t=>{var{from:e,to:n}=t;return e!==n},dY=(t,e,n)=>{var r=y0((i,a)=>{if(KR(a)){var[s,o]=t(a.from,a.to,a.velocity);return ti(ti({},a),{},{from:s,velocity:o})}return a},e);return n<1?y0((i,a)=>KR(a)?ti(ti({},a),{},{velocity:mS(a.velocity,r[i].velocity,n),from:mS(a.from,r[i].from,n)}):a,e):dY(t,r,n-1)};function tke(t,e,n,r,i,a){var s,o=r.reduce((g,m)=>ti(ti({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>y0((g,m)=>m.from,o),c=()=>!Object.values(o).filter(KR).length,u=null,f=g=>{s||(s=g);var m=g-s,y=m/n.dt;o=dY(n,o,y),i(ti(ti(ti({},t),e),l())),s=g,c()||(u=a.setTimeout(f))};return()=>(u=a.setTimeout(f),()=>{var g;(g=u)===null||g===void 0||g()})}function nke(t,e,n,r,i,a,s){var o=null,l=i.reduce((f,g)=>ti(ti({},f),{},{[g]:[t[g],e[g]]}),{}),c,u=f=>{c||(c=f);var g=(f-c)/r,m=y0((v,b)=>mS(...b,n(g)),l);if(a(ti(ti(ti({},t),e),m)),g<1)o=s.setTimeout(u);else{var y=y0((v,b)=>mS(...b,n(1)),l);a(ti(ti(ti({},t),e),y))}};return()=>(o=s.setTimeout(u),()=>{var f;(f=o)===null||f===void 0||f()})}const rke=(t,e,n,r,i,a)=>{var s=ZPe(t,e);return n==null?()=>(i(ti(ti({},t),e)),()=>{}):n.isStepper===!0?tke(t,e,n,s,i,a):nke(t,e,n,r,s,i,a)};var gS=1e-4,fY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],hY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),w6=(t,e)=>n=>{var r=fY(t,e);return hY(r,n)},ike=(t,e)=>n=>{var r=fY(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return hY(i,n)},ake=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},ske=(t,e,n,r)=>{var i=w6(t,n),a=w6(e,r),s=ike(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var u=c>1?1:c,f=u,g=0;g<8;++g){var m=i(f)-u,y=s(f);if(Math.abs(m-u)<gS||y<gS)return a(f);f=o(f-m/y)}return a(f)};return l.isStepper=!1,l},M6=function(){return ske(...ake(...arguments))},oke=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,o,l)=>{var c=-(s-o)*n,u=l*r,f=l+(c-u)*i/1e3,g=l*i/1e3+s;return Math.abs(g-o)<gS&&Math.abs(f)<gS?[o,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},lke=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return M6(t);case"spring":return oke();default:if(t.split("(")[0]==="cubic-bezier")return M6(t)}return typeof t=="function"?t:null};function cke(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var o=s,[l,...c]=o;if(typeof l=="number"){i=t.setTimeout(a.bind(null,c),l);return}a(l),i=t.setTimeout(a.bind(null,c));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{r=!0},start:s=>{r=!1,i&&(i(),i=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class uke{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=s=>{s-r>=n?e(s):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function dke(){return cke(new uke)}var fke=E.createContext(dke);function hke(t,e){var n=E.useContext(fke);return E.useMemo(()=>e??n(t),[t,e,n])}var pke=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Nm={devToolsEnabled:!1,isSsr:pke()},mke={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},E6={t:0},IC={t:1};function J0(t){var e=Yr(t,mke),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:l,children:c}=e,u=n==="auto"?!Nm.isSsr:n,f=hke(e.animationId,e.animationManager),[g,m]=E.useState(u?E6:IC),y=E.useRef(null);return E.useEffect(()=>{u||m(IC)},[u]),E.useEffect(()=>{if(!u||!r)return W0;var v=rke(E6,IC,lke(a),i,m,f.getTimeoutController()),b=()=>{y.current=v()};return f.start([l,s,b,i,o]),()=>{f.stop(),y.current&&y.current(),o()}},[u,r,i,a,s,l,o,f]),c(g.t)}function ev(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(h0(e)),r=E.useRef(t);return r.current!==t&&(n.current=h0(e),r.current=t),n.current}var gke=["radius"],xke=["radius"];function A6(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 T6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A6(Object(n),!0).forEach(function(r){vke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vke(t,e,n){return(e=bke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bke(t){var e=yke(t,"string");return typeof e=="symbol"?e:e+""}function yke(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 xS(){return xS=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},xS.apply(null,arguments)}function C6(t,e){if(t==null)return{};var n,r,i=_ke(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 _ke(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 N6=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,o=n>=0?1:-1,l=r>=0&&n>=0||r<0&&n<0?1:0,c;if(a>0&&i instanceof Array){for(var u=[0,0,0,0],f=0,g=4;f<g;f++)u[f]=i[f]>a?a:i[f];c="M".concat(t,",").concat(e+s*u[0]),u[0]>0&&(c+="A ".concat(u[0],",").concat(u[0],",0,0,").concat(l,",").concat(t+o*u[0],",").concat(e)),c+="L ".concat(t+n-o*u[1],",").concat(e),u[1]>0&&(c+="A ".concat(u[1],",").concat(u[1],",0,0,").concat(l,`,
  8189. `).concat(t+n,",").concat(e+s*u[1])),c+="L ".concat(t+n,",").concat(e+r-s*u[2]),u[2]>0&&(c+="A ".concat(u[2],",").concat(u[2],",0,0,").concat(l,`,
  8190. `).concat(t+n-o*u[2],",").concat(e+r)),c+="L ".concat(t+o*u[3],",").concat(e+r),u[3]>0&&(c+="A ".concat(u[3],",").concat(u[3],",0,0,").concat(l,`,
  8191. `).concat(t,",").concat(e+r-s*u[3])),c+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);c="M ".concat(t,",").concat(e+s*m,`
  8192. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
  8193. L `).concat(t+n-o*m,",").concat(e,`
  8194. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+s*m,`
  8195. L `).concat(t+n,",").concat(e+r-s*m,`
  8196. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+r,`
  8197. L `).concat(t+o*m,",").concat(e+r,`
  8198. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+r-s*m," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return c},R6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},pY=t=>{var e=Yr(t,R6),n=E.useRef(null),[r,i]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:s,width:o,height:l,radius:c,className:u}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:y,isUpdateAnimationActive:v}=e,b=E.useRef(o),x=E.useRef(l),M=E.useRef(a),w=E.useRef(s),A=E.useMemo(()=>({x:a,y:s,width:o,height:l,radius:c}),[a,s,o,l,c]),T=ev(A,"rectangle-");if(a!==+a||s!==+s||o!==+o||l!==+l||o===0||l===0)return null;var R=An("recharts-rectangle",u);if(!v){var N=Ma(e),{radius:j}=N,C=C6(N,gke);return E.createElement("path",xS({},C,{radius:typeof c=="number"?c:void 0,className:R,d:N6(a,s,o,l,c)}))}var k=b.current,U=x.current,I=M.current,H=w.current,O="0px ".concat(r===-1?1:r,"px"),B="".concat(r,"px 0px"),V=uY(["strokeDasharray"],g,typeof f=="string"?f:R6.animationEasing);return E.createElement(J0,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:v,begin:m},G=>{var K=sr(k,o,G),Y=sr(U,l,G),oe=sr(I,a,G),$=sr(H,s,G);n.current&&(b.current=K,x.current=Y,M.current=oe,w.current=$);var X;y?G>0?X={transition:V,strokeDasharray:B}:X={strokeDasharray:O}:X={strokeDasharray:B};var ae=Ma(e),{radius:ce}=ae,xe=C6(ae,xke);return E.createElement("path",xS({},xe,{radius:typeof c=="number"?c:void 0,className:R,d:N6(oe,$,K,Y,c),ref:n,style:T6(T6({},X),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 k6(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){Ske(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 Ske(t,e,n){return(e=wke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wke(t){var e=Mke(t,"string");return typeof e=="symbol"?e:e+""}function Mke(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 vS=Math.PI/180,Eke=t=>t*180/Math.PI,Gr=(t,e,n,r)=>({x:t+Math.cos(-vS*r)*n,y:e+Math.sin(-vS*r)*n}),mY=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},Ake=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Tke=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=Ake({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-i)/s,l=Math.acos(o);return r>a&&(l=2*Math.PI-l),{radius:s,angle:Eke(l),angleInRadian:l}},Cke=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}},Nke=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),s=Math.min(i,a);return t+s*360},Rke=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Tke({x:n,y:r},e),{innerRadius:s,outerRadius:o}=e;if(i<s||i>o||i===0)return null;var{startAngle:l,endAngle:c}=Cke(e),u=a,f;if(l<=c){for(;u>c;)u-=360;for(;u<l;)u+=360;f=u>=l&&u<=c}else{for(;u>l;)u-=360;for(;u<c;)u+=360;f=u>=c&&u<=l}return f?k6(k6({},e),{},{radius:i,angle:Nke(u,e)}):null};function gY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=Gr(e,n,r,i),o=Gr(e,n,r,a);return{points:[s,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function YR(){return YR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},YR.apply(null,arguments)}var Pke=(t,e)=>{var n=Ti(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Jy=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:l}=t,c=o*(s?1:-1)+r,u=Math.asin(o/c)/vS,f=l?i:i+a*u,g=Gr(e,n,c,f),m=Gr(e,n,r,f),y=l?i-a*u:i,v=Gr(e,n,c*Math.cos(u*vS),y);return{center:g,circleTangency:m,lineTangency:v,theta:u}},xY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,o=Pke(a,s),l=a+o,c=Gr(e,n,i,a),u=Gr(e,n,i,l),f="M ".concat(c.x,",").concat(c.y,`
  8199. A `).concat(i,",").concat(i,`,0,
  8200. `).concat(+(Math.abs(o)>180),",").concat(+(a>l),`,
  8201. `).concat(u.x,",").concat(u.y,`
  8202. `);if(r>0){var g=Gr(e,n,r,a),m=Gr(e,n,r,l);f+="L ".concat(m.x,",").concat(m.y,`
  8203. A `).concat(r,",").concat(r,`,0,
  8204. `).concat(+(Math.abs(o)>180),",").concat(+(a<=l),`,
  8205. `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},kke=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:l,endAngle:c}=t,u=Ti(c-l),{circleTangency:f,lineTangency:g,theta:m}=Jy({cx:e,cy:n,radius:i,angle:l,sign:u,cornerRadius:a,cornerIsExternal:o}),{circleTangency:y,lineTangency:v,theta:b}=Jy({cx:e,cy:n,radius:i,angle:c,sign:-u,cornerRadius:a,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-m-b;if(x<0)return s?"M ".concat(g.x,",").concat(g.y,`
  8206. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  8207. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  8208. `):xY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:c});var M="M ".concat(g.x,",").concat(g.y,`
  8209. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(f.x,",").concat(f.y,`
  8210. A`).concat(i,",").concat(i,",0,").concat(+(x>180),",").concat(+(u<0),",").concat(y.x,",").concat(y.y,`
  8211. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(v.x,",").concat(v.y,`
  8212. `);if(r>0){var{circleTangency:w,lineTangency:A,theta:T}=Jy({cx:e,cy:n,radius:r,angle:l,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:R,lineTangency:N,theta:j}=Jy({cx:e,cy:n,radius:r,angle:c,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),C=o?Math.abs(l-c):Math.abs(l-c)-T-j;if(C<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(N.x,",").concat(N.y,`
  8213. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(R.x,",").concat(R.y,`
  8214. A`).concat(r,",").concat(r,",0,").concat(+(C>180),",").concat(+(u>0),",").concat(w.x,",").concat(w.y,`
  8215. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},Dke={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},vY=t=>{var e=Yr(t,Dke),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u,className:f}=e;if(a<i||c===u)return null;var g=An("recharts-sector",f),m=a-i,y=sa(s,m,0,!0),v;return y>0&&Math.abs(c-u)<360?v=kke({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(y,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}):v=xY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:c,endAngle:u}),E.createElement("path",YR({},Ma(e),{className:g,d:v}))};function Oke(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(KX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:o}=e,l=Gr(r,i,a,o),c=Gr(r,i,s,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return gY(e)}}var jC={},UC={},FC={},D6;function Lke(){return D6||(D6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(FC)),FC}var O6;function Ike(){return O6||(O6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lke();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})(UC)),UC}var L6;function jke(){return L6||(L6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lK(),n=Ike();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-i)/(s||1)),0),l=new Array(o);for(let c=0;c<o;c++)l[c]=i,i+=s;return l}t.range=r})(jC)),jC}var zC,I6;function Uke(){return I6||(I6=1,zC=jke().range),zC}var Fke=Uke();const bY=Js(Fke);function Xu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function zke(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function DD(t){let e,n,r;t.length!==2?(e=Xu,n=(o,l)=>Xu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Xu||t===zke?t:Bke,n=t,r=t);function i(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;n(o[f],l)<0?c=f+1:u=f}while(c<u)}return c}function a(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;n(o[f],l)<=0?c=f+1:u=f}while(c<u)}return c}function s(o,l,c=0,u=o.length){const f=i(o,l,c,u-1);return f>c&&r(o[f-1],l)>-r(o[f],l)?f-1:f}return{left:i,center:s,right:a}}function Bke(){return 0}function yY(t){return t===null?NaN:+t}function*Hke(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const $ke=DD(Xu),tv=$ke.right;DD(yY).center;class j6 extends Map{constructor(e,n=Wke){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(U6(this,e))}has(e){return super.has(U6(this,e))}set(e,n){return super.set(Vke(this,e),n)}delete(e){return super.delete(Gke(this,e))}}function U6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Vke({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Gke({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Wke(t){return t!==null&&typeof t=="object"?t.valueOf():t}function qke(t=Xu){if(t===Xu)return _Y;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 _Y(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Xke=Math.sqrt(50),Kke=Math.sqrt(10),Yke=Math.sqrt(2);function bS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=Xke?10:a>=Kke?5:a>=Yke?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/s,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*s,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?bS(t,e,n*2):[o,l,c]}function ZR(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,s]=r?bS(e,t,n):bS(t,e,n);if(!(a>=i))return[];const o=a-i+1,l=new Array(o);if(r)if(s<0)for(let c=0;c<o;++c)l[c]=(a-c)/-s;else for(let c=0;c<o;++c)l[c]=(a-c)*s;else if(s<0)for(let c=0;c<o;++c)l[c]=(i+c)/-s;else for(let c=0;c<o;++c)l[c]=(i+c)*s;return l}function QR(t,e,n){return e=+e,t=+t,n=+n,bS(t,e,n)[2]}function JR(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?QR(e,t,n):QR(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function F6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function z6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function SY(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?_Y:qke(i);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,u=Math.log(l),f=.5*Math.exp(2*u/3),g=.5*Math.sqrt(u*f*(l-f)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*f/l+g)),y=Math.min(r,Math.floor(e+(l-c)*f/l+g));SY(t,e,m,y,i)}const a=t[e];let s=n,o=r;for(Jg(t,n,e),i(t[r],a)>0&&Jg(t,n,r);s<o;){for(Jg(t,s,o),++s,--o;i(t[s],a)<0;)++s;for(;i(t[o],a)>0;)--o}i(t[n],a)===0?Jg(t,n,o):(++o,Jg(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function Jg(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Zke(t,e,n){if(t=Float64Array.from(Hke(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return z6(t);if(e>=1)return F6(t);var r,i=(r-1)*e,a=Math.floor(i),s=F6(SY(t,a).subarray(0,a+1)),o=z6(t.subarray(a+1));return s+(o-s)*(i-a)}}function Qke(t,e,n=yY){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),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(i-a)}}function Jke(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 to(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Rc(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const eP=Symbol("implicit");function OD(){var t=new j6,e=[],n=[],r=eP;function i(a){let s=t.get(a);if(s===void 0){if(r!==eP)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new j6;for(const s of a)t.has(s)||t.set(s,e.push(s)-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 OD(e,n).unknown(r)},to.apply(i,arguments),i}function LD(){var t=OD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,o=!1,l=0,c=0,u=.5;delete t.unknown;function f(){var g=e().length,m=i<r,y=m?i:r,v=m?r:i;a=(v-y)/Math.max(1,g-l+c*2),o&&(a=Math.floor(a)),y+=(v-y-a*(g-l))*u,s=a*(1-l),o&&(y=Math.round(y),s=Math.round(s));var b=Jke(g).map(function(x){return y+a*x});return n(m?b.reverse():b)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,c=+g),f()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),f()):l},t.paddingOuter=function(g){return arguments.length?(c=+g,f()):c},t.align=function(g){return arguments.length?(u=Math.max(0,Math.min(1,g)),f()):u},t.copy=function(){return LD(e(),[r,i]).round(o).paddingInner(l).paddingOuter(c).align(u)},to.apply(f(),arguments)}function wY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return wY(e())},t}function eDe(){return wY(LD.apply(null,arguments).paddingInner(1))}function ID(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function MY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function nv(){}var _0=.7,yS=1/_0,zp="\\s*([+-]?\\d+)\\s*",S0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Yo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",tDe=/^#([0-9a-f]{3,8})$/,nDe=new RegExp(`^rgb\\(${zp},${zp},${zp}\\)$`),rDe=new RegExp(`^rgb\\(${Yo},${Yo},${Yo}\\)$`),iDe=new RegExp(`^rgba\\(${zp},${zp},${zp},${S0}\\)$`),aDe=new RegExp(`^rgba\\(${Yo},${Yo},${Yo},${S0}\\)$`),sDe=new RegExp(`^hsl\\(${S0},${Yo},${Yo}\\)$`),oDe=new RegExp(`^hsla\\(${S0},${Yo},${Yo},${S0}\\)$`),B6={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};ID(nv,w0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:H6,formatHex:H6,formatHex8:lDe,formatHsl:cDe,formatRgb:$6,toString:$6});function H6(){return this.rgb().formatHex()}function lDe(){return this.rgb().formatHex8()}function cDe(){return EY(this).formatHsl()}function $6(){return this.rgb().formatRgb()}function w0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=tDe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?V6(e):n===3?new Ua(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?e_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?e_(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=nDe.exec(t))?new Ua(e[1],e[2],e[3],1):(e=rDe.exec(t))?new Ua(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=iDe.exec(t))?e_(e[1],e[2],e[3],e[4]):(e=aDe.exec(t))?e_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=sDe.exec(t))?q6(e[1],e[2]/100,e[3]/100,1):(e=oDe.exec(t))?q6(e[1],e[2]/100,e[3]/100,e[4]):B6.hasOwnProperty(t)?V6(B6[t]):t==="transparent"?new Ua(NaN,NaN,NaN,0):null}function V6(t){return new Ua(t>>16&255,t>>8&255,t&255,1)}function e_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ua(t,e,n,r)}function uDe(t){return t instanceof nv||(t=w0(t)),t?(t=t.rgb(),new Ua(t.r,t.g,t.b,t.opacity)):new Ua}function tP(t,e,n,r){return arguments.length===1?uDe(t):new Ua(t,e,n,r??1)}function Ua(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}ID(Ua,tP,MY(nv,{brighter(t){return t=t==null?yS:Math.pow(yS,t),new Ua(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?_0:Math.pow(_0,t),new Ua(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ua(yf(this.r),yf(this.g),yf(this.b),_S(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:G6,formatHex:G6,formatHex8:dDe,formatRgb:W6,toString:W6}));function G6(){return`#${of(this.r)}${of(this.g)}${of(this.b)}`}function dDe(){return`#${of(this.r)}${of(this.g)}${of(this.b)}${of((isNaN(this.opacity)?1:this.opacity)*255)}`}function W6(){const t=_S(this.opacity);return`${t===1?"rgb(":"rgba("}${yf(this.r)}, ${yf(this.g)}, ${yf(this.b)}${t===1?")":`, ${t})`}`}function _S(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function yf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function of(t){return t=yf(t),(t<16?"0":"")+t.toString(16)}function q6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new bo(t,e,n,r)}function EY(t){if(t instanceof bo)return new bo(t.h,t.s,t.l,t.opacity);if(t instanceof nv||(t=w0(t)),!t)return new bo;if(t instanceof bo)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),s=NaN,o=a-i,l=(a+i)/2;return o?(e===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-e)/o+2:s=(e-n)/o+4,o/=l<.5?a+i:2-a-i,s*=60):o=l>0&&l<1?0:s,new bo(s,o,l,t.opacity)}function fDe(t,e,n,r){return arguments.length===1?EY(t):new bo(t,e,n,r??1)}function bo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}ID(bo,fDe,MY(nv,{brighter(t){return t=t==null?yS:Math.pow(yS,t),new bo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?_0:Math.pow(_0,t),new bo(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 Ua(BC(t>=240?t-240:t+120,i,r),BC(t,i,r),BC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new bo(X6(this.h),t_(this.s),t_(this.l),_S(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=_S(this.opacity);return`${t===1?"hsl(":"hsla("}${X6(this.h)}, ${t_(this.s)*100}%, ${t_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function X6(t){return t=(t||0)%360,t<0?t+360:t}function t_(t){return Math.max(0,Math.min(1,t||0))}function BC(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 jD=t=>()=>t;function hDe(t,e){return function(n){return t+n*e}}function pDe(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 mDe(t){return(t=+t)==1?AY:function(e,n){return n-e?pDe(e,n,t):jD(isNaN(e)?n:e)}}function AY(t,e){var n=e-t;return n?hDe(t,n):jD(isNaN(t)?e:t)}const K6=(function t(e){var n=mDe(e);function r(i,a){var s=n((i=tP(i)).r,(a=tP(a)).r),o=n(i.g,a.g),l=n(i.b,a.b),c=AY(i.opacity,a.opacity);return function(u){return i.r=s(u),i.g=o(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=t,r})(1);function gDe(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 xDe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function vDe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=Rm(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function bDe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function SS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function yDe(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]=Rm(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var nP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,HC=new RegExp(nP.source,"g");function _De(t){return function(){return t}}function SDe(t){return function(e){return t(e)+""}}function wDe(t,e){var n=nP.lastIndex=HC.lastIndex=0,r,i,a,s=-1,o=[],l=[];for(t=t+"",e=e+"";(r=nP.exec(t))&&(i=HC.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,l.push({i:s,x:SS(r,i)})),n=HC.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?l[0]?SDe(l[0].x):_De(e):(e=l.length,function(c){for(var u=0,f;u<e;++u)o[(f=l[u]).i]=f.x(c);return o.join("")})}function Rm(t,e){var n=typeof e,r;return e==null||n==="boolean"?jD(e):(n==="number"?SS:n==="string"?(r=w0(e))?(e=r,K6):wDe:e instanceof w0?K6:e instanceof Date?bDe:xDe(e)?gDe:Array.isArray(e)?vDe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?yDe:SS)(t,e)}function UD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function MDe(t,e){e===void 0&&(e=t,t=Rm);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(s){var o=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[o](s-o)}}function EDe(t){return function(){return t}}function wS(t){return+t}var Y6=[0,1];function xa(t){return t}function rP(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:EDe(isNaN(e)?NaN:.5)}function ADe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function TDe(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=rP(i,r),a=n(s,a)):(r=rP(r,i),a=n(a,s)),function(o){return a(r(o))}}function CDe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=rP(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var l=tv(t,o,1,r)-1;return a[l](i[l](o))}}function rv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Kw(){var t=Y6,e=Y6,n=Rm,r,i,a,s=xa,o,l,c;function u(){var g=Math.min(t.length,e.length);return s!==xa&&(s=ADe(t[0],t[g-1])),o=g>2?CDe:TDe,l=c=null,f}function f(g){return g==null||isNaN(g=+g)?a:(l||(l=o(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((c||(c=o(e,t.map(r),SS)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,wS),u()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),u()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=UD,u()},f.clamp=function(g){return arguments.length?(s=g?!0:xa,u()):s!==xa},f.interpolate=function(g){return arguments.length?(n=g,u()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,m){return r=g,i=m,u()}}function FD(){return Kw()(xa,xa)}function NDe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function MS(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function pm(t){return t=MS(Math.abs(t)),t?t[1]:NaN}function RDe(t,e){return function(n,r){for(var i=n.length,a=[],s=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),a.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function PDe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var kDe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function M0(t){if(!(e=kDe.exec(t)))throw new Error("invalid format: "+t);var e;return new zD({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}M0.prototype=zD.prototype;function zD(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}zD.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function DDe(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 TY;function ODe(t,e){var n=MS(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(TY=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+MS(t,Math.max(0,e+a-1))[0]}function Z6(t,e){var n=MS(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 Q6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:NDe,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)=>Z6(t*100,e),r:Z6,s:ODe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function J6(t){return t}var e$=Array.prototype.map,t$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function LDe(t){var e=t.grouping===void 0||t.thousands===void 0?J6:RDe(e$.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?J6:PDe(e$.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(f){f=M0(f);var g=f.fill,m=f.align,y=f.sign,v=f.symbol,b=f.zero,x=f.width,M=f.comma,w=f.precision,A=f.trim,T=f.type;T==="n"?(M=!0,T="g"):Q6[T]||(w===void 0&&(w=12),A=!0,T="g"),(b||g==="0"&&m==="=")&&(b=!0,g="0",m="=");var R=v==="$"?n:v==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=v==="$"?r:/[%p]/.test(T)?s:"",j=Q6[T],C=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function k(U){var I=R,H=N,O,B,V;if(T==="c")H=j(U)+H,U="";else{U=+U;var G=U<0||1/U<0;if(U=isNaN(U)?l:j(Math.abs(U),w),A&&(U=DDe(U)),G&&+U==0&&y!=="+"&&(G=!1),I=(G?y==="("?y:o:y==="-"||y==="("?"":y)+I,H=(T==="s"?t$[8+TY/3]:"")+H+(G&&y==="("?")":""),C){for(O=-1,B=U.length;++O<B;)if(V=U.charCodeAt(O),48>V||V>57){H=(V===46?i+U.slice(O+1):U.slice(O))+H,U=U.slice(0,O);break}}}M&&!b&&(U=e(U,1/0));var K=I.length+U.length+H.length,Y=K<x?new Array(x-K+1).join(g):"";switch(M&&b&&(U=e(Y+U,Y.length?x-H.length:1/0),Y=""),m){case"<":U=I+U+H+Y;break;case"=":U=I+Y+U+H;break;case"^":U=Y.slice(0,K=Y.length>>1)+I+U+H+Y.slice(K);break;default:U=Y+I+U+H;break}return a(U)}return k.toString=function(){return f+""},k}function u(f,g){var m=c((f=M0(f),f.type="f",f)),y=Math.max(-8,Math.min(8,Math.floor(pm(g)/3)))*3,v=Math.pow(10,-y),b=t$[8+y/3];return function(x){return m(v*x)+b}}return{format:c,formatPrefix:u}}var n_,BD,CY;IDe({thousands:",",grouping:[3],currency:["$",""]});function IDe(t){return n_=LDe(t),BD=n_.format,CY=n_.formatPrefix,n_}function jDe(t){return Math.max(0,-pm(Math.abs(t)))}function UDe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(pm(e)/3)))*3-pm(Math.abs(t)))}function FDe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,pm(e)-pm(t))+1}function NY(t,e,n,r){var i=JR(t,e,n),a;switch(r=M0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=UDe(i,s))&&(r.precision=a),CY(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=FDe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=jDe(i))&&(r.precision=a-(r.type==="%")*2);break}}return BD(r)}function fd(t){var e=t.domain;return t.ticks=function(n){var r=e();return ZR(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return NY(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,s=r[i],o=r[a],l,c,u=10;for(o<s&&(c=s,s=o,o=c,c=i,i=a,a=c);u-- >0;){if(c=QR(s,o,n),c===l)return r[i]=s,r[a]=o,e(r);if(c>0)s=Math.floor(s/c)*c,o=Math.ceil(o/c)*c;else if(c<0)s=Math.ceil(s*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function RY(){var t=FD();return t.copy=function(){return rv(t,RY())},to.apply(t,arguments),fd(t)}function PY(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,wS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return PY(t).unknown(e)},t=arguments.length?Array.from(t,wS):[0,1],fd(n)}function kY(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],s;return a<i&&(s=n,n=r,r=s,s=i,i=a,a=s),t[n]=e.floor(i),t[r]=e.ceil(a),t}function n$(t){return Math.log(t)}function r$(t){return Math.exp(t)}function zDe(t){return-Math.log(-t)}function BDe(t){return-Math.exp(-t)}function HDe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function $De(t){return t===10?HDe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function VDe(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 i$(t){return(e,n)=>-t(-e,n)}function HD(t){const e=t(n$,r$),n=e.domain;let r=10,i,a;function s(){return i=VDe(r),a=$De(r),n()[0]<0?(i=i$(i),a=i$(a),t(zDe,BDe)):t(n$,r$),e}return e.base=function(o){return arguments.length?(r=+o,s()):r},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const l=n();let c=l[0],u=l[l.length-1];const f=u<c;f&&([c,u]=[u,c]);let g=i(c),m=i(u),y,v;const b=o==null?10:+o;let x=[];if(!(r%1)&&m-g<b){if(g=Math.floor(g),m=Math.ceil(m),c>0){for(;g<=m;++g)for(y=1;y<r;++y)if(v=g<0?y/a(-g):y*a(g),!(v<c)){if(v>u)break;x.push(v)}}else for(;g<=m;++g)for(y=r-1;y>=1;--y)if(v=g>0?y/a(-g):y*a(g),!(v<c)){if(v>u)break;x.push(v)}x.length*2<b&&(x=ZR(c,u,b))}else x=ZR(g,m,Math.min(m-g,b)).map(a);return f?x.reverse():x},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=M0(l)).precision==null&&(l.trim=!0),l=BD(l)),o===1/0)return l;const c=Math.max(1,r*o/e.ticks().length);return u=>{let f=u/a(Math.round(i(u)));return f*r<r-.5&&(f*=r),f<=c?l(u):""}},e.nice=()=>n(kY(n(),{floor:o=>a(Math.floor(i(o))),ceil:o=>a(Math.ceil(i(o)))})),e}function DY(){const t=HD(Kw()).domain([1,10]);return t.copy=()=>rv(t,DY()).base(t.base()),to.apply(t,arguments),t}function a$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function s$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function $D(t){var e=1,n=t(a$(e),s$(e));return n.constant=function(r){return arguments.length?t(a$(e=+r),s$(e)):e},fd(n)}function OY(){var t=$D(Kw());return t.copy=function(){return rv(t,OY()).constant(t.constant())},to.apply(t,arguments)}function o$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function GDe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function WDe(t){return t<0?-t*t:t*t}function VD(t){var e=t(xa,xa),n=1;function r(){return n===1?t(xa,xa):n===.5?t(GDe,WDe):t(o$(n),o$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},fd(e)}function GD(){var t=VD(Kw());return t.copy=function(){return rv(t,GD()).exponent(t.exponent())},to.apply(t,arguments),t}function qDe(){return GD.apply(null,arguments).exponent(.5)}function l$(t){return Math.sign(t)*t*t}function XDe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function LY(){var t=FD(),e=[0,1],n=!1,r;function i(a){var s=XDe(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(l$(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,wS)).map(l$)),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 LY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},to.apply(i,arguments),fd(i)}function IY(){var t=[],e=[],n=[],r;function i(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=Qke(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?r:e[tv(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Xu),i()},a.range=function(s){return arguments.length?(e=Array.from(s),i()):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return IY().domain(t).range(e).unknown(r)},to.apply(a,arguments)}function jY(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(l){return l!=null&&l<=l?i[tv(r,l,0,n)]:a}function o(){var l=-1;for(r=new Array(n);++l<n;)r[l]=((l+1)*e-(l-n)*t)/(n+1);return s}return s.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},s.range=function(l){return arguments.length?(n=(i=Array.from(l)).length-1,o()):i.slice()},s.invertExtent=function(l){var c=i.indexOf(l);return c<0?[NaN,NaN]:c<1?[t,r[0]]:c>=n?[r[n-1],e]:[r[c-1],r[c]]},s.unknown=function(l){return arguments.length&&(a=l),s},s.thresholds=function(){return r.slice()},s.copy=function(){return jY().domain([t,e]).range(i).unknown(a)},to.apply(fd(s),arguments)}function UY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[tv(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 s=e.indexOf(a);return[t[s-1],t[s]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return UY().domain(t).range(e).unknown(n)},to.apply(i,arguments)}const $C=new Date,VC=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 s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const l=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return l;let c;do l.push(c=new Date(+a)),e(a,o),t(a);while(c<a&&a<s);return l},i.filter=a=>di(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>($C.setTime(+a),VC.setTime(+s),t($C),t(VC),Math.floor(n($C,VC))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const ES=di(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);ES.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):ES);ES.range;const ic=1e3,Vs=ic*60,ac=Vs*60,yc=ac*24,WD=yc*7,c$=yc*30,GC=yc*365,lf=di(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*ic)},(t,e)=>(e-t)/ic,t=>t.getUTCSeconds());lf.range;const qD=di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ic)},(t,e)=>{t.setTime(+t+e*Vs)},(t,e)=>(e-t)/Vs,t=>t.getMinutes());qD.range;const XD=di(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Vs)},(t,e)=>(e-t)/Vs,t=>t.getUTCMinutes());XD.range;const KD=di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ic-t.getMinutes()*Vs)},(t,e)=>{t.setTime(+t+e*ac)},(t,e)=>(e-t)/ac,t=>t.getHours());KD.range;const YD=di(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*ac)},(t,e)=>(e-t)/ac,t=>t.getUTCHours());YD.range;const iv=di(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Vs)/yc,t=>t.getDate()-1);iv.range;const Yw=di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/yc,t=>t.getUTCDate()-1);Yw.range;const FY=di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/yc,t=>Math.floor(t/yc));FY.range;function Yf(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())*Vs)/WD)}const Zw=Yf(0),AS=Yf(1),KDe=Yf(2),YDe=Yf(3),mm=Yf(4),ZDe=Yf(5),QDe=Yf(6);Zw.range;AS.range;KDe.range;YDe.range;mm.range;ZDe.range;QDe.range;function Zf(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)/WD)}const Qw=Zf(0),TS=Zf(1),JDe=Zf(2),eOe=Zf(3),gm=Zf(4),tOe=Zf(5),nOe=Zf(6);Qw.range;TS.range;JDe.range;eOe.range;gm.range;tOe.range;nOe.range;const ZD=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());ZD.range;const QD=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());QD.range;const _c=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());_c.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)});_c.range;const Sc=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());Sc.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)});Sc.range;function zY(t,e,n,r,i,a){const s=[[lf,1,ic],[lf,5,5*ic],[lf,15,15*ic],[lf,30,30*ic],[a,1,Vs],[a,5,5*Vs],[a,15,15*Vs],[a,30,30*Vs],[i,1,ac],[i,3,3*ac],[i,6,6*ac],[i,12,12*ac],[r,1,yc],[r,2,2*yc],[n,1,WD],[e,1,c$],[e,3,3*c$],[t,1,GC]];function o(c,u,f){const g=u<c;g&&([c,u]=[u,c]);const m=f&&typeof f.range=="function"?f:l(c,u,f),y=m?m.range(c,+u+1):[];return g?y.reverse():y}function l(c,u,f){const g=Math.abs(u-c)/f,m=DD(([,,b])=>b).right(s,g);if(m===s.length)return t.every(JR(c/GC,u/GC,f));if(m===0)return ES.every(Math.max(JR(c,u,f),1));const[y,v]=s[g/s[m-1][2]<s[m][2]/g?m-1:m];return y.every(v)}return[o,l]}const[rOe,iOe]=zY(Sc,QD,Qw,FY,YD,XD),[aOe,sOe]=zY(_c,ZD,Zw,iv,KD,qD);function WC(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 qC(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 ex(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function oOe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,o=t.months,l=t.shortMonths,c=tx(i),u=nx(i),f=tx(a),g=nx(a),m=tx(s),y=nx(s),v=tx(o),b=nx(o),x=tx(l),M=nx(l),w={a:G,A:K,b:Y,B:oe,c:null,d:m$,e:m$,f:ROe,g:zOe,G:HOe,H:TOe,I:COe,j:NOe,L:BY,m:POe,M:kOe,p:$,q:X,Q:v$,s:b$,S:DOe,u:OOe,U:LOe,V:IOe,w:jOe,W:UOe,x:null,X:null,y:FOe,Y:BOe,Z:$Oe,"%":x$},A={a:ae,A:ce,b:xe,B:te,c:null,d:g$,e:g$,f:qOe,g:rLe,G:aLe,H:VOe,I:GOe,j:WOe,L:$Y,m:XOe,M:KOe,p:ve,q:De,Q:v$,s:b$,S:YOe,u:ZOe,U:QOe,V:JOe,w:eLe,W:tLe,x:null,X:null,y:nLe,Y:iLe,Z:sLe,"%":x$},T={a:k,A:U,b:I,B:H,c:O,d:h$,e:h$,f:wOe,g:f$,G:d$,H:p$,I:p$,j:bOe,L:SOe,m:vOe,M:yOe,p:C,q:xOe,Q:EOe,s:AOe,S:_Oe,u:fOe,U:hOe,V:pOe,w:dOe,W:mOe,x:B,X:V,y:f$,Y:d$,Z:gOe,"%":MOe};w.x=R(n,w),w.X=R(r,w),w.c=R(e,w),A.x=R(n,A),A.X=R(r,A),A.c=R(e,A);function R(he,me){return function(we){var se=[],st=-1,z=0,q=he.length,ie,Q,ee;for(we instanceof Date||(we=new Date(+we));++st<q;)he.charCodeAt(st)===37&&(se.push(he.slice(z,st)),(Q=u$[ie=he.charAt(++st)])!=null?ie=he.charAt(++st):Q=ie==="e"?" ":"0",(ee=me[ie])&&(ie=ee(we,Q)),se.push(ie),z=st+1);return se.push(he.slice(z,st)),se.join("")}}function N(he,me){return function(we){var se=ex(1900,void 0,1),st=j(se,he,we+="",0),z,q;if(st!=we.length)return null;if("Q"in se)return new Date(se.Q);if("s"in se)return new Date(se.s*1e3+("L"in se?se.L:0));if(me&&!("Z"in se)&&(se.Z=0),"p"in se&&(se.H=se.H%12+se.p*12),se.m===void 0&&(se.m="q"in se?se.q:0),"V"in se){if(se.V<1||se.V>53)return null;"w"in se||(se.w=1),"Z"in se?(z=qC(ex(se.y,0,1)),q=z.getUTCDay(),z=q>4||q===0?TS.ceil(z):TS(z),z=Yw.offset(z,(se.V-1)*7),se.y=z.getUTCFullYear(),se.m=z.getUTCMonth(),se.d=z.getUTCDate()+(se.w+6)%7):(z=WC(ex(se.y,0,1)),q=z.getDay(),z=q>4||q===0?AS.ceil(z):AS(z),z=iv.offset(z,(se.V-1)*7),se.y=z.getFullYear(),se.m=z.getMonth(),se.d=z.getDate()+(se.w+6)%7)}else("W"in se||"U"in se)&&("w"in se||(se.w="u"in se?se.u%7:"W"in se?1:0),q="Z"in se?qC(ex(se.y,0,1)).getUTCDay():WC(ex(se.y,0,1)).getDay(),se.m=0,se.d="W"in se?(se.w+6)%7+se.W*7-(q+5)%7:se.w+se.U*7-(q+6)%7);return"Z"in se?(se.H+=se.Z/100|0,se.M+=se.Z%100,qC(se)):WC(se)}}function j(he,me,we,se){for(var st=0,z=me.length,q=we.length,ie,Q;st<z;){if(se>=q)return-1;if(ie=me.charCodeAt(st++),ie===37){if(ie=me.charAt(st++),Q=T[ie in u$?me.charAt(st++):ie],!Q||(se=Q(he,we,se))<0)return-1}else if(ie!=we.charCodeAt(se++))return-1}return se}function C(he,me,we){var se=c.exec(me.slice(we));return se?(he.p=u.get(se[0].toLowerCase()),we+se[0].length):-1}function k(he,me,we){var se=m.exec(me.slice(we));return se?(he.w=y.get(se[0].toLowerCase()),we+se[0].length):-1}function U(he,me,we){var se=f.exec(me.slice(we));return se?(he.w=g.get(se[0].toLowerCase()),we+se[0].length):-1}function I(he,me,we){var se=x.exec(me.slice(we));return se?(he.m=M.get(se[0].toLowerCase()),we+se[0].length):-1}function H(he,me,we){var se=v.exec(me.slice(we));return se?(he.m=b.get(se[0].toLowerCase()),we+se[0].length):-1}function O(he,me,we){return j(he,e,me,we)}function B(he,me,we){return j(he,n,me,we)}function V(he,me,we){return j(he,r,me,we)}function G(he){return s[he.getDay()]}function K(he){return a[he.getDay()]}function Y(he){return l[he.getMonth()]}function oe(he){return o[he.getMonth()]}function $(he){return i[+(he.getHours()>=12)]}function X(he){return 1+~~(he.getMonth()/3)}function ae(he){return s[he.getUTCDay()]}function ce(he){return a[he.getUTCDay()]}function xe(he){return l[he.getUTCMonth()]}function te(he){return o[he.getUTCMonth()]}function ve(he){return i[+(he.getUTCHours()>=12)]}function De(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var me=R(he+="",w);return me.toString=function(){return he},me},parse:function(he){var me=N(he+="",!1);return me.toString=function(){return he},me},utcFormat:function(he){var me=R(he+="",A);return me.toString=function(){return he},me},utcParse:function(he){var me=N(he+="",!0);return me.toString=function(){return he},me}}}var u$={"-":"",_:" ",0:"0"},Ri=/^\s*\d+/,lOe=/^%/,cOe=/[\\^$*+?|[\]().{}]/g;function Tn(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 uOe(t){return t.replace(cOe,"\\$&")}function tx(t){return new RegExp("^(?:"+t.map(uOe).join("|")+")","i")}function nx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function dOe(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function fOe(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function hOe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function pOe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function mOe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function d$(t,e,n){var r=Ri.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function f$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function gOe(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 xOe(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function vOe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function h$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function bOe(t,e,n){var r=Ri.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function p$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function yOe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function _Oe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function SOe(t,e,n){var r=Ri.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function wOe(t,e,n){var r=Ri.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function MOe(t,e,n){var r=lOe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function EOe(t,e,n){var r=Ri.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function AOe(t,e,n){var r=Ri.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function m$(t,e){return Tn(t.getDate(),e,2)}function TOe(t,e){return Tn(t.getHours(),e,2)}function COe(t,e){return Tn(t.getHours()%12||12,e,2)}function NOe(t,e){return Tn(1+iv.count(_c(t),t),e,3)}function BY(t,e){return Tn(t.getMilliseconds(),e,3)}function ROe(t,e){return BY(t,e)+"000"}function POe(t,e){return Tn(t.getMonth()+1,e,2)}function kOe(t,e){return Tn(t.getMinutes(),e,2)}function DOe(t,e){return Tn(t.getSeconds(),e,2)}function OOe(t){var e=t.getDay();return e===0?7:e}function LOe(t,e){return Tn(Zw.count(_c(t)-1,t),e,2)}function HY(t){var e=t.getDay();return e>=4||e===0?mm(t):mm.ceil(t)}function IOe(t,e){return t=HY(t),Tn(mm.count(_c(t),t)+(_c(t).getDay()===4),e,2)}function jOe(t){return t.getDay()}function UOe(t,e){return Tn(AS.count(_c(t)-1,t),e,2)}function FOe(t,e){return Tn(t.getFullYear()%100,e,2)}function zOe(t,e){return t=HY(t),Tn(t.getFullYear()%100,e,2)}function BOe(t,e){return Tn(t.getFullYear()%1e4,e,4)}function HOe(t,e){var n=t.getDay();return t=n>=4||n===0?mm(t):mm.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function $Oe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function g$(t,e){return Tn(t.getUTCDate(),e,2)}function VOe(t,e){return Tn(t.getUTCHours(),e,2)}function GOe(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function WOe(t,e){return Tn(1+Yw.count(Sc(t),t),e,3)}function $Y(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function qOe(t,e){return $Y(t,e)+"000"}function XOe(t,e){return Tn(t.getUTCMonth()+1,e,2)}function KOe(t,e){return Tn(t.getUTCMinutes(),e,2)}function YOe(t,e){return Tn(t.getUTCSeconds(),e,2)}function ZOe(t){var e=t.getUTCDay();return e===0?7:e}function QOe(t,e){return Tn(Qw.count(Sc(t)-1,t),e,2)}function VY(t){var e=t.getUTCDay();return e>=4||e===0?gm(t):gm.ceil(t)}function JOe(t,e){return t=VY(t),Tn(gm.count(Sc(t),t)+(Sc(t).getUTCDay()===4),e,2)}function eLe(t){return t.getUTCDay()}function tLe(t,e){return Tn(TS.count(Sc(t)-1,t),e,2)}function nLe(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function rLe(t,e){return t=VY(t),Tn(t.getUTCFullYear()%100,e,2)}function iLe(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function aLe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?gm(t):gm.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function sLe(){return"+0000"}function x$(){return"%"}function v$(t){return+t}function b$(t){return Math.floor(+t/1e3)}var hp,GY,WY;oLe({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 oLe(t){return hp=oOe(t),GY=hp.format,hp.parse,WY=hp.utcFormat,hp.utcParse,hp}function lLe(t){return new Date(t)}function cLe(t){return t instanceof Date?+t:+new Date(+t)}function JD(t,e,n,r,i,a,s,o,l,c){var u=FD(),f=u.invert,g=u.domain,m=c(".%L"),y=c(":%S"),v=c("%I:%M"),b=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),A=c("%Y");function T(R){return(l(R)<R?m:o(R)<R?y:s(R)<R?v:a(R)<R?b:r(R)<R?i(R)<R?x:M:n(R)<R?w:A)(R)}return u.invert=function(R){return new Date(f(R))},u.domain=function(R){return arguments.length?g(Array.from(R,cLe)):g().map(lLe)},u.ticks=function(R){var N=g();return t(N[0],N[N.length-1],R??10)},u.tickFormat=function(R,N){return N==null?T:c(N)},u.nice=function(R){var N=g();return(!R||typeof R.range!="function")&&(R=e(N[0],N[N.length-1],R??10)),R?g(kY(N,R)):u},u.copy=function(){return rv(u,JD(t,e,n,r,i,a,s,o,l,c))},u}function uLe(){return to.apply(JD(aOe,sOe,_c,ZD,Zw,iv,KD,qD,lf,GY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function dLe(){return to.apply(JD(rOe,iOe,Sc,QD,Qw,Yw,YD,XD,lf,WY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Jw(){var t=0,e=1,n,r,i,a,s=xa,o=!1,l;function c(f){return f==null||isNaN(f=+f)?l:s(i===0?.5:(f=(a(f)-n)*i,o?Math.max(0,Math.min(1,f)):f))}c.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),c):[t,e]},c.clamp=function(f){return arguments.length?(o=!!f,c):o},c.interpolator=function(f){return arguments.length?(s=f,c):s};function u(f){return function(g){var m,y;return arguments.length?([m,y]=g,s=f(m,y),c):[s(0),s(1)]}}return c.range=u(Rm),c.rangeRound=u(UD),c.unknown=function(f){return arguments.length?(l=f,c):l},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),c}}function hd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qY(){var t=fd(Jw()(xa));return t.copy=function(){return hd(t,qY())},Rc.apply(t,arguments)}function XY(){var t=HD(Jw()).domain([1,10]);return t.copy=function(){return hd(t,XY()).base(t.base())},Rc.apply(t,arguments)}function KY(){var t=$D(Jw());return t.copy=function(){return hd(t,KY()).constant(t.constant())},Rc.apply(t,arguments)}function eO(){var t=VD(Jw());return t.copy=function(){return hd(t,eO()).exponent(t.exponent())},Rc.apply(t,arguments)}function fLe(){return eO.apply(null,arguments).exponent(.5)}function YY(){var t=[],e=xa;function n(r){if(r!=null&&!isNaN(r=+r))return e((tv(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(Xu),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)=>Zke(t,a/r))},n.copy=function(){return YY(e).domain(t)},Rc.apply(n,arguments)}function eM(){var t=0,e=.5,n=1,r=1,i,a,s,o,l,c=xa,u,f=!1,g;function m(v){return isNaN(v=+v)?g:(v=.5+((v=+u(v))-a)*(r*v<r*a?o:l),c(f?Math.max(0,Math.min(1,v)):v))}m.domain=function(v){return arguments.length?([t,e,n]=v,i=u(t=+t),a=u(e=+e),s=u(n=+n),o=i===a?0:.5/(a-i),l=a===s?0:.5/(s-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(v){return arguments.length?(f=!!v,m):f},m.interpolator=function(v){return arguments.length?(c=v,m):c};function y(v){return function(b){var x,M,w;return arguments.length?([x,M,w]=b,c=MDe(v,[x,M,w]),m):[c(0),c(.5),c(1)]}}return m.range=y(Rm),m.rangeRound=y(UD),m.unknown=function(v){return arguments.length?(g=v,m):g},function(v){return u=v,i=v(t),a=v(e),s=v(n),o=i===a?0:.5/(a-i),l=a===s?0:.5/(s-a),r=a<i?-1:1,m}}function ZY(){var t=fd(eM()(xa));return t.copy=function(){return hd(t,ZY())},Rc.apply(t,arguments)}function QY(){var t=HD(eM()).domain([.1,1,10]);return t.copy=function(){return hd(t,QY()).base(t.base())},Rc.apply(t,arguments)}function JY(){var t=$D(eM());return t.copy=function(){return hd(t,JY()).constant(t.constant())},Rc.apply(t,arguments)}function tO(){var t=VD(eM());return t.copy=function(){return hd(t,tO()).exponent(t.exponent())},Rc.apply(t,arguments)}function hLe(){return tO.apply(null,arguments).exponent(.5)}const px=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:LD,scaleDiverging:ZY,scaleDivergingLog:QY,scaleDivergingPow:tO,scaleDivergingSqrt:hLe,scaleDivergingSymlog:JY,scaleIdentity:PY,scaleImplicit:eP,scaleLinear:RY,scaleLog:DY,scaleOrdinal:OD,scalePoint:eDe,scalePow:GD,scaleQuantile:IY,scaleQuantize:jY,scaleRadial:LY,scaleSequential:qY,scaleSequentialLog:XY,scaleSequentialPow:eO,scaleSequentialQuantile:YY,scaleSequentialSqrt:fLe,scaleSequentialSymlog:KY,scaleSqrt:qDe,scaleSymlog:OY,scaleThreshold:UY,scaleTime:uLe,scaleUtc:dLe,tickFormat:NY},Symbol.toStringTag,{value:"Module"}));var pd=t=>t.chartData,nO=$e([pd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),tM=(t,e,n,r)=>r?nO(t):pd(t);function nd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(or(e)&&or(n))return!0}return!1}function y$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(or(n))i=n;else if(typeof n=="function")return;if(or(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(nd(s))return s}}function pLe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(nd(r))return y$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,o;if(i==="auto")e!=null&&(s=Math.min(...e));else if(At(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&X8.test(i)){var l=X8.exec(i);if(l==null||e==null)s=void 0;else{var c=+l[1];s=e[0]-c}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(At(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&K8.test(a)){var u=K8.exec(a);if(u==null||e==null)o=void 0;else{var f=+u[1];o=e[1]+f}}else o=e?.[1];var g=[s,o];if(nd(g))return e==null?g:y$(g,e,n)}}}var Pm=1e9,mLe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},iO,dr=!0,Qs="[DecimalError] ",_f=Qs+"Invalid argument: ",rO=Qs+"Exponent out of range: ",km=Math.floor,qd=Math.pow,gLe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,us,Mi=1e7,ar=7,tZ=9007199254740991,CS=km(tZ/ar),Ct={};Ct.absoluteValue=Ct.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Ct.comparedTo=Ct.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};Ct.decimalPlaces=Ct.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ar;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Ct.dividedBy=Ct.div=function(t){return fc(this,new this.constructor(t))};Ct.dividedToIntegerBy=Ct.idiv=function(t){var e=this,n=e.constructor;return Zn(fc(e,new n(t),0,1),n.precision)};Ct.equals=Ct.eq=function(t){return!this.cmp(t)};Ct.exponent=function(){return Xr(this)};Ct.greaterThan=Ct.gt=function(t){return this.cmp(t)>0};Ct.greaterThanOrEqualTo=Ct.gte=function(t){return this.cmp(t)>=0};Ct.isInteger=Ct.isint=function(){return this.e>this.d.length-2};Ct.isNegative=Ct.isneg=function(){return this.s<0};Ct.isPositive=Ct.ispos=function(){return this.s>0};Ct.isZero=function(){return this.s===0};Ct.lessThan=Ct.lt=function(t){return this.cmp(t)<0};Ct.lessThanOrEqualTo=Ct.lte=function(t){return this.cmp(t)<1};Ct.logarithm=Ct.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(Qs+"NaN");if(n.s<1)throw Error(Qs+(n.s?"NaN":"-Infinity"));return n.eq(us)?new r(0):(dr=!1,e=fc(E0(n,a),E0(t,a),a),dr=!0,Zn(e,i))};Ct.minus=Ct.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iZ(e,t):nZ(e,(t.s=-t.s,t))};Ct.modulo=Ct.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Qs+"NaN");return n.s?(dr=!1,e=fc(n,t,0,1).times(t),dr=!0,n.minus(e)):Zn(new r(n),i)};Ct.naturalExponential=Ct.exp=function(){return rZ(this)};Ct.naturalLogarithm=Ct.ln=function(){return E0(this)};Ct.negated=Ct.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Ct.plus=Ct.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nZ(e,t):iZ(e,(t.s=-t.s,t))};Ct.precision=Ct.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(_f+t);if(e=Xr(i)+1,r=i.d.length-1,n=r*ar+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};Ct.squareRoot=Ct.sqrt=function(){var t,e,n,r,i,a,s,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(Qs+"NaN")}for(t=Xr(o),dr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=qo(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=km((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 l(e)):r=new l(i.toString()),n=l.precision,i=s=n+3;;)if(a=r,r=a.plus(fc(o,a,s+2)).times(.5),qo(a.d).slice(0,s)===(e=qo(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(Zn(a,n+1,0),a.times(a).eq(o)){r=a;break}}else if(e!="9999")break;s+=4}return dr=!0,Zn(r,n)};Ct.times=Ct.mul=function(t){var e,n,r,i,a,s,o,l,c,u=this,f=u.constructor,g=u.d,m=(t=new f(t)).d;if(!u.s||!t.s)return new f(0);for(t.s*=u.s,n=u.e+t.e,l=g.length,c=m.length,l<c&&(a=g,g=m,m=a,s=l,l=c,c=s),a=[],s=l+c,r=s;r--;)a.push(0);for(r=c;--r>=0;){for(e=0,i=l+r;i>r;)o=a[i]+m[r]*g[i-r-1]+e,a[i--]=o%Mi|0,e=o/Mi|0;a[i]=(a[i]+e)%Mi|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,dr?Zn(t,f.precision):t};Ct.toDecimalPlaces=Ct.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ol(t,0,Pm),e===void 0?e=r.rounding:ol(e,0,8),Zn(n,t+Xr(n)+1,e))};Ct.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Hf(r,!0):(ol(t,0,Pm),e===void 0?e=i.rounding:ol(e,0,8),r=Zn(new i(r),t+1,e),n=Hf(r,!0,t+1)),n};Ct.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Hf(i):(ol(t,0,Pm),e===void 0?e=a.rounding:ol(e,0,8),r=Zn(new a(i),t+Xr(i)+1,e),n=Hf(r.abs(),!1,t+Xr(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Ct.toInteger=Ct.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Xr(t)+1,e.rounding)};Ct.toNumber=function(){return+this};Ct.toPower=Ct.pow=function(t){var e,n,r,i,a,s,o=this,l=o.constructor,c=12,u=+(t=new l(t));if(!t.s)return new l(us);if(o=new l(o),!o.s){if(t.s<1)throw Error(Qs+"Infinity");return o}if(o.eq(us))return o;if(r=l.precision,t.eq(us))return Zn(o,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=u<0?-u:u)<=tZ){for(i=new l(us),e=Math.ceil(r/ar+4),dr=!1;n%2&&(i=i.times(o),S$(i.d,e)),n=km(n/2),n!==0;)o=o.times(o),S$(o.d,e);return dr=!0,t.s<0?new l(us).div(i):Zn(i,r)}}else if(a<0)throw Error(Qs+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,dr=!1,i=t.times(E0(o,r+c)),dr=!0,i=rZ(i),i.s=a,i};Ct.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Xr(i),r=Hf(i,n<=a.toExpNeg||n>=a.toExpPos)):(ol(t,1,Pm),e===void 0?e=a.rounding:ol(e,0,8),i=Zn(new a(i),t,e),n=Xr(i),r=Hf(i,t<=n||n<=a.toExpNeg,t)),r};Ct.toSignificantDigits=Ct.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ol(t,1,Pm),e===void 0?e=r.rounding:ol(e,0,8)),Zn(new r(n),t,e)};Ct.toString=Ct.valueOf=Ct.val=Ct.toJSON=Ct[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Xr(t),n=t.constructor;return Hf(t,e<=n.toExpNeg||e>=n.toExpPos)};function nZ(t,e){var n,r,i,a,s,o,l,c,u=t.constructor,f=u.precision;if(!t.s||!e.s)return e.s||(e=new u(t)),dr?Zn(e,f):e;if(l=t.d,c=e.d,s=t.e,i=e.e,l=l.slice(),a=s-i,a){for(a<0?(r=l,a=-a,o=c.length):(r=c,i=s,o=l.length),s=Math.ceil(f/ar),o=s>o?s+1:o+1,a>o&&(a=o,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(o=l.length,a=c.length,o-a<0&&(a=o,r=c,c=l,l=r),n=0;a;)n=(l[--a]=l[a]+c[a]+n)/Mi|0,l[a]%=Mi;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,dr?Zn(e,f):e}function ol(t,e,n){if(t!==~~t||t<e||t>n)throw Error(_f+t)}function qo(t){var e,n,r,i=t.length-1,a="",s=t[0];if(i>0){for(a+=s,e=1;e<i;e++)r=t[e]+"",n=ar-r.length,n&&(a+=Au(n)),a+=r;s=t[e],r=s+"",n=ar-r.length,n&&(a+=Au(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var fc=(function(){function t(r,i){var a,s=0,o=r.length;for(r=r.slice();o--;)a=r[o]*i+s,r[o]=a%Mi|0,s=a/Mi|0;return s&&r.unshift(s),r}function e(r,i,a,s){var o,l;if(a!=s)l=a>s?1:-1;else for(o=l=0;o<a;o++)if(r[o]!=i[o]){l=r[o]>i[o]?1:-1;break}return l}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*Mi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var o,l,c,u,f,g,m,y,v,b,x,M,w,A,T,R,N,j,C=r.constructor,k=r.s==i.s?1:-1,U=r.d,I=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(Qs+"Division by zero");for(l=r.e-i.e,N=I.length,T=U.length,m=new C(k),y=m.d=[],c=0;I[c]==(U[c]||0);)++c;if(I[c]>(U[c]||0)&&--l,a==null?M=a=C.precision:s?M=a+(Xr(r)-Xr(i))+1:M=a,M<0)return new C(0);if(M=M/ar+2|0,c=0,N==1)for(u=0,I=I[0],M++;(c<T||u)&&M--;c++)w=u*Mi+(U[c]||0),y[c]=w/I|0,u=w%I|0;else{for(u=Mi/(I[0]+1)|0,u>1&&(I=t(I,u),U=t(U,u),N=I.length,T=U.length),A=N,v=U.slice(0,N),b=v.length;b<N;)v[b++]=0;j=I.slice(),j.unshift(0),R=I[0],I[1]>=Mi/2&&++R;do u=0,o=e(I,v,N,b),o<0?(x=v[0],N!=b&&(x=x*Mi+(v[1]||0)),u=x/R|0,u>1?(u>=Mi&&(u=Mi-1),f=t(I,u),g=f.length,b=v.length,o=e(f,v,g,b),o==1&&(u--,n(f,N<g?j:I,g))):(u==0&&(o=u=1),f=I.slice()),g=f.length,g<b&&f.unshift(0),n(v,f,b),o==-1&&(b=v.length,o=e(I,v,N,b),o<1&&(u++,n(v,N<b?j:I,b))),b=v.length):o===0&&(u++,v=[0]),y[c++]=u,o&&v[0]?v[b++]=U[A]||0:(v=[U[A]],b=1);while((A++<T||v[0]!==void 0)&&M--)}return y[0]||y.shift(),m.e=l,Zn(m,s?a+Xr(m)+1:a)}})();function rZ(t,e){var n,r,i,a,s,o,l=0,c=0,u=t.constructor,f=u.precision;if(Xr(t)>16)throw Error(rO+Xr(t));if(!t.s)return new u(us);for(dr=!1,o=f,s=new u(.03125);t.abs().gte(.1);)t=t.times(s),c+=5;for(r=Math.log(qd(2,c))/Math.LN10*2+5|0,o+=r,n=i=a=new u(us),u.precision=o;;){if(i=Zn(i.times(t),o),n=n.times(++l),s=a.plus(fc(i,n,o)),qo(s.d).slice(0,o)===qo(a.d).slice(0,o)){for(;c--;)a=Zn(a.times(a),o);return u.precision=f,e==null?(dr=!0,Zn(a,f)):a}a=s}}function Xr(t){for(var e=t.e*ar,n=t.d[0];n>=10;n/=10)e++;return e}function XC(t,e,n){if(e>t.LN10.sd())throw dr=!0,n&&(t.precision=n),Error(Qs+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Au(t){for(var e="";t--;)e+="0";return e}function E0(t,e){var n,r,i,a,s,o,l,c,u,f=1,g=10,m=t,y=m.d,v=m.constructor,b=v.precision;if(m.s<1)throw Error(Qs+(m.s?"NaN":"-Infinity"));if(m.eq(us))return new v(0);if(e==null?(dr=!1,c=b):c=e,m.eq(10))return e==null&&(dr=!0),XC(v,c);if(c+=g,v.precision=c,n=qo(y),r=n.charAt(0),a=Xr(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=qo(m.d),r=n.charAt(0),f++;a=Xr(m),r>1?(m=new v("0."+n),a++):m=new v(r+"."+n.slice(1))}else return l=XC(v,c+2,b).times(a+""),m=E0(new v(r+"."+n.slice(1)),c-g).plus(l),v.precision=b,e==null?(dr=!0,Zn(m,b)):m;for(o=s=m=fc(m.minus(us),m.plus(us),c),u=Zn(m.times(m),c),i=3;;){if(s=Zn(s.times(u),c),l=o.plus(fc(s,new v(i),c)),qo(l.d).slice(0,c)===qo(o.d).slice(0,c))return o=o.times(2),a!==0&&(o=o.plus(XC(v,c+2,b).times(a+""))),o=fc(o,new v(f),c),v.precision=b,e==null?(dr=!0,Zn(o,b)):o;o=l,i+=2}}function _$(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=km(n/ar),t.d=[],r=(n+1)%ar,n<0&&(r+=ar),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ar;r<i;)t.d.push(+e.slice(r,r+=ar));e=e.slice(r),r=ar-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),dr&&(t.e>CS||t.e<-CS))throw Error(rO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var r,i,a,s,o,l,c,u,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=ar,i=e,c=f[u=0];else{if(u=Math.ceil((r+1)/ar),a=f.length,u>=a)return t;for(c=a=f[u],s=1;a>=10;a/=10)s++;r%=ar,i=r-ar+s}if(n!==void 0&&(a=qd(10,s-i-1),o=c/a%10|0,l=e<0||f[u+1]!==void 0||c%a,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(r>0?i>0?c/qd(10,s-i):0:f[u-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return l?(a=Xr(t),f.length=1,e=e-a-1,f[0]=qd(10,(ar-e%ar)%ar),t.e=km(-e/ar)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=u,a=1,u--):(f.length=u+1,a=qd(10,ar-r),f[u]=i>0?(c/qd(10,s-i)%qd(10,i)|0)*a:0),l)for(;;)if(u==0){(f[0]+=a)==Mi&&(f[0]=1,++t.e);break}else{if(f[u]+=a,f[u]!=Mi)break;f[u--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(dr&&(t.e>CS||t.e<-CS))throw Error(rO+Xr(t));return t}function iZ(t,e){var n,r,i,a,s,o,l,c,u,f,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),dr?Zn(e,m):e;if(l=t.d,f=e.d,r=e.e,c=t.e,l=l.slice(),s=c-r,s){for(u=s<0,u?(n=l,s=-s,o=f.length):(n=f,r=c,o=l.length),i=Math.max(Math.ceil(m/ar),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=f.length,u=i<o,u&&(o=i),i=0;i<o;i++)if(l[i]!=f[i]){u=l[i]<f[i];break}s=0}for(u&&(n=l,l=f,f=n,e.s=-e.s),o=l.length,i=f.length-o;i>0;--i)l[o++]=0;for(i=f.length;i>s;){if(l[--i]<f[i]){for(a=i;a&&l[--a]===0;)l[a]=Mi-1;--l[a],l[i]+=Mi}l[i]-=f[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,dr?Zn(e,m):e):new g(0)}function Hf(t,e,n){var r,i=Xr(t),a=qo(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Au(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Au(-i-1)+a,n&&(r=n-s)>0&&(a+=Au(r))):i>=s?(a+=Au(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Au(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Au(r))),t.s<0?"-"+a:a}function S$(t,e){if(t.length>e)return t.length=e,!0}function aZ(t){var e,n,r;function i(a){var s=this;if(!(s instanceof i))return new i(a);if(s.constructor=i,a instanceof i){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(_f+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return _$(s,a.toString())}else if(typeof a!="string")throw Error(_f+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,gLe.test(a))_$(s,a);else throw Error(_f+a)}if(i.prototype=Ct,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=aZ,i.config=i.set=xLe,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 xLe(t){if(!t||typeof t!="object")throw Error(Qs+"Object expected");var e,n,r,i=["precision",1,Pm,"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(km(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(_f+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(_f+n+": "+r);return this}var iO=aZ(mLe);us=new iO(1);const Ln=iO;var vLe=t=>t,sZ={},oZ=t=>t===sZ,w$=t=>function e(){return arguments.length===0||arguments.length===1&&oZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lZ=(t,e)=>t===1?e:w$(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(s=>s!==sZ).length;return a>=t?e(...r):lZ(t-a,w$(function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];var c=r.map(u=>oZ(u)?o.shift():u);return e(...c,...o)}))}),bLe=t=>lZ(t.length,t),iP=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},yLe=bLe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),_Le=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return vLe;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((o,l)=>l(o),a(...arguments))}},aP=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cZ(t){var e;return t===0?e=1:e=Math.floor(new Ln(t).abs().log(10).toNumber())+1,e}function uZ(t,e,n){for(var r=new Ln(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var dZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},fZ=(t,e,n)=>{if(t.lte(0))return new Ln(0);var r=cZ(t.toNumber()),i=new Ln(10).pow(r),a=t.div(i),s=r!==1?.05:.1,o=new Ln(Math.ceil(a.div(s).toNumber())).add(n).mul(s),l=o.mul(i);return e?new Ln(l.toNumber()):new Ln(Math.ceil(l.toNumber()))},SLe=(t,e,n)=>{var r=new Ln(1),i=new Ln(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Ln(10).pow(cZ(t)-1),i=new Ln(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Ln(Math.floor(t)))}else t===0?i=new Ln(Math.floor((e-1)/2)):n||(i=new Ln(Math.floor(t)));var s=Math.floor((e-1)/2),o=_Le(yLe(l=>i.add(new Ln(l-s).mul(r)).toNumber()),iP);return o(0,e)},hZ=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 Ln(0),tickMin:new Ln(0),tickMax:new Ln(0)};var s=fZ(new Ln(n).sub(e).div(r-1),i,a),o;e<=0&&n>=0?o=new Ln(0):(o=new Ln(e).add(n).div(2),o=o.sub(new Ln(o).mod(s)));var l=Math.ceil(o.sub(e).div(s).toNumber()),c=Math.ceil(new Ln(n).sub(o).div(s).toNumber()),u=l+c+1;return u>r?hZ(e,n,r,i,a+1):(u<r&&(c=n>0?c+(r-u):c,l=n>0?l:l+(r-u)),{step:s,tickMin:o.sub(new Ln(l).mul(s)),tickMax:o.add(new Ln(c).mul(s))})},wLe=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,s=Math.max(i,2),[o,l]=dZ([n,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...iP(0,i-1).map(()=>1/0)]:[...iP(0,i-1).map(()=>-1/0),l];return n>r?aP(c):c}if(o===l)return SLe(o,i,a);var{step:u,tickMin:f,tickMax:g}=hZ(o,l,s,a,0),m=uZ(f,g.add(new Ln(.1).mul(u)),u);return n>r?aP(m):m},MLe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=dZ([r,i]);if(s===-1/0||o===1/0)return[r,i];if(s===o)return[s];var l=Math.max(n,2),c=fZ(new Ln(o).sub(s).div(l-1),a,0),u=[...uZ(new Ln(s),new Ln(o),c),o];return a===!1&&(u=u.map(f=>Math.round(f))),r>i?aP(u):u},pZ=t=>t.rootProps.maxBarSize,ELe=t=>t.rootProps.barGap,mZ=t=>t.rootProps.barCategoryGap,ALe=t=>t.rootProps.barSize,av=t=>t.rootProps.stackOffset,gZ=t=>t.rootProps.reverseStackOrder,aO=t=>t.options.chartName,sO=t=>t.rootProps.syncId,xZ=t=>t.rootProps.syncMethod,oO=t=>t.options.eventEmitter,TLe=t=>t.rootProps.baseValue,Wr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Zl={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ss={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},nM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},CLe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Zl.angleAxisId,includeHidden:!1,name:void 0,reversed:Zl.reversed,scale:Zl.scale,tick:Zl.tick,tickCount:void 0,ticks:void 0,type:Zl.type,unit:void 0},NLe={allowDataOverflow:ss.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ss.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ss.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ss.scale,tick:ss.tick,tickCount:ss.tickCount,ticks:void 0,type:ss.type,unit:void 0},RLe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Zl.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Zl.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Zl.scale,tick:Zl.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},PLe={allowDataOverflow:ss.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ss.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ss.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ss.scale,tick:ss.tick,tickCount:ss.tickCount,ticks:void 0,type:"category",unit:void 0},lO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?RLe:CLe,cO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?PLe:NLe,rM=t=>t.polarOptions,uO=$e([Cc,Nc,ui],mY),vZ=$e([rM,uO],(t,e)=>{if(t!=null)return sa(t.innerRadius,e,0)}),bZ=$e([rM,uO],(t,e)=>{if(t!=null)return sa(t.outerRadius,e,e*.8)}),kLe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},yZ=$e([rM],kLe);$e([lO,yZ],nM);var _Z=$e([uO,vZ,bZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});$e([cO,_Z],nM);var SZ=$e([Sn,rM,vZ,bZ,Cc,Nc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:o,startAngle:l,endAngle:c}=e;return{cx:sa(s,i,i/2),cy:sa(o,a,a/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:c,clockWise:!1}}}),fr=(t,e)=>e,sv=(t,e,n)=>n;function iM(t){return t?.id}function wZ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(o=>{var l,c=(l=o.data)!==null&&l!==void 0?l:r;if(!(c==null||c.length===0)){var u=iM(o);c.forEach((f,g)=>{var m=a==null||i?g:String(Yn(f,a,null)),y=Yn(f,o.dataKey,0),v;s.has(m)?v=s.get(m):v={},Object.assign(v,{[u]:y}),s.set(m,v)})}}),Array.from(s.values())}function aM(t){return t.stackId!=null&&t.dataKey!=null}var sM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function oM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function DLe(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 fi=t=>{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Dm=t=>t.tooltip.settings.axisId;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 NS(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){OLe(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 OLe(t,e,n){return(e=LLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LLe(t){var e=ILe(t,"string");return typeof e=="symbol"?e:e+""}function ILe(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 sP=[0,"auto"],Si={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},MZ=(t,e)=>t.cartesianAxis.xAxis[e],Pc=(t,e)=>{var n=MZ(t,e);return n??Si},wi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:sP,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:Z0},EZ=(t,e)=>t.cartesianAxis.yAxis[e],kc=(t,e)=>{var n=EZ(t,e);return n??wi},jLe={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:""},dO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??jLe},vr=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"zAxis":return dO(t,n);case"angleAxis":return lO(t,n);case"radiusAxis":return cO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ULe=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ov=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"angleAxis":return lO(t,n);case"radiusAxis":return cO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},AZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function fO(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 lM=t=>t.graphicalItems.cartesianItems,FLe=$e([fr,sv],fO),hO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),lv=$e([lM,vr,FLe],hO,{memoizeOptions:{resultEqualityCheck:oM}}),TZ=$e([lv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(aM)),CZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),zLe=$e([lv],CZ),pO=t=>t.map(e=>e.data).filter(Boolean).flat(1),BLe=$e([lv],pO,{memoizeOptions:{resultEqualityCheck:oM}}),mO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},gO=$e([BLe,tM],mO),xO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Yn(i,r)}))):t.map(r=>({value:r})),cM=$e([gO,vr,lv],xO);function NZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function D_(t){if(al(t)||t instanceof Date){var e=Number(t);if(or(e))return e}}function E$(t){if(Array.isArray(t)){var e=[D_(t[0]),D_(t[1])];return nd(e)?e:void 0}var n=D_(t);if(n!=null)return[n,n]}function wc(t){return t.map(D_).filter(zCe)}function HLe(t,e,n){return!n||typeof e!="number"||Ys(e)?[]:n.length?wc(n.flatMap(r=>{var i=Yn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!or(a)||!or(s)))return[e-a,e+s]})):[]}var hi=t=>{var e=fi(t),n=Dm(t);return ov(t,e,n)},cv=$e([hi],t=>t?.dataKey),$Le=$e([TZ,tM,hi],wZ),RZ=(t,e,n,r)=>{var i={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[o,l]=s,c=r?[...l].reverse():l,u=c.map(iM);return[o,{stackedData:lRe(t,u,n),graphicalItems:c}]}))},A0=$e([$Le,TZ,av,gZ],RZ),PZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=fRe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},VLe=$e([vr],t=>t.allowDataOverflow),vO=t=>{var e;if(t==null||!("domain"in t))return sP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=wc(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:sP},bO=$e([vr],vO),yO=$e([bO,VLe],eZ),GLe=$e([A0,pd,fr,yO],PZ,{memoizeOptions:{resultEqualityCheck:sM}}),uM=t=>t.errorBars,WLe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>NZ(n,r)),RS=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(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},_O=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,u,f=(c=r[l.id])===null||c===void 0?void 0:c.filter(x=>NZ(i,x)),g=Yn(o,(u=e.dataKey)!==null&&u!==void 0?u:l.dataKey),m=HLe(o,g,f);if(m.length>=2){var y=Math.min(...m),v=Math.max(...m);(a==null||y<a)&&(a=y),(s==null||v>s)&&(s=v)}var b=E$(g);b!=null&&(a=a==null?b[0]:Math.min(a,b[0]),s=s==null?b[1]:Math.max(s,b[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=E$(Yn(o,e.dataKey));l!=null&&(a=a==null?l[0]:Math.min(a,l[0]),s=s==null?l[1]:Math.max(s,l[1]))}),or(a)&&or(s))return[a,s]},qLe=$e([gO,vr,zLe,uM,fr],_O,{memoizeOptions:{resultEqualityCheck:sM}});function XLe(t){var{value:e}=t;if(al(e)||e instanceof Date)return e}var KLe=(t,e,n)=>{var r=t.map(XLe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&WX(r))?bY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},kZ=t=>t.referenceElements.dots,Om=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),YLe=$e([kZ,fr,sv],Om),DZ=t=>t.referenceElements.areas,ZLe=$e([DZ,fr,sv],Om),OZ=t=>t.referenceElements.lines,QLe=$e([OZ,fr,sv],Om),LZ=(t,e)=>{var n=wc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},JLe=$e(YLe,fr,LZ),IZ=(t,e)=>{var n=wc(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)]},eIe=$e([ZLe,fr],IZ);function tIe(t){var e;if(t.x!=null)return wc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:wc(n)}function nIe(t){var e;if(t.y!=null)return wc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:wc(n)}var jZ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?tIe(r):nIe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},rIe=$e([QLe,fr],jZ),iIe=$e(JLe,rIe,eIe,(t,e,n)=>RS(t,n,e)),SO=(t,e,n,r,i,a,s,o)=>{if(n!=null)return n;var l=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",c=l?RS(r,a,i):RS(a,i);return pLe(e,c,t.allowDataOverflow)},aIe=$e([vr,bO,yO,GLe,qLe,iIe,Sn,fr],SO,{memoizeOptions:{resultEqualityCheck:sM}}),sIe=[0,1],wO=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:l}=t,c=Tc(e,a);if(c&&o==null){var u;return bY(0,(u=n?.length)!==null&&u!==void 0?u:0)}return l==="category"?KLe(r,t,c):i==="expand"?sIe:s}},MO=$e([vr,Sn,gO,cM,av,fr,aIe],wO),UZ=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(G0(a));return o in px?o:"point"}}},Lm=$e([vr,Sn,AZ,aO,fr],UZ);function oIe(t){if(t!=null){if(t in px)return px[t]();var e="scale".concat(G0(t));if(e in px)return px[e]()}}function EO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=oIe(e);if(i!=null){var a=i.domain(n).range(r);return rRe(a),a}}}var AO=(t,e,n)=>{var r=vO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&nd(t))return wLe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&nd(t))return MLe(t,e.tickCount,e.allowDecimals)}},TO=$e([MO,ov,Lm],AO),CO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&nd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(i,a),Math.max(s,o)]}return e},lIe=$e([vr,MO,TO,fr],CO),cIe=$e(cM,vr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(wc(t.map(o=>o.value))).sort((o,l)=>o-l);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),FZ=$e(cIe,Sn,mZ,ui,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!or(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=sa(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),uIe=(t,e)=>{var n=Pc(t,e);return n==null||typeof n.padding!="string"?0:FZ(t,"xAxis",e,n.padding)},dIe=(t,e)=>{var n=kc(t,e);return n==null||typeof n.padding!="string"?0:FZ(t,"yAxis",e,n.padding)},fIe=$e(Pc,uIe,(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}}),hIe=$e(kc,dIe,(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}}),pIe=$e([ui,fIe,$w,Hw,(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]}),mIe=$e([ui,Sn,hIe,$w,Hw,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:s}=i;return a?[r.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),uv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return pIe(t,n,r);case"yAxis":return mIe(t,n,r);case"zAxis":return(i=dO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return yZ(t);case"radiusAxis":return _Z(t,n);default:return}},zZ=$e([vr,uv],nM),Im=$e([vr,Lm,lIe,zZ],EO);$e([lv,uM,fr],WLe);function BZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var dM=(t,e)=>e,fM=(t,e,n)=>n,gIe=$e(zw,dM,fM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BZ)),xIe=$e(Bw,dM,fM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BZ)),HZ=(t,e)=>({width:t.width,height:e.height}),vIe=(t,e)=>{var n=typeof e.width=="number"?e.width:Z0;return{width:n,height:t.height}},$Z=$e(ui,Pc,HZ),bIe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},yIe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},_Ie=$e(Nc,ui,gIe,dM,fM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var l=HZ(e,o);s==null&&(s=bIe(e,r,t));var c=r==="top"&&!i||r==="bottom"&&i;a[o.id]=s-Number(c)*l.height,s+=(c?-1:1)*l.height}),a}),SIe=$e(Cc,ui,xIe,dM,fM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var l=vIe(e,o);s==null&&(s=yIe(e,r,t));var c=r==="left"&&!i||r==="right"&&i;a[o.id]=s-Number(c)*l.width,s+=(c?-1:1)*l.width}),a}),wIe=(t,e)=>{var n=Pc(t,e);if(n!=null)return _Ie(t,n.orientation,n.mirror)},MIe=$e([ui,Pc,wIe,(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}}}),EIe=(t,e)=>{var n=kc(t,e);if(n!=null)return SIe(t,n.orientation,n.mirror)},AIe=$e([ui,kc,EIe,(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}}}),VZ=$e(ui,kc,(t,e)=>{var n=typeof e.width=="number"?e.width:Z0;return{width:n,height:t.height}}),A$=(t,e,n)=>{switch(e){case"xAxis":return $Z(t,n).width;case"yAxis":return VZ(t,n).height;default:return}},GZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,o=Tc(t,r),l=e.map(c=>c.value);if(s&&o&&a==="category"&&i&&WX(l))return l}},NO=$e([Sn,cM,vr,fr],GZ),WZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=Tc(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(o=>o.value)}},RO=$e([Sn,cM,ov,fr],WZ),T$=$e([Sn,ULe,Lm,Im,NO,RO,uv,TO,fr],(t,e,n,r,i,a,s,o,l)=>{if(e!=null){var c=Tc(t,l);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:l,categoricalDomain:a,duplicateDomain:i,isCategorical:c,niceTicks:o,range:s,realScaleType:n,scale:r}}}),TIe=(t,e,n,r,i,a,s,o,l)=>{if(!(e==null||r==null)){var c=Tc(t,l),{type:u,ticks:f,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,y=u==="category"&&r.bandwidth?r.bandwidth()/m:0;y=l==="angleAxis"&&a!=null&&a.length>=2?Ti(a[0]-a[1])*2*y:y;var v=f||i;if(v){var b=v.map((x,M)=>{var w=s?s.indexOf(x):x;return{index:M,coordinate:r(w)+y,value:x,offset:y}});return b.filter(x=>or(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:r(x)+y,value:x,index:M,offset:y})).filter(x=>or(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+y,value:x,offset:y})):r.domain().map((x,M)=>({coordinate:r(x)+y,value:s?s[x]:x,index:M,offset:y}))}},qZ=$e([Sn,ov,Lm,Im,TO,uv,NO,RO,fr],TIe),CIe=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=Tc(t,s),{tickCount:l}=e,c=0;return c=s==="angleAxis"&&r?.length>=2?Ti(r[0]-r[1])*2*c:c,o&&a?a.map((u,f)=>({coordinate:n(u)+c,value:u,index:f,offset:c})):n.ticks?n.ticks(l).map(u=>({coordinate:n(u)+c,value:u,offset:c})):n.domain().map((u,f)=>({coordinate:n(u)+c,value:i?i[u]:u,index:f,offset:c}))}},rd=$e([Sn,ov,Im,uv,NO,RO,fr],CIe),id=$e(vr,Im,(t,e)=>{if(!(t==null||e==null))return NS(NS({},t),{},{scale:e})}),NIe=$e([vr,Lm,MO,zZ],EO);$e((t,e,n)=>dO(t,n),NIe,(t,e)=>{if(!(t==null||e==null))return NS(NS({},t),{},{scale:e})});var RIe=$e([Sn,zw,Bw],(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}}),XZ=t=>t.options.defaultTooltipEventType,KZ=t=>t.options.validateTooltipEventTypes;function YZ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function PO(t,e){var n=XZ(t),r=KZ(t);return YZ(e,n,r)}function PIe(t){return Tt(e=>PO(e,t))}var ZZ=(t,e)=>{var n,r=Number(e);if(!(Ys(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},kIe=t=>t.tooltip.settings,ku={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},DIe={itemInteraction:{click:ku,hover:ku},axisInteraction:{click:ku,hover:ku},keyboardInteraction:ku,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}},QZ=Ga({name:"tooltip",initialState:DIe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:cr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Mo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:cr()},removeTooltipEntrySettings:{reducer(t,e){var n=Mo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:cr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:OIe,replaceTooltipEntrySettings:LIe,removeTooltipEntrySettings:IIe,setTooltipSettingsState:jIe,setActiveMouseOverItemIndex:JZ,mouseLeaveItem:UIe,mouseLeaveChart:eQ,setActiveClickItemIndex:FIe,setMouseOverAxisIndex:tQ,setMouseClickAxisIndex:zIe,setSyncInteraction:oP,setKeyboardInteraction:lP}=QZ.actions,BIe=QZ.reducer;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 r_(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){HIe(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 HIe(t,e,n){return(e=$Ie(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ie(t){var e=VIe(t,"string");return typeof e=="symbol"?e:e+""}function VIe(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 GIe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function WIe(t){return t.index!=null}var nQ=(t,e,n,r)=>{if(e==null)return ku;var i=GIe(t,e,n);if(i==null)return ku;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(WIe(i)){if(a)return r_(r_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return r_(r_({},ku),{},{coordinate:i.coordinate})};function qIe(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 XIe(t,e){var n=qIe(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),s=Math.max(r,i);return n>=a&&n<=s}function KIe(t,e,n){if(n==null||e==null)return!0;var r=Yn(t,e);return r==null||!nd(n)?!0:XIe(r,n)}var kO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!or(a))return i;var s=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(s,Math.min(a,o)),c=e[l];return c==null||KIe(c,n,r)?String(l):null},rQ=(t,e,n,r,i,a,s,o)=>{if(!(a==null||o==null)){var l=s[0],c=l==null?void 0:o(l.positions,a);if(c!=null)return c;var u=i?.[Number(a)];if(u)switch(n){case"horizontal":return{x:u.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:u.coordinate}}}},iQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===i})},dv=t=>t.options.tooltipPayloadSearcher,jm=t=>t.tooltip;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 R$(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){YIe(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 YIe(t,e,n){return(e=ZIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZIe(t){var e=QIe(t,"string");return typeof e=="symbol"?e:e+""}function QIe(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 JIe(t,e){return t??e}var aQ=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:u}=n,f=[];return t.reduce((g,m)=>{var y,{dataDefinedOnItem:v,settings:b}=m,x=JIe(v,o),M=Array.isArray(x)?zK(x,c,u):x,w=(y=b?.dataKey)!==null&&y!==void 0?y:r,A=b?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=qX(M,r,i):T=a(M,e,l,A),Array.isArray(T))T.forEach(N=>{var j=R$(R$({},b),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(Y8({tooltipEntrySettings:j,dataKey:N.dataKey,payload:N.payload,value:Yn(N.payload,N.dataKey),name:N.name}))});else{var R;g.push(Y8({tooltipEntrySettings:b,dataKey:w,payload:T,value:Yn(T,w),name:(R=Yn(T,A))!==null&&R!==void 0?R:b?.name}))}return g},f)}},DO=$e([hi,Sn,AZ,aO,fi],UZ),eje=$e([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),tje=$e([fi,Dm],fO),fv=$e([eje,hi,tje],hO,{memoizeOptions:{resultEqualityCheck:oM}}),nje=$e([fv],t=>t.filter(aM)),rje=$e([fv],pO,{memoizeOptions:{resultEqualityCheck:oM}}),Um=$e([rje,pd],mO),ije=$e([nje,pd,hi],wZ),OO=$e([Um,hi,fv],xO),sQ=$e([hi],vO),aje=$e([hi],t=>t.allowDataOverflow),oQ=$e([sQ,aje],eZ),sje=$e([fv],t=>t.filter(aM)),oje=$e([ije,sje,av,gZ],RZ),lje=$e([oje,pd,fi,oQ],PZ),cje=$e([fv],CZ),uje=$e([Um,hi,cje,uM,fi],_O,{memoizeOptions:{resultEqualityCheck:sM}}),dje=$e([kZ,fi,Dm],Om),fje=$e([dje,fi],LZ),hje=$e([DZ,fi,Dm],Om),pje=$e([hje,fi],IZ),mje=$e([OZ,fi,Dm],Om),gje=$e([mje,fi],jZ),xje=$e([fje,gje,pje],RS),vje=$e([hi,sQ,oQ,lje,uje,xje,Sn,fi],SO),hv=$e([hi,Sn,Um,OO,av,fi,vje],wO),bje=$e([hv,hi,DO],AO),yje=$e([hi,hv,bje,fi],CO),lQ=t=>{var e=fi(t),n=Dm(t),r=!1;return uv(t,e,n,r)},cQ=$e([hi,lQ],nM),uQ=$e([hi,DO,yje,cQ],EO),_je=$e([Sn,OO,hi,fi],GZ),Sje=$e([Sn,OO,hi,fi],WZ),wje=(t,e,n,r,i,a,s,o)=>{if(e){var{type:l}=e,c=Tc(t,o);if(r){var u=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=l==="category"&&r.bandwidth?r.bandwidth()/u:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Ti(i[0]-i[1])*2*f:f,c&&s?s.map((g,m)=>({coordinate:r(g)+f,value:g,index:m,offset:f})):r.domain().map((g,m)=>({coordinate:r(g)+f,value:a?a[g]:g,index:m,offset:f}))}}},Dc=$e([Sn,hi,DO,uQ,lQ,_je,Sje,fi],wje),LO=$e([XZ,KZ,kIe],(t,e,n)=>YZ(n.shared,t,e)),dQ=t=>t.tooltip.settings.trigger,IO=t=>t.tooltip.settings.defaultIndex,pv=$e([jm,LO,dQ,IO],nQ),ad=$e([pv,Um,cv,hv],kO),fQ=$e([Dc,ad],ZZ),jO=$e([pv],t=>{if(t)return t.dataKey}),Mje=$e([pv],t=>{if(t)return t.graphicalItemId}),hQ=$e([jm,LO,dQ,IO],iQ),Eje=$e([Cc,Nc,Sn,ui,Dc,IO,hQ,dv],rQ),Aje=$e([pv,Eje],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Tje=$e([pv],t=>t.active),Cje=$e([hQ,ad,pd,cv,fQ,dv,LO],aQ),Nje=$e([Cje],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function P$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function k$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P$(Object(n),!0).forEach(function(r){Rje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rje(t,e,n){return(e=Pje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Pje(t){var e=kje(t,"string");return typeof e=="symbol"?e:e+""}function kje(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 Dje=()=>Tt(hi),Oje=()=>{var t=Dje(),e=Tt(Dc),n=Tt(uQ);return dm(!t||!n?void 0:k$(k$({},t),{},{scale:n}),e)};function D$(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 pp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D$(Object(n),!0).forEach(function(r){Lje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lje(t,e,n){return(e=Ije(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ije(t){var e=jje(t,"string");return typeof e=="symbol"?e:e+""}function jje(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 Uje=(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}},Fje=(t,e,n,r)=>{var i=e.find(c=>c&&c.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return pp(pp(pp({},r),Gr(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var o=i.coordinate,{angle:l}=r;return pp(pp(pp({},r),Gr(r.cx,r.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function zje(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 pQ=(t,e,n,r,i)=>{var a,s=-1,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=l>0?n[l-1].coordinate:n[o-1].coordinate,u=n[l].coordinate,f=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(Ti(u-c)!==Ti(f-u)){var m=[];if(Ti(f-u)===Ti(i[1]-i[0])){g=f;var y=u+i[1]-i[0];m[0]=Math.min(y,(y+c)/2),m[1]=Math.max(y,(y+c)/2)}else{g=c;var v=f+i[1]-i[0];m[0]=Math.min(u,(v+u)/2),m[1]=Math.max(u,(v+u)/2)}var b=[Math.min(u,(g+u)/2),Math.max(u,(g+u)/2)];if(t>b[0]&&t<=b[1]||t>=m[0]&&t<=m[1]){({index:s}=n[l]);break}}else{var x=Math.min(c,f),M=Math.max(c,f);if(t>(x+u)/2&&t<=(M+u)/2){({index:s}=n[l]);break}}}else if(e){for(var w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},mQ=()=>Tt(aO),UO=(t,e)=>e,gQ=(t,e,n)=>n,FO=(t,e,n,r)=>r,Bje=$e(Dc,t=>Pw(t,e=>e.coordinate)),zO=$e([jm,UO,gQ,FO],nQ),BO=$e([zO,Um,cv,hv],kO),Hje=(t,e,n)=>{if(e!=null){var r=jm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},xQ=$e([jm,UO,gQ,FO],iQ),PS=$e([Cc,Nc,Sn,ui,Dc,FO,xQ,dv],rQ),$je=$e([zO,PS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),vQ=$e([Dc,BO],ZZ),Vje=$e([xQ,BO,pd,cv,vQ,dv,UO],aQ),Gje=$e([zO,BO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Wje=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&zje(t,s)){var o=hRe(t,e),l=pQ(o,a,i,n,r),c=Uje(e,i,l,t);return{activeIndex:String(l),activeCoordinate:c}}},qje=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var o=Rke(t,n);if(o){var l=pRe(o,e),c=pQ(l,s,a,r,i),u=Fje(e,a,c,o);return{activeIndex:String(c),activeCoordinate:u}}}},Xje=(t,e,n,r,i,a,s,o)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?Wje(t,e,r,i,a,s,o):qje(t,e,n,r,i,a,s)},Kje=$e(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),Yje=$e(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Wr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:DLe}});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 L$(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){Zje(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 Zje(t,e,n){return(e=Qje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qje(t){var e=Jje(t,"string");return typeof e=="symbol"?e:e+""}function Jje(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 e4e={},t4e={zIndexMap:Object.values(Wr).reduce((t,e)=>L$(L$({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),e4e)},n4e=new Set(Object.values(Wr));function r4e(t){return n4e.has(t)}var bQ=Ga({name:"zIndex",initialState:t4e,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:cr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!r4e(n)&&delete t.zIndexMap[n])},prepare:cr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:cr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:cr()}}}),{registerZIndexPortal:i4e,unregisterZIndexPortal:a4e,registerZIndexPortalId:s4e,unregisterZIndexPortalId:o4e}=bQ.actions,l4e=bQ.reducer;function Wa(t){var{zIndex:e,children:n}=t,r=WRe(),i=r&&e!==void 0&&e!==0,a=ca(),s=er();E.useLayoutEffect(()=>i?(s(i4e({zIndex:e})),()=>{s(a4e({zIndex:e}))}):W0,[s,e,i]);var o=Tt(c=>Kje(c,e,a));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?Jl.createPortal(n,l):null}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 I$(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?I$(Object(n),!0).forEach(function(r){c4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c4e(t,e,n){return(e=u4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u4e(t){var e=d4e(t,"string");return typeof e=="symbol"?e:e+""}function d4e(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 f4e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function h4e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:o,cursor:l,tooltipEventType:c,chartName:u}=t,f=n,g=r,m=i;if(!l||!f||u!=="ScatterChart"&&c!=="axis")return null;var y,v,b;if(u==="ScatterChart")y=f,v=GPe,b=Wr.cursorLine;else if(u==="BarChart")y=WPe(o,f,a,s),v=pY,b=Wr.cursorRectangle;else if(o==="radial"&&KX(f)){var{cx:x,cy:M,radius:w,startAngle:A,endAngle:T}=gY(f);y={cx:x,cy:M,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},v=vY,b=Wr.cursorLine}else y={points:Oke(o,f,a)},v=Fp,b=Wr.cursorLine;var R=typeof l=="object"&&"className"in l?l.className:void 0,N=i_(i_(i_(i_({stroke:"#ccc",pointerEvents:"none"},a),y),Uf(l)),{},{payload:g,payloadIndex:m,className:An("recharts-tooltip-cursor",R)});return E.createElement(Wa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},E.createElement(f4e,{cursor:l,cursorComp:v,cursorProps:N}))}function p4e(t){var e=Oje(),n=ZK(),r=Cm(),i=mQ();return e==null||n==null||r==null||i==null?null:E.createElement(h4e,cP({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var yQ=E.createContext(null),m4e=()=>E.useContext(yQ),KC={exports:{}},j$;function g4e(){return j$||(j$=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(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function a(l,c,u,f,g){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new i(u,f||l,g),y=n?n+c:c;return l._events[y]?l._events[y].fn?l._events[y]=[l._events[y],m]:l._events[y].push(m):(l._events[y]=m,l._eventsCount++),l}function s(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,f;if(this._eventsCount===0)return c;for(f in u=this._events)e.call(u,f)&&c.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=n?n+c:c,f=this._events[u];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,m=f.length,y=new Array(m);g<m;g++)y[g]=f[g].fn;return y},o.prototype.listenerCount=function(c){var u=n?n+c:c,f=this._events[u];return f?f.fn?1:f.length:0},o.prototype.emit=function(c,u,f,g,m,y){var v=n?n+c:c;if(!this._events[v])return!1;var b=this._events[v],x=arguments.length,M,w;if(b.fn){switch(b.once&&this.removeListener(c,b.fn,void 0,!0),x){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,u),!0;case 3:return b.fn.call(b.context,u,f),!0;case 4:return b.fn.call(b.context,u,f,g),!0;case 5:return b.fn.call(b.context,u,f,g,m),!0;case 6:return b.fn.call(b.context,u,f,g,m,y),!0}for(w=1,M=new Array(x-1);w<x;w++)M[w-1]=arguments[w];b.fn.apply(b.context,M)}else{var A=b.length,T;for(w=0;w<A;w++)switch(b[w].once&&this.removeListener(c,b[w].fn,void 0,!0),x){case 1:b[w].fn.call(b[w].context);break;case 2:b[w].fn.call(b[w].context,u);break;case 3:b[w].fn.call(b[w].context,u,f);break;case 4:b[w].fn.call(b[w].context,u,f,g);break;default:if(!M)for(T=1,M=new Array(x-1);T<x;T++)M[T-1]=arguments[T];b[w].fn.apply(b[w].context,M)}}return!0},o.prototype.on=function(c,u,f){return a(this,c,u,f,!1)},o.prototype.once=function(c,u,f){return a(this,c,u,f,!0)},o.prototype.removeListener=function(c,u,f,g){var m=n?n+c:c;if(!this._events[m])return this;if(!u)return s(this,m),this;var y=this._events[m];if(y.fn)y.fn===u&&(!g||y.once)&&(!f||y.context===f)&&s(this,m);else{for(var v=0,b=[],x=y.length;v<x;v++)(y[v].fn!==u||g&&!y[v].once||f&&y[v].context!==f)&&b.push(y[v]);b.length?this._events[m]=b.length===1?b[0]:b:s(this,m)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&s(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(KC)),KC.exports}var x4e=g4e();const v4e=Js(x4e);var T0=new v4e,uP="recharts.syncEvent.tooltip",U$="recharts.syncEvent.brush";function HO(t,e){if(e){var n=Number.parseInt(e,10);if(!Ys(n))return t?.[n]}}var b4e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},_Q=Ga({name:"options",initialState:b4e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),y4e=_Q.reducer,{createEventEmitter:_4e}=_Q.actions;function S4e(t){return t.tooltip.syncInteraction}var w4e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},SQ=Ga({name:"chartData",initialState:w4e,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:F$,setDataStartEndIndexes:M4e,setComputedData:u9e}=SQ.actions,E4e=SQ.reducer,A4e=["x","y"];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 mp(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){T4e(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 T4e(t,e,n){return(e=C4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C4e(t){var e=N4e(t,"string");return typeof e=="symbol"?e:e+""}function N4e(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 R4e(t,e){if(t==null)return{};var n,r,i=P4e(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 P4e(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 k4e(){var t=Tt(sO),e=Tt(oO),n=er(),r=Tt(xZ),i=Tt(Dc),a=Cm(),s=Vw(),o=Tt(l=>l.rootProps.className);E.useEffect(()=>{if(t==null)return W0;var l=(c,u,f)=>{if(e!==f&&t===c){if(r==="index"){var g;if(s&&u!==null&&u!==void 0&&(g=u.payload)!==null&&g!==void 0&&g.coordinate&&u.payload.sourceViewBox){var m=u.payload.coordinate,{x:y,y:v}=m,b=R4e(m,A4e),{x,y:M,width:w,height:A}=u.payload.sourceViewBox,T=mp(mp({},b),{},{x:s.x+(w?(y-x)/w:0)*s.width,y:s.y+(A?(v-M)/A:0)*s.height});n(mp(mp({},u),{},{payload:mp(mp({},u.payload),{},{coordinate:T})}))}else n(u);return}if(i!=null){var R;if(typeof r=="function"){var N={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},j=r(i,N);R=i[j]}else r==="value"&&(R=i.find(V=>String(V.value)===u.payload.label));var{coordinate:C}=u.payload;if(R==null||u.payload.active===!1||C==null||s==null){n(oP({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:k,y:U}=C,I=Math.min(k,s.x+s.width),H=Math.min(U,s.y+s.height),O={x:a==="horizontal"?R.coordinate:I,y:a==="horizontal"?H:R.coordinate},B=oP({active:u.payload.active,coordinate:O,dataKey:u.payload.dataKey,index:String(R.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox,graphicalItemId:u.payload.graphicalItemId});n(B)}}};return T0.on(uP,l),()=>{T0.off(uP,l)}},[o,n,e,t,r,i,a,s])}function D4e(){var t=Tt(sO),e=Tt(oO),n=er();E.useEffect(()=>{if(t==null)return W0;var r=(i,a,s)=>{e!==s&&t===i&&n(M4e(a))};return T0.on(U$,r),()=>{T0.off(U$,r)}},[n,e,t])}function O4e(){var t=er();E.useEffect(()=>{t(_4e())},[t]),k4e(),D4e()}function L4e(t,e,n,r,i,a){var s=Tt(m=>Hje(m,t,e)),o=Tt(oO),l=Tt(sO),c=Tt(xZ),u=Tt(S4e),f=u?.active,g=Vw();E.useEffect(()=>{if(!f&&l!=null&&o!=null){var m=oP({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});T0.emit(uP,l,m,o)}},[f,n,s,i,r,o,l,c,a,g])}function B$(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 H$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B$(Object(n),!0).forEach(function(r){I4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I4e(t,e,n){return(e=j4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j4e(t){var e=U4e(t,"string");return typeof e=="symbol"?e:e+""}function U4e(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 F4e(t){return t.dataKey}function z4e(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(MPe,e)}var $$=[],B4e={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function YC(t){var e,n,r=Yr(t,B4e),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:l,filterNull:c,isAnimationActive:u,offset:f,payloadUniqBy:g,position:m,reverseDirection:y,useTranslate3d:v,wrapperStyle:b,cursor:x,shared:M,trigger:w,defaultIndex:A,portal:T,axisId:R}=r,N=er(),j=typeof A=="number"?String(A):A;E.useEffect(()=>{N(jIe({shared:M,trigger:w,axisId:R,active:i,defaultIndex:j}))},[N,M,w,R,i,j]);var C=Vw(),k=cY(),U=PIe(M),{activeIndex:I,isActive:H}=(e=Tt(ve=>Gje(ve,U,w,j)))!==null&&e!==void 0?e:{},O=Tt(ve=>Vje(ve,U,w,j)),B=Tt(ve=>vQ(ve,U,w,j)),V=Tt(ve=>$je(ve,U,w,j)),G=O,K=m4e(),Y=(n=i??H)!==null&&n!==void 0?n:!1,[oe,$]=uK([G,Y]),X=U==="axis"?B:void 0;L4e(U,w,V,X,I,Y);var ae=T??K;if(ae==null||C==null||U==null)return null;var ce=G??$$;Y||(ce=$$),c&&ce.length&&(ce=aK(ce.filter(ve=>ve.value!=null&&(ve.hide!==!0||r.includeHidden)),g,F4e));var xe=ce.length>0,te=E.createElement(PPe,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:u,active:Y,coordinate:V,hasPayload:xe,offset:f,position:m,reverseDirection:y,useTranslate3d:v,viewBox:C,wrapperStyle:b,lastBoundingBox:oe,innerRef:$,hasPortalFromProps:!!T},z4e(l,H$(H$({},r),{},{payload:ce,label:X,active:Y,activeIndex:I,coordinate:V,accessibilityLayer:k})));return E.createElement(E.Fragment,null,Jl.createPortal(te,ae),Y&&E.createElement(p4e,{cursor:x,tooltipEventType:U,coordinate:V,payload:ce,index:I}))}var mv=t=>null;mv.displayName="Cell";function H4e(t,e,n){return(e=$4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $4e(t){var e=V4e(t,"string");return typeof e=="symbol"?e:e+""}function V4e(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 G4e{constructor(e){H4e(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 V$(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 W4e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V$(Object(n),!0).forEach(function(r){q4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function q4e(t,e,n){return(e=X4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X4e(t){var e=K4e(t,"string");return typeof e=="symbol"?e:e+""}function K4e(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 Y4e={cacheSize:2e3,enableCache:!0},wQ=W4e({},Y4e),G$=new G4e(wQ.cacheSize),Z4e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},W$="recharts_measurement_span";function Q4e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(o)}var q$=(t,e)=>{try{var n=document.getElementById(W$);n||(n=document.createElement("span"),n.setAttribute("id",W$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,Z4e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Dx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Nm.isSsr)return{width:0,height:0};if(!wQ.enableCache)return q$(e,n);var r=Q4e(e,n),i=G$.get(r);if(i)return i;var a=q$(e,n);return G$.set(r,a),a},X$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,K$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,J4e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,eUe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,MQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},tUe=Object.keys(MQ),Tp="NaN";function nUe(t,e){return t*MQ[e]}class La{static parse(e){var n,[,r,i]=(n=eUe.exec(e))!==null&&n!==void 0?n:[];return new La(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Ys(e)&&(this.unit=""),n!==""&&!J4e.test(n)&&(this.num=NaN,this.unit=""),tUe.includes(n)&&(this.num=nUe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new La(NaN,""):new La(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new La(NaN,""):new La(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new La(NaN,""):new La(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new La(NaN,""):new La(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Ys(this.num)}}function EQ(t){if(t.includes(Tp))return Tp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=X$.exec(e))!==null&&n!==void 0?n:[],s=La.parse(r??""),o=La.parse(a??""),l=i==="*"?s.multiply(o):s.divide(o);if(l.isNaN())return Tp;e=e.replace(X$,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,u,f,g]=(c=K$.exec(e))!==null&&c!==void 0?c:[],m=La.parse(u??""),y=La.parse(g??""),v=f==="+"?m.add(y):m.subtract(y);if(v.isNaN())return Tp;e=e.replace(K$,v.toString())}return e}var Y$=/\(([^()]*)\)/;function rUe(t){for(var e=t,n;(n=Y$.exec(e))!=null;){var[,r]=n;e=e.replace(Y$,EQ(r))}return e}function iUe(t){var e=t.replace(/\s+/g,"");return e=rUe(e),e=EQ(e),e}function aUe(t){try{return iUe(t)}catch{return Tp}}function ZC(t){var e=aUe(t.slice(5,-1));return e===Tp?"":e}var sUe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],oUe=["dx","dy","angle","className","breakAll"];function dP(){return dP=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},dP.apply(null,arguments)}function Z$(t,e){if(t==null)return{};var n,r,i=lUe(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 lUe(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 AQ=/[ \f\n\r\t\v\u2028\u2029]+/,TQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];gr(e)||(n?i=e.toString().split(""):i=e.toString().split(AQ));var a=i.map(o=>({word:o,width:Dx(o,r).width})),s=n?0:Dx(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function cUe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var CQ=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:o}=a,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+n<Number(e)))l.words.push(s),l.width+=o+n;else{var c={words:[s],width:o};i.push(c)}return i},[]),NQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),uUe="…",Q$=(t,e,n,r,i,a,s,o)=>{var l=t.slice(0,e),c=TQ({breakAll:n,style:r,children:l+uUe});if(!c)return[!1,[]];var u=CQ(c.wordsWithComputedWidth,a,s,o),f=u.length>i||NQ(u).width>Number(a);return[f,u]},dUe=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:o,breakAll:l}=t,c=At(a),u=String(s),f=CQ(e,r,n,i);if(!c||i)return f;var g=f.length>a||NQ(f).width>Number(r);if(!g)return f;for(var m=0,y=u.length-1,v=0,b;m<=y&&v<=u.length-1;){var x=Math.floor((m+y)/2),M=x-1,[w,A]=Q$(u,M,l,o,a,r,n,i),[T]=Q$(u,x,l,o,a,r,n,i);if(!w&&!T&&(m=x+1),w&&T&&(y=x-1),!w&&T){b=A;break}v++}return b||f},J$=t=>{var e=gr(t)?[]:t.toString().split(AQ);return[{words:e,width:void 0}]},fUe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!Nm.isSsr){var o,l,c=TQ({breakAll:a,children:r,style:i});if(c){var{wordsWithComputedWidth:u,spaceWidth:f}=c;o=u,l=f}else return J$(r);return dUe({breakAll:a,children:r,maxLines:s,style:i},o,l,e,!!n)}return J$(r)},RQ="#808080",hUe={angle:0,breakAll:!1,capHeight:"0.71em",fill:RQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},hM=E.forwardRef((t,e)=>{var n=Yr(t,hUe),{x:r,y:i,lineHeight:a,capHeight:s,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:u}=n,f=Z$(n,sUe),g=E.useMemo(()=>fUe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:l,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,l,f.style,f.width]),{dx:m,dy:y,angle:v,className:b,breakAll:x}=f,M=Z$(f,oUe);if(!al(r)||!al(i)||g.length===0)return null;var w=Number(r)+(At(m)?m:0),A=Number(i)+(At(y)?y:0);if(!or(w)||!or(A))return null;var T;switch(u){case"start":T=ZC("calc(".concat(s,")"));break;case"middle":T=ZC("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=ZC("calc(".concat(g.length-1," * -").concat(a,")"));break}var R=[];if(l){var N=g[0].width,{width:j}=f;R.push("scale(".concat(At(j)&&At(N)?j/N:1,")"))}return v&&R.push("rotate(".concat(v,", ").concat(w,", ").concat(A,")")),R.length&&(M.transform=R.join(" ")),E.createElement("text",dP({},Ma(M),{ref:e,x:w,y:A,className:An("recharts-text",b),textAnchor:c,fill:o.includes("url")?RQ:o}),g.map((C,k)=>{var U=C.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:k===0?T:a,key:"".concat(U,"-").concat(k)},U)}))});hM.displayName="Text";var pUe=["labelRef"];function mUe(t,e){if(t==null)return{};var n,r,i=gUe(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 gUe(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 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 Pr(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){xUe(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 xUe(t,e,n){return(e=vUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vUe(t){var e=bUe(t,"string");return typeof e=="symbol"?e:e+""}function bUe(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 Ql(){return Ql=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},Ql.apply(null,arguments)}var PQ=E.createContext(null),yUe=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return E.createElement(PQ.Provider,{value:l},o)},kQ=()=>{var t=E.useContext(PQ),e=Vw();return t||YK(e)},_Ue=E.createContext(null),SUe=()=>{var t=E.useContext(_Ue),e=Tt(SZ);return t||e},wUe=t=>{var{value:e,formatter:n}=t,r=gr(t.children)?e:t.children;return typeof n=="function"?n(r):r},$O=t=>t!=null&&typeof t=="function",MUe=(t,e)=>{var n=Ti(e-t),r=Math.min(Math.abs(e-t),360);return n*r},EUe=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:o,cy:l,innerRadius:c,outerRadius:u,startAngle:f,endAngle:g,clockWise:m}=i,y=(c+u)/2,v=MUe(f,g),b=v>=0?1:-1,x,M;switch(e){case"insideStart":x=f+b*a,M=m;break;case"insideEnd":x=g-b*a,M=!m;break;case"end":x=g+b*a,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=v<=0?M:!M;var w=Gr(o,l,y,x),A=Gr(o,l,y,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
  8216. A`).concat(y,",").concat(y,",0,1,").concat(M?0:1,`,
  8217. `).concat(A.x,",").concat(A.y),R=gr(t.id)?h0("recharts-radial-line-"):t.id;return E.createElement("text",Ql({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",s)}),E.createElement("defs",null,E.createElement("path",{id:R,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(R)},n))},AUe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:u,y:f}=Gr(r,i,s+e,c);return{x:u,y:f,textAnchor:u>=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 g=(a+s)/2,{x:m,y}=Gr(r,i,g,c);return{x:m,y,textAnchor:"middle",verticalAnchor:"middle"}},fP=t=>"cx"in t&&At(t.cx),TUe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!fP(n)&&(a=n);var{x:s,y:o,upperWidth:l,lowerWidth:c,height:u}=e,f=s,g=s+(l-c)/2,m=(f+g)/2,y=(l+c)/2,v=f+l/2,b=u>=0?1:-1,x=b*r,M=b>0?"end":"start",w=b>0?"start":"end",A=l>=0?1:-1,T=A*r,R=A>0?"end":"start",N=A>0?"start":"end";if(i==="top"){var j={x:f+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Pr(Pr({},j),a?{height:Math.max(o-a.y,0),width:l}:{})}if(i==="bottom"){var C={x:g+c/2,y:o+u+x,textAnchor:"middle",verticalAnchor:w};return Pr(Pr({},C),a?{height:Math.max(a.y+a.height-(o+u),0),width:c}:{})}if(i==="left"){var k={x:m-T,y:o+u/2,textAnchor:R,verticalAnchor:"middle"};return Pr(Pr({},k),a?{width:Math.max(k.x-a.x,0),height:u}:{})}if(i==="right"){var U={x:m+y+T,y:o+u/2,textAnchor:N,verticalAnchor:"middle"};return Pr(Pr({},U),a?{width:Math.max(a.x+a.width-U.x,0),height:u}:{})}var I=a?{width:y,height:u}:{};return i==="insideLeft"?Pr({x:m+T,y:o+u/2,textAnchor:N,verticalAnchor:"middle"},I):i==="insideRight"?Pr({x:m+y-T,y:o+u/2,textAnchor:R,verticalAnchor:"middle"},I):i==="insideTop"?Pr({x:f+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},I):i==="insideBottom"?Pr({x:g+c/2,y:o+u-x,textAnchor:"middle",verticalAnchor:M},I):i==="insideTopLeft"?Pr({x:f+T,y:o+x,textAnchor:N,verticalAnchor:w},I):i==="insideTopRight"?Pr({x:f+l-T,y:o+x,textAnchor:R,verticalAnchor:w},I):i==="insideBottomLeft"?Pr({x:g+T,y:o+u-x,textAnchor:N,verticalAnchor:M},I):i==="insideBottomRight"?Pr({x:g+c-T,y:o+u-x,textAnchor:R,verticalAnchor:M},I):i&&typeof i=="object"&&(At(i.x)||vc(i.x))&&(At(i.y)||vc(i.y))?Pr({x:s+sa(i.x,y),y:o+sa(i.y,u),textAnchor:"end",verticalAnchor:"end"},I):Pr({x:v,y:o+u/2,textAnchor:"middle",verticalAnchor:"middle"},I)},CUe={angle:0,offset:5,zIndex:Wr.label,position:"middle",textBreakAll:!1};function Tu(t){var e=Yr(t,CUe),{viewBox:n,position:r,value:i,children:a,content:s,className:o="",textBreakAll:l,labelRef:c}=e,u=SUe(),f=kQ(),g=r==="center"?f:u??f,m,y,v;if(n==null?m=g:fP(n)?m=n:m=YK(n),!m||gr(i)&&gr(a)&&!E.isValidElement(s)&&typeof s!="function")return null;var b=Pr(Pr({},e),{},{viewBox:m});if(E.isValidElement(s)){var{labelRef:x}=b,M=mUe(b,pUe);return E.cloneElement(s,M)}if(typeof s=="function"){if(y=E.createElement(s,b),E.isValidElement(y))return y}else y=wUe(e);var w=Ma(e);if(fP(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return EUe(e,r,y,w,m);v=AUe(m,e.offset,e.position)}else v=TUe(e,m);return E.createElement(Wa,{zIndex:e.zIndex},E.createElement(hM,Ql({ref:c,className:An("recharts-label",o)},w,v,{textAnchor:cUe(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:l}),y))}Tu.displayName="Label";var NUe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Tu,Ql({key:"label-implicit"},r)):al(t)?E.createElement(Tu,Ql({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Tu?E.cloneElement(t,Pr({key:"label-implicit"},r)):E.createElement(Tu,Ql({key:"label-implicit",content:t},r)):$O(t)?E.createElement(Tu,Ql({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Tu,Ql({},t,{key:"label-implicit"},r)):null};function RUe(t){var{label:e,labelRef:n}=t,r=kQ();return NUe(e,r,n)||null}var QC={},JC={},tV;function PUe(){return tV||(tV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(JC)),JC}var eN={},nV;function kUe(){return nV||(nV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(eN)),eN}var rV;function DUe(){return rV||(rV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PUe(),n=kUe(),r=xD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(QC)),QC}var tN,iV;function OUe(){return iV||(iV=1,tN=DUe().last),tN}var LUe=OUe();const IUe=Js(LUe);var jUe=["valueAccessor"],UUe=["dataKey","clockWise","id","textBreakAll","zIndex"];function kS(){return kS=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},kS.apply(null,arguments)}function aV(t,e){if(t==null)return{};var n,r,i=FUe(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 FUe(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 zUe=t=>Array.isArray(t.value)?IUe(t.value):t.value,DQ=E.createContext(void 0),OQ=DQ.Provider,LQ=E.createContext(void 0),BUe=LQ.Provider;function HUe(){return E.useContext(DQ)}function $Ue(){return E.useContext(LQ)}function O_(t){var{valueAccessor:e=zUe}=t,n=aV(t,jUe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:o}=n,l=aV(n,UUe),c=HUe(),u=$Ue(),f=c||u;return!f||!f.length?null:E.createElement(Wa,{zIndex:o??Wr.label},E.createElement(Or,{className:"recharts-label-list"},f.map((g,m)=>{var y,v=gr(r)?e(g,m):Yn(g&&g.payload,r),b=gr(a)?{}:{id:"".concat(a,"-").concat(m)};return E.createElement(Tu,kS({key:"label-".concat(m)},Ma(g),l,b,{fill:(y=n.fill)!==null&&y!==void 0?y:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:m,zIndex:0}))})))}O_.displayName="LabelList";function VO(t){var{label:e}=t;return e?e===!0?E.createElement(O_,{key:"labelList-implicit"}):E.isValidElement(e)||$O(e)?E.createElement(O_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(O_,kS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function hP(){return hP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},hP.apply(null,arguments)}var IQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=An("recharts-dot",i);return At(e)&&At(n)&&At(r)?E.createElement("circle",hP({},$a(t),gD(t),{className:a,cx:e,cy:n,r})):null},jQ=t=>t.graphicalItems.polarItems,VUe=$e([fr,sv],fO),pM=$e([jQ,vr,VUe],hO),GUe=$e([pM],pO),mM=$e([GUe,nO],mO),WUe=$e([mM,vr,pM],xO);$e([mM,vr,pM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Yn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var sV=()=>{},qUe=$e([mM,vr,pM,uM,fr],_O),XUe=$e([vr,bO,yO,sV,qUe,sV,Sn,fr],SO),UQ=$e([vr,Sn,mM,WUe,av,fr,XUe],wO),KUe=$e([UQ,vr,Lm],AO);$e([vr,UQ,KUe,fr],CO);var YUe={radiusAxis:{},angleAxis:{}},FQ=Ga({name:"polarAxis",initialState:YUe,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:d9e,removeRadiusAxis:f9e,addAngleAxis:h9e,removeAngleAxis:p9e}=FQ.actions,ZUe=FQ.reducer;function oV(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 lV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oV(Object(n),!0).forEach(function(r){QUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QUe(t,e,n){return(e=JUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JUe(t){var e=eFe(t,"string");return typeof e=="symbol"?e:e+""}function eFe(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 tFe=(t,e)=>e,GO=$e([jQ,tFe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),nFe=[],WO=(t,e,n)=>n?.length===0?nFe:n,zQ=$e([nO,GO,WO],(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=>lV(lV({},e.presentationProps),a.props))),i!=null)return i}}),rFe=$e([zQ,GO,WO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Yn(r,e.nameKey,e.name),o;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Tm(s,e.dataKey),color:o,payload:r,type:e.legendType}})}),iFe=$e([zQ,GO,WO,ui],(t,e,n,r)=>{if(!(e==null||t==null))return aze({offset:r,pieSettings:e,displayedData:t,cells:n})}),nN={exports:{}},zn={};var cV;function aFe(){if(cV)return zn;cV=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"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function y(v){if(typeof v=="object"&&v!==null){var b=v.$$typeof;switch(b){case t:switch(v=v.type,v){case n:case i:case r:case l:case c:case g:return v;default:switch(v=v&&v.$$typeof,v){case s:case o:case f:case u:return v;case a:return v;default:return b}}case e:return b}}}return zn.ContextConsumer=a,zn.ContextProvider=s,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=f,zn.Memo=u,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(v){return y(v)===a},zn.isContextProvider=function(v){return y(v)===s},zn.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},zn.isForwardRef=function(v){return y(v)===o},zn.isFragment=function(v){return y(v)===n},zn.isLazy=function(v){return y(v)===f},zn.isMemo=function(v){return y(v)===u},zn.isPortal=function(v){return y(v)===e},zn.isProfiler=function(v){return y(v)===i},zn.isStrictMode=function(v){return y(v)===r},zn.isSuspense=function(v){return y(v)===l},zn.isSuspenseList=function(v){return y(v)===c},zn.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===l||v===c||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===u||v.$$typeof===s||v.$$typeof===a||v.$$typeof===o||v.$$typeof===m||v.getModuleId!==void 0)},zn.typeOf=y,zn}var uV;function sFe(){return uV||(uV=1,nN.exports=aFe()),nN.exports}var oFe=sFe(),dV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",fV=null,rN=null,BQ=t=>{if(t===fV&&Array.isArray(rN))return rN;var e=[];return E.Children.forEach(t,n=>{gr(n)||(oFe.isFragment(n)?e=e.concat(BQ(n.props.children)):e.push(n))}),rN=e,fV=t,e};function qO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>dV(i)):r=[dV(e)],BQ(t).forEach(i=>{var a=Ff(i,"type.displayName")||Ff(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var HQ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,iN={},hV;function lFe(){return hV||(hV=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})(iN)),iN}var aN,pV;function cFe(){return pV||(pV=1,aN=lFe().isPlainObject),aN}var uFe=cFe();const dFe=Js(uFe);function mV(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 gV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mV(Object(n),!0).forEach(function(r){fFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fFe(t,e,n){return(e=hFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hFe(t){var e=pFe(t,"string");return typeof e=="symbol"?e:e+""}function pFe(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 DS(){return DS=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},DS.apply(null,arguments)}var xV=(t,e,n,r,i)=>{var a=n-r,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+i),s+="L ".concat(t+n-a/2-r,",").concat(e+i),s+="L ".concat(t,",").concat(e," Z"),s},mFe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},gFe=t=>{var e=Yr(t,mFe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:u,isUpdateAnimationActive:f}=e,g=E.useRef(null),[m,y]=E.useState(-1),v=E.useRef(i),b=E.useRef(a),x=E.useRef(s),M=E.useRef(n),w=E.useRef(r),A=ev(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var O=g.current.getTotalLength();O&&y(O)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=An("recharts-trapezoid",o);if(!f)return E.createElement("g",null,E.createElement("path",DS({},Ma(e),{className:T,d:xV(n,r,i,a,s)})));var R=v.current,N=b.current,j=x.current,C=M.current,k=w.current,U="0px ".concat(m===-1?1:m,"px"),I="".concat(m,"px 0px"),H=uY(["strokeDasharray"],c,l);return E.createElement(J0,{animationId:A,key:A,canBegin:m>0,duration:c,easing:l,isActive:f,begin:u},O=>{var B=sr(R,i,O),V=sr(N,a,O),G=sr(j,s,O),K=sr(C,n,O),Y=sr(k,r,O);g.current&&(v.current=B,b.current=V,x.current=G,M.current=K,w.current=Y);var oe=O>0?{transition:H,strokeDasharray:I}:{strokeDasharray:U};return E.createElement("path",DS({},Ma(e),{className:T,d:xV(K,Y,B,V,G),ref:g,style:gV(gV({},oe),e.style)}))})},xFe=["option","shapeType","propTransformer","activeClassName"];function vFe(t,e){if(t==null)return{};var n,r,i=bFe(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 bFe(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 vV(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 OS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vV(Object(n),!0).forEach(function(r){yFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yFe(t,e,n){return(e=_Fe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Fe(t){var e=SFe(t,"string");return typeof e=="symbol"?e:e+""}function SFe(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 wFe(t,e){return OS(OS({},e),t)}function MFe(t,e){return t==="symbols"}function bV(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(pY,n);case"trapezoid":return E.createElement(gFe,n);case"sector":return E.createElement(vY,n);case"symbols":if(MFe(e))return E.createElement(mD,n);break;case"curve":return E.createElement(Fp,n);default:return null}}function EFe(t){return E.isValidElement(t)?t.props:t}function $Q(t){var{option:e,shapeType:n,propTransformer:r=wFe,activeClassName:i="recharts-active-shape"}=t,a=vFe(t,xFe),s;if(E.isValidElement(e))s=E.cloneElement(e,OS(OS({},a),EFe(e)));else if(typeof e=="function")s=e(a,a.index);else if(dFe(e)&&typeof e!="boolean"){var o=r(e,a);s=E.createElement(bV,{shapeType:n,elementProps:o})}else{var l=a;s=E.createElement(bV,{shapeType:n,elementProps:l})}return a.isActive?E.createElement(Or,{className:i},s):s}var XO=(t,e,n)=>{var r=er();return(i,a)=>s=>{t?.(i,a,s),r(JZ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},KO=t=>{var e=er();return(n,r)=>i=>{t?.(n,r,i),e(UIe())}},YO=(t,e,n)=>{var r=er();return(i,a)=>s=>{t?.(i,a,s),r(FIe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function ZO(t){var{tooltipEntrySettings:e}=t,n=er(),r=ca(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(OIe(e)):i.current!==e&&n(LIe({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(IIe(i.current)),i.current=null)},[n]),null}function VQ(t){var{legendPayload:e}=t,n=er(),r=ca(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(aY(e)):i.current!==e&&n(sY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(oY(i.current)),i.current=null)},[n]),null}function AFe(t){var{legendPayload:e}=t,n=er(),r=Tt(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(aY(e)):i.current!==e&&n(sY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(oY(i.current)),i.current=null)},[n]),null}var sN,TFe=()=>{var[t]=E.useState(()=>h0("uid-"));return t},CFe=(sN=cne.useId)!==null&&sN!==void 0?sN:TFe;function GQ(t,e){var n=CFe();return e||(t?"".concat(t,"-").concat(n):n)}var NFe=E.createContext(void 0),QO=t=>{var{id:e,type:n,children:r}=t,i=GQ("recharts-".concat(n),e);return E.createElement(NFe.Provider,{value:i},r(i))},RFe={cartesianItems:[],polarItems:[]},WQ=Ga({name:"graphicalItems",initialState:RFe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:cr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Mo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:cr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Mo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:cr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:cr()},removePolarGraphicalItem:{reducer(t,e){var n=Mo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:cr()}}}),{addCartesianGraphicalItem:PFe,replaceCartesianGraphicalItem:kFe,removeCartesianGraphicalItem:DFe,addPolarGraphicalItem:OFe,removePolarGraphicalItem:LFe}=WQ.actions,IFe=WQ.reducer,jFe=t=>{var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(PFe(t)):n.current!==t&&e(kFe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(DFe(n.current)),n.current=null)},[e]),null},qQ=E.memo(jFe);function UFe(t){var e=er();return E.useLayoutEffect(()=>(e(OFe(t)),()=>{e(LFe(t))}),[e,t]),null}var FFe=["key"],zFe=["onMouseEnter","onClick","onMouseLeave"],BFe=["id"],HFe=["id"];function yV(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 wr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yV(Object(n),!0).forEach(function(r){$Fe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Fe(t,e,n){return(e=VFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VFe(t){var e=GFe(t,"string");return typeof e=="symbol"?e:e+""}function GFe(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 sd(){return sd=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},sd.apply(null,arguments)}function gM(t,e){if(t==null)return{};var n,r,i=WFe(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 WFe(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 qFe(t){var e=E.useMemo(()=>qO(t.children,mv),[t.children]),n=Tt(r=>rFe(r,t.id,e));return n==null?null:E.createElement(AFe,{legendPayload:n})}var XFe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:o,hide:l,tooltipType:c}=t,u={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:Tm(o,e),hide:l,type:c,color:s,unit:""}};return E.createElement(ZO,{tooltipEntrySettings:u})}),KFe=(t,e)=>t>e?"start":t<e?"end":"middle",YFe=(t,e,n)=>sa(typeof e=="function"?e(t):e,n,n*.8),ZFe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,o=mY(a,s),l=i+sa(t.cx,a,a/2),c=r+sa(t.cy,s,s/2),u=sa(t.innerRadius,o,0),f=YFe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:f,maxRadius:g}},QFe=(t,e)=>{var n=Ti(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function JFe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var eze=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=gM(e,FFe);return E.createElement(Fp,sd({},i,{type:"linear",className:n}))},tze=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=An("recharts-pie-label-text",JFe(t));return E.createElement(hM,sd({},e,{alignmentBaseline:"middle",className:i}),r)};function nze(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var o=$a(n),l=Uf(i),c=Uf(a),u=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,m)=>{var y=(g.startAngle+g.endAngle)/2,v=Gr(g.cx,g.cy,g.outerRadius+u,y),b=wr(wr(wr(wr({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:KFe(v.x,g.cx)},v),x=wr(wr(wr(wr({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[Gr(g.cx,g.cy,g.outerRadius,y),v],key:"line"});return E.createElement(Wa,{zIndex:Wr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(Or,null,a&&eze(a,x),tze(i,b,Yn(g,s))))});return E.createElement(Or,{className:"recharts-pie-labels"},f)}function rze(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(VO,{label:i}):E.createElement(nze,{sectors:e,props:n,showLabels:r})}function ize(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,o=Tt(ad),l=Tt(jO),c=Tt(Mje),{onMouseEnter:u,onClick:f,onMouseLeave:g}=i,m=gM(i,zFe),y=XO(u,i.dataKey,s),v=KO(g),b=YO(f,i.dataKey,s);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===s,A=String(M)===o&&(l==null||i.dataKey===l)&&w,T=o?r:null,R=n&&A?n:T,N=wr(wr({},x),{},{stroke:x.stroke,tabIndex:-1,[GK]:M,[WK]:i.dataKey});return E.createElement(Or,sd({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},q0(m,x,M),{onMouseEnter:y(x,M),onMouseLeave:v(x,M),onClick:b(x,M)}),E.createElement($Q,sd({option:a??R,index:M,shapeType:"sector",isActive:A},N)))}))}function aze(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:l,dataKey:c,nameKey:u,tooltipType:f}=n,g=Math.abs(n.minAngle),m=QFe(o,l),y=Math.abs(m),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(R=>Yn(R,c,0)!==0).length,x=(y>=360?b:b-1)*v,M=y-b*g-x,w=r.reduce((R,N)=>{var j=Yn(N,c,0);return R+(At(j)?j:0)},0),A;if(w>0){var T;A=r.map((R,N)=>{var j=Yn(R,c,0),C=Yn(R,u,N),k=ZFe(n,a,R),U=(At(j)?j:0)/w,I,H=wr(wr({},R),i&&i[N]&&i[N].props);N?I=T.endAngle+Ti(m)*v*(j!==0?1:0):I=o;var O=I+Ti(m)*((j!==0?g:0)+U*M),B=(I+O)/2,V=(k.innerRadius+k.outerRadius)/2,G=[{name:C,value:j,payload:H,dataKey:c,type:f}],K=Gr(k.cx,k.cy,V,B);return T=wr(wr(wr(wr({},n.presentationProps),{},{percent:U,cornerRadius:typeof s=="string"?parseFloat(s):s,name:C,tooltipPayload:G,midAngle:B,middleRadius:V,tooltipPosition:K},H),k),{},{value:j,dataKey:c,startAngle:I,endAngle:O,payload:H,paddingAngle:Ti(m)*v}),T})}return A}function sze(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return E.createElement(BUe,{value:e?i:void 0},r)}function oze(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:u,onAnimationStart:f,onAnimationEnd:g}=e,m=ev(e,"recharts-pie-"),y=n.current,[v,b]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),M=E.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return E.createElement(sze,{showLabels:!v,sectors:i},E.createElement(J0,{animationId:m,begin:s,duration:o,isActive:a,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var A=[],T=i&&i[0],R=T?.startAngle;return i?.forEach((N,j)=>{var C=y&&y[j],k=j>0?Ff(N,"paddingAngle",0):0;if(C){var U=sr(C.endAngle-C.startAngle,N.endAngle-N.startAngle,w),I=wr(wr({},N),{},{startAngle:R+k,endAngle:R+U+k});A.push(I),R=I.endAngle}else{var{endAngle:H,startAngle:O}=N,B=sr(0,H-O,w),V=wr(wr({},N),{},{startAngle:R+k,endAngle:R+B+k});A.push(V),R=V.endAngle}}),n.current=A,E.createElement(Or,null,E.createElement(ize,{sectors:A,activeShape:c,inactiveShape:u,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(rze,{showLabels:!v,sectors:i,props:e}),e.children)}var lze={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:Wr.area};function cze(t){var{id:e}=t,n=gM(t,BFe),{hide:r,className:i,rootTabIndex:a}=t,s=E.useMemo(()=>qO(t.children,mv),[t.children]),o=Tt(u=>iFe(u,e,s)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(Or,{tabIndex:a,className:c})):E.createElement(Wa,{zIndex:t.zIndex},E.createElement(XFe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(Or,{tabIndex:a,className:c},E.createElement(oze,{props:wr(wr({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function XQ(t){var e=Yr(t,lze),{id:n}=e,r=gM(e,HFe),i=$a(r);return E.createElement(QO,{id:n,type:"pie"},a=>E.createElement(E.Fragment,null,E.createElement(UFe,{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}),E.createElement(qFe,sd({},r,{id:a})),E.createElement(cze,sd({},r,{id:a}))))}XQ.displayName="Pie";var uze=["points"];function _V(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 oN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_V(Object(n),!0).forEach(function(r){dze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_V(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dze(t,e,n){return(e=fze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fze(t){var e=hze(t,"string");return typeof e=="symbol"?e:e+""}function hze(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 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)}function pze(t,e){if(t==null)return{};var n,r,i=mze(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 mze(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 gze(t){var{option:e,dotProps:n,className:r}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var i=An(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=pze(a,uze);return E.createElement(IQ,LS({},o,{className:i}))}function xze(t,e){return t==null?!1:e?!0:t.length===1}function vze(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:o,clipPathId:l,zIndex:c=Wr.scatter}=t;if(!xze(e,n))return null;var u=HQ(n),f=X2e(n),g=e.map((y,v)=>{var b,x,M=oN(oN(oN({r:3},s),f),{},{index:v,cx:(b=y.x)!==null&&b!==void 0?b:void 0,cy:(x=y.y)!==null&&x!==void 0?x:void 0,dataKey:a,value:y.value,payload:y.payload,points:e});return E.createElement(gze,{key:"dot-".concat(v),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(l,")")),E.createElement(Wa,{zIndex:c},E.createElement(Or,LS({className:r},m),g))}function SV(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 wV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SV(Object(n),!0).forEach(function(r){bze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bze(t,e,n){return(e=yze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yze(t){var e=_ze(t,"string");return typeof e=="symbol"?e:e+""}function _ze(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 Sze={xAxis:{},yAxis:{},zAxis:{}},KQ=Ga({name:"cartesianAxis",initialState:Sze,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:cr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:cr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:cr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var s=[...a,r].slice(-3);t.yAxis[n]=wV(wV({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:wze,replaceXAxis:Mze,removeXAxis:Eze,addYAxis:Aze,replaceYAxis:Tze,removeYAxis:Cze,addZAxis:m9e,replaceZAxis:g9e,removeZAxis:x9e,updateYAxisWidth:Nze}=KQ.actions,Rze=KQ.reducer,Pze=$e([ui],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),kze=$e([Pze,Cc,Nc],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),JO=()=>Tt(kze),Dze=()=>Tt(Nje);function MV(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 lN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MV(Object(n),!0).forEach(function(r){Oze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oze(t,e,n){return(e=Lze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Lze(t){var e=Ize(t,"string");return typeof e=="symbol"?e:e+""}function Ize(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 jze=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var o={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},l=lN(lN(lN({},o),Uf(i)),gD(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(IQ,l),E.createElement(Or,{className:"recharts-active-dot",clipPath:s},c)};function EV(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Wr.activeDot}=t,o=Tt(ad),l=Dze();if(e==null||l==null)return null;var c=e.find(u=>l.includes(u.payload));return gr(c)?null:E.createElement(Wa,{zIndex:s},E.createElement(jze,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Uze="Invariant failed";function Fze(t,e){throw new Error(Uze)}var zze=["x","y"];function pP(){return pP=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},pP.apply(null,arguments)}function AV(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 rx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AV(Object(n),!0).forEach(function(r){Bze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Bze(t,e,n){return(e=Hze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hze(t){var e=$ze(t,"string");return typeof e=="symbol"?e:e+""}function $ze(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 Vze(t,e){if(t==null)return{};var n,r,i=Gze(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 Gze(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 Wze(t,e){var{x:n,y:r}=t,i=Vze(t,zze),a="".concat(n),s=parseInt(a,10),o="".concat(r),l=parseInt(o,10),c="".concat(e.height||i.height),u=parseInt(c,10),f="".concat(e.width||i.width),g=parseInt(f,10);return rx(rx(rx(rx(rx({},e),i),s?{x:s}:{}),l?{y:l}:{}),{},{height:u,width:g,name:e.name,radius:e.radius})}function IS(t){return E.createElement($Q,pP({shapeType:"rectangle",propTransformer:Wze,activeClassName:"recharts-active-bar"},t))}var qze=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(At(e))return e;var a=At(r)||gr(r);return a?e(r,i):(a||Fze(),n)}},Xze={},YQ=Ga({name:"errorBars",initialState:Xze,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:v9e,replaceErrorBar:b9e,removeErrorBar:y9e}=YQ.actions,Kze=YQ.reducer,Yze=["children"];function Zze(t,e){if(t==null)return{};var n,r,i=Qze(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 Qze(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 Jze={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},e5e=E.createContext(Jze);function t5e(t){var{children:e}=t,n=Zze(t,Yze);return E.createElement(e5e.Provider,{value:n},e)}function eL(t,e){var n,r,i=Tt(c=>Pc(c,t)),a=Tt(c=>kc(c,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Si.allowDataOverflow,o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:wi.allowDataOverflow,l=s||o;return{needClip:l,needClipX:s,needClipY:o}}function ZQ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=JO(),{needClipX:a,needClipY:s,needClip:o}=eL(e,n);if(!o||!i)return null;var{x:l,y:c,width:u,height:f}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:a?l:l-u/2,y:s?c:c-f/2,width:a?u:u*2,height:s?f:f*2}))}function n5e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&or(t.zIndex)?t.zIndex:e}var cN={exports:{}},uN={};var TV;function r5e(){if(TV)return uN;TV=1;var t=xm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,o=t.useDebugValue;return uN.useSyncExternalStoreWithSelector=function(l,c,u,f,g){var m=i(null);if(m.current===null){var y={hasValue:!1,value:null};m.current=y}else y=m.current;m=s(function(){function b(T){if(!x){if(x=!0,M=T,T=f(T),g!==void 0&&y.hasValue){var R=y.value;if(g(R,T))return w=R}return w=T}if(R=w,n(M,T))return R;var N=f(T);return g!==void 0&&g(R,N)?(M=T,R):(M=T,w=N)}var x=!1,M,w,A=u===void 0?null:u;return[function(){return b(c())},A===null?void 0:function(){return b(A())}]},[c,u,f,g]);var v=r(l,m[0],m[1]);return a(function(){y.hasValue=!0,y.value=v},[v]),o(v),v},uN}var CV;function i5e(){return CV||(CV=1,cN.exports=r5e()),cN.exports}i5e();function a5e(t){t()}function s5e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){a5e(()=>{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 NV={notify(){},get:()=>[]};function o5e(t,e){let n,r=NV,i=0,a=!1;function s(v){u();const b=r.subscribe(v);let x=!1;return()=>{x||(x=!0,b(),f())}}function o(){r.notify()}function l(){y.onStateChange&&y.onStateChange()}function c(){return a}function u(){i++,n||(n=t.subscribe(l),r=s5e())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=NV)}function g(){a||(a=!0,u())}function m(){a&&(a=!1,f())}const y={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return y}var l5e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",c5e=l5e(),u5e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",d5e=u5e(),f5e=()=>c5e||d5e?E.useLayoutEffect:E.useEffect,h5e=f5e();function RV(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function p5e(t,e){if(RV(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])||!RV(t[n[i]],e[n[i]]))return!1;return!0}var m5e=Symbol.for("react-redux-context"),g5e=typeof globalThis<"u"?globalThis:{};function x5e(){if(!E.createContext)return{};const t=g5e[m5e]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var v5e=x5e();function b5e(t){const{children:e,context:n,serverState:r,store:i}=t,a=E.useMemo(()=>{const l=o5e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),s=E.useMemo(()=>i.getState(),[i]);h5e(()=>{const{subscription:l}=a;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),s!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[a,s]);const o=n||v5e;return E.createElement(o.Provider,{value:a},e)}var y5e=b5e,_5e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function S5e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function xM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(_5e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!p5e(t[r],e[r]))return!1}else if(!S5e(t[r],e[r]))return!1;return!0}var w5e=["onMouseEnter","onMouseLeave","onClick"],M5e=["value","background","tooltipPosition"],E5e=["id"],A5e=["onMouseEnter","onClick","onMouseLeave"];function Mc(){return Mc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Mc.apply(null,arguments)}function PV(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 ma(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PV(Object(n),!0).forEach(function(r){T5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T5e(t,e,n){return(e=C5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C5e(t){var e=N5e(t,"string");return typeof e=="symbol"?e:e+""}function N5e(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){if(t==null)return{};var n,r,i=R5e(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 R5e(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 P5e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Tm(n,e),payload:t}]},k5e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Tm(a,e),hide:s,type:l,color:i,unit:o}};return E.createElement(ZO,{tooltipEntrySettings:c})});function D5e(t){var e=Tt(ad),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:l}=a,c=jS(a,w5e),u=XO(s,r),f=KO(o),g=YO(l,r);if(!i||n==null)return null;var m=Uf(i);return E.createElement(Wa,{zIndex:n5e(i,Wr.barBackground)},n.map((y,v)=>{var{value:b,background:x,tooltipPosition:M}=y,w=jS(y,M5e);if(!x)return null;var A=u(y,v),T=f(y,v),R=g(y,v),N=ma(ma(ma(ma(ma({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},x),m),q0(c,y,v)),{},{onMouseEnter:A,onMouseLeave:T,onClick:R,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return E.createElement(IS,Mc({key:"background-bar-".concat(v)},N))}))}function O5e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return ma(ma({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return E.createElement(OQ,{value:e?i:void 0},n)}function L5e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,o=Tt(ad),l=Tt(jO),c=n&&String(a)===o&&(l==null||s===l),u=c?n:e;return c?E.createElement(Wa,{zIndex:Wr.activeBar},E.createElement(IS,Mc({},r,{name:String(r.name)},i,{isActive:c,option:u,index:a,dataKey:s}))):E.createElement(IS,Mc({},r,{name:String(r.name)},i,{isActive:c,option:u,index:a,dataKey:s}))}function I5e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return E.createElement(IS,Mc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function j5e(t){var e,{data:n,props:r}=t,i=(e=$a(r))!==null&&e!==void 0?e:{},{id:a}=i,s=jS(i,E5e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:u,onClick:f,onMouseLeave:g}=r,m=jS(r,A5e),y=XO(u,l),v=KO(g),b=YO(f,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(Or,Mc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},q0(m,x,M),{onMouseEnter:y(x,M),onMouseLeave:v(x,M),onClick:b(x,M)}),c?E.createElement(L5e,{shape:o,activeBar:c,baseProps:s,entry:x,index:M,dataKey:l}):E.createElement(I5e,{shape:o,baseProps:s,entry:x,index:M,dataKey:l})))):null}function U5e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:u}=e,f=n.current,g=ev(e,"recharts-bar-"),[m,y]=E.useState(!1),v=!m,b=E.useCallback(()=>{typeof c=="function"&&c(),y(!1)},[c]),x=E.useCallback(()=>{typeof u=="function"&&u(),y(!0)},[u]);return E.createElement(O5e,{showLabels:v,rects:r},E.createElement(J0,{animationId:g,begin:s,duration:o,isActive:a,easing:l,onAnimationEnd:b,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((A,T)=>{var R=f&&f[T];if(R)return ma(ma({},A),{},{x:sr(R.x,A.x,M),y:sr(R.y,A.y,M),width:sr(R.width,A.width,M),height:sr(R.height,A.height,M)});if(i==="horizontal"){var N=sr(0,A.height,M),j=sr(A.stackedBarStart,A.y,M);return ma(ma({},A),{},{y:j,height:N})}var C=sr(0,A.width,M),k=sr(A.stackedBarStart,A.x,M);return ma(ma({},A),{},{width:C,x:k})});return M>0&&(n.current=w??null),w==null?null:E.createElement(Or,null,E.createElement(j5e,{props:e,data:w}))}),E.createElement(VO,{label:e.label}),e.children)}function F5e(t){var e=E.useRef(null);return E.createElement(U5e,{previousRectanglesRef:e,props:t})}var QQ=0,z5e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class B5e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var u=An("recharts-bar",i),f=c;return E.createElement(Or,{className:u,id:c},o&&E.createElement("defs",null,E.createElement(ZQ,{clipPathId:f,xAxisId:a,yAxisId:s})),E.createElement(Or,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},E.createElement(D5e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement(F5e,this.props)))}}var H5e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:QQ,xAxisId:0,yAxisId:0,zIndex:Wr.bar};function $5e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u}=t,{needClip:f}=eL(e,n),g=Cm(),m=ca(),y=qO(t.children,mv),v=Tt(M=>xBe(M,e,n,m,t.id,y));if(g!=="vertical"&&g!=="horizontal")return null;var b,x=v?.[0];return x==null||x.height==null||x.width==null?b=0:b=g==="vertical"?x.height/2:x.width/2,E.createElement(t5e,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:z5e,errorBarOffset:b},E.createElement(B5e,Mc({},t,{layout:g,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u})))}function V5e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:u,displayedData:f,offset:g,cells:m,parentViewBox:y,dataStartIndex:v}=t,b=e==="horizontal"?o:s,x=u?b.scale.domain():null,M=cRe({numericAxis:b}),w=b.scale(M);return f.map((A,T)=>{var R,N,j,C,k,U;u?R=iRe(u[T+v],x):(R=Yn(A,n),Array.isArray(R)||(R=[M,R]));var I=qze(r,QQ)(R[1],T);if(e==="horizontal"){var H,[O,B]=[o.scale(R[0]),o.scale(R[1])];N=q8({axis:s,ticks:l,bandSize:a,offset:i.offset,entry:A,index:T}),j=(H=B??O)!==null&&H!==void 0?H:void 0,C=i.size;var V=O-B;if(k=Ys(V)?0:V,U={x:N,y:g.top,width:C,height:g.height},Math.abs(I)>0&&Math.abs(k)<Math.abs(I)){var G=Ti(k||I)*(Math.abs(I)-Math.abs(k));j-=G,k+=G}}else{var[K,Y]=[s.scale(R[0]),s.scale(R[1])];if(N=K,j=q8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),C=Y-K,k=i.size,U={x:g.left,y:j,width:g.width,height:k},Math.abs(I)>0&&Math.abs(C)<Math.abs(I)){var oe=Ti(C||I)*(Math.abs(I)-Math.abs(C));C+=oe}}if(N==null||j==null||C==null||k==null)return null;var $=ma(ma({},A),{},{stackedBarStart:w,x:N,y:j,width:C,height:k,value:u?R:R[1],payload:A,background:U,tooltipPosition:{x:N+C/2,y:j+k/2},parentViewBox:y},m&&m[T]&&m[T].props);return $}).filter(Boolean)}function G5e(t){var e=Yr(t,H5e),n=ca();return E.createElement(QO,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(VQ,{legendPayload:P5e(e)}),E.createElement(k5e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(qQ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:$K(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Wa,{zIndex:e.zIndex},E.createElement($5e,Mc({},e,{id:r})))))}var JQ=E.memo(G5e,xM);JQ.displayName="Bar";function kV(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?kV(Object(n),!0).forEach(function(r){W5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W5e(t,e,n){return(e=q5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q5e(t){var e=X5e(t,"string");return typeof e=="symbol"?e:e+""}function X5e(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 K5e=(t,e)=>e,Y5e=(t,e,n)=>n,Z5e=(t,e,n,r)=>r,Q5e=(t,e,n,r,i)=>i,gv=$e([lM,Q5e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),J5e=$e([gv],t=>t?.maxBarSize),eBe=(t,e,n,r,i,a)=>a,DV=(t,e,n)=>{var r=n??t;if(!gr(r))return sa(r,e,0)},tBe=$e([Sn,lM,K5e,Y5e,Z5e],(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")),nBe=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?A0(t,"yAxis",n,r):A0(t,"xAxis",e,r)},rBe=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?A$(t,"xAxis",e):A$(t,"yAxis",n)},iBe=(t,e,n)=>{var r={},i=t.filter(aM),a=t.filter(c=>c.stackId==null),s=i.reduce((c,u)=>(c[u.stackId]||(c[u.stackId]=[]),c[u.stackId].push(u),c),r),o=Object.entries(s).map(c=>{var[u,f]=c,g=f.map(y=>y.dataKey),m=DV(e,n,f[0].barSize);return{stackId:u,dataKeys:g,barSize:m}}),l=a.map(c=>{var u=[c.dataKey].filter(g=>g!=null),f=DV(e,n,c.barSize);return{stackId:void 0,dataKeys:u,barSize:f}});return[...o,...l]},aBe=$e([tBe,ALe,rBe],iBe),sBe=(t,e,n,r,i)=>{var a,s,o=gv(t,e,n,r,i);if(o!=null){var l=Sn(t),c=pZ(t),{maxBarSize:u}=o,f=gr(u)?c:u,g,m;return l==="horizontal"?(g=id(t,"xAxis",e,r),m=rd(t,"xAxis",e,r)):(g=id(t,"yAxis",n,r),m=rd(t,"yAxis",n,r)),(a=(s=dm(g,m,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},eJ=(t,e,n,r)=>{var i=Sn(t),a,s;return i==="horizontal"?(a=id(t,"xAxis",e,r),s=rd(t,"xAxis",e,r)):(a=id(t,"yAxis",n,r),s=rd(t,"yAxis",n,r)),dm(a,s)};function oBe(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=sa(t,n,0,!0),o,l=[];if(or(r[0].barSize)){var c=!1,u=n/a,f=r.reduce((x,M)=>x+(M.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&u>0&&(c=!0,u*=.9,f=a*u);var g=(n-f)/2>>0,m={offset:g-s,size:0};o=r.reduce((x,M)=>{var w,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+s,size:c?u:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,A];return m=T[T.length-1].position,T},l)}else{var y=sa(e,n,0,!0);n-2*y-(a-1)*s<=0&&(s=0);var v=(n-2*y-(a-1)*s)/a;v>1&&(v>>=0);var b=or(i)?Math.min(v,i):v;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:y+(v+s)*w+(v-b)/2,size:b}}],l)}return o}}var lBe=(t,e,n,r,i,a,s)=>{var o=gr(s)?e:s,l=oBe(n,r,i!==a?i:a,t,o);return i!==a&&l!=null&&(l=l.map(c=>a_(a_({},c),{},{position:a_(a_({},c.position),{},{offset:c.position.offset-i/2})}))),l},cBe=$e([aBe,pZ,ELe,mZ,sBe,eJ,J5e],lBe),uBe=(t,e,n,r)=>id(t,"xAxis",e,r),dBe=(t,e,n,r)=>id(t,"yAxis",n,r),fBe=(t,e,n,r)=>rd(t,"xAxis",e,r),hBe=(t,e,n,r)=>rd(t,"yAxis",n,r),pBe=$e([cBe,gv],(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}}),mBe=(t,e)=>{var n=iM(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(s=>s.key===n)}}}},gBe=$e([nBe,gv],mBe),xBe=$e([ui,TD,uBe,dBe,fBe,hBe,pBe,Sn,tM,eJ,gBe,gv,eBe],(t,e,n,r,i,a,s,o,l,c,u,f,g)=>{var{chartData:m,dataStartIndex:y,dataEndIndex:v}=l;if(!(f==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||a==null||c==null)){var{data:b}=f,x;if(b!=null&&b.length>0?x=b:x=m?.slice(y,v+1),x!=null)return V5e({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:x,offset:t,cells:g,dataStartIndex:y})}}),tJ=t=>{var{chartData:e}=t,n=er(),r=ca();return E.useEffect(()=>r?()=>{}:(n(F$(e)),()=>{n(F$(void 0))}),[e,n,r]),null},OV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},nJ=Ga({name:"brush",initialState:OV,reducers:{setBrushSettings(t,e){return e.payload==null?OV:e.payload}}}),{setBrushSettings:_9e}=nJ.actions,vBe=nJ.reducer;function bBe(t,e,n){return(e=yBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yBe(t){var e=_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)}class tL{static create(e){return new tL(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}bBe(tL,"EPS",1e-4);function SBe(t){return(t%180+180)%180}var wBe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=SBe(i),s=a*Math.PI/180,o=Math.atan(r/n),l=s>o&&s<Math.PI-o?r/Math.sin(s):n/Math.cos(s);return Math.abs(l)},MBe={dots:[],areas:[],lines:[]},rJ=Ga({name:"referenceElements",initialState:MBe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Mo(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=Mo(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=Mo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:S9e,removeDot:w9e,addArea:M9e,removeArea:E9e,addLine:A9e,removeLine:T9e}=rJ.actions,EBe=rJ.reducer,ABe=E.createContext(void 0),TBe=t=>{var{children:e}=t,[n]=E.useState("".concat(h0("recharts"),"-clip")),r=JO();if(r==null)return null;var{x:i,y:a,width:s,height:o}=r;return E.createElement(ABe.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:a,height:o,width:s}))),e)};function iJ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function CBe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return wBe(r,n)}function NBe(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:o}=t;return e===1?{start:r?i:a,end:r?i+s:a+o}:{start:r?i+s:a+o,end:r?i:a}}function US(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 RBe(t,e){return iJ(t,e+1)}function PBe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:o}=e,l=0,c=1,u=s,f=function(){var y=r?.[l];if(y===void 0)return{v:iJ(r,c)};var v=l,b,x=()=>(b===void 0&&(b=n(y,v)),b),M=y.coordinate,w=l===0||US(t,M,x,u,o);w||(l=0,u=s,c+=1),w&&(u=M+t*(x()/2+i),l+=c)},g;c<=a.length;)if(g=f(),g)return g.v;return[]}function LV(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 na(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LV(Object(n),!0).forEach(function(r){kBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kBe(t,e,n){return(e=DBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DBe(t){var e=OBe(t,"string");return typeof e=="symbol"?e:e+""}function OBe(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 LBe(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:o}=e,{end:l}=e,c=function(g){var m=a[g],y,v=()=>(y===void 0&&(y=n(m,g)),y);if(g===s-1){var b=t*(m.coordinate+t*v()/2-l);a[g]=m=na(na({},m),{},{tickCoord:b>0?m.coordinate-b*t:m.coordinate})}else a[g]=m=na(na({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=US(t,m.tickCoord,v,o,l);x&&(l=m.tickCoord-t*(v()/2+i),a[g]=na(na({},m),{},{isShow:!0}))}},u=s-1;u>=0;u--)c(u);return a}function IBe(t,e,n,r,i,a){var s=(r||[]).slice(),o=s.length,{start:l,end:c}=e;if(a){var u=r[o-1],f=n(u,o-1),g=t*(u.coordinate+t*f/2-c);if(s[o-1]=u=na(na({},u),{},{tickCoord:g>0?u.coordinate-g*t:u.coordinate}),u.tickCoord!=null){var m=US(t,u.tickCoord,()=>f,l,c);m&&(c=u.tickCoord-t*(f/2+i),s[o-1]=na(na({},u),{},{isShow:!0}))}}for(var y=a?o-1:o,v=function(M){var w=s[M],A,T=()=>(A===void 0&&(A=n(w,M)),A);if(M===0){var R=t*(w.coordinate-t*T()/2-l);s[M]=w=na(na({},w),{},{tickCoord:R<0?w.coordinate-R*t:w.coordinate})}else s[M]=w=na(na({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=US(t,w.tickCoord,T,l,c);N&&(l=w.tickCoord+t*(T()/2+i),s[M]=na(na({},w),{},{isShow:!0}))}},b=0;b<y;b++)v(b);return s}function nL(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:o,interval:l,tickFormatter:c,unit:u,angle:f}=t;if(!i||!i.length||!r)return[];if(At(l)||Nm.isSsr){var g;return(g=RBe(i,At(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],y=o==="top"||o==="bottom"?"width":"height",v=u&&y==="width"?Dx(u,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(w,A)=>{var T=typeof c=="function"?c(w.value,A):w.value;return y==="width"?CBe(Dx(T,{fontSize:e,letterSpacing:n}),v,f):Dx(T,{fontSize:e,letterSpacing:n})[y]},x=i.length>=2?Ti(i[1].coordinate-i[0].coordinate):1,M=NBe(a,x,y);return l==="equidistantPreserveStart"?PBe(x,M,b,i,s):(l==="preserveStart"||l==="preserveStartEnd"?m=IBe(x,M,b,i,s,l==="preserveStartEnd"):m=LBe(x,M,b,i,s),m.filter(w=>w.isShow))}var jBe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(u=>{if(u){var f=u.getBoundingClientRect();f.width>s&&(s=f.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+a,c=s+l+o+(n?r:0);return Math.round(c)}return 0},UBe=["axisLine","width","height","className","hide","ticks","axisType"];function FBe(t,e){if(t==null)return{};var n,r,i=zBe(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 zBe(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 $f(){return $f=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},$f.apply(null,arguments)}function IV(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 Hr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IV(Object(n),!0).forEach(function(r){BBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function BBe(t,e,n){return(e=HBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HBe(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 hc={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:Wr.axis};function VBe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var c=Hr(Hr(Hr({},l),$a(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var u=+(a==="top"&&!s||a==="bottom"&&s);c=Hr(Hr({},c),{},{x1:e,y1:n+u*i,x2:e+r,y2:n+u*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);c=Hr(Hr({},c),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return E.createElement("line",$f({},c,{className:An("recharts-cartesian-axis-line",Ff(o,"className"))}))}function GBe(t,e,n,r,i,a,s,o,l){var c,u,f,g,m,y,v=o?-1:1,b=t.tickSize||s,x=At(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":c=u=t.coordinate,g=n+ +!o*i,f=g-v*b,y=f-v*l,m=x;break;case"left":f=g=t.coordinate,u=e+ +!o*r,c=u-v*b,m=c-v*l,y=x;break;case"right":f=g=t.coordinate,u=e+ +o*r,c=u+v*b,m=c+v*l,y=x;break;default:c=u=t.coordinate,g=n+ +o*i,f=g+v*b,y=f+v*l,m=x;break}return{line:{x1:c,y1:f,x2:u,y2:g},tick:{x:m,y}}}function WBe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function qBe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function XBe(t){var{option:e,tickProps:n,value:r}=t,i,a=An(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,Hr(Hr({},n),{},{className:a}));else if(typeof e=="function")i=e(Hr(Hr({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=An(s,e?.className)),i=E.createElement(hM,$f({},n,{className:s}),r)}return i}var KBe=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:o,padding:l,tickTextProps:c,orientation:u,mirror:f,x:g,y:m,width:y,height:v,tickSize:b,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:A,events:T,axisType:R}=t,N=nL(Hr(Hr({},A),{},{ticks:n}),M,w),j=WBe(u,f),C=qBe(u,f),k=$a(A),U=Uf(r),I={};typeof i=="object"&&(I=i);var H=Hr(Hr({},k),{},{fill:"none"},I),O=N.map(G=>Hr({entry:G},GBe(G,g,m,y,v,u,b,f,x))),B=O.map(G=>{var{entry:K,line:Y}=G;return E.createElement(Or,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},i&&E.createElement("line",$f({},H,Y,{className:An("recharts-cartesian-axis-tick-line",Ff(i,"className"))})))}),V=O.map((G,K)=>{var{entry:Y,tick:oe}=G,$=Hr(Hr(Hr(Hr({textAnchor:j,verticalAnchor:C},k),{},{stroke:"none",fill:a},U),oe),{},{index:K,payload:Y,visibleTicksCount:N.length,tickFormatter:s,padding:l},c);return E.createElement(Or,$f({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},q0(T,Y,K)),r&&E.createElement(XBe,{option:r,tickProps:$,value:"".concat(typeof s=="function"?s(Y.value,K):Y.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(R,"-ticks")},V.length>0&&E.createElement(Wa,{zIndex:Wr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(R,"-tick-labels"),ref:e},V)),B.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(R,"-tick-lines")},B))}),YBe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:o,axisType:l}=t,c=FBe(t,UBe),[u,f]=E.useState(""),[g,m]=E.useState(""),y=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return jBe({ticks:y.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=E.useCallback(b=>{if(b){var x=b.getElementsByClassName("recharts-cartesian-axis-tick-value");y.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),A=w.fontSize,T=w.letterSpacing;(A!==u||T!==g)&&(f(A),m(T))}}},[u,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Wa,{zIndex:t.zIndex},E.createElement(Or,{className:An("recharts-cartesian-axis",a)},E.createElement(VBe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:$a(t)}),E.createElement(KBe,{ref:v,axisType:l,events:c,fontSize:u,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement(yUe,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(RUe,{label:t.label,labelRef:t.labelRef}),t.children)))}),rL=E.forwardRef((t,e)=>{var n=Yr(t,hc);return E.createElement(YBe,$f({},n,{ref:e}))});rL.displayName="CartesianAxis";var ZBe=["x1","y1","x2","y2","key"],QBe=["offset"],JBe=["xAxisId","yAxisId"],eHe=["xAxisId","yAxisId"];function jV(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 ra(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jV(Object(n),!0).forEach(function(r){tHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tHe(t,e,n){return(e=nHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nHe(t){var e=rHe(t,"string");return typeof e=="symbol"?e:e+""}function rHe(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 cf(){return cf=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},cf.apply(null,arguments)}function FS(t,e){if(t==null)return{};var n,r,i=iHe(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 iHe(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 aHe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aJ(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:o,y2:l,key:c}=n,u=FS(n,ZBe),f=(i=$a(u))!==null&&i!==void 0?i:{},{offset:g}=f,m=FS(f,QBe);r=E.createElement("line",cf({},m,{x1:a,y1:s,x2:o,y2:l,fill:"none",key:c}))}return r}function sHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=FS(t,JBe),l=i.map((c,u)=>{var f=ra(ra({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(u),index:u});return E.createElement(aJ,{key:"line-".concat(u),option:r,lineItemProps:f})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function oHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=FS(t,eHe),l=i.map((c,u)=>{var f=ra(ra({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(u),index:u});return E.createElement(aJ,{option:r,lineItemProps:f,key:"line-".concat(u)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function lHe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==c[0]&&c.unshift(0);var u=c.map((f,g)=>{var m=!c[g+1],y=m?i+s-f:c[g+1]-f;if(y<=0)return null;var v=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:y,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function cHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==c[0]&&c.unshift(0);var u=c.map((f,g)=>{var m=!c[g+1],y=m?i+s-f:c[g+1]-f;if(y<=0)return null;var v=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:y,height:o,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var uHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return BK(nL(ra(ra(ra({},hc),n),{},{ticks:HK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},dHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return BK(nL(ra(ra(ra({},hc),n),{},{ticks:HK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},fHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Wr.grid};function mP(t){var e=ND(),n=RD(),r=ZK(),i=ra(ra({},Yr(t,fHe)),{},{x:At(t.x)?t.x:r.left,y:At(t.y)?t.y:r.top,width:At(t.width)?t.width:r.width,height:At(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:o,y:l,width:c,height:u,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,y=ca(),v=Tt(C=>T$(C,"xAxis",a,y)),b=Tt(C=>T$(C,"yAxis",s,y));if(!sl(c)||!sl(u)||!At(o)||!At(l))return null;var x=i.verticalCoordinatesGenerator||uHe,M=i.horizontalCoordinatesGenerator||dHe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof M=="function"){var T=g&&g.length,R=M({yAxis:b?ra(ra({},b),{},{ticks:T?g:b.ticks}):void 0,width:e??c,height:n??u,offset:r},T?!0:f);uS(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(w=R)}if((!A||!A.length)&&typeof x=="function"){var N=m&&m.length,j=x({xAxis:v?ra(ra({},v),{},{ticks:N?m:v.ticks}):void 0,width:e??c,height:n??u,offset:r},N?!0:f);uS(Array.isArray(j),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(A=j)}return E.createElement(Wa,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(aHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(lHe,cf({},i,{horizontalPoints:w})),E.createElement(cHe,cf({},i,{verticalPoints:A})),E.createElement(sHe,cf({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:b})),E.createElement(oHe,cf({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:b}))))}mP.displayName="CartesianGrid";function hHe(t){var e=Uf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=r),{r:s,strokeWidth:o}}return{r:n,strokeWidth:r}}var sJ=(t,e,n,r)=>id(t,"xAxis",e,r),oJ=(t,e,n,r)=>rd(t,"xAxis",e,r),lJ=(t,e,n,r)=>id(t,"yAxis",n,r),cJ=(t,e,n,r)=>rd(t,"yAxis",n,r),pHe=$e([Sn,sJ,lJ,oJ,cJ],(t,e,n,r,i)=>Tc(t,"xAxis")?dm(e,r,!1):dm(n,i,!1)),mHe=(t,e,n,r,i)=>i,uJ=$e([lM,mHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),gHe=(t,e,n,r,i)=>{var a,s=uJ(t,e,n,r,i);if(s!=null){var o=Sn(t),l=Tc(o,"xAxis"),c;if(l?c=A0(t,"yAxis",n,r):c=A0(t,"xAxis",e,r),c!=null){var{stackId:u}=s,f=iM(s);if(!(u==null||f==null)){var g=(a=c[u])===null||a===void 0?void 0:a.stackedData;return g?.find(m=>m.key===f)}}}},xHe=$e([Sn,sJ,lJ,oJ,cJ,gHe,tM,pHe,uJ,TLe],(t,e,n,r,i,a,s,o,l,c)=>{var{chartData:u,dataStartIndex:f,dataEndIndex:g}=s;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,y;if(m&&m.length>0?y=m:y=u?.slice(f,g+1),y!=null)return IHe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:l,stackedData:a,displayedData:y,chartBaseValue:c,bandSize:o})}}),vHe=["id"],bHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Sf(){return Sf=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},Sf.apply(null,arguments)}function dJ(t,e){if(t==null)return{};var n,r,i=yHe(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 yHe(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 UV(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 Cp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UV(Object(n),!0).forEach(function(r){_He(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _He(t,e,n){return(e=SHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SHe(t){var e=wHe(t,"string");return typeof e=="symbol"?e:e+""}function wHe(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 zS(t,e){return t&&t!=="none"?t:e}var MHe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:zS(r,i),value:Tm(n,e),payload:t}]},EHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Tm(s,e),hide:o,type:c,color:zS(r,a),unit:l}};return E.createElement(ZO,{tooltipEntrySettings:u})});function AHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,o=$a(r);return E.createElement(vze,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:i,clipPathId:e})}function THe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,o,l={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Cp(Cp({},l),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(OQ,{value:e?i:void 0},n)}function FV(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:o,stroke:l,connectNulls:c,isRange:u}=a,{id:f}=a,g=dJ(a,vHe),m=$a(g),y=Ma(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(Or,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Fp,Sf({},y,{id:f,points:e,connectNulls:c,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Fp,Sf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&u&&E.createElement(Fp,Sf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(AHe,{points:e,props:g,clipPathId:i}))}function CHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!or(a)||!or(s))return null;var o=e*Math.abs(a-s),l=Math.max(...r.map(c=>c.x||0));return At(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),At(l)?E.createElement("rect",{x:0,y:a<s?a:a-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function NHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!or(a)||!or(s))return null;var o=e*Math.abs(a-s),l=Math.max(...r.map(c=>c.y||0));return At(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),At(l)?E.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function RHe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?E.createElement(CHe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):E.createElement(NHe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function PHe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:u,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,y=E.useMemo(()=>({points:s,baseLine:o}),[s,o]),v=ev(y,"recharts-area-"),b=GRe(),[x,M]=E.useState(!1),w=!x,A=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(b==null)return null;var R=i.current,N=a.current;return E.createElement(THe,{showLabels:w,points:s},r.children,E.createElement(J0,{animationId:v,begin:c,duration:u,isActive:l,easing:f,onAnimationEnd:A,onAnimationStart:T,key:v},j=>{if(R){var C=R.length/s.length,k=j===1?s:s.map((I,H)=>{var O=Math.floor(H*C);if(R[O]){var B=R[O];return Cp(Cp({},I),{},{x:sr(B.x,I.x,j),y:sr(B.y,I.y,j)})}return I}),U;return At(o)?U=sr(N,o,j):gr(o)||Ys(o)?U=sr(N,0,j):U=o.map((I,H)=>{var O=Math.floor(H*C);if(Array.isArray(N)&&N[O]){var B=N[O];return Cp(Cp({},I),{},{x:sr(B.x,I.x,j),y:sr(B.y,I.y,j)})}return I}),j>0&&(i.current=k,a.current=U),E.createElement(FV,{points:k,baseLine:U,needClip:e,clipPathId:n,props:r})}return j>0&&(i.current=s,a.current=o),E.createElement(Or,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(RHe,{alpha:j,points:s,baseLine:o,layout:b,strokeWidth:r.strokeWidth}))),E.createElement(Or,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(FV,{points:s,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(VO,{label:r.label}))}function kHe(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),a=E.useRef();return E.createElement(PHe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class DHe extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:o,xAxisId:l,yAxisId:c,width:u,height:f,id:g,baseLine:m,zIndex:y}=this.props;if(e)return null;var v=An("recharts-area",i),b=g,{r:x,strokeWidth:M}=hHe(n),w=HQ(n),A=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return E.createElement(Wa,{zIndex:y},E.createElement(Or,{className:v},o&&E.createElement("defs",null,E.createElement(ZQ,{clipPathId:b,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(b)},E.createElement("rect",{x:s-A/2,y:a-A/2,width:u+A,height:f+A}))),E.createElement(kHe,{needClip:o,clipPathId:b,props:this.props})),E.createElement(EV,{points:r,mainColor:zS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(EV,{points:m,mainColor:zS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var fJ={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:Wr.area};function OHe(t){var e,n=Yr(t,fJ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:l,fill:c,fillOpacity:u,hide:f,isAnimationActive:g,legendType:m,stroke:y,xAxisId:v,yAxisId:b}=n,x=dJ(n,bHe),M=Cm(),w=mQ(),{needClip:A}=eL(v,b),T=ca(),{points:R,isRange:N,baseLine:j}=(e=Tt(O=>xHe(O,v,b,T,t.id)))!==null&&e!==void 0?e:{},C=JO();if(M!=="horizontal"&&M!=="vertical"||C==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:k,width:U,x:I,y:H}=C;return!R||!R.length?null:E.createElement(DHe,Sf({},x,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:j,connectNulls:o,dot:l,fill:c,fillOpacity:u,height:k,hide:f,layout:M,isAnimationActive:g==="auto"?!Nm.isSsr:g,isRange:N,legendType:m,needClip:A,points:R,stroke:y,width:U,left:I,top:H,xAxisId:v,yAxisId:b}))}var LHe=(t,e,n,r,i)=>{var a=n??e;if(At(a))return a;var s=t==="horizontal"?i:r,o=s.scale.domain();if(s.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return a==="dataMin"?c:a==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function IHe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:u,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,y=i&&i.length,v=LHe(a,s,n,o,l),b=a==="horizontal",x=!1,M=c.map((A,T)=>{var R;y?R=i[u+T]:(R=Yn(A,r),Array.isArray(R)?x=!0:R=[v,R]);var N=R[1]==null||y&&!e&&Yn(A,r)==null;return b?{x:W8({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:N?null:l.scale(R[1]),value:R,payload:A}:{x:N?null:o.scale(R[1]),y:W8({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:R,payload:A}}),w;return y||x?w=M.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:T!=null&&A.y!=null?l.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):w=b?l.scale(v):o.scale(v),{points:M,baseLine:w,isRange:x}}function jHe(t){var e=Yr(t,fJ),n=ca();return E.createElement(QO,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(VQ,{legendPayload:MHe(e)}),E.createElement(EHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(qQ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:$K(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(OHe,Sf({},e,{id:r}))))}var hJ=E.memo(jHe,xM);hJ.displayName="Area";var UHe=["domain","range"],FHe=["domain","range"];function zV(t,e){if(t==null)return{};var n,r,i=zHe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function zHe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function BV(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 pJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=zV(t,UHe),{domain:a,range:s}=e,o=zV(e,FHe);return!BV(n,a)||!BV(r,s)?!1:xM(i,o)}var BHe=["dangerouslySetInnerHTML","ticks"],HHe=["id"];function gP(){return gP=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},gP.apply(null,arguments)}function HV(t,e){if(t==null)return{};var n,r,i=$He(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 $He(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 VHe(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(wze(t)):n.current!==t&&e(Mze({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(Eze(n.current)),n.current=null)},[e]),null}var GHe=t=>{var{xAxisId:e,className:n}=t,r=Tt(TD),i=ca(),a="xAxis",s=Tt(b=>Im(b,a,e,i)),o=Tt(b=>qZ(b,a,e,i)),l=Tt(b=>$Z(b,e)),c=Tt(b=>MIe(b,e)),u=Tt(b=>MZ(b,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=HV(t,BHe),{id:y}=u,v=HV(u,HHe);return E.createElement(rL,gP({},m,v,{scale:s,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},WHe={allowDataOverflow:Si.allowDataOverflow,allowDecimals:Si.allowDecimals,allowDuplicatedCategory:Si.allowDuplicatedCategory,angle:Si.angle,axisLine:hc.axisLine,height:Si.height,hide:!1,includeHidden:Si.includeHidden,interval:Si.interval,minTickGap:Si.minTickGap,mirror:Si.mirror,orientation:Si.orientation,padding:Si.padding,reversed:Si.reversed,scale:Si.scale,tick:Si.tick,tickCount:Si.tickCount,tickLine:hc.tickLine,tickSize:hc.tickSize,type:Si.type,xAxisId:0},qHe=t=>{var e=Yr(t,WHe);return E.createElement(E.Fragment,null,E.createElement(VHe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(GHe,e))},xP=E.memo(qHe,pJ);xP.displayName="XAxis";var XHe=["dangerouslySetInnerHTML","ticks"],KHe=["id"];function vP(){return vP=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},vP.apply(null,arguments)}function $V(t,e){if(t==null)return{};var n,r,i=YHe(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 YHe(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 ZHe(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(Aze(t)):n.current!==t&&e(Tze({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(Cze(n.current)),n.current=null)},[e]),null}var QHe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=E.useRef(null),s=E.useRef(null),o=Tt(TD),l=ca(),c=er(),u="yAxis",f=Tt(T=>Im(T,u,e,l)),g=Tt(T=>VZ(T,e)),m=Tt(T=>AIe(T,e)),y=Tt(T=>qZ(T,u,e,l)),v=Tt(T=>EZ(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||$O(i)||E.isValidElement(i)||v==null)){var T=a.current;if(T){var R=T.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&c(Nze({id:e,width:R}))}}},[y,g,c,i,e,r,v]),g==null||m==null||v==null)return null;var{dangerouslySetInnerHTML:b,ticks:x}=t,M=$V(t,XHe),{id:w}=v,A=$V(v,KHe);return E.createElement(rL,vP({},M,A,{ref:a,labelRef:s,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(u," ").concat(u),n),viewBox:o,ticks:y,axisType:u}))},JHe={allowDataOverflow:wi.allowDataOverflow,allowDecimals:wi.allowDecimals,allowDuplicatedCategory:wi.allowDuplicatedCategory,angle:wi.angle,axisLine:hc.axisLine,hide:!1,includeHidden:wi.includeHidden,interval:wi.interval,minTickGap:wi.minTickGap,mirror:wi.mirror,orientation:wi.orientation,padding:wi.padding,reversed:wi.reversed,scale:wi.scale,tick:wi.tick,tickCount:wi.tickCount,tickLine:hc.tickLine,tickSize:hc.tickSize,type:wi.type,width:wi.width,yAxisId:0},e8e=t=>{var e=Yr(t,JHe);return E.createElement(E.Fragment,null,E.createElement(ZHe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(QHe,e))},bP=E.memo(e8e,pJ);bP.displayName="YAxis";var t8e=(t,e)=>e,iL=$e([t8e,Sn,SZ,fi,cQ,Dc,Bje,ui],Xje),aL=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)}},mJ=Zs("mouseClick"),gJ=Y0();gJ.startListening({actionCreator:mJ,effect:(t,e)=>{var n=t.payload,r=iL(e.getState(),aL(n));r?.activeIndex!=null&&e.dispatch(zIe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var yP=Zs("mouseMove"),xJ=Y0(),s_=null;xJ.startListening({actionCreator:yP,effect:(t,e)=>{var n=t.payload;s_!==null&&cancelAnimationFrame(s_);var r=aL(n);s_=requestAnimationFrame(()=>{var i=e.getState(),a=PO(i,i.tooltip.settings.shared);if(a==="axis"){var s=iL(i,r);s?.activeIndex!=null?e.dispatch(tQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(eQ())}s_=null})}});var VV={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},vJ=Ga({name:"rootProps",initialState:VV,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:VV.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}}}),n8e=vJ.reducer,{updateOptions:r8e}=vJ.actions,bJ=Ga({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:i8e}=bJ.actions,a8e=bJ.reducer,yJ=Zs("keyDown"),_J=Zs("focus"),sL=Y0();sL.startListening({actionCreator:yJ,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 s=kO(i,Um(n),cv(n),hv(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var l=Dc(n);if(a==="Enter"){var c=PS(n,"axis","hover",String(i.index));e.dispatch(lP({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var u=RIe(n),f=u==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,m=o+g*f;if(!(l==null||m>=l.length||m<0)){var y=PS(n,"axis","hover",String(m));e.dispatch(lP({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:y}))}}}}}});sL.startListening({actionCreator:_J,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",s=PS(n,"axis","hover",String(a));e.dispatch(lP({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Ps=Zs("externalEvent"),SJ=Y0(),dN=new Map;SJ.startListening({actionCreator:Ps,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=dN.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:Aje(o),activeDataKey:jO(o),activeIndex:ad(o),activeLabel:fQ(o),activeTooltipIndex:ad(o),isTooltipActive:Tje(o)};n(l,r)}finally{dN.delete(i)}});dN.set(i,s)}}});var s8e=$e([jm],t=>t.tooltipItemPayloads),o8e=$e([s8e,dv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),wJ=Zs("touchMove"),MJ=Y0();MJ.startListening({actionCreator:wJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=PO(r,r.tooltip.settings.shared);if(i==="axis"){var a=iL(r,aL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(tQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(GK),u=(s=l.getAttribute(WK))!==null&&s!==void 0?s:void 0,f=o8e(e.getState(),c,u);e.dispatch(JZ({activeDataKey:u,activeIndex:c,activeCoordinate:f}))}}}});var l8e=fK({brush:vBe,cartesianAxis:Rze,chartData:E4e,errorBars:Kze,graphicalItems:IFe,layout:Q3e,legend:sPe,options:y4e,polarAxis:ZUe,polarOptions:a8e,referenceElements:EBe,rootProps:n8e,tooltip:BIe,zIndex:l4e}),c8e=function(e){return w3e({reducer:l8e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([gJ.middleware,xJ.middleware,sL.middleware,SJ.middleware,MJ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(TK({type:"raf"}))},devTools:Nm.devToolsEnabled})};function EJ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ca(),a=E.useRef(null);if(i)return n;a.current==null&&(a.current=c8e(e));var s=vD;return E.createElement(y5e,{context:s,store:a.current},n)}function u8e(t){var{layout:e,margin:n}=t,r=er(),i=ca();return E.useEffect(()=>{i||(r(K3e(e)),r(X3e(n)))},[r,i,e,n]),null}var AJ=E.memo(u8e,xM);function TJ(t){var e=er();return E.useEffect(()=>{e(r8e(t))},[e,t]),null}function GV(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=GQ("".concat(r).concat(e)),a=er();return E.useLayoutEffect(()=>(a(s4e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(o4e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function WV(t){var{children:e,isPanorama:n}=t,r=Tt(Yje);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return E.createElement(E.Fragment,null,i.map(s=>E.createElement(GV,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>E.createElement(GV,{key:s,zIndex:s,isPanorama:n})))}var d8e=["children"];function f8e(t,e){if(t==null)return{};var n,r,i=h8e(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 h8e(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 BS(){return BS=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},BS.apply(null,arguments)}var p8e={width:"100%",height:"100%",display:"block"},m8e=E.forwardRef((t,e)=>{var n=ND(),r=RD(),i=cY();if(!sl(n)||!sl(r))return null;var{children:a,otherAttributes:s,title:o,desc:l}=t,c,u;return s!=null&&(typeof s.tabIndex=="number"?c=s.tabIndex:c=i?0:void 0,typeof s.role=="string"?u=s.role:u=i?"application":void 0),E.createElement(lD,BS({},s,{title:o,desc:l,role:u,tabIndex:c,width:n,height:r,style:p8e,ref:e}),a)}),g8e=t=>{var{children:e}=t,n=Tt($w);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return E.createElement(lD,{width:r,height:i,x:s,y:a},e)},qV=E.forwardRef((t,e)=>{var{children:n}=t,r=f8e(t,d8e),i=ca();return i?E.createElement(g8e,null,E.createElement(WV,{isPanorama:!0},n)):E.createElement(m8e,BS({ref:e},r),E.createElement(WV,{isPanorama:!1},n))});function x8e(){var t=er(),[e,n]=E.useState(null),r=Tt(mRe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;or(a)&&a!==r&&t(Z3e(a))}},[e,t,r]),n}function XV(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 v8e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XV(Object(n),!0).forEach(function(r){b8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function b8e(t,e,n){return(e=y8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y8e(t){var e=_8e(t,"string");return typeof e=="symbol"?e:e+""}function _8e(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 Vf(){return Vf=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},Vf.apply(null,arguments)}var S8e=()=>(O4e(),null);function HS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var w8e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[a,s]=E.useState({containerWidth:HS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:HS((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,u)=>{s(f=>{var g=Math.round(c),m=Math.round(u);return f.containerWidth===g&&f.containerHeight===m?f:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:u,height:f}=c.getBoundingClientRect();o(u,f);var g=y=>{var{width:v,height:b}=y[0].contentRect;o(v,b)},m=new ResizeObserver(g);m.observe(c),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var c=i.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(Gw,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",Vf({ref:l},t)))}),M8e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=E.useState({containerWidth:HS(n),containerHeight:HS(r)}),s=E.useCallback((l,c)=>{a(u=>{var f=Math.round(l),g=Math.round(c);return u.containerWidth===f&&u.containerHeight===g?u:{containerWidth:f,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:u}=l.getBoundingClientRect();s(c,u)}},[e,s]);return E.createElement(E.Fragment,null,E.createElement(Gw,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Vf({ref:o},t)))}),E8e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(Gw,{width:n,height:r}),E.createElement("div",Vf({ref:e},t)))}),A8e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return vc(n)||vc(r)?E.createElement(M8e,Vf({},t,{ref:e})):E.createElement(E8e,Vf({},t,{ref:e}))});function T8e(t){return t===!0?w8e:A8e}var C8e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:f,onMouseUp:g,onTouchEnd:m,onTouchMove:y,onTouchStart:v,style:b,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,A=E.useRef(null),T=er(),[R,N]=E.useState(null),[j,C]=E.useState(null),k=x8e(),U=CD(),I=U?.width>0?U.width:x,H=U?.height>0?U.height:i,O=E.useCallback(he=>{k(he),typeof e=="function"&&e(he),N(he),C(he),he!=null&&(A.current=he)},[k,e,N,C]),B=E.useCallback(he=>{T(mJ(he)),T(Ps({handler:a,reactEvent:he}))},[T,a]),V=E.useCallback(he=>{T(yP(he)),T(Ps({handler:c,reactEvent:he}))},[T,c]),G=E.useCallback(he=>{T(eQ()),T(Ps({handler:u,reactEvent:he}))},[T,u]),K=E.useCallback(he=>{T(yP(he)),T(Ps({handler:f,reactEvent:he}))},[T,f]),Y=E.useCallback(()=>{T(_J())},[T]),oe=E.useCallback(he=>{T(yJ(he.key))},[T]),$=E.useCallback(he=>{T(Ps({handler:s,reactEvent:he}))},[T,s]),X=E.useCallback(he=>{T(Ps({handler:o,reactEvent:he}))},[T,o]),ae=E.useCallback(he=>{T(Ps({handler:l,reactEvent:he}))},[T,l]),ce=E.useCallback(he=>{T(Ps({handler:g,reactEvent:he}))},[T,g]),xe=E.useCallback(he=>{T(Ps({handler:v,reactEvent:he}))},[T,v]),te=E.useCallback(he=>{w&&T(wJ(he)),T(Ps({handler:y,reactEvent:he}))},[T,w,y]),ve=E.useCallback(he=>{T(Ps({handler:m,reactEvent:he}))},[T,m]),De=T8e(M);return E.createElement(yQ.Provider,{value:R},E.createElement(CX.Provider,{value:j},E.createElement(De,{width:I??b?.width,height:H??b?.height,className:An("recharts-wrapper",r),style:v8e({position:"relative",cursor:"default",width:I,height:H},b),onClick:B,onContextMenu:$,onDoubleClick:X,onFocus:Y,onKeyDown:oe,onMouseDown:ae,onMouseEnter:V,onMouseLeave:G,onMouseMove:K,onMouseUp:ce,onTouchEnd:ve,onTouchMove:te,onTouchStart:xe,ref:O},E.createElement(S8e,null),n)))}),N8e=["width","height","responsive","children","className","style","compact","title","desc"];function R8e(t,e){if(t==null)return{};var n,r,i=P8e(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 P8e(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 CJ=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:o,compact:l,title:c,desc:u}=t,f=R8e(t,N8e),g=$a(f);return l?E.createElement(E.Fragment,null,E.createElement(Gw,{width:n,height:r}),E.createElement(qV,{otherAttributes:g,title:c,desc:u},a)):E.createElement(C8e,{className:s,style:o,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},E.createElement(qV,{otherAttributes:g,title:c,desc:u,ref:e},E.createElement(TBe,null,a)))});function _P(){return _P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_P.apply(null,arguments)}var k8e={top:5,right:5,bottom:5,left:5},D8e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:k8e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},NJ=E.forwardRef(function(e,n){var r,i=Yr(e.categoricalChartProps,D8e),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,u={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return E.createElement(EJ,{preloadedState:{options:u},reduxStoreName:(r=c.id)!==null&&r!==void 0?r:a},E.createElement(tJ,{chartData:c.data}),E.createElement(AJ,{layout:i.layout,margin:i.margin}),E.createElement(TJ,{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}),E.createElement(CJ,_P({},i,{ref:n})))}),O8e=["axis","item"],L8e=E.forwardRef((t,e)=>E.createElement(NJ,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:O8e,tooltipPayloadSearcher:HO,categoricalChartProps:t,ref:e}));function I8e(t){var e=er();return E.useEffect(()=>{e(i8e(t))},[e,t]),null}var j8e=["layout"];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 U8e(t,e){if(t==null)return{};var n,r,i=F8e(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 F8e(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 z8e={top:5,right:5,bottom:5,left:5},RJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:z8e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},B8e=E.forwardRef(function(e,n){var r,i=Yr(e.categoricalChartProps,RJ),{layout:a}=i,s=U8e(i,j8e),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u}=e,f={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u,eventEmitter:void 0};return E.createElement(EJ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(tJ,{chartData:i.data}),E.createElement(AJ,{layout:a,margin:i.margin}),E.createElement(TJ,{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}),E.createElement(I8e,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(CJ,SP({},s,{ref:n})))});function KV(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 YV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KV(Object(n),!0).forEach(function(r){H8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H8e(t,e,n){return(e=$8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $8e(t){var e=V8e(t,"string");return typeof e=="symbol"?e:e+""}function V8e(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 G8e=["item"],W8e=YV(YV({},RJ),{},{layout:"centric",startAngle:0,endAngle:360}),q8e=E.forwardRef((t,e)=>{var n=Yr(t,W8e);return E.createElement(B8e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:G8e,tooltipPayloadSearcher:HO,categoricalChartProps:n,ref:e})}),X8e=["axis"],K8e=E.forwardRef((t,e)=>E.createElement(NJ,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:X8e,tooltipPayloadSearcher:HO,categoricalChartProps:t,ref:e}));const o_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function Y8e(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 Z8e({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=Y8e(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),a=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const v=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],b=g.get(v)||{date:v,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(v,b)}),Array.from(g.values()).sort((m,y)=>m.date.localeCompare(y.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=E.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at),v=new Date(y);v.setDate(y.getDate()-y.getDay());const b=v.toISOString().split("T")[0],x=g.get(b)||{week:b,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(b,x)}),Array.from(g.values()).sort((m,y)=>m.week.localeCompare(y.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,a,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const v=(m.filament_type||"Unknown").split(", ");v.forEach(b=>{const x=(m.filament_used_grams||0)/v.length;g.set(b,(g.get(b)||0)+x)})}),Array.from(g.entries()).map(([m,y])=>({name:m,value:Math.round(y)})).sort((m,y)=>y.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let y=5;y>=0;y--){const v=new Date(g.getFullYear(),g.getMonth()-y,1),b=new Date(g.getFullYear(),g.getMonth()-y+1,0),x=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=v&&A<=b});m.push({month:x,filament:Math.round(M.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:M.reduce((w,A)=>w+(A.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?a:s,u=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),f=i.reduce((g,m)=>g+(m.cost||0),0);return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),h.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>h.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[(u/1e3).toFixed(2),"kg"]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.toFixed(0),"g total"]})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(u/i.length).toFixed(0):0,"g"]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),h.jsx(kC,{width:"100%",height:250,children:h.jsxs(K8e,{data:c,children:[h.jsx("defs",{children:h.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[h.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),h.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),h.jsx(mP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),h.jsx(xP,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),h.jsx(bP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),h.jsx(YC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),h.jsx(hJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):h.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx(kC,{width:160,height:160,children:h.jsxs(q8e,{children:[h.jsx(XQ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>h.jsx(mv,{fill:o_[m%o_.length]},`cell-${m}`))}),h.jsx(YC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),h.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const y=o.reduce((b,x)=>b+x.value,0),v=y>0?(g.value/y*100).toFixed(0):0;return h.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[h.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:o_[m%o_.length]}}),h.jsx("span",{className:"text-white truncate flex-1",children:g.name}),h.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},g.name)})})]}):h.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),h.jsx(kC,{width:"100%",height:200,children:h.jsxs(L8e,{data:l,children:[h.jsx(mP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),h.jsx(xP,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),h.jsx(bP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),h.jsx(YC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),h.jsx(lY,{}),h.jsx(JQ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function Q8e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const vM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function oL(t){return"nodeType"in t}function qa(t){var e,n;return t?Fm(t)?t:oL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function lL(t){const{Document:e}=qa(t);return t instanceof e}function xv(t){return Fm(t)?!1:t instanceof qa(t).HTMLElement}function PJ(t){return t instanceof qa(t).SVGElement}function zm(t){return t?Fm(t)?t.document:oL(t)?lL(t)?t:xv(t)||PJ(t)?t.ownerDocument:document:document:document}const ll=vM?E.useLayoutEffect:E.useEffect;function cL(t){const e=E.useRef(t);return ll(()=>{e.current=t}),E.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 J8e(){const t=E.useRef(null),e=E.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function C0(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return ll(()=>{n.current!==t&&(n.current=t)},e),n}function vv(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function $S(t){const e=cL(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function wP(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let fN={};function bv(t,e){return E.useMemo(()=>{if(e)return e;const n=fN[t]==null?0:fN[t]+1;return fN[t]=n,t+"-"+n},[t,e])}function kJ(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,s)=>{const o=Object.entries(s);for(const[l,c]of o){const u=a[l];u!=null&&(a[l]=u+t*c)}return a},{...e})}}const Bp=kJ(1),N0=kJ(-1);function e6e(t){return"clientX"in t&&"clientY"in t}function uL(t){if(!t)return!1;const{KeyboardEvent:e}=qa(t.target);return e&&t instanceof e}function t6e(t){if(!t)return!1;const{TouchEvent:e}=qa(t.target);return e&&t instanceof e}function MP(t){if(t6e(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 e6e(t)?{x:t.clientX,y:t.clientY}:null}const R0=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[R0.Translate.toString(t),R0.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),ZV="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function n6e(t){return t.matches(ZV)?t:t.querySelector(ZV)}const r6e={display:"none"};function i6e(t){let{id:e,value:n}=t;return ur.createElement("div",{id:e,style:r6e},n)}function a6e(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 ur.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function s6e(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const DJ=E.createContext(null);function o6e(t){const e=E.useContext(DJ);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function l6e(){const[t]=E.useState(()=>new Set),e=E.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[E.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var o;return(o=s[i])==null?void 0:o.call(s,a)})},[t]),e]}const c6e={draggable:`
  8218. To pick up a draggable item, press the space bar.
  8219. While dragging, use the arrow keys to move the item.
  8220. Press space again to drop the item in its new position, or press escape to cancel.
  8221. `},u6e={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 d6e(t){let{announcements:e=u6e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=c6e}=t;const{announce:a,announcement:s}=s6e(),o=bv("DndLiveRegion"),[l,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),o6e(E.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:m}=f;e.onDragMove&&a(e.onDragMove({active:g,over:m}))},onDragOver(f){let{active:g,over:m}=f;a(e.onDragOver({active:g,over:m}))},onDragEnd(f){let{active:g,over:m}=f;a(e.onDragEnd({active:g,over:m}))},onDragCancel(f){let{active:g,over:m}=f;a(e.onDragCancel({active:g,over:m}))}}),[a,e])),!l)return null;const u=ur.createElement(ur.Fragment,null,ur.createElement(i6e,{id:r,value:i.draggable}),ur.createElement(a6e,{id:o,announcement:s}));return n?Jl.createPortal(u,n):u}var ni;(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"})(ni||(ni={}));function VS(){}function QV(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function f6e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Ao=Object.freeze({x:0,y:0});function OJ(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function LJ(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function h6e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function JV(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 IJ(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function eG(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 p6e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=eG(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=OJ(eG(l),i);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(LJ)},m6e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=JV(e),a=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=JV(l),u=i.reduce((g,m,y)=>g+OJ(c[y],m),0),f=Number((u/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(LJ)};function g6e(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),s=i-r,o=a-n;if(r<i&&n<a){const l=e.width*e.height,c=t.width*t.height,u=s*o,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const x6e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const l=g6e(o,e);l>0&&i.push({id:s,data:{droppableContainer:a,value:l}})}}return i.sort(h6e)};function v6e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function jJ(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ao}function b6e(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((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const y6e=b6e(1);function _6e(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 S6e(t,e,n){const r=_6e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,l=t.left-s-(1-i)*parseFloat(n),c=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const w6e={ignoreTransform:!1};function Bm(t,e){e===void 0&&(e=w6e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=qa(t).getComputedStyle(t);c&&(n=S6e(n,c,u))}const{top:r,left:i,width:a,height:s,bottom:o,right:l}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:l}}function tG(t){return Bm(t,{ignoreTransform:!0})}function M6e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function E6e(t,e){return e===void 0&&(e=qa(t).getComputedStyle(t)),e.position==="fixed"}function A6e(t,e){e===void 0&&(e=qa(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 bM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(lL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!xv(i)||PJ(i)||n.includes(i))return n;const a=qa(t).getComputedStyle(i);return i!==t&&A6e(i,a)&&n.push(i),E6e(i,a)?n:r(i.parentNode)}return t?r(t):n}function UJ(t){const[e]=bM(t,1);return e??null}function hN(t){return!vM||!t?null:Fm(t)?t:oL(t)?lL(t)||t===zm(t).scrollingElement?window:xv(t)?t:null:null}function FJ(t){return Fm(t)?t.scrollX:t.scrollLeft}function zJ(t){return Fm(t)?t.scrollY:t.scrollTop}function EP(t){return{x:FJ(t),y:zJ(t)}}var Ei;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ei||(Ei={}));function BJ(t){return!vM||!t?!1:t===document.scrollingElement}function HJ(t){const e={x:0,y:0},n=BJ(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,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const T6e={x:.2,y:.2};function C6e(t,e,n,r,i){let{top:a,left:s,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=T6e);const{isTop:c,isBottom:u,isLeft:f,isRight:g}=HJ(t),m={x:0,y:0},y={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!c&&a<=e.top+v.height?(m.y=Ei.Backward,y.y=r*Math.abs((e.top+v.height-a)/v.height)):!u&&l>=e.bottom-v.height&&(m.y=Ei.Forward,y.y=r*Math.abs((e.bottom-v.height-l)/v.height)),!g&&o>=e.right-v.width?(m.x=Ei.Forward,y.x=r*Math.abs((e.right-v.width-o)/v.width)):!f&&s<=e.left+v.width&&(m.x=Ei.Backward,y.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:m,speed:y}}function N6e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function $J(t){return t.reduce((e,n)=>Bp(e,EP(n)),Ao)}function R6e(t){return t.reduce((e,n)=>e+FJ(n),0)}function P6e(t){return t.reduce((e,n)=>e+zJ(n),0)}function k6e(t,e){if(e===void 0&&(e=Bm),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);UJ(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const D6e=[["x",["left","right"],R6e],["y",["top","bottom"],P6e]];class dL{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=bM(n),i=$J(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of D6e)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(r),u=i[a]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ox{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 O6e(t){const{EventTarget:e}=qa(t);return t instanceof e?t:zm(t)}function pN(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 js;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(js||(js={}));function nG(t){t.preventDefault()}function L6e(t){t.stopPropagation()}var _n;(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"})(_n||(_n={}));const VJ={start:[_n.Space,_n.Enter],cancel:[_n.Esc],end:[_n.Space,_n.Enter,_n.Tab]},I6e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case _n.Right:return{...n,x:n.x+25};case _n.Left:return{...n,x:n.x-25};case _n.Down:return{...n,y:n.y+25};case _n.Up:return{...n,y:n.y-25}}};class fL{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 Ox(zm(n)),this.windowListeners=new Ox(qa(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(js.Resize,this.handleCancel),this.windowListeners.add(js.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(js.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&k6e(r),n(Ao)}handleKeyDown(e){if(uL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=VJ,coordinateGetter:s=I6e,scrollBehavior:o="smooth"}=i,{code:l}=e;if(a.end.includes(l)){this.handleEnd(e);return}if(a.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Ao;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(e,{active:n,context:r.current,currentCoordinates:u});if(f){const g=N0(f,u),m={x:0,y:0},{scrollableAncestors:y}=r.current;for(const v of y){const b=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:A,maxScroll:T,minScroll:R}=HJ(v),N=N6e(v),j={x:Math.min(b===_n.Right?N.right-N.width/2:N.right,Math.max(b===_n.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(b===_n.Down?N.bottom-N.height/2:N.bottom,Math.max(b===_n.Down?N.top:N.top+N.height/2,f.y))},C=b===_n.Right&&!M||b===_n.Left&&!w,k=b===_n.Down&&!A||b===_n.Up&&!x;if(C&&j.x!==f.x){const U=v.scrollLeft+g.x,I=b===_n.Right&&U<=T.x||b===_n.Left&&U>=R.x;if(I&&!g.y){v.scrollTo({left:U,behavior:o});return}I?m.x=v.scrollLeft-U:m.x=b===_n.Right?v.scrollLeft-T.x:v.scrollLeft-R.x,m.x&&v.scrollBy({left:-m.x,behavior:o});break}else if(k&&j.y!==f.y){const U=v.scrollTop+g.y,I=b===_n.Down&&U<=T.y||b===_n.Up&&U>=R.y;if(I&&!g.x){v.scrollTo({top:U,behavior:o});return}I?m.y=v.scrollTop-U:m.y=b===_n.Down?v.scrollTop-T.y:v.scrollTop-R.y,m.y&&v.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Bp(N0(f,this.referenceCoordinates),m))}}}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()}}fL.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=VJ,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function rG(t){return!!(t&&"distance"in t)}function iG(t){return!!(t&&"delay"in t)}class hL{constructor(e,n,r){var i;r===void 0&&(r=O6e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=zm(s),this.documentListeners=new Ox(this.document),this.listeners=new Ox(r),this.windowListeners=new Ox(qa(s)),this.initialCoordinates=(i=MP(a))!=null?i:Ao,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(js.Resize,this.handleCancel),this.windowListeners.add(js.DragStart,nG),this.windowListeners.add(js.VisibilityChange,this.handleCancel),this.windowListeners.add(js.ContextMenu,nG),this.documentListeners.add(js.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(iG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(rG(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(js.Click,L6e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(js.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const l=(n=MP(e))!=null?n:Ao,c=N0(i,l);if(!r&&o){if(rG(o)){if(o.tolerance!=null&&pN(c,o.tolerance))return this.handleCancel();if(pN(c,o.distance))return this.handleStart()}if(iG(o)&&pN(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===_n.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const j6e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class pL extends hL{constructor(e){const{event:n}=e,r=zm(n.target);super(e,j6e,r)}}pL.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 U6e={move:{name:"mousemove"},end:{name:"mouseup"}};var AP;(function(t){t[t.RightClick=2]="RightClick"})(AP||(AP={}));class F6e extends hL{constructor(e){super(e,U6e,zm(e.event.target))}}F6e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===AP.RightClick?!1:(r?.({event:n}),!0)}}];const mN={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class z6e extends hL{constructor(e){super(e,mN)}static setup(){return window.addEventListener(mN.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(mN.move.name,e)};function e(){}}}z6e.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 Lx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Lx||(Lx={}));var GS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(GS||(GS={}));function B6e(t){let{acceleration:e,activator:n=Lx.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=GS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:g}=t;const m=$6e({delta:f,disabled:!a}),[y,v]=J8e(),b=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case Lx.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Lx.DraggableRect:return i}},[n,i,l]),w=E.useRef(null),A=E.useCallback(()=>{const R=w.current;if(!R)return;const N=b.current.x*x.current.x,j=b.current.y*x.current.y;R.scrollBy(N,j)},[]),T=E.useMemo(()=>o===GS.TreeOrder?[...c].reverse():c,[o,c]);E.useEffect(()=>{if(!a||!c.length||!M){v();return}for(const R of T){if(r?.(R)===!1)continue;const N=c.indexOf(R),j=u[N];if(!j)continue;const{direction:C,speed:k}=C6e(R,j,M,e,g);for(const U of["x","y"])m[U][C[U]]||(k[U]=0,C[U]=0);if(k.x>0||k.y>0){v(),w.current=R,y(A,s),b.current=k,x.current=C;return}}b.current={x:0,y:0},x.current={x:0,y:0},v()},[e,A,r,v,a,s,JSON.stringify(M),JSON.stringify(m),y,c,T,u,JSON.stringify(g)])}const H6e={x:{[Ei.Backward]:!1,[Ei.Forward]:!1},y:{[Ei.Backward]:!1,[Ei.Forward]:!1}};function $6e(t){let{delta:e,disabled:n}=t;const r=wP(e);return vv(i=>{if(n||!r||!i)return H6e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ei.Backward]:i.x[Ei.Backward]||a.x===-1,[Ei.Forward]:i.x[Ei.Forward]||a.x===1},y:{[Ei.Backward]:i.y[Ei.Backward]||a.y===-1,[Ei.Forward]:i.y[Ei.Forward]||a.y===1}}},[n,e,r])}function V6e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return vv(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function G6e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var P0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(P0||(P0={}));var TP;(function(t){t.Optimized="optimized"})(TP||(TP={}));const aG=new Map;function W6e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=E.useState(null),{frequency:o,measure:l,strategy:c}=i,u=E.useRef(t),f=b(),g=C0(f),m=E.useCallback(function(x){x===void 0&&(x=[]),!g.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[g]),y=E.useRef(null),v=vv(x=>{if(f&&!n)return aG;if(!x||x===aG||u.current!==t||a!=null){const M=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const A=w.node.current,T=A?new dL(l(A),A):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,f,l]);return E.useEffect(()=>{u.current=t},[t]),E.useEffect(()=>{f||m()},[n,f]),E.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),E.useEffect(()=>{f||typeof o!="number"||y.current!==null||(y.current=setTimeout(()=>{m(),y.current=null},o))},[o,f,m,...r]),{droppableRects:v,measureDroppableContainers:m,measuringScheduled:a!=null};function b(){switch(c){case P0.Always:return!1;case P0.BeforeDragging:return n;default:return!n}}}function GJ(t,e){return vv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function q6e(t,e){return GJ(t,e)}function X6e(t){let{callback:e,disabled:n}=t;const r=cL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function yM(t){let{callback:e,disabled:n}=t;const r=cL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function K6e(t){return new dL(Bm(t),t)}function sG(t,e,n){e===void 0&&(e=K6e);const[r,i]=E.useState(null);function a(){i(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=X6e({callback(l){if(t)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=yM({callback:a});return ll(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function Y6e(t){const e=GJ(t);return jJ(t,e)}const oG=[];function Z6e(t){const e=E.useRef(t),n=vv(r=>t?r&&r!==oG&&t&&e.current&&t.parentNode===e.current.parentNode?r:bM(t):oG,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function Q6e(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(a=>{const s=hN(a.target);s&&n(o=>o?(o.set(s,EP(s)),new Map(o)):null)},[]);return E.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(l=>{const c=hN(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,EP(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(l=>{const c=hN(l);c?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Bp(a,s),Ao):$J(t):Ao,[t,e])}function lG(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==Ao;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?N0(t,n.current):Ao}function J6e(t){E.useEffect(()=>{if(!vM)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 e$e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function WJ(t){return E.useMemo(()=>t?M6e(t):null,[t])}const cG=[];function t$e(t,e){e===void 0&&(e=Bm);const[n]=t,r=WJ(n?qa(n):null),[i,a]=E.useState(cG);function s(){a(()=>t.length?t.map(l=>BJ(l)?r:new dL(e(l),l)):cG)}const o=yM({callback:s});return ll(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),i}function n$e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return xv(e)?e:t}function r$e(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(c=>{for(const{target:u}of c)if(xv(u)){r(f=>{const g=e(u);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=yM({callback:i}),s=E.useCallback(c=>{const u=n$e(c);a?.disconnect(),u&&a?.observe(u),r(u?e(u):null)},[e,a]),[o,l]=$S(s);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const i$e=[{sensor:pL,options:{}},{sensor:fL,options:{}}],a$e={current:{}},L_={draggable:{measure:tG},droppable:{measure:tG,strategy:P0.WhileDragging,frequency:TP.Optimized},dragOverlay:{measure:Bm}};class Ix 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 s$e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ix,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:VS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:L_,measureDroppableContainers:VS,windowRect:null,measuringScheduled:!1},o$e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:VS,draggableNodes:new Map,over:null,measureDroppableContainers:VS},_M=E.createContext(o$e),qJ=E.createContext(s$e);function l$e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ix}}}function c$e(t,e){switch(e.type){case ni.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ni.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 ni.DragEnd:case ni.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ni.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Ix(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ni.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new Ix(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case ni.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new Ix(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function u$e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext(_M),a=wP(r),s=wP(n?.id);return E.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!uL(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=n6e(u);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function d$e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function f$e(t){return E.useMemo(()=>({draggable:{...L_.draggable,...t?.draggable},droppable:{...L_.droppable,...t?.droppable},dragOverlay:{...L_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function h$e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=E.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;ll(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=jJ(u,r);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=UJ(c);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,o,r,n])}const XJ=E.createContext({...Ao,scaleX:1,scaleY:1});var Cu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Cu||(Cu={}));const p$e=E.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:u=i$e,collisionDetection:f=x6e,measuring:g,modifiers:m,...y}=e;const v=E.useReducer(c$e,void 0,l$e),[b,x]=v,[M,w]=l6e(),[A,T]=E.useState(Cu.Uninitialized),R=A===Cu.Initialized,{draggable:{active:N,nodes:j,translate:C},droppable:{containers:k}}=b,U=N!=null?j.get(N):null,I=E.useRef({initial:null,translated:null}),H=E.useMemo(()=>{var Le;return N!=null?{id:N,data:(Le=U?.data)!=null?Le:a$e,rect:I}:null},[N,U]),O=E.useRef(null),[B,V]=E.useState(null),[G,K]=E.useState(null),Y=C0(y,Object.values(y)),oe=bv("DndDescribedBy",s),$=E.useMemo(()=>k.getEnabled(),[k]),X=f$e(g),{droppableRects:ae,measureDroppableContainers:ce,measuringScheduled:xe}=W6e($,{dragging:R,dependencies:[C.x,C.y],config:X.droppable}),te=V6e(j,N),ve=E.useMemo(()=>G?MP(G):null,[G]),De=fe(),he=q6e(te,X.draggable.measure);h$e({activeNode:N!=null?j.get(N):null,config:De.layoutShiftCompensation,initialRect:he,measure:X.draggable.measure});const me=sG(te,X.draggable.measure,he),we=sG(te?te.parentElement:null),se=E.useRef({activatorEvent:null,active:null,activeNode:te,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),st=k.getNodeFor((n=se.current.over)==null?void 0:n.id),z=r$e({measure:X.dragOverlay.measure}),q=(r=z.nodeRef.current)!=null?r:te,ie=R?(i=z.rect)!=null?i:me:null,Q=!!(z.nodeRef.current&&z.rect),ee=Y6e(Q?null:me),le=WJ(q?qa(q):null),Re=Z6e(R?st??te:null),Pe=t$e(Re),ne=d$e(m,{transform:{x:C.x-ee.x,y:C.y-ee.y,scaleX:1,scaleY:1},activatorEvent:G,active:H,activeNodeRect:me,containerNodeRect:we,draggingNodeRect:ie,over:se.current.over,overlayNodeRect:z.rect,scrollableAncestors:Re,scrollableAncestorRects:Pe,windowRect:le}),F=ve?Bp(ve,C):null,L=Q6e(Re),Z=lG(L),ge=lG(L,[me]),ye=Bp(ne,Z),pe=ie?y6e(ie,ne):null,Ze=H&&pe?f({active:H,collisionRect:pe,droppableRects:ae,droppableContainers:$,pointerCoordinates:F}):null,Ie=IJ(Ze,"id"),[Xe,ot]=E.useState(null),je=Q?ne:Bp(ne,ge),ke=v6e(je,(a=Xe?.rect)!=null?a:null,me),pt=E.useRef(null),rt=E.useCallback((Le,Ee)=>{let{sensor:be,options:He}=Ee;if(O.current==null)return;const ut=j.get(O.current);if(!ut)return;const _t=Le.nativeEvent,Rt=new be({active:O.current,activeNode:ut,event:_t,options:He,context:se,onAbort(Dt){if(!j.get(Dt))return;const{onDragAbort:qn}=Y.current,pi={id:Dt};qn?.(pi),M({type:"onDragAbort",event:pi})},onPending(Dt,Rn,qn,pi){if(!j.get(Dt))return;const{onDragPending:mi}=Y.current,Pi={id:Dt,constraint:Rn,initialCoordinates:qn,offset:pi};mi?.(Pi),M({type:"onDragPending",event:Pi})},onStart(Dt){const Rn=O.current;if(Rn==null)return;const qn=j.get(Rn);if(!qn)return;const{onDragStart:pi}=Y.current,Zr={activatorEvent:_t,active:{id:Rn,data:qn.data,rect:I}};Jl.unstable_batchedUpdates(()=>{pi?.(Zr),T(Cu.Initializing),x({type:ni.DragStart,initialCoordinates:Dt,active:Rn}),M({type:"onDragStart",event:Zr}),V(pt.current),K(_t)})},onMove(Dt){x({type:ni.DragMove,coordinates:Dt})},onEnd:ln(ni.DragEnd),onCancel:ln(ni.DragCancel)});pt.current=Rt;function ln(Dt){return async function(){const{active:qn,collisions:pi,over:Zr,scrollAdjustedTranslate:mi}=se.current;let Pi=null;if(qn&&mi){const{cancelDrop:qi}=Y.current;Pi={activatorEvent:_t,active:qn,collisions:pi,delta:mi,over:Zr},Dt===ni.DragEnd&&typeof qi=="function"&&await Promise.resolve(qi(Pi))&&(Dt=ni.DragCancel)}O.current=null,Jl.unstable_batchedUpdates(()=>{x({type:Dt}),T(Cu.Uninitialized),ot(null),V(null),K(null),pt.current=null;const qi=Dt===ni.DragEnd?"onDragEnd":"onDragCancel";if(Pi){const Lr=Y.current[qi];Lr?.(Pi),M({type:qi,event:Pi})}})}}},[j]),nt=E.useCallback((Le,Ee)=>(be,He)=>{const ut=be.nativeEvent,_t=j.get(He);if(O.current!==null||!_t||ut.dndKit||ut.defaultPrevented)return;const Rt={active:_t};Le(be,Ee.options,Rt)===!0&&(ut.dndKit={capturedBy:Ee.sensor},O.current=He,rt(be,Ee))},[j,rt]),dt=G6e(u,nt);J6e(u),ll(()=>{me&&A===Cu.Initializing&&T(Cu.Initialized)},[me,A]),E.useEffect(()=>{const{onDragMove:Le}=Y.current,{active:Ee,activatorEvent:be,collisions:He,over:ut}=se.current;if(!Ee||!be)return;const _t={active:Ee,activatorEvent:be,collisions:He,delta:{x:ye.x,y:ye.y},over:ut};Jl.unstable_batchedUpdates(()=>{Le?.(_t),M({type:"onDragMove",event:_t})})},[ye.x,ye.y]),E.useEffect(()=>{const{active:Le,activatorEvent:Ee,collisions:be,droppableContainers:He,scrollAdjustedTranslate:ut}=se.current;if(!Le||O.current==null||!Ee||!ut)return;const{onDragOver:_t}=Y.current,Rt=He.get(Ie),ln=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Dt={active:Le,activatorEvent:Ee,collisions:be,delta:{x:ut.x,y:ut.y},over:ln};Jl.unstable_batchedUpdates(()=>{ot(ln),_t?.(Dt),M({type:"onDragOver",event:Dt})})},[Ie]),ll(()=>{se.current={activatorEvent:G,active:H,activeNode:te,collisionRect:pe,collisions:Ze,droppableRects:ae,draggableNodes:j,draggingNode:q,draggingNodeRect:ie,droppableContainers:k,over:Xe,scrollableAncestors:Re,scrollAdjustedTranslate:ye},I.current={initial:ie,translated:pe}},[H,te,Ze,pe,j,q,ie,ae,k,Xe,Re,ye]),B6e({...De,delta:C,draggingRect:pe,pointerCoordinates:F,scrollableAncestors:Re,scrollableAncestorRects:Pe});const de=E.useMemo(()=>({active:H,activeNode:te,activeNodeRect:me,activatorEvent:G,collisions:Ze,containerNodeRect:we,dragOverlay:z,draggableNodes:j,droppableContainers:k,droppableRects:ae,over:Xe,measureDroppableContainers:ce,scrollableAncestors:Re,scrollableAncestorRects:Pe,measuringConfiguration:X,measuringScheduled:xe,windowRect:le}),[H,te,me,G,Ze,we,z,j,k,ae,Xe,ce,Re,Pe,X,xe,le]),it=E.useMemo(()=>({activatorEvent:G,activators:dt,active:H,activeNodeRect:me,ariaDescribedById:{draggable:oe},dispatch:x,draggableNodes:j,over:Xe,measureDroppableContainers:ce}),[G,dt,H,me,x,oe,j,Xe,ce]);return ur.createElement(DJ.Provider,{value:w},ur.createElement(_M.Provider,{value:it},ur.createElement(qJ.Provider,{value:de},ur.createElement(XJ.Provider,{value:ke},c)),ur.createElement(u$e,{disabled:o?.restoreFocus===!1})),ur.createElement(d6e,{...o,hiddenTextDescribedById:oe}));function fe(){const Le=B?.autoScrollEnabled===!1,Ee=typeof l=="object"?l.enabled===!1:l===!1,be=R&&!Le&&!Ee;return typeof l=="object"?{...l,enabled:be}:{enabled:be}}}),m$e=E.createContext(null),uG="button",g$e="Draggable";function x$e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=bv(g$e),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:g}=E.useContext(_M),{role:m=uG,roleDescription:y="draggable",tabIndex:v=0}=i??{},b=l?.id===e,x=E.useContext(b?XJ:m$e),[M,w]=$S(),[A,T]=$S(),R=e$e(s,e),N=C0(n);ll(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:A,data:N}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const j=E.useMemo(()=>({role:m,tabIndex:v,"aria-disabled":r,"aria-pressed":b&&m===uG?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[r,m,v,b,y,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:b,listeners:r?void 0:R,node:M,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function v$e(){return E.useContext(qJ)}const b$e="Droppable",y$e={timeout:25};function _$e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=bv(b$e),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=E.useContext(_M),u=E.useRef({disabled:n}),f=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:b}={...y$e,...i},x=C0(v??r),M=E.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),m.current=null},b)},[b]),w=yM({callback:M,disabled:y||!s}),A=E.useCallback((j,C)=>{w&&(C&&(w.unobserve(C),f.current=!1),j&&w.observe(j))},[w]),[T,R]=$S(A),N=C0(e);return E.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),E.useEffect(()=>(o({type:ni.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:N}}),()=>o({type:ni.UnregisterDroppable,key:a,id:r})),[r]),E.useEffect(()=>{n!==u.current.disabled&&(o({type:ni.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,o]),{active:s,rect:g,isOver:l?.id===r,node:T,over:l,setNodeRef:R}}function mL(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function S$e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function l_(t){return t!==null&&t>=0}function w$e(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 M$e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const gL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=mL(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},KJ="Sortable",YJ=ur.createContext({activeIndex:-1,containerId:KJ,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gL,disabled:{draggable:!1,droppable:!1}});function E$e(t){let{children:e,id:n,items:r,strategy:i=gL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=v$e(),f=bv(KJ,n),g=o.rect!==null,m=E.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),y=s!=null,v=s?m.indexOf(s.id):-1,b=c?m.indexOf(c.id):-1,x=E.useRef(m),M=!w$e(m,x.current),w=b!==-1&&v===-1||M,A=M$e(a);ll(()=>{M&&y&&u(m)},[M,m,y,u]),E.useEffect(()=>{x.current=m},[m]);const T=E.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:w,items:m,overIndex:b,useDragOverlay:g,sortedRects:S$e(m,l),strategy:i}),[v,f,A.draggable,A.droppable,w,m,b,l,g,i]);return ur.createElement(YJ.Provider,{value:T},e)}const A$e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return mL(n,r,i).indexOf(e)},T$e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===l},C$e={duration:200,easing:"ease"},ZJ="transform",N$e=R0.Transition.toString({property:ZJ,duration:0,easing:"linear"}),R$e={roleDescription:"sortable"};function P$e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=E.useState(null),o=E.useRef(n);return ll(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const c=Bm(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{a&&s(null)},[a]),a}function k$e(t){let{animateLayoutChanges:e=T$e,attributes:n,disabled:r,data:i,getNewIndex:a=A$e,id:s,strategy:o,resizeObserverConfig:l,transition:c=C$e}=t;const{items:u,containerId:f,activeIndex:g,disabled:m,disableTransforms:y,sortedRects:v,overIndex:b,useDragOverlay:x,strategy:M}=E.useContext(YJ),w=D$e(r,m),A=u.indexOf(s),T=E.useMemo(()=>({sortable:{containerId:f,index:A,items:u},...i}),[f,i,A,u]),R=E.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:N,node:j,isOver:C,setNodeRef:k}=_$e({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:U,activatorEvent:I,activeNodeRect:H,attributes:O,setNodeRef:B,listeners:V,isDragging:G,over:K,setActivatorNodeRef:Y,transform:oe}=x$e({id:s,data:T,attributes:{...R$e,...n},disabled:w.draggable}),$=Q8e(k,B),X=!!U,ae=X&&!y&&l_(g)&&l_(b),ce=!x&&G,xe=ce&&ae?oe:null,ve=ae?xe??(o??M)({rects:v,activeNodeRect:H,activeIndex:g,overIndex:b,index:A}):null,De=l_(g)&&l_(b)?a({id:s,items:u,activeIndex:g,overIndex:b}):A,he=U?.id,me=E.useRef({activeId:he,items:u,newIndex:De,containerId:f}),we=u!==me.current.items,se=e({active:U,containerId:f,isDragging:G,isSorting:X,id:s,index:A,items:u,newIndex:me.current.newIndex,previousItems:me.current.items,previousContainerId:me.current.containerId,transition:c,wasDragging:me.current.activeId!=null}),st=P$e({disabled:!se,index:A,node:j,rect:N});return E.useEffect(()=>{X&&me.current.newIndex!==De&&(me.current.newIndex=De),f!==me.current.containerId&&(me.current.containerId=f),u!==me.current.items&&(me.current.items=u)},[X,De,f,u]),E.useEffect(()=>{if(he===me.current.activeId)return;if(he!=null&&me.current.activeId==null){me.current.activeId=he;return}const q=setTimeout(()=>{me.current.activeId=he},50);return()=>clearTimeout(q)},[he]),{active:U,activeIndex:g,attributes:O,data:T,rect:N,index:A,newIndex:De,items:u,isOver:C,isSorting:X,isDragging:G,listeners:V,node:j,overIndex:b,over:K,setNodeRef:$,setActivatorNodeRef:Y,setDroppableNodeRef:k,setDraggableNodeRef:B,transform:st??ve,transition:z()};function z(){if(st||we&&me.current.newIndex===A)return N$e;if(!(ce&&!uL(I)||!c)&&(X||se))return R0.Transition.toString({...c,property:ZJ})}}function D$e(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 WS(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 O$e=[_n.Down,_n.Right,_n.Up,_n.Left],L$e=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(O$e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case _n.Down:r.top<g.top&&l.push(f);break;case _n.Up:r.top>g.top&&l.push(f);break;case _n.Left:r.left>g.left&&l.push(f);break;case _n.Right:r.left<g.left&&l.push(f);break}});const c=m6e({collisionRect:r,droppableRects:i,droppableContainers:l});let u=IJ(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const f=a.get(n.id),g=a.get(u),m=g?i.get(g.id):null,y=g?.node.current;if(y&&m&&f&&g){const b=bM(y).some((R,N)=>o[N]!==R),x=QJ(f,g),M=I$e(f,g),w=b||!x?{x:0,y:0}:{x:M?r.width-m.width:0,y:M?r.height-m.height:0},A={x:m.left,y:m.top};return w.x&&w.y?A:N0(A,w)}}}};function QJ(t,e){return!WS(t)||!WS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function I$e(t,e){return!WS(t)||!WS(e)||!QJ(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function j$e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:f,isDragging:g}=k$e({id:t}),m={transform:R0.Transform.toString(u),transition:f,opacity:g?.5:1};return r?null:h.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:h.jsx($P,{className:"w-4 h-4 text-bambu-gray"})}),h.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?h.jsx(boe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):h.jsx(f9,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),h.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:h.jsx(Mse,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),h.jsx("div",{className:"p-4",children:n})]})}function U$e({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const b={};return t.forEach(x=>{b[x.id]=x.defaultSize||4}),b},[i,a]=E.useState(()=>{const b=localStorage.getItem(e);if(b)try{const x=JSON.parse(b);return x.sizes||(x.sizes=r()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()}}),[s,o]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(i))},[i,e]),E.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!i.order.includes(M));x.length>0&&a(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=f6e(QV(pL,{activationConstraint:{distance:8}}),QV(fL,{coordinateGetter:L$e})),c=b=>{const{active:x,over:M}=b;M&&x.id!==M.id&&a(w=>{const A=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:mL(w.order,A,T)}})},u=b=>{a(x=>({...x,hidden:x.hidden.includes(b)?x.hidden.filter(M=>M!==b):[...x.hidden,b]}))},f=b=>{a(x=>{const M=x.sizes[b]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[b]:w}}})},g=()=>{const b={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()};a(b)},m=i.order.map(b=>t.find(x=>x.id===b)).filter(Boolean),y=m.filter(b=>!i.hidden.includes(b.id)),v=m.filter(b=>i.hidden.includes(b.id));return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[v.length>0&&h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[h.jsx(YU,{className:"w-4 h-4"}),v.length," Hidden"]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:g,children:[h.jsx(nw,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&v.length>0&&h.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),h.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(b=>h.jsxs("button",{onClick:()=>u(b.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[h.jsx(YU,{className:"w-3 h-3"}),b.title]},b.id))})]}),h.jsx(p$e,{sensors:l,collisionDetection:p6e,onDragEnd:c,children:h.jsx(E$e,{items:y.map(b=>b.id),strategy:gL,children:h.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(b=>h.jsx(j$e,{id:b.id,title:b.title,isHidden:i.hidden.includes(b.id),size:i.sizes[b.id]||2,onToggleVisibility:()=>u(b.id),onToggleSize:()=>f(b.id),children:b.component},b.id))})})}),y.length===0&&h.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[h.jsx("p",{children:"All widgets are hidden."}),h.jsx(ct,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function F$e({stats:t,currency:e}){return h.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:h.jsx(W_,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),h.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:h.jsx(ba,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:h.jsx(W_,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:h.jsx(KU,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:h.jsx(v9,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:h.jsx(KU,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function z$e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return h.jsxs("div",{className:"flex items-center gap-6",children:[h.jsxs("div",{className:"relative w-28 h-28",children:[h.jsxs("svg",{className:"w-full h-full -rotate-90",children:[h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),h.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ld,{className:"w-4 h-4 text-bambu-green"}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),h.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(L0,{className:"w-4 h-4 text-red-400"}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),h.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function B$e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,s=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return h.jsxs("div",{className:"flex items-center gap-6",children:[h.jsxs("div",{className:"relative w-28 h-28",children:[h.jsxs("svg",{className:"w-full h-full -rotate-90",children:[h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),h.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[h.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),h.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),h.jsxs("div",{className:"space-y-2 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[h.jsx(cle,{className:"w-3 h-3"}),h.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&h.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>h.jsxs("div",{className:"flex items-center justify-between text-xs",children:[h.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),h.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function H$e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return h.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return h.jsxs("div",{children:[h.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[h.jsx("span",{className:"text-white",children:n}),h.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),h.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:h.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function $$e({printDates:t}){return h.jsx(V2e,{printDates:t,months:4})}function V$e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[h.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:h.jsx(mc,{className:"w-4 h-4 text-bambu-green"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function G$e({archives:t,currency:e}){return!t||t.length===0?h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):h.jsx(Z8e,{archives:t,currency:e})}function W$e(){const{data:t,isLoading:e}=Ut({queryKey:["archiveStats"],queryFn:Fe.getArchiveStats}),{data:n}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:r}=Ut({queryKey:["archives"],queryFn:()=>Fe.getArchives(void 0,1e3,0)}),{data:i}=Ut({queryKey:["settings"],queryFn:Fe.getSettings}),a=i?.currency||"$",s=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return h.jsx("div",{className:"p-8",children:h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:h.jsx(F$e,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:h.jsx(z$e,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:h.jsx(B$e,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:h.jsx(H$e,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:h.jsx($$e,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:h.jsx(V$e,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:h.jsx(G$e,{archives:r||[],currency:a}),defaultSize:4}];return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),h.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),h.jsx(U$e,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function q$e({plug:t,onEdit:e}){const n=In(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),{data:f,isLoading:g,refetch:m}=Ut({queryKey:["smart-plug-status",t.id],queryFn:()=>Fe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),v=y?.find(R=>R.id===t.printer_id),b=yt({mutationFn:R=>Fe.controlSmartPlug(t.id,R),onSuccess:()=>{m()}}),x=yt({mutationFn:R=>Fe.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=yt({mutationFn:()=>Fe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,T=b.isPending;return h.jsxs(h.Fragment,{children:[h.jsx(Yt,{className:"relative",children:h.jsxs(on,{className:"p-4",children:[h.jsxs("div",{className:"flex items-start justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h.jsx(jN,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-medium text-white",children:t.name}),h.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),h.jsx("div",{className:"flex items-center gap-2",children:g?h.jsx(Ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?h.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[h.jsx(WP,{className:"w-4 h-4 text-bambu-green"}),h.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):h.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[h.jsx(Vp,{className:"w-4 h-4"}),h.jsx("span",{children:"Offline"})]})})]}),v&&h.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),h.jsx("span",{className:"text-sm text-white",children:v.name})]}),h.jsxs("div",{className:"flex gap-2 mb-3",children:[h.jsxs(ct,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(tw,{className:"w-4 h-4"}),"On"]}),h.jsxs(ct,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(m9,{className:"w-4 h-4"}),"Off"]})]}),h.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(GP,{className:"w-4 h-4"}),"Automation Settings"]}),h.jsx("span",{children:c?"-":"+"})]}),c&&h.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Enabled"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),h.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Auto On"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),h.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),h.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&h.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[h.jsx(ba,{className:"w-4 h-4"}),"Time"]}),h.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[h.jsx(p_,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),h.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),h.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),h.jsxs("div",{className:"flex gap-2 pt-2",children:[h.jsxs(ct,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[h.jsx(p9,{className:"w-4 h-4"}),"Edit"]}),h.jsx(ct,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:h.jsx(aa,{className:"w-4 h-4"})})]})]})]})}),r&&h.jsx(ii,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&h.jsx(ii,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&h.jsx(ii,{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:()=>{b.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function X$e({plug:t,onClose:e}){const n=In(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[u,f]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[y,v]=E.useState(null),[b,x]=E.useState(null),{data:M}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:w}=Ut({queryKey:["smart-plugs"],queryFn:Fe.getSmartPlugs});E.useEffect(()=>{const k=U=>{U.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const A=yt({mutationFn:()=>Fe.testSmartPlugConnection(s,l||null,u||null),onSuccess:k=>{v(k),x(null),!i&&k.device_name&&a(k.device_name)},onError:k=>{v(null),x(k.message)}}),T=yt({mutationFn:k=>Fe.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),R=yt({mutationFn:k=>Fe.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),N=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const U={name:i.trim(),ip_address:s.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:g};r?R.mutate(U):T.mutate(U)},C=T.isPending||R.isPending;return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[b&&h.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",value:s,onChange:k=>{o(k.target.value),v(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),h.jsxs(ct,{type:"button",variant:"secondary",onClick:()=>A.mutate(),disabled:!s.trim()||A.isPending,children:[A.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(WP,{className:"w-4 h-4"}),"Test"]})]})]}),y&&h.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${y.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:y.success?h.jsxs(h.Fragment,{children:[h.jsx(ld,{className:"w-5 h-5"}),h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Connected!"}),h.jsxs("p",{className:"text-sm opacity-80",children:[y.device_name&&`Device: ${y.device_name} - `,"State: ",y.state]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(Vp,{className:"w-5 h-5"}),h.jsx("span",{children:"Connection failed"})]})}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),h.jsx("input",{type:"text",value:i,onChange:k=>a(k.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),h.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),h.jsx("input",{type:"password",value:u,onChange:k=>f(k.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),h.jsxs("select",{value:g??"",onChange:k=>m(k.target.value?Number(k.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"",children:"No printer (manual control only)"}),N?.map(k=>h.jsx("option",{value:k.id,children:k.name},k.id))]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(ct,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(ct,{type:"submit",disabled:C,className:"flex-1",children:[C?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(I0,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function as({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return h.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:h.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const K$e={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function Y$e({provider:t,onEdit:e}){const n=In(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),u=c?.find(v=>v.id===t.printer_id),f=yt({mutationFn:v=>Fe.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=yt({mutationFn:()=>Fe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=yt({mutationFn:()=>Fe.testNotificationProvider(t.id),onSuccess:v=>{l(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{l({success:!1,message:v.message})}}),y=v=>v||"";return h.jsxs(h.Fragment,{children:[h.jsx(Yt,{className:"relative",children:h.jsxs(on,{className:"p-4",children:[h.jsxs("div",{className:"flex items-start justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:h.jsx(ON,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-medium text-white",children:t.name}),h.jsx("p",{className:"text-sm text-bambu-gray",children:K$e[t.provider_type]||t.provider_type})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&h.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&h.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&h.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),h.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&h.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:h.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),h.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&h.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&h.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&h.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&h.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&h.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&h.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&h.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&h.jsx("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&h.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&h.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[h.jsx(G_,{className:"w-3 h-3"}),"Quiet"]})]}),h.jsx("div",{className:"mb-3",children:h.jsxs(ct,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(g9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&h.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?h.jsx(ld,{className:"w-4 h-4"}):h.jsx(L0,{className:"w-4 h-4"}),h.jsx("span",{children:o.message})]}),h.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(GP,{className:"w-4 h-4"}),"Event Settings"]}),a?h.jsx(QS,{className:"w-4 h-4"}):h.jsx(Gf,{className:"w-4 h-4"})]}),a&&h.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Enabled"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),h.jsx(as,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Started"}),h.jsx(as,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),h.jsx(as,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),h.jsx(as,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),h.jsx(as,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),h.jsx(as,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),h.jsx(as,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),h.jsx(as,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),h.jsx(as,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),h.jsx(as,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(G_,{className:"w-4 h-4 text-purple-400"}),h.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),h.jsx(as,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&h.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ba,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("span",{className:"text-sm text-white",children:[y(t.quiet_hours_start)||"22:00"," - ",y(t.quiet_hours_end)||"07:00"]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),h.jsxs("div",{className:"flex gap-2 pt-2",children:[h.jsxs(ct,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[h.jsx(p9,{className:"w-4 h-4"}),"Edit"]}),h.jsx(ct,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:h.jsx(aa,{className:"w-4 h-4"})})]})]})]})}),r&&h.jsx(ii,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const dG=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function Z$e({provider:t,onClose:e}){const n=In(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.provider_type||"ntfy"),[l,c]=E.useState(t?.printer_id||null),[u,f]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[y,v]=E.useState(t?.quiet_hours_end||"07:00"),[b,x]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,V])=>[B,String(V)])):{}),[M,w]=E.useState(null),[A,T]=E.useState(null),{data:R}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters});E.useEffect(()=>{const B=V=>{V.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const N=yt({mutationFn:()=>Fe.testNotificationConfig({provider_type:s,config:b}),onSuccess:B=>{w(B),T(null)},onError:B=>{w({success:!1,message:B.message})}}),j=yt({mutationFn:B=>Fe.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),C=yt({mutationFn:B=>Fe.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),k=B=>{if(B.preventDefault(),T(null),!i.trim()){T("Name is required");return}const V=H(s);for(const K of V)if(!b[K.key]?.trim()){T(`${K.label} is required`);return}const G={name:i.trim(),provider_type:s,config:b,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?g:null,quiet_hours_end:u?y:null};r?C.mutate(G):j.mutate(G)},U=j.isPending||C.isPending,I=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];default:return[]}},H=B=>I(B).filter(V=>V.required),O=I(s);return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:B=>B.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[A&&h.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:A}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),h.jsx("input",{type:"text",value:i,onChange:B=>a(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),h.jsx("select",{value:s,onChange:B=>{o(B.target.value),x({}),w(null)},disabled: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:dG.map(B=>h.jsx("option",{value:B.value,children:B.label},B.value))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:dG.find(B=>B.value===s)?.description})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),O.map(B=>h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?h.jsx("select",{value:b[B.key]||B.options[0]?.value||"",onChange:V=>{x({...b,[B.key]:V.target.value}),w(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:B.options.map(V=>h.jsx("option",{value:V.value,children:V.label},V.value))}):h.jsx("input",{type:B.type,value:b[B.key]||"",onChange:V=>{x({...b,[B.key]:V.target.value}),w(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),h.jsx("div",{className:"flex gap-2",children:h.jsxs(ct,{type:"button",variant:"secondary",onClick:()=>{w(null),N.mutate()},disabled:N.isPending||!b[H(s)[0]?.key],className:"flex-1",children:[N.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(g9,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&h.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${M.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:M.success?h.jsxs(h.Fragment,{children:[h.jsx(ld,{className:"w-5 h-5"}),h.jsx("span",{children:M.message})]}):h.jsxs(h.Fragment,{children:[h.jsx(L0,{className:"w-5 h-5"}),h.jsx("span",{children:M.message})]})}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),h.jsxs("select",{value:l??"",onChange:B=>c(B.target.value?Number(B.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"",children:"All printers"}),R?.map(B=>h.jsx("option",{value:B.id,children:B.name},B.id))]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),h.jsx(as,{checked:u,onChange:f})]}),u&&h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),h.jsx("input",{type:"time",value:g,onChange:B=>m(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),h.jsx("input",{type:"time",value:y,onChange:B=>v(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(ct,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(ct,{type:"submit",disabled:U,className:"flex-1",children:[U?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(I0,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}async function Q$e(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function J$e(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 eVe(){const t=In(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[a,s]=E.useState("auto"),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,g]=E.useState("all"),{data:m,isLoading:y}=Ut({queryKey:["spoolman-settings"],queryFn:Q$e}),{data:v,isLoading:b,refetch:x}=Ut({queryKey:["spoolman-status"],queryFn:Fe.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),s(m.spoolman_sync_mode||"auto"))},[m]),E.useEffect(()=>{if(m){const I=m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==a;l(I)}},[m,e,r,a]);const w=yt({mutationFn:()=>J$e({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),u(!0),setTimeout(()=>u(!1),2e3)}}),A=yt({mutationFn:Fe.connectSpoolman,onSuccess:()=>{x()}}),T=yt({mutationFn:Fe.disconnectSpoolman,onSuccess:()=>{x()}}),R=yt({mutationFn:Fe.syncAllPrintersAms,onSuccess:I=>{I.success}}),N=yt({mutationFn:I=>Fe.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{f==="all"?R.mutate():N.mutate(f)},C=R.isPending||N.isPending,k=f==="all"?R.data:N.data,U=f==="all"?R.isSuccess:N.isSuccess;return y?h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(XU,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),h.jsx(on,{children:h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ft,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(XU,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&h.jsx(ct,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):c?h.jsx(Hp,{className:"w-4 h-4"}):"Save"})]})}),h.jsxs(on,{className:"space-y-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Enable Spoolman"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),h.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),h.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:I=>i(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),h.jsxs("select",{value:a,onChange:I=>s(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[h.jsx("option",{value:"auto",children:"Automatic"}),h.jsx("option",{value:"manual",children:"Manual Only"})]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&h.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),b?h.jsx(Ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?h.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[h.jsx(Hp,{className:"w-4 h-4"}),"Connected"]}):h.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[h.jsx(mn,{className:"w-4 h-4"}),"Disconnected"]})]}),h.jsx("div",{className:"flex gap-2",children:v?.connected?h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(aoe,{className:"w-4 h-4"}),"Disconnect"]}):h.jsxs(ct,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(ooe,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&h.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),v?.connected&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"relative flex-1",children:[h.jsxs("select",{value:f,onChange:I=>g(I.target.value==="all"?"all":Number(I.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[h.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]}),h.jsx(Gf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:j,disabled:C,children:[C?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(el,{className:"w-4 h-4"}),"Sync"]})]})]}),U&&k&&h.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function tVe(){const t=In(),{t:e,i18n:n}=PP(),[r,i]=E.useState(null),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,g]=E.useState(null),[m,y]=E.useState(!1),[v,b]=E.useState(null),[x,M]=E.useState(y9()),w=X=>{M(X),Xle(X)},A=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:T,isLoading:R}=Ut({queryKey:["settings"],queryFn:Fe.getSettings}),{data:N,isLoading:j}=Ut({queryKey:["smart-plugs"],queryFn:Fe.getSmartPlugs}),{data:C,isLoading:k}=Ut({queryKey:["notification-providers"],queryFn:Fe.getNotificationProviders}),{data:U}=Ut({queryKey:["ffmpeg-status"],queryFn:Fe.checkFfmpeg}),{data:I}=Ut({queryKey:["version"],queryFn:Fe.getVersion}),{data:H,refetch:O,isRefetching:B}=Ut({queryKey:["updateCheck"],queryFn:Fe.checkForUpdates,staleTime:300*1e3}),{data:V,refetch:G}=Ut({queryKey:["updateStatus"],queryFn:Fe.getUpdateStatus,refetchInterval:X=>{const ae=X.state.data;return ae?.status==="downloading"||ae?.status==="installing"?1e3:!1}}),K=yt({mutationFn:Fe.applyUpdate,onSuccess:()=>{G()}});E.useEffect(()=>{T&&!r&&i(T)},[T,r]),E.useEffect(()=>{if(T&&r){const X=T.auto_archive!==r.auto_archive||T.save_thumbnails!==r.save_thumbnails||T.capture_finish_photo!==r.capture_finish_photo||T.default_filament_cost!==r.default_filament_cost||T.currency!==r.currency||T.energy_cost_per_kwh!==r.energy_cost_per_kwh||T.energy_tracking_mode!==r.energy_tracking_mode||T.check_updates!==r.check_updates||T.notification_language!==r.notification_language;s(X)}},[T,r]);const Y=yt({mutationFn:Fe.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),i(X),s(!1),l(!0),setTimeout(()=>l(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),oe=()=>{r&&Y.mutate(r)},$=(X,ae)=>{r&&i({...r,[X]:ae})};return R||!r?h.jsx("div",{className:"p-8 flex justify-center",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),h.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),h.jsxs(ct,{onClick:oe,disabled:!a||Y.isPending,children:[Y.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):o?h.jsx(Hp,{className:"w-4 h-4"}):h.jsx(I0,{className:"w-4 h-4"}),o?"Saved!":"Save"]})]}),Y.isError&&h.jsxs("div",{className:"mb-6 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to save settings: ",Y.error.message]}),h.jsxs("div",{className:"flex gap-8",children:[h.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),h.jsxs(on,{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Auto-archive prints"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:r.auto_archive,onChange:X=>$("auto_archive",X.target.checked),className:"sr-only peer"}),h.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Save thumbnails"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:r.save_thumbnails,onChange:X=>$("save_thumbnails",X.target.checked),className:"sr-only peer"}),h.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Capture finish photo"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:r.capture_finish_photo,onChange:X=>$("capture_finish_photo",X.target.checked),className:"sr-only peer"}),h.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),r.capture_finish_photo&&U&&!U.installed&&h.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[h.jsx(ya,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),h.jsxs("div",{className:"text-sm",children:[h.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),h.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",h.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",h.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),h.jsxs(on,{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),h.jsx("input",{type:"number",step:"0.01",min:"0",value:r.default_filament_cost,onChange:X=>$("default_filament_cost",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),h.jsxs("select",{value:r.currency,onChange:X=>$("currency",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"USD",children:"USD ($)"}),h.jsx("option",{value:"EUR",children:"EUR (€)"}),h.jsx("option",{value:"GBP",children:"GBP (£)"}),h.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),h.jsx("option",{value:"JPY",children:"JPY (¥)"}),h.jsx("option",{value:"CNY",children:"CNY (¥)"}),h.jsx("option",{value:"CAD",children:"CAD ($)"}),h.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),h.jsx("input",{type:"number",step:"0.01",min:"0",value:r.energy_cost_per_kwh,onChange:X=>$("energy_cost_per_kwh",parseFloat(X.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),h.jsxs("select",{value:r.energy_tracking_mode||"total",onChange:X=>$("energy_tracking_mode",X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"print",children:"Prints Only"}),h.jsx("option",{value:"total",children:"Total Consumption"})]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),h.jsxs(on,{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[h.jsx(V_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),h.jsx("select",{value:n.language,onChange:X=>n.changeLanguage(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:CU.map(X=>h.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),h.jsx("select",{value:x,onChange:X=>w(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:m_.map(X=>h.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Sidebar order"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:A,children:[h.jsx(nw,{className:"w-4 h-4"}),"Reset"]})]})]})]})]}),h.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[h.jsx(eVe,{}),h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),h.jsxs(on,{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Check for updates"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:r.check_updates,onChange:X=>$("check_updates",X.target.checked),className:"sr-only peer"}),h.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),h.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[h.jsxs("div",{className:"flex items-center justify-between mb-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Current version"}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",I?.version||"..."]})]}),h.jsxs(ct,{variant:"secondary",size:"sm",onClick:()=>O(),disabled:B,children:[B?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(el,{className:"w-4 h-4"}),"Check now"]})]}),H?.update_available?h.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsxs("div",{children:[h.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",H.latest_version]}),H.release_name&&H.release_name!==H.latest_version&&h.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:H.release_name}),H.release_notes&&h.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:H.release_notes})]}),H.release_url&&h.jsx("a",{href:H.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:h.jsx(Qo,{className:"w-4 h-4"})})]}),V?.status==="downloading"||V?.status==="installing"?h.jsxs("div",{className:"mt-3",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),h.jsx("span",{children:V.message})]}),h.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:h.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${V.progress}%`}})})]}):V?.status==="complete"?h.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:V.message}):V?.status==="error"?h.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:V.error||V.message}):h.jsxs(ct,{className:"mt-3",onClick:()=>K.mutate(),disabled:K.isPending,children:[K.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(Ku,{className:"w-4 h-4"}),"Install Update"]})]}):H?.error?h.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",H.error]}):H&&!H.update_available?h.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),h.jsx("div",{className:"w-80 flex-shrink-0",children:h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(jN,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),h.jsxs(ct,{size:"sm",onClick:()=>{g(null),u(!0)},children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add"]})]})}),h.jsxs(on,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),j?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?h.jsx("div",{className:"space-y-4",children:N.map(X=>h.jsx(q$e,{plug:X,onEdit:ae=>{g(ae),u(!0)}},X.id))}):h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(jN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No smart plugs configured"}),h.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),h.jsx("div",{className:"w-80 flex-shrink-0",children:h.jsxs(Yt,{children:[h.jsx(Xl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ON,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),h.jsxs(ct,{size:"sm",onClick:()=>{b(null),y(!0)},children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add"]})]})}),h.jsxs(on,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),h.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary mb-4",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:e("settings.notificationLanguage")}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),h.jsx("select",{value:r.notification_language||"en",onChange:X=>$("notification_language",X.target.value),className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green",children:CU.map(X=>h.jsx("option",{value:X.code,children:X.nativeName},X.code))})]}),k?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):C&&C.length>0?h.jsx("div",{className:"space-y-4",children:C.map(X=>h.jsx(Y$e,{provider:X,onEdit:ae=>{b(ae),y(!0)}},X.id))}):h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(ON,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No notification providers configured"}),h.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),c&&h.jsx(X$e,{plug:f,onClose:()=>{u(!1),g(null)}}),m&&h.jsx(Z$e,{provider:v,onClose:()=>{y(!1),b(null)}})]})}const JJ=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},nVe=t=>t.startsWith("HH")?"HF":"S",rVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},eee=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 gN({profile:t,onEdit:e}){const n=nVe(t.nozzle_id),r=t.nozzle_diameter,i=t.name||"Unnamed",a=eee(t.name||"");return h.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:JJ(t.k_value)}),h.jsx("span",{className:"text-white text-sm truncate flex-1",title:i,children:i}),h.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[n," ",r]})]}),h.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 truncate",title:`Filament: ${a}`,children:["Filament: ",a||t.filament_id]})]})}function fG({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,onClose:a,onSave:s}){const{showToast:o}=eo(),l=In(),[c,u]=E.useState(t?.name||""),[f,g]=E.useState(t?.k_value?JJ(t.k_value):"0.020"),[m,y]=E.useState(t?.filament_id||""),[v,b]=E.useState(t?.nozzle_id?rVe(t.nozzle_id):"HH00"),[x,M]=E.useState(t?.nozzle_diameter||n),[w,A]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,R]=E.useState(!1),[N,j]=E.useState({current:0,total:0}),C=ur.useMemo(()=>{const V=new Map;for(const G of r)if(G.filament_id&&!V.has(G.filament_id)){const K=eee(G.name||"");V.set(G.filament_id,{id:G.filament_id,name:K||G.filament_id})}return Array.from(V.values()).sort((G,K)=>G.name.localeCompare(K.name))},[r]),k=yt({mutationFn:V=>(console.log("[KProfile] Calling API..."),Fe.setKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Save success:",V),o("K-profile saved"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),s()},2500)},onError:V=>{console.error("[KProfile] Save error:",V),o(V.message,"error"),R(!1)}}),U=yt({mutationFn:V=>(console.log("[KProfile] Deleting profile..."),Fe.deleteKProfile(e,V)),onSuccess:V=>{console.log("[KProfile] Delete success:",V),o("K-profile deleted"),R(!0),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),a()},2500)},onError:V=>{console.error("[KProfile] Delete error:",V),o(V.message,"error"),R(!1)}}),[I,H]=E.useState(!1),O=()=>{t&&U.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})},B=async V=>{if(V.preventDefault(),i&&!t&&w.length===0){o("Please select at least one extruder","error");return}const G=parseFloat(f).toFixed(6),K=`${v}-${x}`;if(t||w.length===1){const Y={name:c,k_value:G,filament_id:m,nozzle_id:K,nozzle_diameter:x,extruder_id:t?t.extruder_id:w[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",Y),k.mutate(Y);return}R(!0),j({current:0,total:w.length});for(let Y=0;Y<w.length;Y++){const oe=w[Y],$={name:c,k_value:G,filament_id:m,nozzle_id:K,nozzle_diameter:x,extruder_id:oe,setting_id:void 0,slot_id:0};j({current:Y+1,total:w.length}),console.log(`[KProfile] Saving profile ${Y+1}/${w.length} for extruder ${oe}:`,$);try{await Fe.setKProfile(e,$),Y<w.length-1&&await new Promise(X=>setTimeout(X,1500))}catch(X){console.error(`[KProfile] Failed to save for extruder ${oe}:`,X),o(`Failed to save for ${oe===1?"Left":"Right"} extruder`,"error"),R(!1),j({current:0,total:0});return}}o(`K-profile saved to ${w.length} extruders`),setTimeout(()=>{l.invalidateQueries({queryKey:["kprofiles",e]}),R(!1),j({current:0,total:0}),s()},2500)};return h.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[h.jsxs(Yt,{className:"w-full max-w-md relative",children:[T&&h.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),h.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),h.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),h.jsxs(on,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),h.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:B,className:"p-4 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),h.jsx("input",{type:"text",value:c,onChange:V=>u(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),h.jsx("input",{type:"text",inputMode:"decimal",value:f,onChange:V=>{const G=V.target.value;(G===""||/^\d*\.?\d*$/.test(G))&&g(G)},onBlur:V=>{const G=parseFloat(V.target.value);isNaN(G)||g((Math.trunc(G*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),h.jsxs("select",{value:m,onChange:V=>{const G=V.target.value;if(y(G),!t&&G&&!c){const K=C.find(Y=>Y.id===G);K&&u(`${v==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[h.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&h.jsx("option",{value:t.filament_id,children:C.find(V=>V.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&C.map(V=>h.jsx("option",{value:V.id,children:V.name},V.id))]}),!t&&C.length===0&&h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),h.jsxs("select",{value:v,onChange:V=>{const G=V.target.value;if(b(G),!t&&m&&!c){const K=C.find(Y=>Y.id===m);K&&u(`${G==="HH00"?"HF":"S"} ${K.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[h.jsx("option",{value:"HH00",children:"High Flow"}),h.jsx("option",{value:"HS00",children:"Standard"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),h.jsxs("select",{value:x,onChange:V=>M(V.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[h.jsx("option",{value:"0.2",children:"0.2mm"}),h.jsx("option",{value:"0.4",children:"0.4mm"}),h.jsx("option",{value:"0.6",children:"0.6mm"}),h.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?h.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):h.jsxs("div",{className:"flex gap-4",children:[h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:w.includes(1),onChange:V=>{V.target.checked?A([...w,1]):A(w.filter(G=>G!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),h.jsx("span",{className:"text-white",children:"Left"})]}),h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:w.includes(0),onChange:V=>{V.target.checked?A([...w,0]):A(w.filter(G=>G!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),h.jsx("span",{className:"text-white",children:"Right"})]})]})]}),h.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&h.jsx(ct,{type:"button",variant:"secondary",onClick:()=>H(!0),disabled:U.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:U.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(aa,{className:"w-4 h-4"})}),h.jsx(ct,{type:"button",variant:"secondary",onClick:a,disabled:T,className:"flex-1",children:"Cancel"}),h.jsxs(ct,{type:"submit",disabled:k.isPending||T,className:"flex-1",children:[k.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(HP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),I&&h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:h.jsx(Yt,{className:"w-full max-w-sm",children:h.jsxs(on,{className:"p-6",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[h.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:h.jsx(aa,{className:"w-5 h-5 text-red-500"})}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),h.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",h.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx(ct,{variant:"secondary",onClick:()=>H(!1),className:"flex-1",children:"Cancel"}),h.jsxs(ct,{onClick:()=>{H(!1),O()},disabled:U.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[U.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(aa,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function iVe(){const[t,e]=E.useState(null),[n,r]=E.useState("0.4"),[i,a]=E.useState(null),[s,o]=E.useState(!1),[l,c]=E.useState(""),[u,f]=E.useState("all"),[g,m]=E.useState("all"),{data:y,isLoading:v}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:b,isLoading:x,error:M,refetch:w}=Ut({queryKey:["kprofiles",t,n],queryFn:()=>Fe.getKProfiles(t,n),enabled:!!t,retry:!1,staleTime:0,refetchOnMount:"always"}),A=M?.message?.includes("not connected");E.useEffect(()=>{if(!t&&y&&y.length>0){const C=y.find(k=>k.is_active);C&&e(C.id)}},[t,y]),E.useEffect(()=>{if(t){const C=setTimeout(()=>{w()},150);return()=>clearTimeout(C)}},[t,n]);const T=y?.filter(C=>C.is_active)||[],R=ur.useMemo(()=>b?.profiles?b.profiles.filter(C=>{const k=l.toLowerCase(),U=!k||C.name.toLowerCase().includes(k)||C.filament_id.toLowerCase().includes(k),I=u==="all"||u==="left"&&C.extruder_id===1||u==="right"&&C.extruder_id===0,H=g==="all"||g==="hf"&&C.nozzle_id.startsWith("HH")||g==="s"&&C.nozzle_id.startsWith("HS");return U&&I&&H}):[],[b?.profiles,l,u,g]),j=y?.find(C=>C.id===t)?.nozzle_count===2;return v?h.jsx("div",{className:"flex justify-center py-12",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!y||y.length===0?h.jsx(Yt,{children:h.jsxs(on,{className:"py-12 text-center",children:[h.jsx(od,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),h.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):T.length===0?h.jsx(Yt,{children:h.jsxs(on,{className:"py-12 text-center",children:[h.jsx(mc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),h.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[h.jsxs("div",{className:"flex-1 min-w-48",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),h.jsx("select",{value:t||"",onChange:C=>e(parseInt(C.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:T.map(C=>h.jsx("option",{value:C.id,children:C.name},C.id))})]}),h.jsxs("div",{className:"w-32",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),h.jsxs("select",{value:n,onChange:C=>r(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"0.2",children:"0.2mm"}),h.jsx("option",{value:"0.4",children:"0.4mm"}),h.jsx("option",{value:"0.6",children:"0.6mm"}),h.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),h.jsxs("div",{className:"flex items-end gap-2",children:[h.jsxs(ct,{variant:"secondary",onClick:()=>w(),disabled:x,children:[h.jsx(el,{className:`w-4 h-4 ${x?"animate-spin":""}`}),"Refresh"]}),h.jsxs(ct,{onClick:()=>o(!0),children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add Profile"]})]})]}),h.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[h.jsxs("div",{className:"flex-1 min-w-48 relative",children:[h.jsx(q_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",value:l,onChange:C=>c(C.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"})]}),j&&h.jsx("div",{className:"w-36",children:h.jsxs("select",{value:u,onChange:C=>f(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"all",children:"All Extruders"}),h.jsx("option",{value:"left",children:"Left Only"}),h.jsx("option",{value:"right",children:"Right Only"})]})}),h.jsx("div",{className:"w-32",children:h.jsxs("select",{value:g,onChange:C=>m(C.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"all",children:"All Flow"}),h.jsx("option",{value:"hf",children:"HF Only"}),h.jsx("option",{value:"s",children:"S Only"})]})})]}),x?h.jsx("div",{className:"flex justify-center py-12",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):A?h.jsx(Yt,{children:h.jsxs(on,{className:"py-12 text-center",children:[h.jsx(Vp,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),h.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),h.jsxs(ct,{variant:"secondary",onClick:()=>w(),children:[h.jsx(el,{className:"w-4 h-4"}),"Retry"]})]})}):R.length>0?j?h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),h.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===1).map(C=>h.jsx(gN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),h.jsx("div",{className:"space-y-1",children:R.filter(C=>C.extruder_id===0).map(C=>h.jsx(gN,{profile:C,onEdit:()=>a(C)},C.slot_id))})]})]}):h.jsx("div",{className:"space-y-1",children:R.map(C=>h.jsx(gN,{profile:C,onEdit:()=>a(C)},C.slot_id))}):l||u!=="all"||g!=="all"?h.jsx(Yt,{children:h.jsxs(on,{className:"py-12 text-center",children:[h.jsx(q_,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),h.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):h.jsx(Yt,{children:h.jsxs(on,{className:"py-12 text-center",children:[h.jsx(HP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),h.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",n,"mm nozzle"]}),h.jsxs(ct,{onClick:()=>o(!0),children:[h.jsx(Jo,{className:"w-4 h-4"}),"Create First Profile"]})]})}),i&&t&&h.jsx(fG,{profile:i,printerId:t,nozzleDiameter:n,existingProfiles:b?.profiles,isDualNozzle:j,onClose:()=>a(null),onSave:()=>a(null)}),s&&t&&h.jsx(fG,{printerId:t,nozzleDiameter:n,existingProfiles:b?.profiles,isDualNozzle:j,onClose:()=>o(!1),onSave:()=>o(!1)})]})}function aVe({onSuccess:t}){const{showToast:e}=eo(),[n,r]=E.useState("email"),[i,a]=E.useState(""),[s,o]=E.useState(""),[l,c]=E.useState(""),[u,f]=E.useState(""),[g,m]=E.useState("global"),y=yt({mutationFn:()=>Fe.cloudLogin(i,s,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),v=yt({mutationFn:()=>Fe.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),b=yt({mutationFn:()=>Fe.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>{e(w.message,"error")}}),x=w=>{w.preventDefault(),n==="email"?y.mutate():n==="code"?v.mutate():n==="token"&&b.mutate()},M=y.isPending||v.isPending||b.isPending;return h.jsxs(Yt,{className:"max-w-md mx-auto",children:[h.jsx(Xl,{children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(BP,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"})]})}),h.jsx(on,{children:h.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),h.jsx("input",{type:"email",value:i,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),h.jsx("input",{type:"password",value:s,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),h.jsxs("select",{value:g,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"global",children:"Global"}),h.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),h.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),h.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),h.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),h.jsx("textarea",{value:u,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:3,required:!0})]}),h.jsxs("div",{className:"flex gap-2",children:[n==="code"&&h.jsx(ct,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),h.jsxs(ct,{type:"submit",disabled:M,className:"flex-1",children:[M?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(JU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[h.jsx(Jse,{className:"w-3 h-3"}),"Use access token instead"]})}),n==="token"&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[h.jsx(JU,{className:"w-3 h-3"}),"Login with email instead"]})})]})})]})}function sVe({setting:t,onClick:e}){return h.jsxs("button",{onClick:e,className:"w-full text-left p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[h.jsx("p",{className:"text-white font-medium truncate",children:t.name}),t.updated_time&&h.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Updated: ",new Date(t.updated_time).toLocaleDateString()]})]})}function oVe({setting:t,onClose:e}){const{data:n,isLoading:r}=Ut({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Fe.getCloudSettingDetail(t.setting_id)});return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx(Yt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:h.jsxs(on,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:t.name}),h.jsxs("p",{className:"text-sm text-bambu-gray capitalize",children:[t.type," preset"]})]}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):n?h.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap overflow-x-auto bg-bambu-dark p-4 rounded-lg",children:JSON.stringify(n,null,2)}):h.jsx("p",{className:"text-bambu-gray text-center py-8",children:"Failed to load preset details"})}),h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:h.jsx(ct,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})})}function lVe({settings:t}){const[e,n]=E.useState(new Set),[r,i]=E.useState(null),a=l=>[...l].sort((c,u)=>c.name.localeCompare(u.name)),s=l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u})},o=[{key:"filament",label:"Filament Presets",icon:a9,items:a(t.filament)},{key:"printer",label:"Printer Presets",icon:mc,items:a(t.printer)},{key:"process",label:"Process Presets",icon:GP,items:a(t.process)}];return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"space-y-4",children:o.map(({key:l,label:c,icon:u,items:f})=>h.jsxs(Yt,{children:[h.jsxs("button",{onClick:()=>s(l),className:"w-full flex items-center justify-between p-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(u,{className:"w-5 h-5 text-bambu-green"}),h.jsx("span",{className:"text-lg font-semibold text-white",children:c}),h.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",f.length,")"]})]}),e.has(l)?h.jsx(Gf,{className:"w-5 h-5 text-bambu-gray"}):h.jsx(Wf,{className:"w-5 h-5 text-bambu-gray"})]}),e.has(l)&&f.length>0&&h.jsx(on,{className:"pt-0",children:h.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:f.map(g=>h.jsx(sVe,{setting:g,onClick:()=>i(g)},g.setting_id))})}),e.has(l)&&f.length===0&&h.jsx(on,{className:"pt-0",children:h.jsx("p",{className:"text-bambu-gray text-sm",children:"No presets found"})})]},l))}),r&&h.jsx(oVe,{setting:r,onClose:()=>i(null)})]})}function cVe(){const t=In(),{showToast:e}=eo(),[n,r]=E.useState("kprofiles"),{data:i,isLoading:a}=Ut({queryKey:["cloudStatus"],queryFn:Fe.getCloudStatus}),{data:s,isLoading:o,refetch:l}=Ut({queryKey:["cloudSettings"],queryFn:()=>Fe.getCloudSettings(),enabled:!!i?.is_authenticated,retry:!1,staleTime:1e3*60*5}),c=yt({mutationFn:Fe.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),u=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return a?h.jsx("div",{className:"p-8 flex justify-center",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),h.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),h.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[h.jsxs("button",{onClick:()=>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:[h.jsx(BP,{className:"w-4 h-4"}),"Cloud Profiles"]}),h.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:[h.jsx(HP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[h.jsx("p",{className:"text-bambu-gray",children:i?.is_authenticated?`Connected as ${i.email}`:"Connect to Bambu Cloud to access your slicer presets"}),i?.is_authenticated&&h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(ct,{variant:"secondary",onClick:()=>l(),disabled:o,children:[h.jsx(el,{className:`w-4 h-4 ${o?"animate-spin":""}`}),"Refresh"]}),h.jsxs(ct,{variant:"secondary",onClick:()=>c.mutate(),disabled:c.isPending,children:[h.jsx(goe,{className:"w-4 h-4"}),"Logout"]})]})]}),i?.is_authenticated?o?h.jsx("div",{className:"flex justify-center py-12",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s?h.jsx(lVe,{settings:s}):h.jsx(Yt,{children:h.jsxs(on,{className:"py-8 text-center",children:[h.jsx("p",{className:"text-bambu-gray",children:"Failed to load profiles"}),h.jsx(ct,{className:"mt-4",onClick:()=>l(),children:"Retry"})]})}):h.jsx(aVe,{onSuccess:u})]}),n==="kprofiles"&&h.jsx(iVe,{})]})}const CP={Droplet:a9,Flame:o9,Ruler:Boe,Sparkles:ele,Square:$p,Cable:Gae,Wrench:Gp};function I_(t){return t&&CP[t]||Gp}function jx(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function uVe(t){const e=Math.floor(t),n=Math.round((t-e)*60);return e===0?`${n} minutes`:n===0?`${e} hours`:`${e}h ${n}m`}function dVe({item:t,onPerform:e,onToggle:n}){const r=I_(t.maintenance_type_icon),i=Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100)),a=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-yellow-400":"text-bambu-green":"text-bambu-gray",s=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-yellow-500":"bg-bambu-green":"bg-bambu-gray/30",o=()=>t.enabled?t.is_due?`Overdue by ${jx(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${jx(t.hours_until_due)}`:`${jx(t.hours_until_due)} left`:"Disabled";return h.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${t.is_due?"bg-red-500/10":t.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[h.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[h.jsx(r,{className:`w-4 h-4 ${a()}`}),h.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),h.jsx("div",{className:"flex-1 max-w-[200px]",children:h.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:h.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${i}%`}})})}),h.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&h.jsx(ya,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&h.jsx(ba,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&h.jsx(Hp,{className:"w-3 h-3 inline mr-1"}),o()]}),h.jsx(as,{checked:t.enabled,onChange:l=>n(t.id,l)}),h.jsxs(ct,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[h.jsx(nw,{className:"w-3 h-3"}),"Done"]})]})}function fVe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=E.useState(!1),[s,o]=E.useState(!1),[l,c]=E.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((m,y)=>m.maintenance_type_id-y.maintenance_type_id),f=[...t.maintenance_items].filter(m=>m.enabled).sort((m,y)=>m.is_due&&!y.is_due?-1:!m.is_due&&y.is_due?1:m.is_warning&&!y.is_warning?-1:!m.is_warning&&y.is_warning?1:m.hours_until_due-y.hours_until_due)[0],g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return h.jsxs(Yt,{children:[h.jsxs("div",{className:"p-4",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&h.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1",children:[h.jsx(ya,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&h.jsxs("span",{className:"px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-full flex items-center gap-1",children:[h.jsx(ba,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&h.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1",children:[h.jsx(Hp,{className:"w-3 h-3"}),"All good"]})]}),h.jsx("button",{onClick:()=>a(!i),className:"flex items-center gap-1 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded transition-colors",children:i?h.jsxs(h.Fragment,{children:[h.jsx(QS,{className:"w-4 h-4"}),"Hide"]}):h.jsxs(h.Fragment,{children:[h.jsx(Gf,{className:"w-4 h-4"}),"Details"]})})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[h.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!1)},className:"w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-lg font-semibold",min:"0",step:"1",autoFocus:!0}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),h.jsxs("div",{className:"flex gap-1 ml-auto",children:[h.jsx(ct,{size:"sm",onClick:g,children:"Save"}),h.jsx(ct,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):h.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"flex items-center gap-2 group",title:"Click to edit total print hours",children:[h.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:uVe(t.total_print_hours)}),h.jsx(VP,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),h.jsxs("div",{className:`p-3 rounded-lg ${f?.is_due?"bg-red-500/10":f?.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[h.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),f?h.jsxs("div",{children:[h.jsx("div",{className:`text-lg font-semibold ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-white"}`,children:f.maintenance_type_name}),h.jsx("div",{className:`text-sm ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:f.is_due?h.jsxs(h.Fragment,{children:["Overdue by ",jx(Math.abs(f.hours_until_due))]}):h.jsxs(h.Fragment,{children:["Due in ",jx(f.hours_until_due)]})})]}):h.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),i&&h.jsx(on,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:h.jsx("div",{className:"pt-4",children:u.map(m=>h.jsx(dVe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function hVe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onDeleteType:i}){const[a,s]=E.useState(null),[o,l]=E.useState(""),[c,u]=E.useState(!1),[f,g]=E.useState(""),[m,y]=E.useState("100"),[v,b]=E.useState("Wrench"),x=(R,N)=>{const j=parseFloat(o);if(!isNaN(j)&&j>0){const C=Math.abs(j-N)<.01?null:j;n(R,C)}s(null)},M=R=>{R.preventDefault(),f.trim()&&parseFloat(m)>0&&(r({name:f.trim(),default_interval_hours:parseFloat(m),icon:v}),g(""),y("100"),u(!1))},w=t?.map(R=>({printerId:R.printer_id,printerName:R.printer_name,items:R.maintenance_items.sort((N,j)=>N.maintenance_type_id-j.maintenance_type_id)})).sort((R,N)=>R.printerName.localeCompare(N.printerName))||[],A=e.filter(R=>R.is_system),T=e.filter(R=>!R.is_system);return h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),h.jsxs(ct,{size:"sm",variant:"secondary",onClick:()=>u(!c),children:[h.jsx(Jo,{className:"w-4 h-4"}),"Add Custom Type"]})]}),c&&h.jsx(Yt,{className:"mb-4",children:h.jsx("div",{className:"p-4",children:h.jsx("form",{onSubmit:M,children:h.jsxs("div",{className:"flex gap-3 items-end",children:[h.jsxs("div",{className:"flex-1",children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Name"}),h.jsx("input",{type:"text",value:f,onChange:R=>g(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),h.jsxs("div",{className:"w-28",children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Interval (hours)"}),h.jsx("input",{type:"number",value:m,onChange:R=>y(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"1"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Icon"}),h.jsx("div",{className:"flex gap-1",children:Object.keys(CP).map(R=>{const N=CP[R];return h.jsx("button",{type:"button",onClick:()=>b(R),className:`p-2 rounded ${v===R?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:h.jsx(N,{className:"w-4 h-4"})},R)})})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ct,{type:"submit",size:"sm",disabled:!f.trim(),children:"Add"}),h.jsx(ct,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!1),children:"Cancel"})]})]})})})}),h.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[A.map(R=>{const N=I_(R.icon);return h.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-dark-tertiary",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:h.jsx(N,{className:"w-5 h-5 text-bambu-gray"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-white truncate",children:R.name}),h.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]})]})},R.id)}),T.map(R=>{const N=I_(R.icon);return h.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-green/30",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"p-2 bg-bambu-green/20 rounded-lg",children:h.jsx(N,{className:"w-5 h-5 text-bambu-green"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium text-white truncate",children:R.name}),h.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),h.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]}),h.jsx("button",{onClick:()=>{confirm(`Delete "${R.name}"?`)&&i(R.id)},className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:h.jsx(aa,{className:"w-4 h-4"})})]})},R.id)})]})]}),w.length>0&&h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Interval Overrides"}),h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Set custom intervals per printer."}),h.jsx("div",{className:"space-y-3",children:w.map(R=>h.jsx(Yt,{children:h.jsxs("div",{className:"p-4",children:[h.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:R.printerName}),h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:R.items.map(N=>{const j=I_(N.maintenance_type_icon),k=e.find(I=>I.id===N.maintenance_type_id)?.default_interval_hours||N.interval_hours,U=a===N.id;return h.jsxs("div",{className:"flex items-center gap-2 p-2 bg-bambu-dark rounded-lg",children:[h.jsx(j,{className:"w-4 h-4 text-bambu-gray shrink-0"}),h.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:N.maintenance_type_name}),U?h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("input",{type:"number",value:o,onChange:I=>l(I.target.value),onKeyDown:I=>{I.key==="Enter"&&x(N.id,k),I.key==="Escape"&&s(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1",autoFocus:!0}),h.jsx(ct,{size:"sm",onClick:()=>x(N.id,k),children:"OK"})]}):h.jsxs("button",{onClick:()=>{s(N.id),l(N.interval_hours.toString())},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors",children:[N.interval_hours,"h",h.jsx(VP,{className:"w-3 h-3 inline ml-1.5 text-bambu-gray"})]})]},N.id)})})]})},R.printerId))})]}),w.length===0&&h.jsx(Yt,{children:h.jsxs(on,{className:"text-center py-12",children:[h.jsx(ba,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),h.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),h.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function pVe(){const t=In(),{showToast:e}=eo(),[n,r]=E.useState("status"),{data:i,isLoading:a}=Ut({queryKey:["maintenanceOverview"],queryFn:Fe.getMaintenanceOverview}),{data:s}=Ut({queryKey:["maintenanceTypes"],queryFn:Fe.getMaintenanceTypes}),o=yt({mutationFn:({id:x,notes:M})=>Fe.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=yt({mutationFn:({id:x,data:M})=>Fe.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=yt({mutationFn:Fe.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),u=yt({mutationFn:Fe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),f=yt({mutationFn:({printerId:x,hours:M})=>Fe.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),g=x=>{o.mutate({id:x})},m=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},y=(x,M)=>{f.mutate({printerId:x,hours:M})};if(a)return h.jsx("div",{className:"p-8 flex justify-center",children:h.jsx(Ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((x,M)=>x+M.due_count,0)||0,b=i?.reduce((x,M)=>x+M.warning_count,0)||0;return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),h.jsx("p",{className:"text-bambu-gray text-sm",children:n==="status"?h.jsxs(h.Fragment,{children:[v>0&&h.jsxs("span",{className:"text-red-400",children:[v," tasks overdue"]}),v>0&&b>0&&" · ",b>0&&h.jsxs("span",{className:"text-yellow-400",children:[b," due soon"]}),v===0&&b===0&&"All maintenance up to date"]}):"Configure maintenance types and intervals"})]}),h.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[h.jsx("button",{onClick:()=>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"}),h.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"?h.jsx("div",{className:"space-y-4",children:i&&i.length>0?[...i].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>h.jsx(fVe,{overview:x,onPerform:g,onToggle:m,onSetHours:y},x.printer_id)):h.jsx(Yt,{children:h.jsxs(on,{className:"text-center py-12",children:[h.jsx(Gp,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),h.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),h.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}):h.jsx(hVe,{overview:i,types:s||[],onUpdateInterval:(x,M)=>l.mutate({id:x,data:{custom_interval_hours:M}}),onAddType:x=>c.mutate(x),onDeleteType:x=>u.mutate(x)})]})}function mVe({printerId:t,isConnected:e}){const[n,r]=E.useState(!1),[i,a]=E.useState(!1),[s,o]=E.useState(null),l=E.useRef(null),c=Fe.getCameraStreamUrl(t,10),u=()=>{n?(r(!1),o(null)):(a(!0),o(null),r(!0))},f=()=>{a(!1),o(null)},g=()=>{a(!1),o("Failed to load camera stream")},m=()=>{l.current&&(document.fullscreenElement?document.exitFullscreen():l.current.requestFullscreen())},y=()=>{r(!1),setTimeout(()=>{a(!0),r(!0)},100)};return h.jsx("div",{className:"relative w-full h-full bg-black",children:n?h.jsxs(h.Fragment,{children:[i&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h.jsx(Ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}),s?h.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-red-400",children:[h.jsx(Yae,{className:"w-12 h-12 mb-2"}),h.jsx("span",{className:"text-sm",children:s}),h.jsx("button",{onClick:y,className:"mt-2 text-xs text-bambu-green hover:underline",children:"Retry"})]}):h.jsx("img",{ref:l,src:c,alt:"Camera stream",className:"w-full h-full object-contain",onLoad:f,onError:g}),h.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[h.jsx("button",{onClick:y,className:"p-2 rounded bg-gray-500 hover:bg-gray-400 text-white transition-colors shadow-lg",title:"Refresh stream",children:h.jsx(el,{className:"w-4 h-4"})}),h.jsx("button",{onClick:m,className:"p-2 rounded bg-gray-500 hover:bg-gray-400 text-white transition-colors shadow-lg",title:"Fullscreen",children:h.jsx(f9,{className:"w-4 h-4"})}),h.jsx("button",{onClick:u,className:"px-3 py-1.5 rounded bg-red-600 hover:bg-red-500 text-white text-sm transition-colors shadow-lg",children:"Stop"})]})]}):h.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-bambu-gray",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 flex flex-col items-center",children:[h.jsx($_,{className:"w-8 h-8 mb-2"}),h.jsx("span",{className:"text-sm mb-3",children:e?"Click Start to view camera":"Printer not connected"}),h.jsx("button",{onClick:u,disabled:!e,className:"px-4 py-1.5 rounded text-sm bg-bambu-green text-white hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed",children:"Start"})]})})})}function gVe(t){if(!t)return"N/A";const e=new Date;return new Date(e.getTime()+t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function xVe({printerId:t,status:e}){const n=In(),[r,i]=E.useState(null),a=e?.connected??!1,s=e?.state==="RUNNING",o=e?.state==="PAUSE",l=e?.progress??0,c=yt({mutationFn:()=>Fe.pausePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),u=yt({mutationFn:()=>Fe.resumePrint(t),onSuccess:()=>{n.invalidateQueries({queryKey:["printerStatuses"]})}}),f=yt({mutationFn:x=>Fe.stopPrint(t,x),onSuccess:x=>{Wx(x)?i({action:"stop",token:x.token,warning:x.warning}):n.invalidateQueries({queryKey:["printerStatuses"]})}}),g=()=>{s?c.mutate():o&&u.mutate()},m=()=>{f.mutate(void 0)},y=()=>{r&&(f.mutate(r.token),i(null))},v=c.isPending||u.isPending||f.isPending,b=a&&(s||o);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"text-xs text-bambu-gray mb-3",children:"Printing Progress"}),h.jsxs("div",{className:"flex gap-4 items-center",children:[h.jsx("div",{className:"w-20 h-20 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:e?.subtask_name?h.jsx("img",{src:`/api/v1/archives/thumbnail/${encodeURIComponent(e.subtask_name)}`,alt:"",className:"w-full h-full object-contain",onError:x=>{x.target.style.display="none",x.target.parentElement.innerHTML='<span class="text-xs text-bambu-gray">Bambu<br/>Lab</span>'}}):h.jsxs("span",{className:"text-xs text-bambu-gray text-center",children:["Bambu",h.jsx("br",{}),"Lab"]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"font-medium text-sm text-white truncate mb-0.5",children:e?.subtask_name||"N/A"}),h.jsx("div",{className:`text-sm mb-2 ${e?.state==="RUNNING"||e?.state==="PAUSE"?"text-bambu-green":"text-bambu-gray"}`,children:e?.state||"N/A"}),h.jsx("div",{className:"h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mb-2",children:h.jsx("div",{className:`h-full transition-all duration-300 ${e?.state==="PAUSE"?"bg-yellow-500":"bg-bambu-green"}`,style:{width:`${l}%`}})}),h.jsxs("div",{className:"text-xs text-bambu-gray mb-1",children:["Layer: ",e?.layer_num??"N/A"," / ",e?.total_layers??"N/A","    ",Math.round(l),"%"]}),h.jsxs("div",{className:"text-xs text-bambu-gray",children:["Estimated finish time: ",gVe(e?.remaining_time)]})]}),h.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[h.jsx("button",{onClick:g,disabled:!b||v,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:s?"Pause":"Resume",children:c.isPending||u.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(h9,{className:"w-4 h-4"})}),h.jsx("button",{onClick:m,disabled:!b||v,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Stop",children:f.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx($p,{className:"w-4 h-4"})}),h.jsx("button",{disabled:!b||v,className:"w-8 h-8 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Skip Objects",children:h.jsx("img",{src:"/icons/skip-objects.svg",alt:"Skip Objects",className:"w-4 h-4 icon-theme"})})]})]}),(c.error||u.error||f.error)&&h.jsx("p",{className:"mt-2 text-xs text-red-500",children:(c.error||u.error||f.error)?.message}),r&&h.jsx(ii,{title:"Confirm Stop",message:r.warning,confirmText:"Stop Print",variant:"danger",onConfirm:y,onCancel:()=>i(null)})]})}function vVe({checked:t,onChange:e,disabled:n}){return h.jsx("button",{onClick:()=>!n&&e(!t),disabled:n,className:`w-11 h-6 rounded-full relative transition-all shadow-inner border ${t?"bg-bambu-green border-bambu-green":"bg-bambu-dark-tertiary border-bambu-dark-tertiary"} ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:h.jsx("div",{className:`w-5 h-5 rounded-full bg-white shadow-md absolute top-0.5 transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})}function xN({name:t,icon:e,speed:n,enabled:r,onToggle:i,onSpeedChange:a,disabled:s,showSpeedControl:o=!0}){const l=()=>{const u=Math.min(100,n+10);a(u)},c=()=>{const u=Math.max(0,n-10);a(u)};return h.jsxs("div",{className:"bg-bambu-dark rounded-xl p-4 shadow-lg border border-bambu-dark-tertiary/50",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("div",{className:"flex items-center gap-2.5",children:[h.jsx("div",{className:"w-8 h-8 rounded-lg bg-bambu-dark-tertiary flex items-center justify-center",children:e}),h.jsx("span",{className:"text-white font-medium",children:t})]}),o&&h.jsx(vVe,{checked:r,onChange:i,disabled:s})]}),o?h.jsxs("div",{className:"flex items-center justify-between bg-bambu-dark-secondary rounded-lg p-2",children:[h.jsx("button",{onClick:c,disabled:s||!r,className:"w-9 h-9 rounded-lg bg-bambu-dark-tertiary flex items-center justify-center text-white hover:bg-bambu-dark transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:h.jsx(_oe,{className:"w-4 h-4"})}),h.jsx("div",{className:"flex-1 text-center",children:h.jsxs("span",{className:`text-xl font-semibold ${r?"text-white":"text-bambu-gray"}`,children:[n,"%"]})}),h.jsx("button",{onClick:l,disabled:s||!r,className:"w-9 h-9 rounded-lg bg-bambu-dark-tertiary flex items-center justify-center text-white hover:bg-bambu-dark transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:h.jsx(Jo,{className:"w-4 h-4"})})]}):h.jsx("div",{className:"p-3 text-center",children:h.jsx("span",{className:"text-xl font-semibold text-bambu-green",children:r?"Auto":"Off"})})]})}function bVe({onConfirm:t,onCancel:e}){return h.jsx("div",{className:"absolute inset-0 bg-black/80 flex items-center justify-center z-10 rounded-2xl",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-5 m-4 max-w-sm border border-bambu-dark-tertiary shadow-xl",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[h.jsx("div",{className:"w-10 h-10 rounded-full bg-yellow-500/20 flex items-center justify-center flex-shrink-0",children:h.jsx(ya,{className:"w-5 h-5 text-yellow-500"})}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-white font-semibold",children:"Print in Progress"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"The printer is currently controlling air conditioning."})]})]}),h.jsx("p",{className:"text-sm text-bambu-gray mb-5",children:"Changing these settings during a print may affect print quality. Are you sure you want to continue?"}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx("button",{onClick:e,className:"flex-1 py-2.5 px-4 rounded-lg font-medium text-sm bg-bambu-dark-tertiary text-white hover:bg-bambu-dark transition-colors",children:"Cancel"}),h.jsx("button",{onClick:t,className:"flex-1 py-2.5 px-4 rounded-lg font-medium text-sm bg-yellow-600 text-white hover:bg-yellow-700 transition-colors",children:"Continue"})]})]})})}function yVe({printer:t,status:e,onClose:n}){const r=e?.connected??!1,i=e?.state==="RUNNING"||e?.state==="PRINTING",a=!r,s=(e?.airduct_mode??0)===1?"heating":"cooling",[o,l]=E.useState(s),[c,u]=E.useState(!1),[f,g]=E.useState(null),[m,y]=E.useState(!1),[v,b]=E.useState(0),[x,M]=E.useState(!1),[w,A]=E.useState(0),[T,R]=E.useState(!1),[N,j]=E.useState(0),C=yt({mutationFn:te=>Fe.setAirductMode(t.id,te)}),k=yt({mutationFn:te=>Fe.setPartFan(t.id,te)}),U=yt({mutationFn:te=>Fe.setAuxFan(t.id,te)}),I=yt({mutationFn:te=>Fe.setChamberFan(t.id,te)}),H=te=>{i?(g(()=>te),u(!0)):te()},O=()=>{f&&(f(),g(null)),u(!1)},B=()=>{g(null),u(!1)},V=te=>{te!==o&&H(()=>{l(te),C.mutate(te)})},G=te=>{H(()=>{y(te),te||(b(0),k.mutate(0))})},K=te=>{H(()=>{b(te),y(te>0),k.mutate(te)})},Y=te=>{H(()=>{M(te),te||(A(0),U.mutate(0))})},oe=te=>{H(()=>{A(te),M(te>0),U.mutate(te)})},$=te=>{H(()=>{R(te),te||(j(0),I.mutate(0))})},X=te=>{H(()=>{j(te),R(te>0),I.mutate(te)})};E.useEffect(()=>{const te=ve=>{ve.key==="Escape"&&(c?B():n())};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[n,c]);const ae={cooling:"Suitable for PLA, PETG, TPU. Filters and cools the chamber air.",heating:"Suitable for ABS, ASA, PC, PA. Circulates and heats chamber air."},ce=()=>h.jsx("img",{src:"/icons/ventilation.svg",alt:"",className:"w-5 h-5 icon-theme"}),xe=()=>h.jsx("img",{src:"/icons/chamber.svg",alt:"",className:"w-5 h-5 icon-theme"});return h.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:n,children:h.jsxs("div",{className:"relative w-full max-w-lg bg-bambu-dark-secondary rounded-2xl shadow-2xl border border-bambu-dark-tertiary overflow-hidden",onClick:te=>te.stopPropagation(),children:[c&&h.jsx(bVe,{onConfirm:O,onCancel:B}),h.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-bambu-dark border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:h.jsx("img",{src:"/icons/ventilation.svg",alt:"",className:"w-5 h-5 icon-green"})}),h.jsx("span",{className:"text-base font-semibold text-white",children:"Air Condition"})]}),h.jsx("button",{onClick:n,className:"w-8 h-8 rounded-lg flex items-center justify-center text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-5 space-y-5",children:[i&&h.jsxs("div",{className:"flex items-center gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[h.jsx(ya,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-yellow-500",children:"Print in progress. Changes may affect print quality."})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-xl p-1.5 flex gap-1.5 shadow-inner",children:[h.jsxs("button",{onClick:()=>V("cooling"),disabled:a||C.isPending,className:`flex-1 py-3 px-4 rounded-lg flex items-center justify-center gap-2 font-medium transition-all disabled:opacity-50 ${o==="cooling"?"bg-bambu-green text-white shadow-lg":"text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(Ole,{className:"w-4 h-4"}),"Cooling"]}),h.jsxs("button",{onClick:()=>V("heating"),disabled:a||C.isPending,className:`flex-1 py-3 px-4 rounded-lg flex items-center justify-center gap-2 font-medium transition-all disabled:opacity-50 ${o==="heating"?"bg-bambu-green text-white shadow-lg":"text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(o9,{className:"w-4 h-4"}),"Heating"]})]}),h.jsx("p",{className:"text-sm text-bambu-gray text-center px-2",children:ae[o]}),h.jsx("div",{className:"border-t border-bambu-dark-tertiary"}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsx(xN,{name:"Part",icon:h.jsx(ce,{}),speed:v,enabled:m,onToggle:G,onSpeedChange:K,disabled:a,showSpeedControl:!0}),h.jsx(xN,{name:"Aux",icon:h.jsx(ce,{}),speed:w,enabled:x,onToggle:Y,onSpeedChange:oe,disabled:a,showSpeedControl:o==="cooling"}),h.jsx(xN,{name:"Exhaust",icon:h.jsx(ce,{}),speed:N,enabled:T,onToggle:$,onSpeedChange:X,disabled:a,showSpeedControl:o==="cooling"}),h.jsxs("div",{className:"bg-bambu-dark rounded-xl p-4 shadow-lg border border-bambu-dark-tertiary/50",children:[h.jsxs("div",{className:"flex items-center gap-2.5 mb-4",children:[h.jsx("div",{className:"w-8 h-8 rounded-lg bg-bambu-dark-tertiary flex items-center justify-center",children:h.jsx(xe,{})}),h.jsx("span",{className:"text-white font-medium",children:"Heat"})]}),h.jsx("div",{className:"p-3 text-center",children:h.jsx("span",{className:"text-xl font-semibold text-bambu-green",children:o==="heating"?"Auto":"Off"})})]})]})]})]})})}const _Ve=[{mode:1,name:"Silent",description:"Quieter printing, slower speed",percentage:"50%"},{mode:2,name:"Standard",description:"Balanced speed and quality",percentage:"100%"},{mode:3,name:"Sport",description:"Faster printing, moderate noise",percentage:"124%"},{mode:4,name:"Ludicrous",description:"Maximum speed",percentage:"166%"}];function SVe({printer:t,status:e,onClose:n}){const r=e?.connected??!1,i=e?.state==="RUNNING"||e?.state==="PRINTING",a=!r||!i,s=e?.speed_level??2,[o,l]=E.useState(s),c=yt({mutationFn:f=>Fe.setPrintSpeed(t.id,f)}),u=f=>{f===o||a||(l(f),c.mutate(f))};return E.useEffect(()=>{const f=g=>{g.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),h.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:n,children:h.jsxs("div",{className:"relative w-full max-w-lg bg-bambu-dark-secondary rounded-2xl shadow-2xl border border-bambu-dark-tertiary overflow-hidden",onClick:f=>f.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-bambu-dark border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-8 h-8 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:h.jsx("img",{src:"/icons/speed.svg",alt:"",className:"w-5 h-5 icon-green"})}),h.jsx("span",{className:"text-base font-semibold text-white",children:"Print Speed"})]}),h.jsx("button",{onClick:n,className:"w-8 h-8 rounded-lg flex items-center justify-center text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white transition-colors",children:h.jsx(mn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-5 space-y-4",children:[i?h.jsxs("div",{className:"flex items-center gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[h.jsx(ya,{className:"w-4 h-4 text-yellow-500 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-yellow-500",children:"Speed changes take effect immediately."})]}):h.jsxs("div",{className:"flex items-center gap-2 p-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg",children:[h.jsx(ya,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),h.jsx("span",{className:"text-xs text-bambu-gray",children:"No print in progress. Speed can only be changed during printing."})]}),h.jsx("div",{className:"space-y-2",children:_Ve.map(f=>h.jsxs("button",{onClick:()=>u(f.mode),disabled:a||c.isPending,className:`w-full p-4 rounded-xl flex items-center justify-between transition-all disabled:opacity-50 disabled:cursor-not-allowed ${o===f.mode?"bg-bambu-green text-white shadow-lg":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary"}`,children:[h.jsxs("div",{className:"flex flex-col items-start",children:[h.jsx("span",{className:"font-medium",children:f.name}),h.jsx("span",{className:`text-xs ${o===f.mode?"text-white/80":"text-bambu-gray"}`,children:f.description})]}),h.jsx("span",{className:`text-lg font-semibold ${o===f.mode?"text-white":"text-bambu-gray"}`,children:f.percentage})]},f.mode))})]})]})})}function wVe({printer:t,status:e,disabled:n=!1}){const r=e?.temperatures??{},i=t.nozzle_count>1,a=(e?.connected??!1)&&!n,[s,o]=E.useState(null),[l,c]=E.useState(""),[u,f]=E.useState(!1),[g,m]=E.useState(!1),y=yt({mutationFn:I=>Fe.setBedTemperature(t.id,I)}),v=yt({mutationFn:({target:I,nozzle:H})=>Fe.setNozzleTemperature(t.id,I,H)}),b=yt({mutationFn:I=>Fe.setChamberTemperature(t.id,I)}),x=yt({mutationFn:I=>Fe.setChamberLight(t.id,I)}),M=(I,H)=>{a&&(o(I),c(String(Math.round(H))))},w=()=>{o(null),c("")},A=()=>{const I=parseInt(l,10);if(isNaN(I)||I<0){w();return}s==="bed"?y.mutate(I):s==="nozzle"?v.mutate({target:I,nozzle:i?1:0}):s==="nozzle_2"?v.mutate({target:I,nozzle:0}):s==="chamber"&&b.mutate(I),w()},T=I=>{I.key==="Enter"?A():I.key==="Escape"&&w()},R=!a,N=r.nozzle_heating??!1,j=r.nozzle_2_heating??!1,C=r.bed_heating??!1,k=r.chamber_heating??!1,U=(I,H)=>s===I?h.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:l,onChange:O=>{const B=O.target.value.replace(/[^0-9]/g,"");c(B)},onBlur:A,onKeyDown:T,autoFocus:!0,className:"w-12 text-sm bg-bambu-dark border border-bambu-green rounded px-1 py-0.5 text-white text-center [appearance:textfield]"}):h.jsxs("button",{onClick:()=>M(I,H),disabled:R,className:"text-sm text-bambu-gray hover:text-bambu-green disabled:hover:text-bambu-gray disabled:cursor-not-allowed",title:R?"Printer not connected":"Click to set target temperature",children:["/",Math.round(H)," °C"]});return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col justify-evenly min-w-[150px] pr-5 border-r border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:h.jsx("img",{src:"/icons/hotend.svg",alt:"",className:`w-5 ${N?"icon-heating":"icon-theme"}`})}),i&&h.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"L"}),h.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle??0)}),U("nozzle",r.nozzle_target??0)]}),i&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:h.jsx("img",{src:"/icons/hotend.svg",alt:"",className:`w-5 ${j?"icon-heating":"icon-theme"}`})}),h.jsx("span",{className:"text-[11px] font-semibold text-bambu-green bg-bambu-green/20 px-1.5 py-0.5 rounded min-w-[18px] text-center flex-shrink-0",children:"R"}),h.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.nozzle_2??0)}),U("nozzle_2",r.nozzle_2_target??0)]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:h.jsx("img",{src:"/icons/heatbed.svg",alt:"",className:`w-5 ${C?"icon-heating":"icon-theme"}`})}),i&&h.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),h.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.bed??0)}),U("bed",r.bed_target??0)]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:h.jsx("img",{src:"/icons/chamber.svg",alt:"",className:`w-5 ${k?"icon-heating":"icon-theme"}`})}),i&&h.jsx("span",{className:"min-w-[18px] flex-shrink-0"}),h.jsx("span",{className:"text-lg font-medium text-white",children:Math.round(r.chamber??0)}),U("chamber",r.chamber_target??0)]}),h.jsxs("button",{onClick:()=>f(!0),disabled:R,className:"flex items-center justify-between w-full px-3 py-4 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("img",{src:"/icons/ventilation.svg",alt:"",className:"w-5 h-5 icon-theme"}),h.jsx("span",{className:"text-xs text-bambu-gray",children:"A/C"})]}),h.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${e?.airduct_mode===1?"bg-orange-500/20 text-orange-400":"bg-blue-500/20 text-blue-400"}`,children:e?.airduct_mode===1?"Heat":"Cool"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("button",{onClick:()=>m(!0),disabled:R,className:"flex-1 flex flex-col items-center py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:[h.jsx("img",{src:"/icons/speed.svg",alt:"",className:"w-5 h-5 icon-theme"}),h.jsx("span",{className:"text-[10px] text-bambu-gray mt-0.5",children:e?.speed_level===1?"50%":e?.speed_level===3?"124%":e?.speed_level===4?"166%":"100%"})]}),h.jsxs("button",{onClick:()=>x.mutate(!(e?.chamber_light??!1)),disabled:R||x.isPending,className:"flex-1 flex flex-col items-center py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:[h.jsx("img",{src:"/icons/lamp.svg",alt:"",className:`w-5 h-5 ${e?.chamber_light?"icon-green":"icon-theme"}`}),h.jsx("span",{className:"text-[10px] text-bambu-gray mt-0.5",children:"Lamp"})]})]})]}),u&&h.jsx(yVe,{printer:t,status:e,onClose:()=>f(!1)}),g&&h.jsx(SVe,{printer:t,status:e,onClose:()=>m(!1)})]})}const MVe=220,_i=MVe/2,c_=108,vu=72,u_=35,hG=28;function bu(t,e,n,r,i,a,s=8){const o=[];for(let l=0;l<=s;l++){const c=i+(a-i)*(l/s),u=Math.round(t+r*Math.cos(c)),f=Math.round(e+r*Math.sin(c));o.push(`${u},${f}`)}for(let l=s;l>=0;l--){const c=i+(a-i)*(l/s),u=Math.round(t+n*Math.cos(c)),f=Math.round(e+n*Math.sin(c));o.push(`${u},${f}`)}return o.join(",")}const ea={up:{start:-Math.PI*3/4,end:-Math.PI/4},right:{start:-Math.PI/4,end:Math.PI/4},down:{start:Math.PI/4,end:Math.PI*3/4},left:{start:Math.PI*3/4,end:Math.PI*5/4}};function EVe({printerId:t,status:e,disabled:n=!1}){const r=(e?.connected??!1)&&!n,i=E.useId(),[a,s]=E.useState(null),o=yt({mutationFn:({axes:v,token:b})=>Fe.homeAxes(t,v,b),onSuccess:v=>{Wx(v)&&s({action:"home",token:v.token,warning:v.warning,onConfirm:()=>o.mutate({axes:"XY",token:v.token})})}}),l=yt({mutationFn:({axis:v,distance:b,token:x})=>Fe.moveAxis(t,v,b,3e3,x),onSuccess:(v,b)=>{Wx(v)&&s({action:"move",token:v.token,warning:v.warning,onConfirm:()=>l.mutate({axis:b.axis,distance:b.distance,token:v.token})})}}),c=()=>{m||o.mutate({axes:"XY"})},u=(v,b)=>{m||l.mutate({axis:v,distance:b})},f=()=>{a&&(a.onConfirm(),s(null))},g=o.isPending||l.isPending,m=!r||g,y=Array.from({length:16},(v,b)=>{const x=b/16*Math.PI*2,M=Math.round(_i+hG*Math.cos(x)),w=Math.round(_i+hG*Math.sin(x));return`${M},${w}`}).join(",");return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"relative w-[220px] h-[220px] mb-3.5",children:[h.jsx("img",{src:"/icons/jogpad.svg",alt:"Jog Pad",useMap:`#${i}`,className:"w-full h-full jogpad-theme"}),h.jsxs("map",{name:i,children:[h.jsx("area",{shape:"poly",coords:bu(_i,_i,vu,c_,ea.up.start,ea.up.end),onClick:()=>u("Y",10),title:"Y+10mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,vu,c_,ea.down.start,ea.down.end),onClick:()=>u("Y",-10),title:"Y-10mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,vu,c_,ea.left.start,ea.left.end),onClick:()=>u("X",-10),title:"X-10mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,vu,c_,ea.right.start,ea.right.end),onClick:()=>u("X",10),title:"X+10mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,u_,vu,ea.up.start,ea.up.end),onClick:()=>u("Y",1),title:"Y+1mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,u_,vu,ea.down.start,ea.down.end),onClick:()=>u("Y",-1),title:"Y-1mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,u_,vu,ea.left.start,ea.left.end),onClick:()=>u("X",-1),title:"X-1mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:bu(_i,_i,u_,vu,ea.right.start,ea.right.end),onClick:()=>u("X",1),title:"X+1mm",style:{cursor:m?"not-allowed":"pointer"}}),h.jsx("area",{shape:"poly",coords:y,onClick:c,title:"Home XY",style:{cursor:m?"not-allowed":"pointer"}})]})]}),a&&h.jsx(ii,{title:"Confirm Action",message:a.warning,confirmText:"Continue",variant:"warning",onConfirm:f,onCancel:()=>s(null)})]})}function AVe({printerId:t,status:e,disabled:n=!1}){const r=(e?.connected??!1)&&!n,[i,a]=E.useState(null),s=yt({mutationFn:({distance:u,token:f})=>Fe.moveAxis(t,"Z",u,1e3,f),onSuccess:(u,f)=>{Wx(u)&&a({token:u.token,warning:u.warning,distance:f.distance})}}),o=u=>{s.mutate({distance:u})},l=()=>{i&&(s.mutate({distance:i.distance,token:i.token}),a(null))},c=!r||s.isPending;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:()=>o(-10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Bed up 10mm",children:"↑10"}),h.jsx("button",{onClick:()=>o(-1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Bed up 1mm",children:"↑1"}),h.jsx("span",{className:"px-2 py-2 text-sm text-bambu-gray",children:"Bed"}),h.jsx("button",{onClick:()=>o(1),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Bed down 1mm",children:"↓1"}),h.jsx("button",{onClick:()=>o(10),disabled:c,className:"px-3.5 py-2 rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary text-sm text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Bed down 10mm",children:"↓10"})]}),i&&h.jsx(ii,{title:"Confirm Bed Movement",message:i.warning,confirmText:"Continue",variant:"warning",onConfirm:l,onCancel:()=>a(null)})]})}function TVe({printerId:t,status:e,nozzleCount:n,disabled:r=!1}){const i=In(),a=(e?.connected??!1)&&!r,s=e?.state==="RUNNING"||e?.state==="PAUSE",o=n>1,l=e?.active_extruder??0,[c,u]=E.useState(null),f=yt({mutationFn:M=>(console.log("selectExtruder called with:",M),Fe.selectExtruder(t,M)),onSuccess:M=>{console.log("selectExtruder success:",M),setTimeout(()=>{i.invalidateQueries({queryKey:["printerStatuses"]})},2e3)},onError:M=>{console.error("selectExtruder error:",M)}}),g=yt({mutationFn:({distance:M,token:w})=>{const A=`G91
  8222. G1 E${M} F300
  8223. G90`;return Fe.sendGcode(t,A,w)},onSuccess:(M,w)=>{Wx(M)&&u({token:M.token,warning:M.warning,distance:w.distance})}}),m=M=>{g.mutate({distance:M})},y=()=>{c&&(g.mutate({distance:c.distance,token:c.token}),u(null))},v=!a||s||g.isPending,b=f.isPending,x=()=>o?l===1?"/icons/dual-extruder-left.png":"/icons/dual-extruder-right.png":"/icons/single-extruder1.png";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col items-center gap-1.5 justify-center",children:[o&&h.jsxs("div",{className:`flex rounded-md overflow-hidden border border-bambu-dark-tertiary mb-1 flex-shrink-0 ${v||b?"opacity-50":""}`,children:[h.jsx("button",{onClick:()=>f.mutate(1),disabled:v||b,className:`px-3 py-1.5 text-sm border-r border-bambu-dark-tertiary transition-colors disabled:cursor-not-allowed ${l===1?"bg-bambu-green text-white":"bg-bambu-dark-secondary text-bambu-gray hover:bg-bambu-dark-tertiary disabled:hover:bg-bambu-dark-secondary"}`,children:"Left"}),h.jsx("button",{onClick:()=>f.mutate(0),disabled:v||b,className:`px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed ${l===0?"bg-bambu-green text-white":"bg-bambu-dark-secondary text-bambu-gray hover:bg-bambu-dark-tertiary disabled:hover:bg-bambu-dark-secondary"}`,children:"Right"})]}),h.jsx("button",{onClick:()=>m(5),disabled:v,className:"w-9 h-[30px] rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Extrude 5mm",children:h.jsx(QS,{className:"w-4 h-4"})}),h.jsx("div",{className:"h-[120px] flex items-center justify-center",children:h.jsx("img",{src:x(),alt:o?`${l===1?"Left":"Right"} Extruder Active`:"Single Extruder",className:"h-full object-contain",onError:M=>{M.target.style.display="none"}})}),h.jsx("button",{onClick:()=>m(-5),disabled:v,className:"w-9 h-[30px] rounded-md bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary flex items-center justify-center text-bambu-gray disabled:opacity-50 disabled:cursor-not-allowed",title:"Retract 5mm",children:h.jsx(Gf,{className:"w-4 h-4"})}),h.jsx("span",{className:"text-xs text-bambu-gray mt-0.5",children:"Extruder"})]}),c&&h.jsx(ii,{title:"Confirm Extrusion",message:c.warning,confirmText:"Continue",variant:"warning",onConfirm:y,onCancel:()=>u(null)})]})}function CVe({humidity:t}){const e=()=>t<25?"/icons/humidity-empty.svg":t<40?"/icons/humidity-half.svg":"/icons/humidity-full.svg";return h.jsx("img",{src:e(),alt:"",className:"w-16 h-24"})}function NVe({humidity:t,temperature:e,dryingStatus:n,remainingTime:r,onClose:i}){E.useEffect(()=>{const s=o=>{o.key==="Escape"&&i()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i]);const a=()=>{if(n==="idle")return"Idle";if(!r)return"Drying...";const s=Math.floor(r/60),o=r%60;return s>0?`${s}h ${o}m`:`${o}m`};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-white dark:bg-bambu-dark-secondary rounded-lg shadow-xl max-w-md w-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Current AMS humidity"}),h.jsx("button",{onClick:i,className:"p-1 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(mn,{className:"w-5 h-5 text-gray-500 dark:text-bambu-gray"})})]}),h.jsxs("div",{className:"p-6",children:[h.jsxs("div",{className:"flex flex-col items-center mb-6",children:[h.jsx(CVe,{humidity:t}),h.jsxs("div",{className:"flex items-center gap-2 mt-2 text-gray-600 dark:text-bambu-gray",children:[h.jsx("span",{className:"text-yellow-500",children:"❊"}),h.jsx("span",{children:n==="idle"?"Idle":"Drying"})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-sm text-gray-500 dark:text-bambu-gray mb-1",children:"Humidity"}),h.jsxs("div",{className:"text-lg font-medium text-gray-900 dark:text-white",children:[t,"%"]})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-sm text-gray-500 dark:text-bambu-gray mb-1",children:"Temperature"}),h.jsxs("div",{className:"text-lg font-medium text-gray-900 dark:text-white",children:[e," °C"]})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-sm text-gray-500 dark:text-bambu-gray mb-1",children:"Remaining Time"}),h.jsx("div",{className:"text-lg font-medium text-gray-900 dark:text-white",children:a()})]})]})]})]})})}function vN(t){const e=t.indexOf(" @");return e>0?t.substring(0,e):t}function RVe(t){let e=t;e.startsWith("# ")&&(e=e.substring(2));const n=e.indexOf(" @");return n>0?e.substring(0,n):e}function bN(t){let e=t;e.startsWith("# ")&&(e=e.substring(2));const n=e.indexOf(" @");return n>0?e.substring(0,n):e}function PVe(t){if(!t)return"rgb(128, 128, 128)";const e=t.replace("#","").substring(0,6),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=isNaN(n)?128:n,s=isNaN(r)?128:r,o=isNaN(i)?128:i;return`rgb(${a}, ${s}, ${o})`}function yN(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function kVe(t){const e=t.replace("#","").toUpperCase();return e.length===6?`${e}FF`:`${e.substring(0,6)}FF`}function DVe(t){if(!t)return!1;const e=t.trim();return e.length!==32||e==="00000000000000000000000000000000"?!1:/^[0-9a-fA-F]{32}$/.test(e)}const OVe={Y2:"Sunflower Yellow",Y0:"Yellow",Y1:"Lemon Yellow",K0:"Black",W0:"White",W1:"Ivory White",R0:"Red",R1:"Scarlet Red",R2:"Magenta",B0:"Blue",B1:"Navy Blue",B2:"Sky Blue",B3:"Cyan",G0:"Green",G1:"Grass Green",G2:"Jade Green",O0:"Orange",O1:"Mandarin Orange",P0:"Purple",P1:"Pink",P2:"Sakura Pink",N0:"Gray",N1:"Silver Gray",N2:"Charcoal",D0:"Brown",D1:"Chocolate",T0:"Titan Gray",T1:"Jade White"};function LVe(t){if(!t)return null;const e=t.split("-");if(e.length<2)return null;const n=e[1];return OVe[n]||null}function IVe(t,e,n,r){if(!t.length)return null;const i=e?.toLowerCase()||"",a=n?.toUpperCase()||"",s=r?.toLowerCase()||"";if(i&&s){const l=t.find(c=>{const u=c.name.toLowerCase();return u.includes(i)&&u.includes(s)});if(l)return l}if(i){const l=t.find(c=>c.name.toLowerCase().includes(i));if(l)return l}if(a){const l=t.filter(c=>c.name.toUpperCase().includes(a));if(l.length>0){const c=l.find(u=>u.name.toLowerCase().includes("basic"));return c||l[0]}}return t.find(l=>l.name.toLowerCase()==="default"||l.slot_id===0)||null}function jVe({tray:t,amsId:e,slotLabel:n,printerId:r,printerModel:i,nozzleDiameter:a="0.4",extruderId:s=0,onClose:o,onConfirm:l}){const c=In(),u=!t.tray_type||t.tray_type===""||t.tray_type==="NONE",f=DVe(t.tray_uuid),g=u||!f,{data:m}=Ut({queryKey:["kprofiles",r,a],queryFn:()=>Fe.getKProfiles(r,a)}),{data:y}=Ut({queryKey:["cloudSettings"],queryFn:()=>Fe.getCloudSettings()}),{data:v}=Ut({queryKey:["slotPreset",r,e,t.id],queryFn:()=>Fe.getSlotPreset(r,e,t.id),enabled:g}),b=yt({mutationFn:({presetId:me,presetName:we})=>Fe.saveSlotPreset(r,e,t.id,me,we),onSuccess:()=>{c.invalidateQueries({queryKey:["slotPreset",r,e,t.id]})}}),x=yt({mutationFn:me=>Fe.amsSetFilamentSetting(r,me),onSuccess:me=>{console.log("[AMSMaterialsModal] saveFilamentSettingMutation SUCCESS:",me)},onError:me=>{console.error("[AMSMaterialsModal] saveFilamentSettingMutation ERROR:",me)}}),M=(()=>{const we=(y?.filament||[]).filter(Q=>!Q.name.startsWith("# ")),se=new RegExp(`@.*\\b${i}\\b`,"i"),st=[...we].sort((Q,ee)=>{const le=se.test(Q.name),Re=se.test(ee.name);return le&&!Re?-1:!le&&Re?1:0}),z=new Set;return st.filter(Q=>{const ee=RVe(Q.name);return z.has(ee)?!1:(z.add(ee),!0)}).sort((Q,ee)=>vN(Q.name).localeCompare(vN(ee.name)))})(),[w,A]=E.useState(null),[T,R]=E.useState(null),[N,j]=E.useState(t.tray_type||""),[C,k]=E.useState(yN(t.tray_color)),[U,I]=E.useState(t.nozzle_temp_max||220),[H,O]=E.useState(t.nozzle_temp_min||190),[B,V]=E.useState(""),[G,K]=E.useState(t.k||0);E.useEffect(()=>{v&&!w&&(A(v.preset_id),R(v.preset_name))},[v,w]);const Y=me=>{if(!me){A(null),R(null);return}A(me);const we=M.find(se=>se.setting_id===me);if(we){R(we.name);const se=we.name.match(/\b(PLA|PETG|ABS|TPU|ASA|PA|PC|PVA|HIPS|PLA-S|PETG-CF|PA-CF|PET-CF)\b/i);se&&j(se[1].toUpperCase())}},$=(m?.profiles||[]).filter(me=>me.extruder_id===s),ae=(()=>{if(!$.length)return[];const me=f?t.tray_sub_brands?.toLowerCase():T?bN(T).toLowerCase():null,we=f?t.tray_type?.toUpperCase():N?.toUpperCase()||t.tray_type?.toUpperCase();if(me){const se=$.filter(st=>st.name.toLowerCase().includes(me));return f?se.filter(st=>st.name.toLowerCase().includes("bambu")):se}return we?$.filter(se=>se.name.toUpperCase().includes(we)):[]})(),ce=LVe(t.tray_id_name);E.useEffect(()=>{const me=t.k;if(me&&me>0){const q=ae.find(ie=>{const Q=parseFloat(ie.k_value);return Math.abs(Q-me)<1e-4});if(q){V(q.name),K(me);return}}const we=f?t.tray_sub_brands:T?bN(T):null,se=f?t.tray_type:N||t.tray_type,z=IVe($,we,se,f?ce:null);z?(V(z.name),K(parseFloat(z.k_value)||0)):(V("Default"),K(0))},[$,ae,N,T,t.tray_type,t.tray_sub_brands,t.tray_id_name,t.k,f,ce]),E.useEffect(()=>{const me=we=>{we.key==="Escape"&&o()};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[o]);const xe=me=>{V(me);const we=$.find(se=>se.name===me);we&&K(parseFloat(we.k_value)||0)},te=()=>{console.log("[AMSMaterialsModal] handleConfirm called"),console.log("[AMSMaterialsModal] amsId:",e,"tray.id:",t.id,"kValue:",G),g&&w&&T&&(console.log("[AMSMaterialsModal] Saving preset mapping"),b.mutate({presetId:w,presetName:T}));const me=f?t.tray_color||"808080FF":kVe(C),we=f?t.tray_type||"PLA":N||"PLA",se=f?t.tray_sub_brands||"":T?bN(T):"",st={ams_id:e,tray_id:t.id,tray_info_idx:t.tray_info_idx||"",tray_type:we,tray_sub_brands:se,tray_color:me,nozzle_temp_min:H,nozzle_temp_max:U,k:G};console.log("[AMSMaterialsModal] Calling saveFilamentSettingMutation with payload:",st),x.mutate(st),l?.({filamentType:N,color:C,nozzleTempMax:U,nozzleTempMin:H,kProfile:B,kValue:G}),o()},ve=()=>{j(t.tray_type||""),k(yN(t.tray_color)),I(t.nozzle_temp_max||220),O(t.nozzle_temp_min||190),K(t.k||0)},De=f?t.tray_sub_brands||t.tray_type||"Unknown":N||"Select filament",he=f&&t.tray_uuid?t.tray_uuid:"N/A";return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-white dark:bg-bambu-dark-secondary rounded-lg shadow-xl max-w-md w-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[h.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:["AMS Materials Setting - ",n]}),h.jsx("button",{onClick:o,className:"p-1 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(mn,{className:"w-5 h-5 text-gray-500 dark:text-bambu-gray"})})]}),h.jsxs("div",{className:"p-6 space-y-4",children:[f&&h.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-green bg-bambu-green/10 px-3 py-1.5 rounded-md",children:[h.jsx("span",{className:"w-2 h-2 bg-bambu-green rounded-full"}),"Bambu Lab RFID detected - fields auto-filled"]}),!f&&!u&&h.jsxs("div",{className:"flex items-center gap-2 text-xs text-yellow-600 dark:text-yellow-400 bg-yellow-100 dark:bg-yellow-900/20 px-3 py-1.5 rounded-md",children:[h.jsx("span",{className:"w-2 h-2 bg-yellow-500 rounded-full"}),"Non-Bambu Lab filament - please verify settings"]}),u&&h.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-bambu-gray bg-gray-100 dark:bg-bambu-dark px-3 py-1.5 rounded-md",children:[h.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full"}),"Empty slot - configure filament settings"]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray",children:"Filament"}),g?h.jsxs("select",{value:w||"",onChange:me=>Y(me.target.value),className:"flex-1 min-w-0 px-3 py-2 bg-gray-100 dark:bg-bambu-dark rounded-md border border-gray-300 dark:border-bambu-dark-tertiary text-gray-900 dark:text-white text-sm truncate",children:[h.jsx("option",{value:"",children:"Select filament..."}),M.length>0?M.map(me=>h.jsx("option",{value:me.setting_id,children:vN(me.name)},me.setting_id)):h.jsxs("option",{value:"",disabled:!0,children:["No filament presets for ",i]})]}):h.jsx("div",{className:"flex-1 px-3 py-2 bg-gray-100 dark:bg-bambu-dark rounded-md text-gray-900 dark:text-white",children:De})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray",children:"Color"}),h.jsx("div",{className:"flex items-center gap-2 flex-1",children:g?h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"color",value:C,onChange:me=>k(me.target.value),className:"w-10 h-10 rounded cursor-pointer border-2 border-gray-300 dark:border-bambu-dark-tertiary"}),h.jsx("span",{className:"text-gray-900 dark:text-white text-sm",children:C.toUpperCase()})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-gray-300 dark:border-bambu-dark-tertiary flex-shrink-0",style:{backgroundColor:PVe(t.tray_color)}}),h.jsx("span",{className:"text-gray-900 dark:text-white",children:ce||yN(t.tray_color).toUpperCase()})]})})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray",children:"Nozzle Temp"}),h.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-gray-500 dark:text-bambu-gray mb-1",children:"min"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("input",{type:"number",value:H,onChange:me=>O(Number(me.target.value)),disabled:!g,className:"w-20 px-2 py-1 bg-gray-100 dark:bg-bambu-dark rounded border border-gray-300 dark:border-bambu-dark-tertiary text-gray-900 dark:text-white disabled:opacity-60"}),h.jsx("span",{className:"text-gray-600 dark:text-bambu-gray",children:"°C"})]})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-gray-500 dark:text-bambu-gray mb-1",children:"max"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("input",{type:"number",value:U,onChange:me=>I(Number(me.target.value)),disabled:!g,className:"w-20 px-2 py-1 bg-gray-100 dark:bg-bambu-dark rounded border border-gray-300 dark:border-bambu-dark-tertiary text-gray-900 dark:text-white disabled:opacity-60"}),h.jsx("span",{className:"text-gray-600 dark:text-bambu-gray",children:"°C"})]})]})]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray",children:"SN"}),h.jsx("div",{className:"flex-1 px-3 py-2 bg-gray-100 dark:bg-bambu-dark rounded-md text-gray-900 dark:text-white text-xs font-mono truncate",children:he})]}),h.jsxs("div",{className:"pt-4 border-t border-gray-200 dark:border-bambu-dark-tertiary",children:[h.jsxs("h3",{className:"text-sm font-medium text-gray-900 dark:text-white mb-3",children:["Flow Dynamics Calibration"," ",h.jsxs("a",{href:"https://wiki.bambulab.com/en/software/bambu-studio/calibration_pa",target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:["Wiki",h.jsx(Qo,{className:"w-3 h-3"})]})]}),h.jsxs("div",{className:"flex items-center gap-4 mb-3",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray flex-shrink-0",children:"PA Profile"}),h.jsxs("select",{value:B,onChange:me=>xe(me.target.value),className:"flex-1 min-w-0 px-3 py-2 bg-gray-100 dark:bg-bambu-dark rounded-md border border-gray-300 dark:border-bambu-dark-tertiary text-gray-900 dark:text-white text-sm truncate",children:[h.jsx("option",{value:"Default",children:"Default"}),ae.map(me=>h.jsxs("option",{value:me.name,children:[me.name," (K=",parseFloat(me.k_value).toFixed(3),")"]},me.slot_id))]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx("label",{className:"w-28 text-sm text-gray-600 dark:text-bambu-gray",children:"Factor K"}),h.jsx("div",{className:"flex-1 px-3 py-2 bg-gray-100 dark:bg-bambu-dark rounded-md text-gray-900 dark:text-white",children:G.toFixed(3)})]})]})]}),h.jsxs("div",{className:"flex items-center justify-center gap-3 p-4 border-t border-gray-200 dark:border-bambu-dark-tertiary",children:[h.jsx("button",{onClick:te,className:"px-6 py-2 bg-bambu-green text-white rounded-md hover:bg-bambu-green-dark transition-colors",children:"Confirm"}),h.jsx("button",{onClick:ve,className:"px-6 py-2 bg-gray-200 dark:bg-bambu-dark text-gray-700 dark:text-bambu-gray rounded-md hover:bg-gray-300 dark:hover:bg-bambu-dark-tertiary transition-colors",children:"Reset"}),h.jsx("button",{onClick:o,className:"px-6 py-2 bg-gray-200 dark:bg-bambu-dark text-gray-700 dark:text-bambu-gray rounded-md hover:bg-gray-300 dark:hover:bg-bambu-dark-tertiary transition-colors",children:"Close"})]})]})})}const UVe=15e3,pG=12e4;function FVe({printerId:t,amsUnits:e,amsStatusMain:n,trayNow:r,lastAmsUpdate:i,onToast:a}){const[s,o]=E.useState("IDLE"),[l,c]=E.useState(null),u=E.useRef(n),f=E.useRef(""),g=E.useRef(0),m=E.useRef(null),y=E.useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),v=E.useCallback(()=>{y(),o("IDLE"),c(null),f.current="",g.current=0},[y]),b=yt({mutationFn:({amsId:k,trayId:U})=>Fe.refreshAmsTray(t,k,U),onSuccess:k=>{k.success?a(k.message||"RFID refresh started","success"):(a(k.message||"Failed to refresh tray","error"),v())},onError:k=>{console.error("[useAmsOperations] Refresh error:",k),a("Failed to refresh tray","error"),v()}}),x=yt({mutationFn:({trayId:k,extruderId:U})=>Fe.amsLoadFilament(t,k,U),onSuccess:k=>{console.log("[useAmsOperations] Load request sent:",k)},onError:k=>{console.error("[useAmsOperations] Load error:",k),v()}}),M=yt({mutationFn:()=>Fe.amsUnloadFilament(t),onSuccess:k=>{console.log("[useAmsOperations] Unload request sent:",k)},onError:k=>{console.error("[useAmsOperations] Unload error:",k),v()}}),w=E.useCallback((k,U)=>{if(s!=="IDLE"){console.log("[useAmsOperations] Cannot start refresh - operation in progress:",s);return}const H=e.find(B=>B.id===k)?.tray?.find(B=>B.id===U);H&&(f.current=JSON.stringify({tag_uid:H.tag_uid,tray_uuid:H.tray_uuid,tray_type:H.tray_type,tray_color:H.tray_color})),g.current=i;const O=Date.now();console.log(`[useAmsOperations] Starting refresh: AMS ${k}, Tray ${U}, startTime=${O}, initialAmsUpdate=${i}`),o("REFRESHING"),c({refreshTarget:{amsId:k,trayId:U},startTime:O}),m.current=setTimeout(()=>{console.log(`[useAmsOperations] Refresh timeout for AMS ${k} tray ${U}`),v()},UVe),b.mutate({amsId:k,trayId:U})},[s,e,i,v,b]),A=E.useCallback((k,U)=>{if(s!=="IDLE"){console.log("[useAmsOperations] Cannot start load - operation in progress:",s);return}console.log(`[useAmsOperations] Starting load: tray ${k}, extruder ${U}`);const I=Date.now();o("LOADING"),c({loadTargetTrayId:k,startTime:I}),m.current=setTimeout(()=>{console.log(`[useAmsOperations] Load timeout for tray ${k}`),v()},pG),x.mutate({trayId:k,extruderId:U})},[s,v,x]),T=E.useCallback(()=>{if(s!=="IDLE"){console.log("[useAmsOperations] Cannot start unload - operation in progress:",s);return}console.log("[useAmsOperations] Starting unload");const k=Date.now();o("UNLOADING"),c({startTime:k}),m.current=setTimeout(()=>{console.log("[useAmsOperations] Unload timeout"),v()},pG),M.mutate()},[s,v,M]);E.useEffect(()=>{if(s!=="REFRESHING"||!l?.refreshTarget)return;const{amsId:k,trayId:U}=l.refreshTarget,I=Date.now()-l.startTime,O=e.find(K=>K.id===k)?.tray?.find(K=>K.id===U);if(!O)return;const B=JSON.stringify({tag_uid:O.tag_uid,tray_uuid:O.tray_uuid,tray_type:O.tray_type,tray_color:O.tray_color}),V=f.current&&B!==f.current,G=i!==g.current;if(V&&I>1e3){console.log(`[useAmsOperations] Refresh complete: data changed for AMS ${k} tray ${U} (took ${I}ms)`),v();return}G&&I>8e3&&(console.log(`[useAmsOperations] Refresh complete: new AMS update after ${I}ms for AMS ${k} tray ${U}`),v())},[s,l,e,i,v]),E.useEffect(()=>{if(s!=="LOADING"&&s!=="UNLOADING"){u.current=n;return}u.current===1&&n===0&&(console.log(`[useAmsOperations] ${s} complete: ams_status_main transitioned 1→0`),v()),u.current=n},[s,n,v]),E.useEffect(()=>{s!=="LOADING"||!l?.loadTargetTrayId||r===l.loadTargetTrayId&&(console.log(`[useAmsOperations] Load complete: tray_now=${r} matches target`),v())},[s,l,r,v]),E.useEffect(()=>{if(s!=="UNLOADING")return;const k=l?.startTime?Date.now()-l.startTime:0;r===255&&k>1e3&&(console.log("[useAmsOperations] Unload complete: tray_now=255"),v())},[s,l,r,v]),E.useEffect(()=>()=>{y()},[y]);const R=s!=="IDLE",N=E.useCallback((k,U)=>s!=="REFRESHING"||!l?.refreshTarget?!1:l.refreshTarget.amsId===k&&l.refreshTarget.trayId===U,[s,l]),j=s==="LOADING",C=l?.loadTargetTrayId??null;return{state:s,context:l,startRefresh:w,startLoad:A,startUnload:T,reset:v,isOperationInProgress:R,isRefreshingSlot:N,isLoadOperation:j,loadTargetTrayId:C,loadError:x.error,unloadError:M.error,refreshError:b.error}}function Ux(t){if(!t)return"rgb(128, 128, 128)";const e=t.replace("#","").substring(0,6),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=isNaN(n)?128:n,s=isNaN(r)?128:r,o=isNaN(i)?128:i;return`rgb(${a}, ${s}, ${o})`}function zVe(t){if(!t)return!1;const e=t.replace("#","").substring(0,6);if(e.length<6)return!1;const n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);return isNaN(n)||isNaN(r)||isNaN(i)?!1:(.299*n+.587*r+.114*i)/255>.45}const BVe={Y2:"Sunflower Yellow",Y0:"Yellow",Y1:"Lemon Yellow",K0:"Black",W0:"White",W1:"Ivory White",R0:"Red",R1:"Scarlet Red",R2:"Magenta",B0:"Blue",B1:"Navy Blue",B2:"Sky Blue",B3:"Cyan",G0:"Green",G1:"Grass Green",G2:"Jade Green",O0:"Orange",O1:"Mandarin Orange",P0:"Purple",P1:"Pink",P2:"Sakura Pink",N0:"Gray",N1:"Silver Gray",N2:"Charcoal",D0:"Brown",D1:"Chocolate",T0:"Titan Gray",T1:"Jade White"};function HVe(t){if(!t)return null;const e=t.split("-");if(e.length<2)return null;const n=e[1];return BVe[n]||null}function $Ve(t,e,n,r){if(!t.length)return null;const i=e?.toLowerCase()||"",a=n?.toUpperCase()||"",s=r?.toLowerCase()||"";if(i&&s){const l=t.find(c=>{const u=c.name.toLowerCase();return u.includes(i)&&u.includes(s)});if(l)return l}if(i){const l=t.find(c=>c.name.toLowerCase().includes(i));if(l)return l}if(a){const l=t.filter(c=>c.name.toUpperCase().includes(a));if(l.length>0){const c=l.find(u=>u.name.toLowerCase().includes("basic"));return c||l[0]}}return t.find(l=>l.name.toLowerCase()==="default"||l.slot_id===0)||null}function VVe({humidity:t}){const e=()=>t<25?"/icons/humidity-empty.svg":t<40?"/icons/humidity-half.svg":"/icons/humidity-full.svg";return h.jsx("img",{src:e(),alt:"",className:"w-2.5 h-[14px]"})}function GVe({isLoading:t,amsStatusMain:e,amsStatusSub:n,trayNow:r,targetTrayId:i,onComplete:a,onRetry:s}){const[o,l]=E.useState(!1),[c,u]=E.useState(!1),f=E.useRef(e),g=E.useRef(r),m=E.useRef(null),y=2,v=3,b=4,x=5,M=6,w=7;E.useEffect(()=>{console.log(`[FilamentChangeCard] Status: main=${e}, sub=${n}, trayNow=${r}, isLoading=${t}`)},[e,n,r,t]),E.useEffect(()=>{const U=f.current===1,I=e===0,H=r!==g.current;U&&I?(console.log("[FilamentChangeCard] ams_status_main transitioned 1->0, operation complete!"),u(!0),m.current=setTimeout(()=>{a()},1500)):H&&(t&&i!==null&&r===i?(console.log(`[FilamentChangeCard] Load completed! tray_now=${r} matches target=${i}`),u(!0),m.current=setTimeout(()=>{a()},1500)):!t&&r===255&&(console.log("[FilamentChangeCard] Unload completed! tray_now=255 (no filament)"),u(!0),m.current=setTimeout(()=>{a()},1500))),f.current=e,g.current=r},[e,r,t,i,a]),E.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const T=c?99:e!==1?0:t?n===x||n===M||n===v?1:n===y?2:n===w?3:1:n===y?1:n===b?2:1;console.log(`[FilamentChangeCard] Step calculation: currentStep=${T}, amsStatusSub=${n}`);const j=t?(()=>{let U="pending",I="pending",H="pending";return T>=99?(U="completed",I="completed",H="completed"):T>=3?(U="completed",I="completed",H="in_progress"):T>=2?(U="completed",I="in_progress"):T>=1&&(U="in_progress"),[{label:"Push new filament into extruder",stepNumber:1,status:U},{label:"Heat the nozzle",stepNumber:2,status:I},{label:"Purge old filament",stepNumber:3,status:H}]})():(()=>{let U="pending",I="pending";return T>=99?(U="completed",I="completed"):T>=2?(U="completed",I="in_progress"):T>=1&&(U="in_progress"),[{label:"Heat the nozzle",stepNumber:1,status:U},{label:"Retract filament from extruder",stepNumber:2,status:I}]})(),C=t?"Loading":"Unloading",k=t?"Filament loading...":"Filament unloading...";return h.jsxs("div",{className:"mt-3 border-l-4 border-bambu-green bg-white dark:bg-bambu-dark-secondary rounded-r-lg overflow-hidden",children:[h.jsxs("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between px-4 py-2 text-bambu-green hover:bg-gray-50 dark:hover:bg-bambu-dark-tertiary transition-colors",children:[h.jsx("span",{className:"text-sm font-medium",children:k}),o?h.jsx(Gf,{className:"w-4 h-4"}):h.jsx(QS,{className:"w-4 h-4"})]}),!o&&h.jsxs("div",{className:"px-4 pb-4",children:[h.jsxs("div",{className:"flex gap-6",children:[h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"text-bambu-green font-semibold mb-3",children:C}),h.jsx("div",{className:"space-y-2",children:j.map(U=>h.jsxs("div",{className:"flex items-center gap-2",children:[U.status==="completed"?h.jsx("div",{className:"w-5 h-5 rounded-full bg-bambu-green flex items-center justify-center flex-shrink-0",children:h.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})}):U.status==="in_progress"?h.jsx("div",{className:"w-5 h-5 rounded-full bg-bambu-green flex items-center justify-center flex-shrink-0",children:h.jsx("span",{className:"text-white text-xs font-bold",children:U.stepNumber})}):h.jsx("div",{className:"w-5 h-5 rounded-full border-2 border-gray-400 dark:border-gray-500 flex items-center justify-center flex-shrink-0",children:h.jsx("span",{className:"text-gray-400 dark:text-gray-500 text-xs font-medium",children:U.stepNumber})}),h.jsx("span",{className:`text-sm ${U.status==="in_progress"?"text-gray-900 dark:text-white font-semibold":U.status==="completed"?"text-gray-500 dark:text-gray-400":"text-gray-400 dark:text-gray-500"}`,children:U.label})]},U.stepNumber))})]}),h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:"/icons/extruder-change-filament.png",alt:"Extruder",className:"w-[150px] h-auto"})})]}),s&&h.jsxs("button",{onClick:s,className:"mt-3 px-4 py-1.5 border border-bambu-gray rounded-full text-sm text-bambu-gray hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-1.5",children:[h.jsx(Foe,{className:"w-3.5 h-3.5"}),"Retry"]})]})]})}function mG(t,e){if(t>=128){const r=t-128,i=String.fromCharCode(65+e);return r===0?`HT-${i}`:`HT${r+1}-${i}`}return`${String.fromCharCode(65+t)}${e+1}`}function NP(t){return t>=128}function gG({units:t,side:e,isPrinting:n,selectedAmsIndex:r,onSelectAms:i,selectedTray:a,onSelectTray:s,onHumidityClick:o,onSlotRefresh:l,onEyeClick:c,refreshingSlot:u,getKValue:f,kProfilesLoaded:g}){const m=t[r],y=m?NP(m.id):!1;return h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex gap-1.5 mb-2.5 p-1.5 bg-gray-300 dark:bg-bambu-dark rounded-lg",children:t.map((v,b)=>h.jsx("button",{onClick:()=>i(b),className:`flex items-center p-1.5 rounded border-2 transition-colors ${r===b?"border-bambu-green bg-white dark:bg-bambu-dark-tertiary":"bg-gray-200 dark:bg-bambu-dark-secondary border-transparent hover:border-bambu-gray"}`,children:h.jsx("div",{className:"flex gap-0.5",children:v.tray.map(x=>h.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:x.tray_color?Ux(x.tray_color):"#808080"}},x.id))})},v.id))}),m&&h.jsxs("div",{className:"bg-gray-100 dark:bg-bambu-dark-secondary rounded-[10px] p-2.5",children:[h.jsxs("button",{onClick:()=>o(m.humidity??0,m.temp??0),className:"flex items-center justify-center gap-4 text-xs text-bambu-gray mb-2.5 w-full py-1 hover:bg-gray-50 dark:hover:bg-bambu-dark-tertiary rounded-md transition-colors cursor-pointer",children:[m.humidity!==null&&h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx(VVe,{humidity:m.humidity}),m.humidity," %"]}),m.temp!==null&&h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("img",{src:"/icons/temperature.svg",alt:"",className:"w-3.5 icon-theme"}),m.temp,"°C"]})]}),h.jsx("div",{className:`flex gap-2 mb-1.5 ${y?"justify-start pl-2":"justify-center"}`,children:m.tray.map((v,b)=>{const x=mG(m.id,b),M=u?.amsId===m.id&&u?.trayId===v.id;return h.jsxs("button",{onClick:w=>{w.stopPropagation(),l(m.id,v.id)},disabled:M,className:`w-14 flex items-center justify-center gap-0.5 text-[10px] text-bambu-gray px-1.5 py-[3px] bg-bambu-dark rounded-full border border-bambu-dark-tertiary transition-colors ${M?"opacity-70 cursor-wait":"hover:bg-bambu-dark-tertiary"}`,children:[x,h.jsx("img",{src:"/icons/reload.svg",alt:"",className:`w-2.5 h-2.5 icon-theme ${M?"animate-spin":""}`})]},v.id)})}),h.jsx("div",{className:`flex gap-2 ${y?"justify-start pl-2":"justify-center"}`,children:m.tray.map((v,b)=>{const x=m.id*4+v.id,M=a===x,w=!v.tray_type||v.tray_type===""||v.tray_type==="NONE",A=zVe(v.tray_color),T=mG(m.id,b);return h.jsxs("div",{onClick:()=>{console.log(`[AMSSectionDual] Slot clicked: AMS ${m.id}, tray ${v.id}, globalTrayId: ${x}, isEmpty: ${w}, isPrinting: ${n}, isSelected: ${M}`),!w&&!n&&s(M?null:x)},className:`w-14 h-[80px] rounded-md border-2 overflow-hidden transition-all bg-bambu-dark relative ${M?"border-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-gray"} ${w?"opacity-50":"cursor-pointer"}`,children:[!w&&v.remain>=0&&h.jsx("div",{className:"absolute bottom-0 left-0 right-0 transition-all",style:{height:`${Math.min(100,Math.max(0,v.remain))}%`,backgroundColor:Ux(v.tray_color)}}),!w&&v.remain<0&&h.jsx("div",{className:"absolute inset-0",style:{backgroundColor:Ux(v.tray_color)}}),w&&h.jsx("div",{className:"absolute inset-0",style:{background:"repeating-linear-gradient(45deg, #3a3a3a, #3a3a3a 4px, #4a4a4a 4px, #4a4a4a 8px)"}}),h.jsxs("div",{className:"relative w-full h-full flex flex-col items-center justify-end pb-[5px]",children:[h.jsx("span",{className:"text-[11px] font-semibold",style:{color:A?"#000000":"#ffffff"},children:w?"--":v.tray_type}),!w&&g&&h.jsxs("span",{className:"text-[10px] font-medium",style:{color:A?"rgba(0,0,0,0.8)":"rgba(255,255,255,0.85)"},children:["K ",(f(v)??.02).toFixed(3)]}),!w&&h.jsx("button",{onClick:R=>{R.stopPropagation(),c(v,T,m.id)},className:"w-4 h-4 flex items-center justify-center rounded hover:bg-black/20 transition-colors",children:h.jsx("img",{src:"/icons/eye.svg",alt:"Settings",className:`w-3.5 h-3.5 ${A?"":"invert"}`,style:{opacity:.8}})})]})]},v.id)})})]}),t.length===0&&h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-[10px] p-6 text-center text-bambu-gray text-sm",children:["No AMS connected to ",e," nozzle"]})]})}function WVe({isDualNozzle:t,leftSlotCount:e,rightSlotCount:n,leftIsHT:r,rightIsHT:i,leftActiveSlot:a,rightActiveSlot:s,leftFilamentColor:o,rightFilamentColor:l}){if(!t)return null;const c="#909090",u=o?Ux(o):null,f=l?Ux(l):null,g=[54,118,182,246],m=[354,418,482,546];return h.jsxs("div",{className:"relative w-full pointer-events-none",style:{height:"120px"},children:[h.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:"0 0 600 120",preserveAspectRatio:"xMidYMid meet",children:[r?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:"36",y1:"0",x2:"36",y2:"36",stroke:a===0&&u?u:c,strokeWidth:a===0&&u?3:2}),e>1&&h.jsx("line",{x1:"100",y1:"0",x2:"100",y2:"36",stroke:a===1&&u?u:c,strokeWidth:a===1&&u?3:2}),e>1&&h.jsx("line",{x1:"36",y1:"36",x2:"100",y2:"36",stroke:u??c,strokeWidth:u?3:2}),h.jsx("line",{x1:e>1?"68":"36",y1:"36",x2:"288",y2:"36",stroke:u??c,strokeWidth:u?3:2}),h.jsx("line",{x1:"288",y1:"36",x2:"288",y2:"85",stroke:u??c,strokeWidth:u?3:2})]}):h.jsxs(h.Fragment,{children:[g.map((y,v)=>h.jsx("line",{x1:y,y1:"0",x2:y,y2:"14",stroke:a===v&&u?u:c,strokeWidth:a===v&&u?3:2},`left-slot-${v}`)),a!=null&&u?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:"54",y1:"14",x2:"246",y2:"14",stroke:c,strokeWidth:"2"}),h.jsx("line",{x1:Math.min(g[a],150),y1:"14",x2:Math.max(g[a],150),y2:"14",stroke:u,strokeWidth:"3"})]}):h.jsx("line",{x1:"54",y1:"14",x2:"246",y2:"14",stroke:c,strokeWidth:"2"}),h.jsx("rect",{x:"136",y:"8",width:"28",height:"14",rx:"2",fill:u??"#c0c0c0",stroke:u??c,strokeWidth:"1"}),h.jsx("line",{x1:"150",y1:"22",x2:"150",y2:"36",stroke:u??c,strokeWidth:u?3:2}),h.jsx("line",{x1:"150",y1:"36",x2:"288",y2:"36",stroke:u??c,strokeWidth:u?3:2}),h.jsx("line",{x1:"288",y1:"36",x2:"288",y2:"85",stroke:u??c,strokeWidth:u?3:2})]}),i?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:"336",y1:"0",x2:"336",y2:"36",stroke:s===0&&f?f:c,strokeWidth:s===0&&f?3:2}),n>1&&h.jsx("line",{x1:"400",y1:"0",x2:"400",y2:"36",stroke:s===1&&f?f:c,strokeWidth:s===1&&f?3:2}),n>1&&h.jsx("line",{x1:"336",y1:"36",x2:"400",y2:"36",stroke:f??c,strokeWidth:f?3:2}),h.jsx("line",{x1:"312",y1:"36",x2:n>1?"368":"336",y2:"36",stroke:f??c,strokeWidth:f?3:2}),h.jsx("line",{x1:"312",y1:"36",x2:"312",y2:"85",stroke:f??c,strokeWidth:f?3:2})]}):h.jsxs(h.Fragment,{children:[m.map((y,v)=>h.jsx("line",{x1:y,y1:"0",x2:y,y2:"14",stroke:s===v&&f?f:c,strokeWidth:s===v&&f?3:2},`right-slot-${v}`)),s!=null&&f?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:"354",y1:"14",x2:"546",y2:"14",stroke:c,strokeWidth:"2"}),h.jsx("line",{x1:Math.min(m[s],450),y1:"14",x2:Math.max(m[s],450),y2:"14",stroke:f,strokeWidth:"3"})]}):h.jsx("line",{x1:"354",y1:"14",x2:"546",y2:"14",stroke:c,strokeWidth:"2"}),h.jsx("rect",{x:"436",y:"8",width:"28",height:"14",rx:"2",fill:f??"#c0c0c0",stroke:f??c,strokeWidth:"1"}),h.jsx("line",{x1:"450",y1:"22",x2:"450",y2:"36",stroke:f??c,strokeWidth:f?3:2}),h.jsx("line",{x1:"312",y1:"36",x2:"450",y2:"36",stroke:f??c,strokeWidth:f?3:2}),h.jsx("line",{x1:"312",y1:"36",x2:"312",y2:"85",stroke:f??c,strokeWidth:f?3:2})]})]}),h.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-0 h-[50px] w-[39px]",children:[h.jsx("img",{src:"/icons/extruder-left-right.png",alt:"Extruder",className:"h-full w-full"}),h.jsx("div",{className:"absolute w-[8px] h-[8px] rounded-full",style:{left:"7px",top:"20px",backgroundColor:u??"transparent"}}),h.jsx("div",{className:"absolute w-[8px] h-[8px] rounded-full",style:{left:"25px",top:"20px",backgroundColor:f??"transparent"}})]})]})}function qVe({printerId:t,printerModel:e,status:n,nozzleCount:r}){const{showToast:i}=eo(),a=n?.connected??!1,s=n?.state==="RUNNING",o=r>1,l=n?.ams??[],c=n?.ams_extruder_map??{},u=n?.nozzles?.[0]?.nozzle_diameter||"0.4",{data:f,isFetched:g}=Ut({queryKey:["kprofiles",t,u],queryFn:()=>Fe.getKProfiles(t,u),enabled:a,staleTime:3e4}),m=we=>{const se=f?.profiles||[];if(!se.length)return null;const st=HVe(we.tray_id_name||null),z=$Ve(se,we.tray_sub_brands||null,we.tray_type||null,st);return z&&parseFloat(z.k_value)||null},y=o?Object.keys(c).length>0?l.filter(we=>c[String(we.id)]===0):l.filter((we,se)=>se%2===0):l,v=o?Object.keys(c).length>0?l.filter(we=>c[String(we.id)]===1):l.filter((we,se)=>se%2===1):[],[b,x]=E.useState(0),[M,w]=E.useState(0),[A,T]=E.useState(null),[R,N]=E.useState(null),[j,C]=E.useState(null),k=n?.ams_status_main??0,U=n?.tray_now??255,I=n?.last_ams_update??0,H=FVe({printerId:t,amsUnits:l,amsStatusMain:k,trayNow:U,lastAmsUpdate:I,onToast:i}),O=E.useRef(!1);E.useEffect(()=>{if(O.current)return;const we=n?.tray_now;we!=null&&(O.current=!0,we!==255&&we!==254?(console.log(`[AMSSectionDual] Initializing from tray_now: ${we}`),T(we)):console.log(`[AMSSectionDual] tray_now=${we} (no AMS filament loaded)`))},[n?.tray_now]);const B=we=>{T(we)},V=we=>{if(o)for(const se of l){const st=se.id>=128?2:4,z=se.id*4;if(we>=z&&we<z+st){const q=c[String(se.id)];return console.log(`[AMSSectionDual] Tray ${we} belongs to AMS ${se.id}, extruder: ${q}`),q}}},G=()=>{if(console.log(`[AMSSectionDual] handleLoad called, selectedTray: ${A}`),A!==null){const we=V(A);console.log(`[AMSSectionDual] Starting load via hook: tray ${A}, extruder ${we}`),H.startLoad(A,we)}},K=()=>{console.log(`[AMSSectionDual] handleUnload called, printerId: ${t}, trayNow: ${U}`),H.startUnload()},Y=()=>{console.log("[AMSSectionDual] FilamentChangeCard completed, resetting operation"),H.reset()},oe=(we,se)=>{N({humidity:we,temp:se})},$=(we,se)=>{console.log(`[AMSSectionDual] Slot refresh triggered: AMS ${we}, Slot ${se}`),H.startRefresh(we,se)},X=(we,se,st)=>{C({tray:we,slotLabel:se,amsId:st})},ae=k===1,ce=H.state==="LOADING"||H.state==="UNLOADING"||ae,xe=()=>{if(U===255||U===254)return{leftActiveSlot:null,rightActiveSlot:null,leftFilamentColor:null,rightFilamentColor:null};for(const we of l){const se=we.id>=128?2:4,st=we.id*4;if(U>=st&&U<st+se){const z=U-st,ie=we.tray[z]?.tray_color??null,Q=c[String(we.id)],ee=y[b],le=v[M];if(Q===0){const Re=ee?.id===we.id;return{leftActiveSlot:Re?z:null,rightActiveSlot:null,leftFilamentColor:Re?ie:null,rightFilamentColor:null}}else{const Re=le?.id===we.id;return{leftActiveSlot:null,rightActiveSlot:Re?z:null,leftFilamentColor:null,rightFilamentColor:Re?ie:null}}}}return{leftActiveSlot:null,rightActiveSlot:null,leftFilamentColor:null,rightFilamentColor:null}},{leftActiveSlot:te,rightActiveSlot:ve,leftFilamentColor:De,rightFilamentColor:he}=xe(),me=H.state==="REFRESHING"&&H.context?.refreshTarget?{amsId:H.context.refreshTarget.amsId,trayId:H.context.refreshTarget.trayId}:null;return h.jsxs("div",{className:"bg-bambu-dark-tertiary rounded-[10px] p-3",children:[h.jsxs("div",{className:"flex gap-5",children:[h.jsx(gG,{units:y,side:"left",isPrinting:s,selectedAmsIndex:b,onSelectAms:x,selectedTray:A,onSelectTray:B,onHumidityClick:oe,onSlotRefresh:$,onEyeClick:X,refreshingSlot:me,getKValue:m,kProfilesLoaded:g}),o&&h.jsx(gG,{units:v,side:"right",isPrinting:s,selectedAmsIndex:M,onSelectAms:w,selectedTray:A,onSelectTray:B,onHumidityClick:oe,onSlotRefresh:$,onEyeClick:X,refreshingSlot:me,getKValue:m,kProfilesLoaded:g})]}),h.jsx(WVe,{isDualNozzle:o,leftSlotCount:y[b]?.tray?.length??4,rightSlotCount:v[M]?.tray?.length??4,leftIsHT:y[b]?NP(y[b].id):!1,rightIsHT:v[M]?NP(v[M].id):!1,leftActiveSlot:te,rightActiveSlot:ve,leftFilamentColor:De,rightFilamentColor:he}),h.jsxs("div",{className:"flex items-start -mt-[50px]",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{className:"w-10 h-10 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark border border-bambu-dark-tertiary flex items-center justify-center",children:h.jsx("img",{src:"/icons/ams-settings.svg",alt:"Settings",className:"w-5 icon-theme"})}),h.jsx("button",{className:"px-[18px] py-2.5 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark border border-bambu-dark-tertiary text-sm text-bambu-gray flex items-center gap-1.5",children:"Auto-refill"})]}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:K,disabled:!a||s||H.isOperationInProgress||U===255,className:`px-7 py-2.5 rounded-lg text-sm transition-colors border ${!a||s||H.isOperationInProgress||U===255?"bg-bambu-gray-dark text-gray-500 border-bambu-gray-dark cursor-not-allowed":"bg-bambu-dark-secondary text-white border-bambu-dark-tertiary hover:bg-bambu-dark"}`,children:H.state==="UNLOADING"?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):"Unload"}),h.jsx("button",{onClick:G,disabled:!a||s||A===null||H.isOperationInProgress||A===U,className:`px-7 py-2.5 rounded-lg text-sm transition-colors border ${!a||s||A===null||H.isOperationInProgress||A===U?"bg-bambu-gray-dark text-gray-500 border-bambu-gray-dark cursor-not-allowed":"bg-bambu-dark-secondary text-white border-bambu-dark-tertiary hover:bg-bambu-dark"}`,children:H.state==="LOADING"?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):"Load"})]})]}),(H.loadError||H.unloadError)&&h.jsx("p",{className:"mt-2 text-sm text-red-500 text-center",children:(H.loadError||H.unloadError)?.message}),ce&&h.jsx(GVe,{isLoading:H.isLoadOperation,amsStatusMain:k,amsStatusSub:n?.ams_status_sub??0,trayNow:U,targetTrayId:H.loadTargetTrayId,onComplete:Y}),R&&h.jsx(NVe,{humidity:R.humidity,temperature:R.temp,dryingStatus:"idle",onClose:()=>N(null)}),j&&h.jsx(jVe,{tray:j.tray,amsId:j.amsId,slotLabel:j.slotLabel,printerId:t,printerModel:e,nozzleDiameter:n?.nozzles?.[0]?.nozzle_diameter||"0.4",extruderId:c[j.amsId.toString()]??0,onClose:()=>C(null)})]})}function xG(t){const e=t.toUpperCase();if(e.startsWith("HH")||e.startsWith("HS"))return"Hardened Steel";if(e.startsWith("SS"))return"Stainless Steel";switch(t){case"hardened_steel":return"Hardened Steel";case"stainless_steel":return"Stainless Steel";default:return t||"Unknown"}}function vG(t){return t.toUpperCase().startsWith("HH")?"High flow":"Standard"}function XVe({printer:t,status:e,onClose:n}){const r=In(),i=t.nozzle_count>1;E.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const a=e?.nozzles?.[0],s=e?.nozzles?.[1],o=s?.nozzle_type||s?.nozzle_diameter?s:a,l=yt({mutationFn:()=>Fe.refreshStatus(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["printerStatuses"]})}}),c=()=>{l.mutate()};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsx(Yt,{className:"w-full max-w-2xl",onClick:u=>u.stopPropagation(),children:h.jsxs(on,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-sm font-medium text-white",children:"Printer Parts"}),h.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:h.jsx(mn,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"p-6 space-y-6",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:i?"Left Nozzle":"Nozzle"}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Type"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:xG(a?.nozzle_type||"")})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Diameter"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:a?.nozzle_diameter||"—"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Flow"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:vG(a?.nozzle_type||"")})]})]})]}),i&&h.jsxs("div",{children:[h.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:"Right Nozzle"}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Type"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:xG(o?.nozzle_type||"")})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Diameter"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:o?.nozzle_diameter||"—"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1.5",children:"Flow"}),h.jsx("div",{className:"px-3 py-2 bg-bambu-dark rounded border border-bambu-dark-tertiary text-sm text-bambu-gray",children:vG(o?.nozzle_type||"")})]})]})]}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:["Please change the nozzle settings on the printer."," ",h.jsx("a",{href:"https://wiki.bambulab.com",target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:"View wiki"})]})]}),h.jsx("div",{className:"flex justify-end px-4 py-3 border-t border-bambu-dark-tertiary",children:h.jsxs("button",{onClick:c,disabled:l.isPending,className:"flex items-center gap-2 px-4 py-2 bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 text-white text-sm font-medium rounded",children:[l.isPending?h.jsx(Ft,{className:"w-4 h-4 animate-spin"}):h.jsx(el,{className:"w-4 h-4"}),"Refresh"]})})]})})})}function $d({checked:t,onChange:e,disabled:n,loading:r}){return h.jsx("button",{onClick:()=>!n&&!r&&e(!t),disabled:n||r,className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${t?"bg-bambu-green border-bambu-green":"bg-transparent border-bambu-gray"} ${n||r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:r?h.jsx(Ft,{className:"w-3 h-3 animate-spin text-white"}):t?h.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):null})}function d_({value:t,onChange:e,disabled:n,loading:r}){const[i,a]=E.useState(!1),s=["Low","Medium","High"],o=t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),l=n||r;return h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>!l&&a(!i),disabled:l,className:`flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white min-w-[100px] justify-between ${l?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-bambu-gray"}`,children:[r?h.jsx(Ft,{className:"w-4 h-4 animate-spin text-bambu-green"}):h.jsx("span",{children:o}),h.jsx(Gf,{className:"w-4 h-4 text-bambu-gray"})]}),i&&!l&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),h.jsx("div",{className:"absolute top-full left-0 mt-1 w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded shadow-lg z-20",children:s.map(c=>h.jsx("button",{onClick:()=>{e(c.toLowerCase()),a(!1)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.toLowerCase()===c.toLowerCase()?"text-bambu-green":"text-white"}`,children:c},c))})]})]})}function KVe({printer:t,status:e,onClose:n}){const r=In(),i=e?.print_options,a=e?.connected??!1;E.useEffect(()=>{const f=g=>{g.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]);const s=yt({mutationFn:({apiModuleName:f,enabled:g,printHalt:m,sensitivity:y})=>Fe.setPrintOption(t.id,f,g,m,y),onSuccess:()=>{r.invalidateQueries({queryKey:["printerStatuses"]})}}),o=(f,g,m)=>{const y=g&&m!==void 0&&m!=="never_halt";s.mutate({uiModuleName:f,apiModuleName:f,enabled:g,printHalt:y,sensitivity:m??"medium"})},l=(f,g)=>{let m=f;f==="pileup_detector"&&(m="spaghetti_detector"),s.mutate({uiModuleName:f,apiModuleName:m,enabled:!0,printHalt:!0,sensitivity:g})},c=f=>s.isPending&&s.variables?.uiModuleName===f,u=f=>{if(!s.isPending||!s.variables?.sensitivity)return!1;const g=s.variables.uiModuleName;return g===f||g==="spaghetti_detector"&&f==="pileup_detector"||g==="pileup_detector"&&f==="spaghetti_detector"};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsx(Yt,{className:"w-full max-w-xl max-h-[90vh] flex flex-col",onClick:f=>f.stopPropagation(),children:h.jsxs(on,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-sm font-medium text-white",children:"Print Options"}),h.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:h.jsx(mn,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[!a&&h.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400",children:[h.jsx(ya,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm",children:"Printer not connected. Options cannot be changed."})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-base font-semibold text-white mb-1",children:"AI Detections"}),h.jsx("p",{className:"text-xs text-bambu-gray mb-4",children:"Printer will send assistant message or pause printing if any of the following problem is detected."}),h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.spaghetti_detector,onChange:f=>o("spaghetti_detector",f,i.halt_print_sensitivity),disabled:!a,loading:c("spaghetti_detector")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Spaghetti Detection"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Detects spaghetti failure (scattered loose filament)."}),h.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),h.jsx(d_,{value:i.halt_print_sensitivity||"medium",onChange:f=>l("spaghetti_detector",f),disabled:!a||!i.spaghetti_detector,loading:u("spaghetti_detector")})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.pileup_detector,onChange:f=>o("pileup_detector",f,i.pileup_sensitivity),disabled:!a,loading:c("pileup_detector")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Purge Chute Pile-Up Detection"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Monitors if the waste is piled up in the purge chute."}),h.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),h.jsx(d_,{value:i.pileup_sensitivity||"medium",onChange:f=>l("pileup_detector",f),disabled:!a||!i.pileup_detector,loading:u("pileup_detector")})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.nozzle_clumping_detector,onChange:f=>o("clump_detector",f,i.nozzle_clumping_sensitivity),disabled:!a,loading:c("clump_detector")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Nozzle Clumping Detection"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Checks if the nozzle is clumping by filaments or other foreign objects."}),h.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),h.jsx(d_,{value:i.nozzle_clumping_sensitivity||"medium",onChange:f=>l("clump_detector",f),disabled:!a||!i.nozzle_clumping_detector,loading:u("clump_detector")})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.airprint_detector,onChange:f=>o("airprint_detector",f,i.airprint_sensitivity),disabled:!a,loading:c("airprint_detector")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Air Printing Detection"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Detects air printing caused by nozzle clogging or filament grinding."}),h.jsxs("div",{className:"flex items-center gap-3 ml-8",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Pausing Sensitivity:"}),h.jsx(d_,{value:i.airprint_sensitivity||"medium",onChange:f=>l("airprint_detector",f),disabled:!a||!i.airprint_detector,loading:u("airprint_detector")})]})]})]})]}),h.jsx("hr",{className:"border-bambu-dark-tertiary"}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-base font-semibold text-white mb-1",children:"Build Plate Detection"}),h.jsx("p",{className:"text-xs text-bambu-gray mb-4",children:"Ensures the build plate type and placement are correct."}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.buildplate_marker_detector,onChange:f=>o("buildplate_marker_detector",f),disabled:!a,loading:c("buildplate_marker_detector")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Type Detection"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Pauses printing when the detected build plate type does not match the selected one."})]})]}),h.jsx("hr",{className:"border-bambu-dark-tertiary"}),h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:i.auto_recovery_step_loss,onChange:f=>o("auto_recovery_step_loss",f),disabled:!a,loading:c("auto_recovery_step_loss")}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Auto-recover from step loss"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx($d,{checked:e?.store_to_sdcard??!1,onChange:()=>{},disabled:!0}),h.jsx("span",{className:"text-sm font-medium text-white",children:"Store Sent Files on External Storage"}),h.jsx("span",{className:"text-xs text-bambu-gray italic",children:"(read-only)"})]}),h.jsx("p",{className:"text-xs text-bambu-gray ml-8",children:"Save the printing files initiated from Bambu Studio, Bambu Handy and MakerWorld on External Storage. This option can only be changed on the printer's touchscreen."})]})]})]}):h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(ya,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm",children:"Print options not available. Try refreshing."})]})]})]})})})}const YVe=new Set([1,3,13,25,39,40,47,48,50]);function ix({checked:t,onChange:e,disabled:n}){return h.jsx("button",{onClick:()=>!n&&e(!t),disabled:n,className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${t?"bg-bambu-green border-bambu-green":"bg-transparent border-bambu-gray"} ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:t&&h.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}function ZVe({step:t,name:e,isActive:n,isComplete:r,isLast:i}){return h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsxs("div",{className:"flex flex-col items-center",children:[h.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium flex-shrink-0 bg-bambu-green text-white",children:t}),!i&&h.jsx("div",{className:`w-0.5 h-6 ${r?"bg-bambu-green":"bg-bambu-gray/30"}`})]}),h.jsx("span",{className:`text-sm pt-0.5 ${n?"text-white font-semibold":"text-bambu-gray"}`,children:e})]})}function QVe({printer:t,status:e,onClose:n}){const r=e?.connected??!1,i=t.nozzle_count===2,a=e?.stg_cur??-1,[s,o]=E.useState(!1),[l,c]=E.useState(!1),[u,f]=E.useState(!1),g=`calibration_options_${t.id}`,m=typeof window<"u"?localStorage.getItem(g):null,y=m?JSON.parse(m):null,[v,b]=E.useState(y?.bedLeveling??!0),[x,M]=E.useState(y?.vibration??!0),[w,A]=E.useState(y?.motorNoise??!0),[T,R]=E.useState(y?.nozzleOffset??i),[N,j]=E.useState(y?.highTempHeatbed??!1),[C,k]=E.useState(!1),U=e?.state,I=YVe.has(a)&&U==="RUNNING";E.useEffect(()=>{!C&&I?(c(!0),o(!0),k(!0)):!C&&!I&&k(!0)},[C,I]),E.useEffect(()=>{I&&!l&&(c(!0),f(!1))},[I,l]),E.useEffect(()=>{I&&!s&&o(!0)},[I,s]),E.useEffect(()=>{l&&!I&&!u&&f(!0)},[l,I,u]);const H=()=>{localStorage.removeItem(g),o(!1),c(!1),f(!1),b(!0),M(!0),A(!0),R(i),j(!1)};E.useEffect(()=>{const Y=oe=>{oe.key==="Escape"&&n()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n]);const O=yt({mutationFn:()=>Fe.startCalibration(t.id,{bed_leveling:v,vibration:x,motor_noise:w,nozzle_offset:T,high_temp_heatbed:N}),onSuccess:()=>{localStorage.setItem(g,JSON.stringify({bedLeveling:v,vibration:x,motorNoise:w,nozzleOffset:T,highTempHeatbed:N})),o(!0)}}),B=v||x||w||T||N,V=r&&B&&!O.isPending&&!I&&!u,G=[];G.push({name:"Homing toolhead",stages:[13]}),(v||N)&&G.push({name:"Cooling heatbed",stages:[50]}),v&&G.push({name:"Auto bed leveling - phase 1",stages:[1,47]}),w&&G.push({name:"Motor noise cancellation",stages:[25]}),x&&G.push({name:"Vibration compensation",stages:[3]}),v&&G.push({name:"Auto bed leveling - phase 2",stages:[48]}),i&&T&&G.push({name:"Nozzle offset calibration",stages:[39]}),N&&G.push({name:"High-temp heatbed calibration",stages:[40]});const K=G.findIndex(Y=>Y.stages.includes(a));return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsx(Yt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col",onClick:Y=>Y.stopPropagation(),children:h.jsxs(on,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-sm font-medium text-white",children:"Calibration"}),h.jsx("button",{onClick:n,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white",children:h.jsx(mn,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[!r&&h.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-red-500/20 border border-red-500/50 rounded text-red-400",children:[h.jsx(ya,{className:"w-4 h-4"}),h.jsx("span",{className:"text-sm",children:"Printer not connected. Calibration cannot be started."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-base font-semibold text-white mb-4",children:"Calibration step selection"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(ix,{checked:v,onChange:b,disabled:!r||I}),h.jsx("span",{className:"text-sm text-white",children:"Bed leveling"})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(ix,{checked:x,onChange:M,disabled:!r||I}),h.jsx("span",{className:"text-sm text-white",children:"Vibration compensation"})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(ix,{checked:w,onChange:A,disabled:!r||I}),h.jsx("span",{className:"text-sm text-white",children:"Motor noise cancellation"})]}),i&&h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(ix,{checked:T,onChange:R,disabled:!r||I}),h.jsx("span",{className:"text-sm text-white",children:"Nozzle offset calibration"})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(ix,{checked:N,onChange:j,disabled:!r||I}),h.jsx("span",{className:"text-sm text-white whitespace-nowrap",children:"High-temperature Heatbed Calibration"})]})]}),h.jsxs("div",{className:"mt-6",children:[h.jsx("h4",{className:"text-sm font-semibold text-white mb-2",children:"Calibration program"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"The calibration program detects the status of your device automatically to minimize deviation. It keeps the device performing optimally."})]})]}),h.jsxs("div",{className:"flex flex-col",children:[h.jsx("h3",{className:"text-base font-semibold text-bambu-green mb-4 text-center border-b border-bambu-dark-tertiary pb-2",children:"Calibration Flow"}),h.jsx("div",{className:"flex-1 py-4 pl-4",children:B?h.jsxs("div",{className:"space-y-0",children:[G.map((Y,oe)=>{const $=s&&!u&&Y.stages.includes(a),X=u||s&&K>oe;return h.jsx(ZVe,{step:oe+1,name:Y.name,isActive:$,isComplete:X,isLast:oe===G.length-1},Y.name)}),a>=0&&K===-1&&e?.stg_cur_name&&h.jsxs("div",{className:"mt-4 text-xs text-bambu-gray",children:["Current: ",e.stg_cur_name]})]}):h.jsx("div",{className:"flex items-center justify-center h-full text-sm text-bambu-gray italic",children:"Select calibration steps"})}),u?h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{disabled:!0,className:"w-full py-2.5 px-4 rounded-lg font-medium text-sm flex items-center justify-center gap-2 bg-bambu-green text-white cursor-default",children:[h.jsx(Hp,{className:"w-4 h-4"}),"Completed"]}),h.jsx("button",{onClick:H,className:"w-full py-2 px-4 rounded-lg font-medium text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:"New Calibration"})]}):h.jsx("button",{onClick:()=>O.mutate(),disabled:!V,className:`w-full py-2.5 px-4 rounded-lg font-medium text-sm flex items-center justify-center gap-2 transition-colors ${I?"bg-bambu-gray/50 text-white cursor-not-allowed":V?"bg-bambu-green hover:bg-bambu-green/90 text-white":"bg-bambu-dark-tertiary text-bambu-gray cursor-not-allowed"}`,children:I?h.jsxs(h.Fragment,{children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),"Calibrating"]}):O.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Ft,{className:"w-4 h-4 animate-spin"}),"Starting..."]}):"Start Calibration"}),O.isError&&h.jsx("div",{className:"mt-2 text-xs text-red-400 text-center",children:O.error?.message||"Failed to start calibration"})]})]})]})]})})})}function JVe({signal:t,className:e="w-4 h-4"}){let n=0;t!=null&&(t>=-50?n=4:t>=-60?n=3:t>=-70?n=2:n=1);const r="#00ae42",i="#4a4a4a";return h.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[h.jsx("circle",{cx:"12",cy:"20",r:"1",fill:n>=1?r:i,stroke:n>=1?r:i}),h.jsx("path",{d:"M8.5 16.5a5 5 0 0 1 7 0",stroke:n>=2?r:i,fill:"none"}),h.jsx("path",{d:"M5 13a10 10 0 0 1 14 0",stroke:n>=3?r:i,fill:"none"}),h.jsx("path",{d:"M1.5 9.5a15 15 0 0 1 21 0",stroke:n>=4?r:i,fill:"none"})]})}function eGe(){const[t,e]=Fie(),[n,r]=E.useState(null),[i,a]=E.useState(!1),[s,o]=E.useState(!1),[l,c]=E.useState(!1),{data:u,isLoading:f}=Ut({queryKey:["printers"],queryFn:Fe.getPrinters}),{data:g}=Ut({queryKey:["printerStatuses"],queryFn:async()=>{if(!u)return{};const M={};return await Promise.all(u.map(async w=>{try{M[w.id]=await Fe.getPrinterStatus(w.id)}catch{}})),M},enabled:!!u&&u.length>0,refetchInterval:2e3});E.useEffect(()=>{const M=t.get("printer");if(M){const w=parseInt(M,10);if(!isNaN(w)){r(w);return}}u&&u.length>0&&!n&&r(u[0].id)},[u,t,n]);const m=M=>{r(M),e({printer:String(M)})},y=u?.find(M=>M.id===n),v=n?g?.[n]:null,x=v?new Set([1,3,13,25,39,40,47,48,50]).has(v.stg_cur):!1;return f?h.jsx("div",{className:"flex items-center justify-center h-screen",children:h.jsx(Ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):!u||u.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-screen text-bambu-gray",children:[h.jsx(Vp,{className:"w-16 h-16 mb-4"}),h.jsx("p",{className:"text-xl",children:"No printers configured"}),h.jsx("p",{className:"text-sm mt-2",children:"Add a printer in the Printers page first"})]}):h.jsxs("div",{className:"h-screen flex flex-col bg-bambu-dark",children:[h.jsx("div",{className:"bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:h.jsx("div",{className:"flex overflow-x-auto",children:u.filter(M=>g?.[M.id]?.connected).map(M=>{const w=g?.[M.id],A=M.id===n;return h.jsxs("button",{onClick:()=>m(M.id),className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors whitespace-nowrap border-b-2 ${A?"border-bambu-green text-bambu-green bg-bambu-dark":"border-transparent text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),M.name,w?.state&&w.state!=="IDLE"&&h.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary",children:w.state})]},M.id)})})}),y&&h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsxs("div",{className:"flex-1 flex flex-col bg-bambu-dark",children:[h.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 py-2.5 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary min-h-[44px]",children:[h.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${v?.sdcard?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:h.jsx("img",{src:"/icons/micro-sd.svg",alt:"SD Card",className:`w-4 h-4 ${v?.sdcard?"icon-green":"icon-theme"}`})}),h.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${v?.timelapse?"text-red-500":"text-bambu-gray hover:text-white"}`,children:h.jsx(Cle,{className:"w-4 h-4"})}),h.jsx("button",{className:`p-1.5 rounded hover:bg-bambu-dark-tertiary ${v?.ipcam?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:h.jsx(Rle,{className:"w-4 h-4"})}),h.jsx("div",{className:"p-1.5 rounded",title:v?.wifi_signal!=null?`WiFi: ${v.wifi_signal} dBm`:"WiFi signal unknown",children:h.jsx(JVe,{signal:v?.wifi_signal,className:"w-4 h-4"})})]}),h.jsx("div",{className:"flex-1 bg-black",children:h.jsx(mVe,{printerId:y.id,isConnected:v?.connected??!1})}),h.jsx("div",{className:"h-1 bg-bambu-green"}),h.jsx("div",{className:"bg-bambu-dark-secondary p-4 px-5",children:h.jsx(xVe,{printerId:y.id,status:v})})]}),h.jsxs("div",{className:"w-[680px] flex flex-col bg-bambu-dark-secondary border-l border-bambu-dark-tertiary overflow-y-auto",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-bambu-dark-tertiary min-h-[44px]",children:[h.jsx("span",{className:"text-sm text-bambu-gray",children:"Control"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>a(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Printer Parts"}),h.jsx("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Print Options"}),h.jsx("button",{onClick:()=>c(!0),className:"px-4 py-1.5 text-xs rounded bg-bambu-green text-white hover:bg-bambu-green-dark",children:"Calibration"})]})]}),!v?.connected&&h.jsxs("div",{className:"m-3 p-3 bg-red-500/20 border border-red-500/50 rounded-lg flex items-center gap-3",children:[h.jsx(Vp,{className:"w-4 h-4 text-red-500"}),h.jsx("span",{className:"text-sm text-red-400",children:"Printer is not connected. Controls are disabled."})]}),h.jsxs("div",{className:"flex-1 p-4 bg-bambu-dark",children:[h.jsx("div",{className:"mb-4 bg-bambu-dark-tertiary rounded-[10px] p-3",children:h.jsxs("div",{className:"flex gap-4 bg-bambu-dark-secondary rounded-[8px] p-4 overflow-hidden",style:{minHeight:"300px"},children:[h.jsx(wVe,{printer:y,status:v,disabled:x}),h.jsxs("div",{className:"flex-1 flex gap-6 items-center justify-center",children:[h.jsxs("div",{className:"flex flex-col items-center",children:[h.jsx(EVe,{printerId:y.id,status:v,disabled:x}),h.jsx(AVe,{printerId:y.id,status:v,disabled:x})]}),h.jsx(TVe,{printerId:y.id,status:v,nozzleCount:y.nozzle_count,disabled:x})]})]})}),h.jsx(qVe,{printerId:y.id,printerModel:y.model||"X1C",status:v,nozzleCount:y.nozzle_count})]})]})]}),i&&y&&h.jsx(XVe,{printer:y,status:v,onClose:()=>a(!1)}),s&&y&&h.jsx(KVe,{printer:y,status:v,onClose:()=>o(!1)}),l&&y&&h.jsx(QVe,{printer:y,status:v,onClose:()=>c(!1)})]})}function tGe(){const t=E.useRef(null),e=E.useRef(null),n=In(),[r,i]=E.useState(!1),a=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,u=new WebSocket(c);let f=null;u.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),f=window.setInterval(()=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"}))},3e4)},u.onmessage=g=>{try{const m=JSON.parse(g.data);s(m)}catch{}},u.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),f&&(clearInterval(f),f=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{a()},3e3)},u.onerror=g=>{console.error("[WebSocket] Error",g),u.close()},t.current=u},[]),s=E.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>({...c,...l.data}));break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);E.useEffect(()=>(a(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[a]);const o=E.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const nGe=new pae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function rGe({children:t}){return tGe(),h.jsx(h.Fragment,{children:t})}function iGe(){return h.jsx(Hle,{children:h.jsx(Qle,{children:h.jsx(mae,{client:nGe,children:h.jsx(rGe,{children:h.jsx(Lie,{children:h.jsx(die,{children:h.jsxs(jo,{path:"/",element:h.jsx(Kle,{}),children:[h.jsx(jo,{index:!0,element:h.jsx(pce,{})}),h.jsx(jo,{path:"archives",element:h.jsx(z2e,{})}),h.jsx(jo,{path:"queue",element:h.jsx($2e,{})}),h.jsx(jo,{path:"stats",element:h.jsx(W$e,{})}),h.jsx(jo,{path:"profiles",element:h.jsx(cVe,{})}),h.jsx(jo,{path:"maintenance",element:h.jsx(pVe,{})}),h.jsx(jo,{path:"control",element:h.jsx(eGe,{})}),h.jsx(jo,{path:"settings",element:h.jsx(tVe,{})})]})})})})})})})}mne.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(iGe,{})}));