index-CycmYzoY.js 2.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611
  1. function Mne(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 s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{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 s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Bv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ro(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var F2={exports:{}},zg={};var mU;function Ene(){if(mU)return zg;mU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var a=null;if(s!==void 0&&(a=""+s),i.key!==void 0&&(a=""+i.key),"key"in i){s={};for(var o in i)o!=="key"&&(s[o]=i[o])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:a,ref:i!==void 0?i:null,props:s}}return zg.Fragment=e,zg.jsx=n,zg.jsxs=n,zg}var gU;function Ane(){return gU||(gU=1,F2.exports=Ene()),F2.exports}var u=Ane(),z2={exports:{}},Zt={};var xU;function Tne(){if(xU)return Zt;xU=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"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=g&&H[g]||H["@@iterator"],typeof H=="function"?H:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function x(H,q,te){this.props=H,this.context=q,this.refs=b,this.updater=te||v}x.prototype.isReactComponent={},x.prototype.setState=function(H,q){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,q,"setState")},x.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function M(){}M.prototype=x.prototype;function w(H,q,te){this.props=H,this.context=q,this.refs=b,this.updater=te||v}var A=w.prototype=new M;A.constructor=w,y(A,x.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function R(){}var C={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function N(H,q,te){var ae=te.ref;return{$$typeof:t,type:H,key:q,ref:ae!==void 0?ae:null,props:te}}function D(H,q){return N(H.type,q,H.props)}function z(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function j(H){var q={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(te){return q[te]})}var W=/\/+/g;function P(H,q){return typeof H=="object"&&H!==null&&H.key!=null?j(""+H.key):q.toString(36)}function $(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(R,R):(H.status="pending",H.then(function(q){H.status==="pending"&&(H.status="fulfilled",H.value=q)},function(q){H.status==="pending"&&(H.status="rejected",H.reason=q)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function K(H,q,te,ae,xe){var re=typeof H;(re==="undefined"||re==="boolean")&&(H=null);var pe=!1;if(H===null)pe=!0;else switch(re){case"bigint":case"string":case"number":pe=!0;break;case"object":switch(H.$$typeof){case t:case e:pe=!0;break;case d:return pe=H._init,K(pe(H._payload),q,te,ae,xe)}}if(pe)return xe=xe(H),pe=ae===""?"."+P(H,0):ae,T(xe)?(te="",pe!=null&&(te=pe.replace(W,"$&/")+"/"),K(xe,q,te,"",function(Se){return Se})):xe!=null&&(z(xe)&&(xe=D(xe,te+(xe.key==null||H&&H.key===xe.key?"":(""+xe.key).replace(W,"$&/")+"/")+pe)),q.push(xe)),1;pe=0;var Ce=ae===""?".":ae+":";if(T(H))for(var fe=0;fe<H.length;fe++)ae=H[fe],re=Ce+P(ae,fe),pe+=K(ae,q,te,re,xe);else if(fe=m(H),typeof fe=="function")for(H=fe.call(H),fe=0;!(ae=H.next()).done;)ae=ae.value,re=Ce+P(ae,fe++),pe+=K(ae,q,te,re,xe);else if(re==="object"){if(typeof H.then=="function")return K($(H),q,te,ae,xe);throw q=String(H),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return pe}function G(H,q,te){if(H==null)return H;var ae=[],xe=0;return K(H,ae,"","",function(re){return q.call(te,re,xe++)}),ae}function Z(H){if(H._status===-1){var q=H._result;q=q(),q.then(function(te){(H._status===0||H._status===-1)&&(H._status=1,H._result=te)},function(te){(H._status===0||H._status===-1)&&(H._status=2,H._result=te)}),H._status===-1&&(H._status=0,H._result=q)}if(H._status===1)return H._result.default;throw H._result}var Q=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ee={map:G,forEach:function(H,q,te){G(H,function(){q.apply(this,arguments)},te)},count:function(H){var q=0;return G(H,function(){q++}),q},toArray:function(H){return G(H,function(q){return q})||[]},only:function(H){if(!z(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Zt.Activity=h,Zt.Children=ee,Zt.Component=x,Zt.Fragment=n,Zt.Profiler=i,Zt.PureComponent=w,Zt.StrictMode=r,Zt.Suspense=l,Zt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Zt.__COMPILER_RUNTIME={__proto__:null,c:function(H){return C.H.useMemoCache(H)}},Zt.cache=function(H){return function(){return H.apply(null,arguments)}},Zt.cacheSignal=function(){return null},Zt.cloneElement=function(H,q,te){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ae=y({},H.props),xe=H.key;if(q!=null)for(re in q.key!==void 0&&(xe=""+q.key),q)!I.call(q,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&q.ref===void 0||(ae[re]=q[re]);var re=arguments.length-2;if(re===1)ae.children=te;else if(1<re){for(var pe=Array(re),Ce=0;Ce<re;Ce++)pe[Ce]=arguments[Ce+2];ae.children=pe}return N(H.type,xe,ae)},Zt.createContext=function(H){return H={$$typeof:a,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:s,_context:H},H},Zt.createElement=function(H,q,te){var ae,xe={},re=null;if(q!=null)for(ae in q.key!==void 0&&(re=""+q.key),q)I.call(q,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(xe[ae]=q[ae]);var pe=arguments.length-2;if(pe===1)xe.children=te;else if(1<pe){for(var Ce=Array(pe),fe=0;fe<pe;fe++)Ce[fe]=arguments[fe+2];xe.children=Ce}if(H&&H.defaultProps)for(ae in pe=H.defaultProps,pe)xe[ae]===void 0&&(xe[ae]=pe[ae]);return N(H,re,xe)},Zt.createRef=function(){return{current:null}},Zt.forwardRef=function(H){return{$$typeof:o,render:H}},Zt.isValidElement=z,Zt.lazy=function(H){return{$$typeof:d,_payload:{_status:-1,_result:H},_init:Z}},Zt.memo=function(H,q){return{$$typeof:c,type:H,compare:q===void 0?null:q}},Zt.startTransition=function(H){var q=C.T,te={};C.T=te;try{var ae=H(),xe=C.S;xe!==null&&xe(te,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(R,Q)}catch(re){Q(re)}finally{q!==null&&te.types!==null&&(q.types=te.types),C.T=q}},Zt.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Zt.use=function(H){return C.H.use(H)},Zt.useActionState=function(H,q,te){return C.H.useActionState(H,q,te)},Zt.useCallback=function(H,q){return C.H.useCallback(H,q)},Zt.useContext=function(H){return C.H.useContext(H)},Zt.useDebugValue=function(){},Zt.useDeferredValue=function(H,q){return C.H.useDeferredValue(H,q)},Zt.useEffect=function(H,q){return C.H.useEffect(H,q)},Zt.useEffectEvent=function(H){return C.H.useEffectEvent(H)},Zt.useId=function(){return C.H.useId()},Zt.useImperativeHandle=function(H,q,te){return C.H.useImperativeHandle(H,q,te)},Zt.useInsertionEffect=function(H,q){return C.H.useInsertionEffect(H,q)},Zt.useLayoutEffect=function(H,q){return C.H.useLayoutEffect(H,q)},Zt.useMemo=function(H,q){return C.H.useMemo(H,q)},Zt.useOptimistic=function(H,q){return C.H.useOptimistic(H,q)},Zt.useReducer=function(H,q,te){return C.H.useReducer(H,q,te)},Zt.useRef=function(H){return C.H.useRef(H)},Zt.useState=function(H){return C.H.useState(H)},Zt.useSyncExternalStore=function(H,q,te){return C.H.useSyncExternalStore(H,q,te)},Zt.useTransition=function(){return C.H.useTransition()},Zt.version="19.2.0",Zt}var bU;function Tm(){return bU||(bU=1,z2.exports=Tne()),z2.exports}var E=Tm();const fr=ro(E),Cne=Mne({__proto__:null,default:fr},[E]);var B2={exports:{}},Bg={},H2={exports:{}},$2={};var vU;function Nne(){return vU||(vU=1,(function(t){function e(K,G){var Z=K.length;K.push(G);e:for(;0<Z;){var Q=Z-1>>>1,ee=K[Q];if(0<i(ee,G))K[Q]=G,K[Z]=ee,Z=Q;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],Z=K.pop();if(Z!==G){K[0]=Z;e:for(var Q=0,ee=K.length,H=ee>>>1;Q<H;){var q=2*(Q+1)-1,te=K[q],ae=q+1,xe=K[ae];if(0>i(te,Z))ae<ee&&0>i(xe,te)?(K[Q]=xe,K[ae]=Z,Q=ae):(K[Q]=te,K[q]=Z,Q=q);else if(ae<ee&&0>i(xe,Z))K[Q]=xe,K[ae]=Z,Q=ae;else break e}}return G}function i(K,G){var Z=K.sortIndex-G.sortIndex;return Z!==0?Z:K.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],c=[],d=1,h=null,g=3,m=!1,v=!1,y=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var G=n(c);G!==null;){if(G.callback===null)r(c);else if(G.startTime<=K)r(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=n(c)}}function T(K){if(y=!1,A(K),!v)if(n(l)!==null)v=!0,R||(R=!0,j());else{var G=n(c);G!==null&&$(T,G.startTime-K)}}var R=!1,C=-1,I=5,N=-1;function D(){return b?!0:!(t.unstable_now()-N<I)}function z(){if(b=!1,R){var K=t.unstable_now();N=K;var G=!0;try{e:{v=!1,y&&(y=!1,M(C),C=-1),m=!0;var Z=g;try{t:{for(A(K),h=n(l);h!==null&&!(h.expirationTime>K&&D());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,g=h.priorityLevel;var ee=Q(h.expirationTime<=K);if(K=t.unstable_now(),typeof ee=="function"){h.callback=ee,A(K),G=!0;break t}h===n(l)&&r(l),A(K)}else r(l);h=n(l)}if(h!==null)G=!0;else{var H=n(c);H!==null&&$(T,H.startTime-K),G=!1}}break e}finally{h=null,g=Z,m=!1}G=void 0}}finally{G?j():R=!1}}}var j;if(typeof w=="function")j=function(){w(z)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,P=W.port2;W.port1.onmessage=z,j=function(){P.postMessage(null)}}else j=function(){x(z,0)};function $(K,G){C=x(function(){K(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(K){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var Z=g;g=G;try{return K()}finally{g=Z}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var Z=g;g=K;try{return G()}finally{g=Z}},t.unstable_scheduleCallback=function(K,G,Z){var Q=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Q+Z:Q):Z=Q,K){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=Z+ee,K={id:d++,callback:G,priorityLevel:K,startTime:Z,expirationTime:ee,sortIndex:-1},Z>Q?(K.sortIndex=Z,e(c,K),n(l)===null&&K===n(c)&&(y?(M(C),C=-1):y=!0,$(T,Z-Q))):(K.sortIndex=ee,e(l,K),v||m||(v=!0,R||(R=!0,j()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var G=g;return function(){var Z=g;g=G;try{return K.apply(this,arguments)}finally{g=Z}}}})($2)),$2}var yU;function kne(){return yU||(yU=1,H2.exports=Nne()),H2.exports}var V2={exports:{}},Ji={};var _U;function Rne(){if(_U)return Ji;_U=1;var t=Tm();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var 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 s(l,c,d){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:l,containerInfo:c,implementation:d}}var a=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 Ji.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ji.createPortal=function(l,c){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return s(l,c,null,d)},Ji.flushSync=function(l){var c=a.T,d=r.p;try{if(a.T=null,r.p=2,l)return l()}finally{a.T=c,r.p=d,r.d.f()}},Ji.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))},Ji.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},Ji.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var d=c.as,h=o(d,c.crossOrigin),g=typeof c.integrity=="string"?c.integrity:void 0,m=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;d==="style"?r.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:h,integrity:g,fetchPriority:m}):d==="script"&&r.d.X(l,{crossOrigin:h,integrity:g,fetchPriority:m,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Ji.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var d=o(c.as,c.crossOrigin);r.d.M(l,{crossOrigin:d,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&r.d.M(l)},Ji.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var d=c.as,h=o(d,c.crossOrigin);r.d.L(l,d,{crossOrigin:h,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})}},Ji.preloadModule=function(l,c){if(typeof l=="string")if(c){var d=o(c.as,c.crossOrigin);r.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:d,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else r.d.m(l)},Ji.requestFormReset=function(l){r.d.r(l)},Ji.unstable_batchedUpdates=function(l,c){return l(c)},Ji.useFormState=function(l,c,d){return a.H.useFormState(l,c,d)},Ji.useFormStatus=function(){return a.H.useHostTransitionStatus()},Ji.version="19.2.0",Ji}var SU;function RG(){if(SU)return V2.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(),V2.exports=Rne(),V2.exports}var wU;function Pne(){if(wU)return Bg;wU=1;var t=kne(),e=Tm(),n=RG();function r(f){var p="https://react.dev/errors/"+f;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+f+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(f){return!(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)}function s(f){var p=f,_=f;if(f.alternate)for(;p.return;)p=p.return;else{f=p;do p=f,(p.flags&4098)!==0&&(_=p.return),f=p.return;while(f)}return p.tag===3?_:null}function a(f){if(f.tag===13){var p=f.memoizedState;if(p===null&&(f=f.alternate,f!==null&&(p=f.memoizedState)),p!==null)return p.dehydrated}return null}function o(f){if(f.tag===31){var p=f.memoizedState;if(p===null&&(f=f.alternate,f!==null&&(p=f.memoizedState)),p!==null)return p.dehydrated}return null}function l(f){if(s(f)!==f)throw Error(r(188))}function c(f){var p=f.alternate;if(!p){if(p=s(f),p===null)throw Error(r(188));return p!==f?null:f}for(var _=f,S=p;;){var k=_.return;if(k===null)break;var O=k.alternate;if(O===null){if(S=k.return,S!==null){_=S;continue}break}if(k.child===O.child){for(O=k.child;O;){if(O===_)return l(k),f;if(O===S)return l(k),p;O=O.sibling}throw Error(r(188))}if(_.return!==S.return)_=k,S=O;else{for(var Y=!1,oe=k.child;oe;){if(oe===_){Y=!0,_=k,S=O;break}if(oe===S){Y=!0,S=k,_=O;break}oe=oe.sibling}if(!Y){for(oe=O.child;oe;){if(oe===_){Y=!0,_=O,S=k;break}if(oe===S){Y=!0,S=O,_=k;break}oe=oe.sibling}if(!Y)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?f:p}function d(f){var p=f.tag;if(p===5||p===26||p===27||p===6)return f;for(f=f.child;f!==null;){if(p=d(f),p!==null)return p;f=f.sibling}return null}var h=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),y=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"),C=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function j(f){return f===null||typeof f!="object"?null:(f=z&&f[z]||f["@@iterator"],typeof f=="function"?f:null)}var W=Symbol.for("react.client.reference");function P(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===W?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case y:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList";case N:return"Activity"}if(typeof f=="object")switch(f.$$typeof){case v:return"Portal";case w:return f.displayName||"Context";case M:return(f._context.displayName||"Context")+".Consumer";case A:var p=f.render;return f=f.displayName,f||(f=p.displayName||p.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case C:return p=f.displayName||null,p!==null?p:P(f.type)||"Memo";case I:p=f._payload,f=f._init;try{return P(f(p))}catch{}}return null}var $=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Q=[],ee=-1;function H(f){return{current:f}}function q(f){0>ee||(f.current=Q[ee],Q[ee]=null,ee--)}function te(f,p){ee++,Q[ee]=f.current,f.current=p}var ae=H(null),xe=H(null),re=H(null),pe=H(null);function Ce(f,p){switch(te(re,p),te(xe,f),te(ae,null),p.nodeType){case 9:case 11:f=(f=p.documentElement)&&(f=f.namespaceURI)?U4(f):0;break;default:if(f=p.tagName,p=p.namespaceURI)p=U4(p),f=F4(p,f);else switch(f){case"svg":f=1;break;case"math":f=2;break;default:f=0}}q(ae),te(ae,f)}function fe(){q(ae),q(xe),q(re)}function Se(f){f.memoizedState!==null&&te(pe,f);var p=ae.current,_=F4(p,f.type);p!==_&&(te(xe,f),te(ae,_))}function Re(f){xe.current===f&&(q(ae),q(xe)),pe.current===f&&(q(pe),jg._currentValue=Z)}var ue,ct;function B(f){if(ue===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);ue=p&&p[1]||"",ct=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+ue+f+ct}var F=!1;function ie(f,p){if(!f||F)return"";F=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(nt){var qe=nt}Reflect.construct(f,[],dt)}else{try{dt.call()}catch(nt){qe=nt}f.call(dt.prototype)}}else{try{throw Error()}catch(nt){qe=nt}(dt=f())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(nt){if(nt&&qe&&typeof nt.stack=="string")return[nt.stack,qe.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=S.DetermineComponentFrameRoot(),Y=O[0],oe=O[1];if(Y&&oe){var we=Y.split(`
  4. `),Ve=oe.split(`
  5. `);for(k=S=0;S<we.length&&!we[S].includes("DetermineComponentFrameRoot");)S++;for(;k<Ve.length&&!Ve[k].includes("DetermineComponentFrameRoot");)k++;if(S===we.length||k===Ve.length)for(S=we.length-1,k=Ve.length-1;1<=S&&0<=k&&we[S]!==Ve[k];)k--;for(;1<=S&&0<=k;S--,k--)if(we[S]!==Ve[k]){if(S!==1||k!==1)do if(S--,k--,0>k||we[S]!==Ve[k]){var st=`
  6. `+we[S].replace(" at new "," at ");return f.displayName&&st.includes("<anonymous>")&&(st=st.replace("<anonymous>",f.displayName)),st}while(1<=S&&0<=k);break}}}finally{F=!1,Error.prepareStackTrace=_}return(_=f?f.displayName||f.name:"")?B(_):""}function V(f,p){switch(f.tag){case 26:case 27:case 5:return B(f.type);case 16:return B("Lazy");case 13:return f.child!==p&&p!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return ie(f.type,!1);case 11:return ie(f.type.render,!1);case 1:return ie(f.type,!0);case 31:return B("Activity");default:return""}}function J(f){try{var p="",_=null;do p+=V(f,_),_=f,f=f.return;while(f);return p}catch(S){return`
  7. Error generating stack: `+S.message+`
  8. `+S.stack}}var le=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,Ee=t.unstable_cancelCallback,se=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,X=t.unstable_getCurrentPriorityLevel,me=t.unstable_ImmediatePriority,ve=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,Ke=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,ze=t.log,at=t.unstable_setDisableYieldValue,Fe=null,ce=null;function Qe(f){if(typeof ze=="function"&&at(f),ce&&typeof ce.setStrictMode=="function")try{ce.setStrictMode(Fe,f)}catch{}}var He=Math.clz32?Math.clz32:de,Ye=Math.log,ut=Math.LN2;function de(f){return f>>>=0,f===0?32:31-(Ye(f)/ut|0)|0}var Je=256,be=262144,je=4194304;function Te(f){var p=f&42;if(p!==0)return p;switch(f&-f){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 f&261888;case 262144:case 524288:case 1048576:case 2097152:return f&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return f&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return f}}function ye(f,p,_){var S=f.pendingLanes;if(S===0)return 0;var k=0,O=f.suspendedLanes,Y=f.pingedLanes;f=f.warmLanes;var oe=S&134217727;return oe!==0?(S=oe&~O,S!==0?k=Te(S):(Y&=oe,Y!==0?k=Te(Y):_||(_=oe&~f,_!==0&&(k=Te(_))))):(oe=S&~O,oe!==0?k=Te(oe):Y!==0?k=Te(Y):_||(_=S&~f,_!==0&&(k=Te(_)))),k===0?0:p!==0&&p!==k&&(p&O)===0&&(O=k&-k,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:k}function Ge(f,p){return(f.pendingLanes&~(f.suspendedLanes&~f.pingedLanes)&p)===0}function ft(f,p){switch(f){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 yt(){var f=je;return je<<=1,(je&62914560)===0&&(je=4194304),f}function Rt(f){for(var p=[],_=0;31>_;_++)p.push(f);return p}function cn(f,p){f.pendingLanes|=p,p!==268435456&&(f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0)}function jt(f,p,_,S,k,O){var Y=f.pendingLanes;f.pendingLanes=_,f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0,f.expiredLanes&=_,f.entangledLanes&=_,f.errorRecoveryDisabledLanes&=_,f.shellSuspendCounter=0;var oe=f.entanglements,we=f.expirationTimes,Ve=f.hiddenUpdates;for(_=Y&~_;0<_;){var st=31-He(_),dt=1<<st;oe[st]=0,we[st]=-1;var qe=Ve[st];if(qe!==null)for(Ve[st]=null,st=0;st<qe.length;st++){var nt=qe[st];nt!==null&&(nt.lane&=-536870913)}_&=~dt}S!==0&&Rn(f,S,0),O!==0&&k===0&&f.tag!==0&&(f.suspendedLanes|=O&~(Y&~p))}function Rn(f,p,_){f.pendingLanes|=p,f.suspendedLanes&=~p;var S=31-He(p);f.entangledLanes|=p,f.entanglements[S]=f.entanglements[S]|1073741824|_&261930}function qn(f,p){var _=f.entangledLanes|=p;for(f=f.entanglements;_;){var S=31-He(_),k=1<<S;k&p|f[S]&p&&(f[S]|=p),_&=~k}}function bi(f,p){var _=p&-p;return _=(_&42)!==0?1:ti(_),(_&(f.suspendedLanes|p))!==0?0:_}function ti(f){switch(f){case 2:f=1;break;case 8:f=4;break;case 32:f=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:f=128;break;case 268435456:f=134217728;break;default:f=0}return f}function vi(f){return f&=-f,2<f?8<f?(f&134217727)!==0?32:268435456:8:2}function Li(){var f=G.p;return f!==0?f:(f=window.event,f===void 0?32:lU(f.type))}function Qi(f,p){var _=G.p;try{return G.p=f,p()}finally{G.p=_}}var Ir=Math.random().toString(36).slice(2),mr="__reactFiber$"+Ir,Nr="__reactProps$"+Ir,so="__reactContainer$"+Ir,Ic="__reactEvents$"+Ir,he="__reactListeners$"+Ir,Be="__reactHandles$"+Ir,et="__reactResources$"+Ir,tt="__reactMarker$"+Ir;function Ze(f){delete f[mr],delete f[Nr],delete f[Ic],delete f[he],delete f[Be]}function _t(f){var p=f[mr];if(p)return p;for(var _=f.parentNode;_;){if(p=_[so]||_[mr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(f=W4(f);f!==null;){if(_=f[mr])return _;f=W4(f)}return p}f=_,_=f.parentNode}return null}function ne(f){if(f=f[mr]||f[so]){var p=f.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return f}return null}function _e(f){var p=f.tag;if(p===5||p===26||p===27||p===6)return f.stateNode;throw Error(r(33))}function De(f){var p=f[et];return p||(p=f[et]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Pe(f){f[tt]=!0}var Me=new Set,it={};function ht(f,p){bt(f,p),bt(f+"Capture",p)}function bt(f,p){for(it[f]=p,f=0;f<p.length;f++)Me.add(p[f])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Pt={},wt={};function mt(f){return le.call(wt,f)?!0:le.call(Pt,f)?!1:xt.test(f)?wt[f]=!0:(Pt[f]=!0,!1)}function qt(f,p,_){if(mt(p))if(_===null)f.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":f.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){f.removeAttribute(p);return}}f.setAttribute(p,""+_)}}function Ut(f,p,_){if(_===null)f.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(p);return}f.setAttribute(p,""+_)}}function nn(f,p,_,S){if(S===null)f.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(_);return}f.setAttributeNS(p,_,""+S)}}function dn(f){switch(typeof f){case"bigint":case"boolean":case"number":case"string":case"undefined":return f;case"object":return f;default:return""}}function gn(f){var p=f.type;return(f=f.nodeName)&&f.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function It(f,p,_){var S=Object.getOwnPropertyDescriptor(f.constructor.prototype,p);if(!f.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var k=S.get,O=S.set;return Object.defineProperty(f,p,{configurable:!0,get:function(){return k.call(this)},set:function(Y){_=""+Y,O.call(this,Y)}}),Object.defineProperty(f,p,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(Y){_=""+Y},stopTracking:function(){f._valueTracker=null,delete f[p]}}}}function Yt(f){if(!f._valueTracker){var p=gn(f)?"checked":"value";f._valueTracker=It(f,p,""+f[p])}}function Jt(f){if(!f)return!1;var p=f._valueTracker;if(!p)return!0;var _=p.getValue(),S="";return f&&(S=gn(f)?f.checked?"true":"false":f.value),f=S,f!==_?(p.setValue(f),!0):!1}function Sr(f){if(f=f||(typeof document<"u"?document:void 0),typeof f>"u")return null;try{return f.activeElement||f.body}catch{return f.body}}var kr=/[\n"\\]/g;function kn(f){return f.replace(kr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function ao(f,p,_,S,k,O,Y,oe){f.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?f.type=Y:f.removeAttribute("type"),p!=null?Y==="number"?(p===0&&f.value===""||f.value!=p)&&(f.value=""+dn(p)):f.value!==""+dn(p)&&(f.value=""+dn(p)):Y!=="submit"&&Y!=="reset"||f.removeAttribute("value"),p!=null?yi(f,Y,dn(p)):_!=null?yi(f,Y,dn(_)):S!=null&&f.removeAttribute("value"),k==null&&O!=null&&(f.defaultChecked=!!O),k!=null&&(f.checked=k&&typeof k!="function"&&typeof k!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?f.name=""+dn(oe):f.removeAttribute("name")}function Pn(f,p,_,S,k,O,Y,oe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(f.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Yt(f);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,oe||p===f.value||(f.value=p),f.defaultValue=p}S=S??k,S=typeof S!="function"&&typeof S!="symbol"&&!!S,f.checked=oe?f.checked:!!S,f.defaultChecked=!!S,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(f.name=Y),Yt(f)}function yi(f,p,_){p==="number"&&Sr(f.ownerDocument)===f||f.defaultValue===""+_||(f.defaultValue=""+_)}function ni(f,p,_,S){if(f=f.options,p){p={};for(var k=0;k<_.length;k++)p["$"+_[k]]=!0;for(_=0;_<f.length;_++)k=p.hasOwnProperty("$"+f[_].value),f[_].selected!==k&&(f[_].selected=k),k&&S&&(f[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,k=0;k<f.length;k++){if(f[k].value===_){f[k].selected=!0,S&&(f[k].defaultSelected=!0);return}p!==null||f[k].disabled||(p=f[k])}p!==null&&(p.selected=!0)}}function _i(f,p,_){if(p!=null&&(p=""+dn(p),p!==f.value&&(f.value=p),_==null)){f.defaultValue!==p&&(f.defaultValue=p);return}f.defaultValue=_!=null?""+dn(_):""}function ji(f,p,_,S){if(p==null){if(S!=null){if(_!=null)throw Error(r(92));if($(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),p=_}_=dn(p),f.defaultValue=_,S=f.textContent,S===_&&S!==""&&S!==null&&(f.value=S),Yt(f)}function jo(f,p){if(p){var _=f.firstChild;if(_&&_===f.lastChild&&_.nodeType===3){_.nodeValue=p;return}}f.textContent=p}var ml=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 LL(f,p,_){var S=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?f.setProperty(p,""):p==="float"?f.cssFloat="":f[p]="":S?f.setProperty(p,_):typeof _!="number"||_===0||ml.has(p)?p==="float"?f.cssFloat=_:f[p]=(""+_).trim():f[p]=_+"px"}function jL(f,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(f=f.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?f.setProperty(S,""):S==="float"?f.cssFloat="":f[S]="");for(var k in p)S=p[k],p.hasOwnProperty(k)&&_[k]!==S&&LL(f,k,S)}else for(var O in p)p.hasOwnProperty(O)&&LL(f,O,p[O])}function LM(f){if(f.indexOf("-")===-1)return!1;switch(f){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 yee=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"]]),_ee=/^[\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 Pb(f){return _ee.test(""+f)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":f}function gl(){}var jM=null;function IM(f){return f=f.target||f.srcElement||window,f.correspondingUseElement&&(f=f.correspondingUseElement),f.nodeType===3?f.parentNode:f}var ih=null,sh=null;function IL(f){var p=ne(f);if(p&&(f=p.stateNode)){var _=f[Nr]||null;e:switch(f=p.stateNode,p.type){case"input":if(ao(f,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=f;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+kn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var S=_[p];if(S!==f&&S.form===f.form){var k=S[Nr]||null;if(!k)throw Error(r(90));ao(S,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(p=0;p<_.length;p++)S=_[p],S.form===f.form&&Jt(S)}break e;case"textarea":_i(f,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&ni(f,!!_.multiple,p,!1)}}}var UM=!1;function UL(f,p,_){if(UM)return f(p,_);UM=!0;try{var S=f(p);return S}finally{if(UM=!1,(ih!==null||sh!==null)&&(vv(),ih&&(p=ih,f=sh,sh=ih=null,IL(p),f)))for(p=0;p<f.length;p++)IL(f[p])}}function Jm(f,p){var _=f.stateNode;if(_===null)return null;var S=_[Nr]||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)||(f=f.type,S=!(f==="button"||f==="input"||f==="select"||f==="textarea")),f=!S;break e;default:f=!1}if(f)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var xl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),FM=!1;if(xl)try{var eg={};Object.defineProperty(eg,"passive",{get:function(){FM=!0}}),window.addEventListener("test",eg,eg),window.removeEventListener("test",eg,eg)}catch{FM=!1}var Uc=null,zM=null,Db=null;function FL(){if(Db)return Db;var f,p=zM,_=p.length,S,k="value"in Uc?Uc.value:Uc.textContent,O=k.length;for(f=0;f<_&&p[f]===k[f];f++);var Y=_-f;for(S=1;S<=Y&&p[_-S]===k[O-S];S++);return Db=k.slice(f,1<S?1-S:void 0)}function Ob(f){var p=f.keyCode;return"charCode"in f?(f=f.charCode,f===0&&p===13&&(f=13)):f=p,f===10&&(f=13),32<=f||f===13?f:0}function Lb(){return!0}function zL(){return!1}function Rs(f){function p(_,S,k,O,Y){this._reactName=_,this._targetInst=k,this.type=S,this.nativeEvent=O,this.target=Y,this.currentTarget=null;for(var oe in f)f.hasOwnProperty(oe)&&(_=f[oe],this[oe]=_?_(O):O[oe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Lb:zL,this.isPropagationStopped=zL,this}return h(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Lb)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Lb)},persist:function(){},isPersistent:Lb}),p}var bd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(f){return f.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},jb=Rs(bd),tg=h({},bd,{view:0,detail:0}),See=Rs(tg),BM,HM,ng,Ib=h({},tg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:VM,button:0,buttons:0,relatedTarget:function(f){return f.relatedTarget===void 0?f.fromElement===f.srcElement?f.toElement:f.fromElement:f.relatedTarget},movementX:function(f){return"movementX"in f?f.movementX:(f!==ng&&(ng&&f.type==="mousemove"?(BM=f.screenX-ng.screenX,HM=f.screenY-ng.screenY):HM=BM=0,ng=f),BM)},movementY:function(f){return"movementY"in f?f.movementY:HM}}),BL=Rs(Ib),wee=h({},Ib,{dataTransfer:0}),Mee=Rs(wee),Eee=h({},tg,{relatedTarget:0}),$M=Rs(Eee),Aee=h({},bd,{animationName:0,elapsedTime:0,pseudoElement:0}),Tee=Rs(Aee),Cee=h({},bd,{clipboardData:function(f){return"clipboardData"in f?f.clipboardData:window.clipboardData}}),Nee=Rs(Cee),kee=h({},bd,{data:0}),HL=Rs(kee),Ree={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pee={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"},Dee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Oee(f){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(f):(f=Dee[f])?!!p[f]:!1}function VM(){return Oee}var Lee=h({},tg,{key:function(f){if(f.key){var p=Ree[f.key]||f.key;if(p!=="Unidentified")return p}return f.type==="keypress"?(f=Ob(f),f===13?"Enter":String.fromCharCode(f)):f.type==="keydown"||f.type==="keyup"?Pee[f.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:VM,charCode:function(f){return f.type==="keypress"?Ob(f):0},keyCode:function(f){return f.type==="keydown"||f.type==="keyup"?f.keyCode:0},which:function(f){return f.type==="keypress"?Ob(f):f.type==="keydown"||f.type==="keyup"?f.keyCode:0}}),jee=Rs(Lee),Iee=h({},Ib,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$L=Rs(Iee),Uee=h({},tg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:VM}),Fee=Rs(Uee),zee=h({},bd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Bee=Rs(zee),Hee=h({},Ib,{deltaX:function(f){return"deltaX"in f?f.deltaX:"wheelDeltaX"in f?-f.wheelDeltaX:0},deltaY:function(f){return"deltaY"in f?f.deltaY:"wheelDeltaY"in f?-f.wheelDeltaY:"wheelDelta"in f?-f.wheelDelta:0},deltaZ:0,deltaMode:0}),$ee=Rs(Hee),Vee=h({},bd,{newState:0,oldState:0}),Gee=Rs(Vee),Wee=[9,13,27,32],GM=xl&&"CompositionEvent"in window,rg=null;xl&&"documentMode"in document&&(rg=document.documentMode);var qee=xl&&"TextEvent"in window&&!rg,VL=xl&&(!GM||rg&&8<rg&&11>=rg),GL=" ",WL=!1;function qL(f,p){switch(f){case"keyup":return Wee.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function XL(f){return f=f.detail,typeof f=="object"&&"data"in f?f.data:null}var ah=!1;function Xee(f,p){switch(f){case"compositionend":return XL(p);case"keypress":return p.which!==32?null:(WL=!0,GL);case"textInput":return f=p.data,f===GL&&WL?null:f;default:return null}}function Kee(f,p){if(ah)return f==="compositionend"||!GM&&qL(f,p)?(f=FL(),Db=zM=Uc=null,ah=!1,f):null;switch(f){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 VL&&p.locale!=="ko"?null:p.data;default:return null}}var Yee={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 KL(f){var p=f&&f.nodeName&&f.nodeName.toLowerCase();return p==="input"?!!Yee[f.type]:p==="textarea"}function YL(f,p,_,S){ih?sh?sh.push(S):sh=[S]:ih=S,p=Av(p,"onChange"),0<p.length&&(_=new jb("onChange","change",null,_,S),f.push({event:_,listeners:p}))}var ig=null,sg=null;function Zee(f){P4(f,0)}function Ub(f){var p=_e(f);if(Jt(p))return f}function ZL(f,p){if(f==="change")return p}var QL=!1;if(xl){var WM;if(xl){var qM="oninput"in document;if(!qM){var JL=document.createElement("div");JL.setAttribute("oninput","return;"),qM=typeof JL.oninput=="function"}WM=qM}else WM=!1;QL=WM&&(!document.documentMode||9<document.documentMode)}function ej(){ig&&(ig.detachEvent("onpropertychange",tj),sg=ig=null)}function tj(f){if(f.propertyName==="value"&&Ub(sg)){var p=[];YL(p,sg,f,IM(f)),UL(Zee,p)}}function Qee(f,p,_){f==="focusin"?(ej(),ig=p,sg=_,ig.attachEvent("onpropertychange",tj)):f==="focusout"&&ej()}function Jee(f){if(f==="selectionchange"||f==="keyup"||f==="keydown")return Ub(sg)}function ete(f,p){if(f==="click")return Ub(p)}function tte(f,p){if(f==="input"||f==="change")return Ub(p)}function nte(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var Js=typeof Object.is=="function"?Object.is:nte;function ag(f,p){if(Js(f,p))return!0;if(typeof f!="object"||f===null||typeof p!="object"||p===null)return!1;var _=Object.keys(f),S=Object.keys(p);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var k=_[S];if(!le.call(p,k)||!Js(f[k],p[k]))return!1}return!0}function nj(f){for(;f&&f.firstChild;)f=f.firstChild;return f}function rj(f,p){var _=nj(f);f=0;for(var S;_;){if(_.nodeType===3){if(S=f+_.textContent.length,f<=p&&S>=p)return{node:_,offset:p-f};f=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=nj(_)}}function ij(f,p){return f&&p?f===p?!0:f&&f.nodeType===3?!1:p&&p.nodeType===3?ij(f,p.parentNode):"contains"in f?f.contains(p):f.compareDocumentPosition?!!(f.compareDocumentPosition(p)&16):!1:!1}function sj(f){f=f!=null&&f.ownerDocument!=null&&f.ownerDocument.defaultView!=null?f.ownerDocument.defaultView:window;for(var p=Sr(f.document);p instanceof f.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)f=p.contentWindow;else break;p=Sr(f.document)}return p}function XM(f){var p=f&&f.nodeName&&f.nodeName.toLowerCase();return p&&(p==="input"&&(f.type==="text"||f.type==="search"||f.type==="tel"||f.type==="url"||f.type==="password")||p==="textarea"||f.contentEditable==="true")}var rte=xl&&"documentMode"in document&&11>=document.documentMode,oh=null,KM=null,og=null,YM=!1;function aj(f,p,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;YM||oh==null||oh!==Sr(S)||(S=oh,"selectionStart"in S&&XM(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}),og&&ag(og,S)||(og=S,S=Av(KM,"onSelect"),0<S.length&&(p=new jb("onSelect","select",null,p,_),f.push({event:p,listeners:S}),p.target=oh)))}function vd(f,p){var _={};return _[f.toLowerCase()]=p.toLowerCase(),_["Webkit"+f]="webkit"+p,_["Moz"+f]="moz"+p,_}var lh={animationend:vd("Animation","AnimationEnd"),animationiteration:vd("Animation","AnimationIteration"),animationstart:vd("Animation","AnimationStart"),transitionrun:vd("Transition","TransitionRun"),transitionstart:vd("Transition","TransitionStart"),transitioncancel:vd("Transition","TransitionCancel"),transitionend:vd("Transition","TransitionEnd")},ZM={},oj={};xl&&(oj=document.createElement("div").style,"AnimationEvent"in window||(delete lh.animationend.animation,delete lh.animationiteration.animation,delete lh.animationstart.animation),"TransitionEvent"in window||delete lh.transitionend.transition);function yd(f){if(ZM[f])return ZM[f];if(!lh[f])return f;var p=lh[f],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in oj)return ZM[f]=p[_];return f}var lj=yd("animationend"),cj=yd("animationiteration"),uj=yd("animationstart"),ite=yd("transitionrun"),ste=yd("transitionstart"),ate=yd("transitioncancel"),dj=yd("transitionend"),fj=new Map,QM="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(" ");QM.push("scrollEnd");function oo(f,p){fj.set(f,p),ht(p,[f])}var Fb=typeof reportError=="function"?reportError:function(f){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof f=="object"&&f!==null&&typeof f.message=="string"?String(f.message):String(f),error:f});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",f);return}console.error(f)},Sa=[],ch=0,JM=0;function zb(){for(var f=ch,p=JM=ch=0;p<f;){var _=Sa[p];Sa[p++]=null;var S=Sa[p];Sa[p++]=null;var k=Sa[p];Sa[p++]=null;var O=Sa[p];if(Sa[p++]=null,S!==null&&k!==null){var Y=S.pending;Y===null?k.next=k:(k.next=Y.next,Y.next=k),S.pending=k}O!==0&&hj(_,k,O)}}function Bb(f,p,_,S){Sa[ch++]=f,Sa[ch++]=p,Sa[ch++]=_,Sa[ch++]=S,JM|=S,f.lanes|=S,f=f.alternate,f!==null&&(f.lanes|=S)}function eE(f,p,_,S){return Bb(f,p,_,S),Hb(f)}function _d(f,p){return Bb(f,null,null,p),Hb(f)}function hj(f,p,_){f.lanes|=_;var S=f.alternate;S!==null&&(S.lanes|=_);for(var k=!1,O=f.return;O!==null;)O.childLanes|=_,S=O.alternate,S!==null&&(S.childLanes|=_),O.tag===22&&(f=O.stateNode,f===null||f._visibility&1||(k=!0)),f=O,O=O.return;return f.tag===3?(O=f.stateNode,k&&p!==null&&(k=31-He(_),f=O.hiddenUpdates,S=f[k],S===null?f[k]=[p]:S.push(p),p.lane=_|536870912),O):null}function Hb(f){if(50<Ng)throw Ng=0,c2=null,Error(r(185));for(var p=f.return;p!==null;)f=p,p=f.return;return f.tag===3?f.stateNode:null}var uh={};function ote(f,p,_,S){this.tag=f,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 ea(f,p,_,S){return new ote(f,p,_,S)}function tE(f){return f=f.prototype,!(!f||!f.isReactComponent)}function bl(f,p){var _=f.alternate;return _===null?(_=ea(f.tag,p,f.key,f.mode),_.elementType=f.elementType,_.type=f.type,_.stateNode=f.stateNode,_.alternate=f,f.alternate=_):(_.pendingProps=p,_.type=f.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=f.flags&65011712,_.childLanes=f.childLanes,_.lanes=f.lanes,_.child=f.child,_.memoizedProps=f.memoizedProps,_.memoizedState=f.memoizedState,_.updateQueue=f.updateQueue,p=f.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=f.sibling,_.index=f.index,_.ref=f.ref,_.refCleanup=f.refCleanup,_}function pj(f,p){f.flags&=65011714;var _=f.alternate;return _===null?(f.childLanes=0,f.lanes=p,f.child=null,f.subtreeFlags=0,f.memoizedProps=null,f.memoizedState=null,f.updateQueue=null,f.dependencies=null,f.stateNode=null):(f.childLanes=_.childLanes,f.lanes=_.lanes,f.child=_.child,f.subtreeFlags=0,f.deletions=null,f.memoizedProps=_.memoizedProps,f.memoizedState=_.memoizedState,f.updateQueue=_.updateQueue,f.type=_.type,p=_.dependencies,f.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),f}function $b(f,p,_,S,k,O){var Y=0;if(S=f,typeof f=="function")tE(f)&&(Y=1);else if(typeof f=="string")Y=fne(f,_,ae.current)?26:f==="html"||f==="head"||f==="body"?27:5;else e:switch(f){case N:return f=ea(31,_,p,k),f.elementType=N,f.lanes=O,f;case y:return Sd(_.children,k,O,p);case b:Y=8,k|=24;break;case x:return f=ea(12,_,p,k|2),f.elementType=x,f.lanes=O,f;case T:return f=ea(13,_,p,k),f.elementType=T,f.lanes=O,f;case R:return f=ea(19,_,p,k),f.elementType=R,f.lanes=O,f;default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case w:Y=10;break e;case M:Y=9;break e;case A:Y=11;break e;case C:Y=14;break e;case I:Y=16,S=null;break e}Y=29,_=Error(r(130,f===null?"null":typeof f,"")),S=null}return p=ea(Y,_,p,k),p.elementType=f,p.type=S,p.lanes=O,p}function Sd(f,p,_,S){return f=ea(7,f,S,p),f.lanes=_,f}function nE(f,p,_){return f=ea(6,f,null,p),f.lanes=_,f}function mj(f){var p=ea(18,null,null,0);return p.stateNode=f,p}function rE(f,p,_){return p=ea(4,f.children!==null?f.children:[],f.key,p),p.lanes=_,p.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},p}var gj=new WeakMap;function wa(f,p){if(typeof f=="object"&&f!==null){var _=gj.get(f);return _!==void 0?_:(p={value:f,source:p,stack:J(p)},gj.set(f,p),p)}return{value:f,source:p,stack:J(p)}}var dh=[],fh=0,Vb=null,lg=0,Ma=[],Ea=0,Fc=null,Io=1,Uo="";function vl(f,p){dh[fh++]=lg,dh[fh++]=Vb,Vb=f,lg=p}function xj(f,p,_){Ma[Ea++]=Io,Ma[Ea++]=Uo,Ma[Ea++]=Fc,Fc=f;var S=Io;f=Uo;var k=32-He(S)-1;S&=~(1<<k),_+=1;var O=32-He(p)+k;if(30<O){var Y=k-k%5;O=(S&(1<<Y)-1).toString(32),S>>=Y,k-=Y,Io=1<<32-He(p)+k|_<<k|S,Uo=O+f}else Io=1<<O|_<<k|S,Uo=f}function iE(f){f.return!==null&&(vl(f,1),xj(f,1,0))}function sE(f){for(;f===Vb;)Vb=dh[--fh],dh[fh]=null,lg=dh[--fh],dh[fh]=null;for(;f===Fc;)Fc=Ma[--Ea],Ma[Ea]=null,Uo=Ma[--Ea],Ma[Ea]=null,Io=Ma[--Ea],Ma[Ea]=null}function bj(f,p){Ma[Ea++]=Io,Ma[Ea++]=Uo,Ma[Ea++]=Fc,Io=p.id,Uo=p.overflow,Fc=f}var Ii=null,rr=null,yn=!1,zc=null,Aa=!1,aE=Error(r(519));function Bc(f){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw cg(wa(p,f)),aE}function vj(f){var p=f.stateNode,_=f.type,S=f.memoizedProps;switch(p[mr]=f,p[Nr]=S,_){case"dialog":pn("cancel",p),pn("close",p);break;case"iframe":case"object":case"embed":pn("load",p);break;case"video":case"audio":for(_=0;_<Rg.length;_++)pn(Rg[_],p);break;case"source":pn("error",p);break;case"img":case"image":case"link":pn("error",p),pn("load",p);break;case"details":pn("toggle",p);break;case"input":pn("invalid",p),Pn(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),ji(p,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||S.suppressHydrationWarning===!0||j4(p.textContent,_)?(S.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),S.onScroll!=null&&pn("scroll",p),S.onScrollEnd!=null&&pn("scrollend",p),S.onClick!=null&&(p.onclick=gl),p=!0):p=!1,p||Bc(f,!0)}function yj(f){for(Ii=f.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:Aa=!1;return;case 27:case 3:Aa=!0;return;default:Ii=Ii.return}}function hh(f){if(f!==Ii)return!1;if(!yn)return yj(f),yn=!0,!1;var p=f.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=f.type,_=!(_!=="form"&&_!=="button")||M2(f.type,f.memoizedProps)),_=!_),_&&rr&&Bc(f),yj(f),p===13){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));rr=G4(f)}else if(p===31){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));rr=G4(f)}else p===27?(p=rr,tu(f.type)?(f=N2,N2=null,rr=f):rr=p):rr=Ii?Ca(f.stateNode.nextSibling):null;return!0}function wd(){rr=Ii=null,yn=!1}function oE(){var f=zc;return f!==null&&(Ls===null?Ls=f:Ls.push.apply(Ls,f),zc=null),f}function cg(f){zc===null?zc=[f]:zc.push(f)}var lE=H(null),Md=null,yl=null;function Hc(f,p,_){te(lE,p._currentValue),p._currentValue=_}function _l(f){f._currentValue=lE.current,q(lE)}function cE(f,p,_){for(;f!==null;){var S=f.alternate;if((f.childLanes&p)!==p?(f.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),f===_)break;f=f.return}}function uE(f,p,_,S){var k=f.child;for(k!==null&&(k.return=f);k!==null;){var O=k.dependencies;if(O!==null){var Y=k.child;O=O.firstContext;e:for(;O!==null;){var oe=O;O=k;for(var we=0;we<p.length;we++)if(oe.context===p[we]){O.lanes|=_,oe=O.alternate,oe!==null&&(oe.lanes|=_),cE(O.return,_,f),S||(Y=null);break e}O=oe.next}}else if(k.tag===18){if(Y=k.return,Y===null)throw Error(r(341));Y.lanes|=_,O=Y.alternate,O!==null&&(O.lanes|=_),cE(Y,_,f),Y=null}else Y=k.child;if(Y!==null)Y.return=k;else for(Y=k;Y!==null;){if(Y===f){Y=null;break}if(k=Y.sibling,k!==null){k.return=Y.return,Y=k;break}Y=Y.return}k=Y}}function ph(f,p,_,S){f=null;for(var k=p,O=!1;k!==null;){if(!O){if((k.flags&524288)!==0)O=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var Y=k.alternate;if(Y===null)throw Error(r(387));if(Y=Y.memoizedProps,Y!==null){var oe=k.type;Js(k.pendingProps.value,Y.value)||(f!==null?f.push(oe):f=[oe])}}else if(k===pe.current){if(Y=k.alternate,Y===null)throw Error(r(387));Y.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(f!==null?f.push(jg):f=[jg])}k=k.return}f!==null&&uE(p,f,_,S),p.flags|=262144}function Gb(f){for(f=f.firstContext;f!==null;){if(!Js(f.context._currentValue,f.memoizedValue))return!0;f=f.next}return!1}function Ed(f){Md=f,yl=null,f=f.dependencies,f!==null&&(f.firstContext=null)}function Ui(f){return _j(Md,f)}function Wb(f,p){return Md===null&&Ed(f),_j(f,p)}function _j(f,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},yl===null){if(f===null)throw Error(r(308));yl=p,f.dependencies={lanes:0,firstContext:p},f.flags|=524288}else yl=yl.next=p;return _}var lte=typeof AbortController<"u"?AbortController:function(){var f=[],p=this.signal={aborted:!1,addEventListener:function(_,S){f.push(S)}};this.abort=function(){p.aborted=!0,f.forEach(function(_){return _()})}},cte=t.unstable_scheduleCallback,ute=t.unstable_NormalPriority,Ur={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function dE(){return{controller:new lte,data:new Map,refCount:0}}function ug(f){f.refCount--,f.refCount===0&&cte(ute,function(){f.controller.abort()})}var dg=null,fE=0,mh=0,gh=null;function dte(f,p){if(dg===null){var _=dg=[];fE=0,mh=m2(),gh={status:"pending",value:void 0,then:function(S){_.push(S)}}}return fE++,p.then(Sj,Sj),p}function Sj(){if(--fE===0&&dg!==null){gh!==null&&(gh.status="fulfilled");var f=dg;dg=null,mh=0,gh=null;for(var p=0;p<f.length;p++)(0,f[p])()}}function fte(f,p){var _=[],S={status:"pending",value:null,reason:null,then:function(k){_.push(k)}};return f.then(function(){S.status="fulfilled",S.value=p;for(var k=0;k<_.length;k++)(0,_[k])(p)},function(k){for(S.status="rejected",S.reason=k,k=0;k<_.length;k++)(0,_[k])(void 0)}),S}var wj=K.S;K.S=function(f,p){a4=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&dte(f,p),wj!==null&&wj(f,p)};var Ad=H(null);function hE(){var f=Ad.current;return f!==null?f:Xn.pooledCache}function qb(f,p){p===null?te(Ad,Ad.current):te(Ad,p.pool)}function Mj(){var f=hE();return f===null?null:{parent:Ur._currentValue,pool:f}}var xh=Error(r(460)),pE=Error(r(474)),Xb=Error(r(542)),Kb={then:function(){}};function Ej(f){return f=f.status,f==="fulfilled"||f==="rejected"}function Aj(f,p,_){switch(_=f[_],_===void 0?f.push(p):_!==p&&(p.then(gl,gl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw f=p.reason,Cj(f),f;default:if(typeof p.status=="string")p.then(gl,gl);else{if(f=Xn,f!==null&&100<f.shellSuspendCounter)throw Error(r(482));f=p,f.status="pending",f.then(function(S){if(p.status==="pending"){var k=p;k.status="fulfilled",k.value=S}},function(S){if(p.status==="pending"){var k=p;k.status="rejected",k.reason=S}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw f=p.reason,Cj(f),f}throw Cd=p,xh}}function Td(f){try{var p=f._init;return p(f._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Cd=_,xh):_}}var Cd=null;function Tj(){if(Cd===null)throw Error(r(459));var f=Cd;return Cd=null,f}function Cj(f){if(f===xh||f===Xb)throw Error(r(483))}var bh=null,fg=0;function Yb(f){var p=fg;return fg+=1,bh===null&&(bh=[]),Aj(bh,f,p)}function hg(f,p){p=p.props.ref,f.ref=p!==void 0?p:null}function Zb(f,p){throw p.$$typeof===g?Error(r(525)):(f=Object.prototype.toString.call(p),Error(r(31,f==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":f)))}function Nj(f){function p(Oe,Ne){if(f){var $e=Oe.deletions;$e===null?(Oe.deletions=[Ne],Oe.flags|=16):$e.push(Ne)}}function _(Oe,Ne){if(!f)return null;for(;Ne!==null;)p(Oe,Ne),Ne=Ne.sibling;return null}function S(Oe){for(var Ne=new Map;Oe!==null;)Oe.key!==null?Ne.set(Oe.key,Oe):Ne.set(Oe.index,Oe),Oe=Oe.sibling;return Ne}function k(Oe,Ne){return Oe=bl(Oe,Ne),Oe.index=0,Oe.sibling=null,Oe}function O(Oe,Ne,$e){return Oe.index=$e,f?($e=Oe.alternate,$e!==null?($e=$e.index,$e<Ne?(Oe.flags|=67108866,Ne):$e):(Oe.flags|=67108866,Ne)):(Oe.flags|=1048576,Ne)}function Y(Oe){return f&&Oe.alternate===null&&(Oe.flags|=67108866),Oe}function oe(Oe,Ne,$e,ot){return Ne===null||Ne.tag!==6?(Ne=nE($e,Oe.mode,ot),Ne.return=Oe,Ne):(Ne=k(Ne,$e),Ne.return=Oe,Ne)}function we(Oe,Ne,$e,ot){var zt=$e.type;return zt===y?st(Oe,Ne,$e.props.children,ot,$e.key):Ne!==null&&(Ne.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Td(zt)===Ne.type)?(Ne=k(Ne,$e.props),hg(Ne,$e),Ne.return=Oe,Ne):(Ne=$b($e.type,$e.key,$e.props,null,Oe.mode,ot),hg(Ne,$e),Ne.return=Oe,Ne)}function Ve(Oe,Ne,$e,ot){return Ne===null||Ne.tag!==4||Ne.stateNode.containerInfo!==$e.containerInfo||Ne.stateNode.implementation!==$e.implementation?(Ne=rE($e,Oe.mode,ot),Ne.return=Oe,Ne):(Ne=k(Ne,$e.children||[]),Ne.return=Oe,Ne)}function st(Oe,Ne,$e,ot,zt){return Ne===null||Ne.tag!==7?(Ne=Sd($e,Oe.mode,ot,zt),Ne.return=Oe,Ne):(Ne=k(Ne,$e),Ne.return=Oe,Ne)}function dt(Oe,Ne,$e){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number"||typeof Ne=="bigint")return Ne=nE(""+Ne,Oe.mode,$e),Ne.return=Oe,Ne;if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case m:return $e=$b(Ne.type,Ne.key,Ne.props,null,Oe.mode,$e),hg($e,Ne),$e.return=Oe,$e;case v:return Ne=rE(Ne,Oe.mode,$e),Ne.return=Oe,Ne;case I:return Ne=Td(Ne),dt(Oe,Ne,$e)}if($(Ne)||j(Ne))return Ne=Sd(Ne,Oe.mode,$e,null),Ne.return=Oe,Ne;if(typeof Ne.then=="function")return dt(Oe,Yb(Ne),$e);if(Ne.$$typeof===w)return dt(Oe,Wb(Oe,Ne),$e);Zb(Oe,Ne)}return null}function qe(Oe,Ne,$e,ot){var zt=Ne!==null?Ne.key:null;if(typeof $e=="string"&&$e!==""||typeof $e=="number"||typeof $e=="bigint")return zt!==null?null:oe(Oe,Ne,""+$e,ot);if(typeof $e=="object"&&$e!==null){switch($e.$$typeof){case m:return $e.key===zt?we(Oe,Ne,$e,ot):null;case v:return $e.key===zt?Ve(Oe,Ne,$e,ot):null;case I:return $e=Td($e),qe(Oe,Ne,$e,ot)}if($($e)||j($e))return zt!==null?null:st(Oe,Ne,$e,ot,null);if(typeof $e.then=="function")return qe(Oe,Ne,Yb($e),ot);if($e.$$typeof===w)return qe(Oe,Ne,Wb(Oe,$e),ot);Zb(Oe,$e)}return null}function nt(Oe,Ne,$e,ot,zt){if(typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint")return Oe=Oe.get($e)||null,oe(Ne,Oe,""+ot,zt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:return Oe=Oe.get(ot.key===null?$e:ot.key)||null,we(Ne,Oe,ot,zt);case v:return Oe=Oe.get(ot.key===null?$e:ot.key)||null,Ve(Ne,Oe,ot,zt);case I:return ot=Td(ot),nt(Oe,Ne,$e,ot,zt)}if($(ot)||j(ot))return Oe=Oe.get($e)||null,st(Ne,Oe,ot,zt,null);if(typeof ot.then=="function")return nt(Oe,Ne,$e,Yb(ot),zt);if(ot.$$typeof===w)return nt(Oe,Ne,$e,Wb(Ne,ot),zt);Zb(Ne,ot)}return null}function kt(Oe,Ne,$e,ot){for(var zt=null,wn=null,Dt=Ne,tn=Ne=0,bn=null;Dt!==null&&tn<$e.length;tn++){Dt.index>tn?(bn=Dt,Dt=null):bn=Dt.sibling;var Mn=qe(Oe,Dt,$e[tn],ot);if(Mn===null){Dt===null&&(Dt=bn);break}f&&Dt&&Mn.alternate===null&&p(Oe,Dt),Ne=O(Mn,Ne,tn),wn===null?zt=Mn:wn.sibling=Mn,wn=Mn,Dt=bn}if(tn===$e.length)return _(Oe,Dt),yn&&vl(Oe,tn),zt;if(Dt===null){for(;tn<$e.length;tn++)Dt=dt(Oe,$e[tn],ot),Dt!==null&&(Ne=O(Dt,Ne,tn),wn===null?zt=Dt:wn.sibling=Dt,wn=Dt);return yn&&vl(Oe,tn),zt}for(Dt=S(Dt);tn<$e.length;tn++)bn=nt(Dt,Oe,tn,$e[tn],ot),bn!==null&&(f&&bn.alternate!==null&&Dt.delete(bn.key===null?tn:bn.key),Ne=O(bn,Ne,tn),wn===null?zt=bn:wn.sibling=bn,wn=bn);return f&&Dt.forEach(function(au){return p(Oe,au)}),yn&&vl(Oe,tn),zt}function Vt(Oe,Ne,$e,ot){if($e==null)throw Error(r(151));for(var zt=null,wn=null,Dt=Ne,tn=Ne=0,bn=null,Mn=$e.next();Dt!==null&&!Mn.done;tn++,Mn=$e.next()){Dt.index>tn?(bn=Dt,Dt=null):bn=Dt.sibling;var au=qe(Oe,Dt,Mn.value,ot);if(au===null){Dt===null&&(Dt=bn);break}f&&Dt&&au.alternate===null&&p(Oe,Dt),Ne=O(au,Ne,tn),wn===null?zt=au:wn.sibling=au,wn=au,Dt=bn}if(Mn.done)return _(Oe,Dt),yn&&vl(Oe,tn),zt;if(Dt===null){for(;!Mn.done;tn++,Mn=$e.next())Mn=dt(Oe,Mn.value,ot),Mn!==null&&(Ne=O(Mn,Ne,tn),wn===null?zt=Mn:wn.sibling=Mn,wn=Mn);return yn&&vl(Oe,tn),zt}for(Dt=S(Dt);!Mn.done;tn++,Mn=$e.next())Mn=nt(Dt,Oe,tn,Mn.value,ot),Mn!==null&&(f&&Mn.alternate!==null&&Dt.delete(Mn.key===null?tn:Mn.key),Ne=O(Mn,Ne,tn),wn===null?zt=Mn:wn.sibling=Mn,wn=Mn);return f&&Dt.forEach(function(wne){return p(Oe,wne)}),yn&&vl(Oe,tn),zt}function Fn(Oe,Ne,$e,ot){if(typeof $e=="object"&&$e!==null&&$e.type===y&&$e.key===null&&($e=$e.props.children),typeof $e=="object"&&$e!==null){switch($e.$$typeof){case m:e:{for(var zt=$e.key;Ne!==null;){if(Ne.key===zt){if(zt=$e.type,zt===y){if(Ne.tag===7){_(Oe,Ne.sibling),ot=k(Ne,$e.props.children),ot.return=Oe,Oe=ot;break e}}else if(Ne.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Td(zt)===Ne.type){_(Oe,Ne.sibling),ot=k(Ne,$e.props),hg(ot,$e),ot.return=Oe,Oe=ot;break e}_(Oe,Ne);break}else p(Oe,Ne);Ne=Ne.sibling}$e.type===y?(ot=Sd($e.props.children,Oe.mode,ot,$e.key),ot.return=Oe,Oe=ot):(ot=$b($e.type,$e.key,$e.props,null,Oe.mode,ot),hg(ot,$e),ot.return=Oe,Oe=ot)}return Y(Oe);case v:e:{for(zt=$e.key;Ne!==null;){if(Ne.key===zt)if(Ne.tag===4&&Ne.stateNode.containerInfo===$e.containerInfo&&Ne.stateNode.implementation===$e.implementation){_(Oe,Ne.sibling),ot=k(Ne,$e.children||[]),ot.return=Oe,Oe=ot;break e}else{_(Oe,Ne);break}else p(Oe,Ne);Ne=Ne.sibling}ot=rE($e,Oe.mode,ot),ot.return=Oe,Oe=ot}return Y(Oe);case I:return $e=Td($e),Fn(Oe,Ne,$e,ot)}if($($e))return kt(Oe,Ne,$e,ot);if(j($e)){if(zt=j($e),typeof zt!="function")throw Error(r(150));return $e=zt.call($e),Vt(Oe,Ne,$e,ot)}if(typeof $e.then=="function")return Fn(Oe,Ne,Yb($e),ot);if($e.$$typeof===w)return Fn(Oe,Ne,Wb(Oe,$e),ot);Zb(Oe,$e)}return typeof $e=="string"&&$e!==""||typeof $e=="number"||typeof $e=="bigint"?($e=""+$e,Ne!==null&&Ne.tag===6?(_(Oe,Ne.sibling),ot=k(Ne,$e),ot.return=Oe,Oe=ot):(_(Oe,Ne),ot=nE($e,Oe.mode,ot),ot.return=Oe,Oe=ot),Y(Oe)):_(Oe,Ne)}return function(Oe,Ne,$e,ot){try{fg=0;var zt=Fn(Oe,Ne,$e,ot);return bh=null,zt}catch(Dt){if(Dt===xh||Dt===Xb)throw Dt;var wn=ea(29,Dt,null,Oe.mode);return wn.lanes=ot,wn.return=Oe,wn}finally{}}}var Nd=Nj(!0),kj=Nj(!1),$c=!1;function mE(f){f.updateQueue={baseState:f.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gE(f,p){f=f.updateQueue,p.updateQueue===f&&(p.updateQueue={baseState:f.baseState,firstBaseUpdate:f.firstBaseUpdate,lastBaseUpdate:f.lastBaseUpdate,shared:f.shared,callbacks:null})}function Vc(f){return{lane:f,tag:0,payload:null,callback:null,next:null}}function Gc(f,p,_){var S=f.updateQueue;if(S===null)return null;if(S=S.shared,(Cn&2)!==0){var k=S.pending;return k===null?p.next=p:(p.next=k.next,k.next=p),S.pending=p,p=Hb(f),hj(f,null,_),p}return Bb(f,S,p,_),Hb(f)}function pg(f,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var S=p.lanes;S&=f.pendingLanes,_|=S,p.lanes=_,qn(f,_)}}function xE(f,p){var _=f.updateQueue,S=f.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var k=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var Y={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?k=O=Y:O=O.next=Y,_=_.next}while(_!==null);O===null?k=O=p:O=O.next=p}else k=O=p;_={baseState:S.baseState,firstBaseUpdate:k,lastBaseUpdate:O,shared:S.shared,callbacks:S.callbacks},f.updateQueue=_;return}f=_.lastBaseUpdate,f===null?_.firstBaseUpdate=p:f.next=p,_.lastBaseUpdate=p}var bE=!1;function mg(){if(bE){var f=gh;if(f!==null)throw f}}function gg(f,p,_,S){bE=!1;var k=f.updateQueue;$c=!1;var O=k.firstBaseUpdate,Y=k.lastBaseUpdate,oe=k.shared.pending;if(oe!==null){k.shared.pending=null;var we=oe,Ve=we.next;we.next=null,Y===null?O=Ve:Y.next=Ve,Y=we;var st=f.alternate;st!==null&&(st=st.updateQueue,oe=st.lastBaseUpdate,oe!==Y&&(oe===null?st.firstBaseUpdate=Ve:oe.next=Ve,st.lastBaseUpdate=we))}if(O!==null){var dt=k.baseState;Y=0,st=Ve=we=null,oe=O;do{var qe=oe.lane&-536870913,nt=qe!==oe.lane;if(nt?(xn&qe)===qe:(S&qe)===qe){qe!==0&&qe===mh&&(bE=!0),st!==null&&(st=st.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var kt=f,Vt=oe;qe=p;var Fn=_;switch(Vt.tag){case 1:if(kt=Vt.payload,typeof kt=="function"){dt=kt.call(Fn,dt,qe);break e}dt=kt;break e;case 3:kt.flags=kt.flags&-65537|128;case 0:if(kt=Vt.payload,qe=typeof kt=="function"?kt.call(Fn,dt,qe):kt,qe==null)break e;dt=h({},dt,qe);break e;case 2:$c=!0}}qe=oe.callback,qe!==null&&(f.flags|=64,nt&&(f.flags|=8192),nt=k.callbacks,nt===null?k.callbacks=[qe]:nt.push(qe))}else nt={lane:qe,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},st===null?(Ve=st=nt,we=dt):st=st.next=nt,Y|=qe;if(oe=oe.next,oe===null){if(oe=k.shared.pending,oe===null)break;nt=oe,oe=nt.next,nt.next=null,k.lastBaseUpdate=nt,k.shared.pending=null}}while(!0);st===null&&(we=dt),k.baseState=we,k.firstBaseUpdate=Ve,k.lastBaseUpdate=st,O===null&&(k.shared.lanes=0),Yc|=Y,f.lanes=Y,f.memoizedState=dt}}function Rj(f,p){if(typeof f!="function")throw Error(r(191,f));f.call(p)}function Pj(f,p){var _=f.callbacks;if(_!==null)for(f.callbacks=null,f=0;f<_.length;f++)Rj(_[f],p)}var vh=H(null),Qb=H(0);function Dj(f,p){f=kl,te(Qb,f),te(vh,p),kl=f|p.baseLanes}function vE(){te(Qb,kl),te(vh,vh.current)}function yE(){kl=Qb.current,q(vh),q(Qb)}var ta=H(null),Ta=null;function Wc(f){var p=f.alternate;te(Rr,Rr.current&1),te(ta,f),Ta===null&&(p===null||vh.current!==null||p.memoizedState!==null)&&(Ta=f)}function _E(f){te(Rr,Rr.current),te(ta,f),Ta===null&&(Ta=f)}function Oj(f){f.tag===22?(te(Rr,Rr.current),te(ta,f),Ta===null&&(Ta=f)):qc()}function qc(){te(Rr,Rr.current),te(ta,ta.current)}function na(f){q(ta),Ta===f&&(Ta=null),q(Rr)}var Rr=H(0);function Jb(f){for(var p=f;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||T2(_)||C2(_)))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===f)break;for(;p.sibling===null;){if(p.return===null||p.return===f)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var Sl=0,en=null,In=null,Fr=null,ev=!1,yh=!1,kd=!1,tv=0,xg=0,_h=null,hte=0;function wr(){throw Error(r(321))}function SE(f,p){if(p===null)return!1;for(var _=0;_<p.length&&_<f.length;_++)if(!Js(f[_],p[_]))return!1;return!0}function wE(f,p,_,S,k,O){return Sl=O,en=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=f===null||f.memoizedState===null?xI:UE,kd=!1,O=_(S,k),kd=!1,yh&&(O=jj(p,_,S,k)),Lj(f),O}function Lj(f){K.H=yg;var p=In!==null&&In.next!==null;if(Sl=0,Fr=In=en=null,ev=!1,xg=0,_h=null,p)throw Error(r(300));f===null||zr||(f=f.dependencies,f!==null&&Gb(f)&&(zr=!0))}function jj(f,p,_,S){en=f;var k=0;do{if(yh&&(_h=null),xg=0,yh=!1,25<=k)throw Error(r(301));if(k+=1,Fr=In=null,f.updateQueue!=null){var O=f.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}K.H=bI,O=p(_,S)}while(yh);return O}function pte(){var f=K.H,p=f.useState()[0];return p=typeof p.then=="function"?bg(p):p,f=f.useState()[0],(In!==null?In.memoizedState:null)!==f&&(en.flags|=1024),p}function ME(){var f=tv!==0;return tv=0,f}function EE(f,p,_){p.updateQueue=f.updateQueue,p.flags&=-2053,f.lanes&=~_}function AE(f){if(ev){for(f=f.memoizedState;f!==null;){var p=f.queue;p!==null&&(p.pending=null),f=f.next}ev=!1}Sl=0,Fr=In=en=null,yh=!1,xg=tv=0,_h=null}function ps(){var f={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fr===null?en.memoizedState=Fr=f:Fr=Fr.next=f,Fr}function Pr(){if(In===null){var f=en.alternate;f=f!==null?f.memoizedState:null}else f=In.next;var p=Fr===null?en.memoizedState:Fr.next;if(p!==null)Fr=p,In=f;else{if(f===null)throw en.alternate===null?Error(r(467)):Error(r(310));In=f,f={memoizedState:In.memoizedState,baseState:In.baseState,baseQueue:In.baseQueue,queue:In.queue,next:null},Fr===null?en.memoizedState=Fr=f:Fr=Fr.next=f}return Fr}function nv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function bg(f){var p=xg;return xg+=1,_h===null&&(_h=[]),f=Aj(_h,f,p),p=en,(Fr===null?p.memoizedState:Fr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?xI:UE),f}function rv(f){if(f!==null&&typeof f=="object"){if(typeof f.then=="function")return bg(f);if(f.$$typeof===w)return Ui(f)}throw Error(r(438,String(f)))}function TE(f){var p=null,_=en.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var S=en.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(k){return k.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=nv(),en.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(f),S=0;S<f;S++)_[S]=D;return p.index++,_}function wl(f,p){return typeof p=="function"?p(f):p}function iv(f){var p=Pr();return CE(p,In,f)}function CE(f,p,_){var S=f.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var k=f.baseQueue,O=S.pending;if(O!==null){if(k!==null){var Y=k.next;k.next=O.next,O.next=Y}p.baseQueue=k=O,S.pending=null}if(O=f.baseState,k===null)f.memoizedState=O;else{p=k.next;var oe=Y=null,we=null,Ve=p,st=!1;do{var dt=Ve.lane&-536870913;if(dt!==Ve.lane?(xn&dt)===dt:(Sl&dt)===dt){var qe=Ve.revertLane;if(qe===0)we!==null&&(we=we.next={lane:0,revertLane:0,gesture:null,action:Ve.action,hasEagerState:Ve.hasEagerState,eagerState:Ve.eagerState,next:null}),dt===mh&&(st=!0);else if((Sl&qe)===qe){Ve=Ve.next,qe===mh&&(st=!0);continue}else dt={lane:0,revertLane:Ve.revertLane,gesture:null,action:Ve.action,hasEagerState:Ve.hasEagerState,eagerState:Ve.eagerState,next:null},we===null?(oe=we=dt,Y=O):we=we.next=dt,en.lanes|=qe,Yc|=qe;dt=Ve.action,kd&&_(O,dt),O=Ve.hasEagerState?Ve.eagerState:_(O,dt)}else qe={lane:dt,revertLane:Ve.revertLane,gesture:Ve.gesture,action:Ve.action,hasEagerState:Ve.hasEagerState,eagerState:Ve.eagerState,next:null},we===null?(oe=we=qe,Y=O):we=we.next=qe,en.lanes|=dt,Yc|=dt;Ve=Ve.next}while(Ve!==null&&Ve!==p);if(we===null?Y=O:we.next=oe,!Js(O,f.memoizedState)&&(zr=!0,st&&(_=gh,_!==null)))throw _;f.memoizedState=O,f.baseState=Y,f.baseQueue=we,S.lastRenderedState=O}return k===null&&(S.lanes=0),[f.memoizedState,S.dispatch]}function NE(f){var p=Pr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=f;var S=_.dispatch,k=_.pending,O=p.memoizedState;if(k!==null){_.pending=null;var Y=k=k.next;do O=f(O,Y.action),Y=Y.next;while(Y!==k);Js(O,p.memoizedState)||(zr=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,S]}function Ij(f,p,_){var S=en,k=Pr(),O=yn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var Y=!Js((In||k).memoizedState,_);if(Y&&(k.memoizedState=_,zr=!0),k=k.queue,PE(zj.bind(null,S,k,f),[f]),k.getSnapshot!==p||Y||Fr!==null&&Fr.memoizedState.tag&1){if(S.flags|=2048,Sh(9,{destroy:void 0},Fj.bind(null,S,k,_,p),null),Xn===null)throw Error(r(349));O||(Sl&127)!==0||Uj(S,p,_)}return _}function Uj(f,p,_){f.flags|=16384,f={getSnapshot:p,value:_},p=en.updateQueue,p===null?(p=nv(),en.updateQueue=p,p.stores=[f]):(_=p.stores,_===null?p.stores=[f]:_.push(f))}function Fj(f,p,_,S){p.value=_,p.getSnapshot=S,Bj(p)&&Hj(f)}function zj(f,p,_){return _(function(){Bj(p)&&Hj(f)})}function Bj(f){var p=f.getSnapshot;f=f.value;try{var _=p();return!Js(f,_)}catch{return!0}}function Hj(f){var p=_d(f,2);p!==null&&js(p,f,2)}function kE(f){var p=ps();if(typeof f=="function"){var _=f;if(f=_(),kd){Qe(!0);try{_()}finally{Qe(!1)}}}return p.memoizedState=p.baseState=f,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wl,lastRenderedState:f},p}function $j(f,p,_,S){return f.baseState=_,CE(f,In,typeof S=="function"?S:wl)}function mte(f,p,_,S,k){if(ov(f))throw Error(r(485));if(f=p.action,f!==null){var O={payload:k,action:f,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Y){O.listeners.push(Y)}};K.T!==null?_(!0):O.isTransition=!1,S(O),_=p.pending,_===null?(O.next=p.pending=O,Vj(p,O)):(O.next=_.next,p.pending=_.next=O)}}function Vj(f,p){var _=p.action,S=p.payload,k=f.state;if(p.isTransition){var O=K.T,Y={};K.T=Y;try{var oe=_(k,S),we=K.S;we!==null&&we(Y,oe),Gj(f,p,oe)}catch(Ve){RE(f,p,Ve)}finally{O!==null&&Y.types!==null&&(O.types=Y.types),K.T=O}}else try{O=_(k,S),Gj(f,p,O)}catch(Ve){RE(f,p,Ve)}}function Gj(f,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){Wj(f,p,S)},function(S){return RE(f,p,S)}):Wj(f,p,_)}function Wj(f,p,_){p.status="fulfilled",p.value=_,qj(p),f.state=_,p=f.pending,p!==null&&(_=p.next,_===p?f.pending=null:(_=_.next,p.next=_,Vj(f,_)))}function RE(f,p,_){var S=f.pending;if(f.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=_,qj(p),p=p.next;while(p!==S)}f.action=null}function qj(f){f=f.listeners;for(var p=0;p<f.length;p++)(0,f[p])()}function Xj(f,p){return p}function Kj(f,p){if(yn){var _=Xn.formState;if(_!==null){e:{var S=en;if(yn){if(rr){t:{for(var k=rr,O=Aa;k.nodeType!==8;){if(!O){k=null;break t}if(k=Ca(k.nextSibling),k===null){k=null;break t}}O=k.data,k=O==="F!"||O==="F"?k:null}if(k){rr=Ca(k.nextSibling),S=k.data==="F!";break e}}Bc(S)}S=!1}S&&(p=_[0])}}return _=ps(),_.memoizedState=_.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xj,lastRenderedState:p},_.queue=S,_=pI.bind(null,en,S),S.dispatch=_,S=kE(!1),O=IE.bind(null,en,!1,S.queue),S=ps(),k={state:p,dispatch:null,action:f,pending:null},S.queue=k,_=mte.bind(null,en,k,O,_),k.dispatch=_,S.memoizedState=f,[p,_,!1]}function Yj(f){var p=Pr();return Zj(p,In,f)}function Zj(f,p,_){if(p=CE(f,p,Xj)[0],f=iv(wl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=bg(p)}catch(Y){throw Y===xh?Xb:Y}else S=p;p=Pr();var k=p.queue,O=k.dispatch;return _!==p.memoizedState&&(en.flags|=2048,Sh(9,{destroy:void 0},gte.bind(null,k,_),null)),[S,O,f]}function gte(f,p){f.action=p}function Qj(f){var p=Pr(),_=In;if(_!==null)return Zj(p,_,f);Pr(),p=p.memoizedState,_=Pr();var S=_.queue.dispatch;return _.memoizedState=f,[p,S,!1]}function Sh(f,p,_,S){return f={tag:f,create:_,deps:S,inst:p,next:null},p=en.updateQueue,p===null&&(p=nv(),en.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=f.next=f:(S=_.next,_.next=f,f.next=S,p.lastEffect=f),f}function Jj(){return Pr().memoizedState}function sv(f,p,_,S){var k=ps();en.flags|=f,k.memoizedState=Sh(1|p,{destroy:void 0},_,S===void 0?null:S)}function av(f,p,_,S){var k=Pr();S=S===void 0?null:S;var O=k.memoizedState.inst;In!==null&&S!==null&&SE(S,In.memoizedState.deps)?k.memoizedState=Sh(p,O,_,S):(en.flags|=f,k.memoizedState=Sh(1|p,O,_,S))}function eI(f,p){sv(8390656,8,f,p)}function PE(f,p){av(2048,8,f,p)}function xte(f){en.flags|=4;var p=en.updateQueue;if(p===null)p=nv(),en.updateQueue=p,p.events=[f];else{var _=p.events;_===null?p.events=[f]:_.push(f)}}function tI(f){var p=Pr().memoizedState;return xte({ref:p,nextImpl:f}),function(){if((Cn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function nI(f,p){return av(4,2,f,p)}function rI(f,p){return av(4,4,f,p)}function iI(f,p){if(typeof p=="function"){f=f();var _=p(f);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return f=f(),p.current=f,function(){p.current=null}}function sI(f,p,_){_=_!=null?_.concat([f]):null,av(4,4,iI.bind(null,p,f),_)}function DE(){}function aI(f,p){var _=Pr();p=p===void 0?null:p;var S=_.memoizedState;return p!==null&&SE(p,S[1])?S[0]:(_.memoizedState=[f,p],f)}function oI(f,p){var _=Pr();p=p===void 0?null:p;var S=_.memoizedState;if(p!==null&&SE(p,S[1]))return S[0];if(S=f(),kd){Qe(!0);try{f()}finally{Qe(!1)}}return _.memoizedState=[S,p],S}function OE(f,p,_){return _===void 0||(Sl&1073741824)!==0&&(xn&261930)===0?f.memoizedState=p:(f.memoizedState=_,f=l4(),en.lanes|=f,Yc|=f,_)}function lI(f,p,_,S){return Js(_,p)?_:vh.current!==null?(f=OE(f,_,S),Js(f,p)||(zr=!0),f):(Sl&42)===0||(Sl&1073741824)!==0&&(xn&261930)===0?(zr=!0,f.memoizedState=_):(f=l4(),en.lanes|=f,Yc|=f,p)}function cI(f,p,_,S,k){var O=G.p;G.p=O!==0&&8>O?O:8;var Y=K.T,oe={};K.T=oe,IE(f,!1,p,_);try{var we=k(),Ve=K.S;if(Ve!==null&&Ve(oe,we),we!==null&&typeof we=="object"&&typeof we.then=="function"){var st=fte(we,S);vg(f,p,st,sa(f))}else vg(f,p,S,sa(f))}catch(dt){vg(f,p,{then:function(){},status:"rejected",reason:dt},sa())}finally{G.p=O,Y!==null&&oe.types!==null&&(Y.types=oe.types),K.T=Y}}function bte(){}function LE(f,p,_,S){if(f.tag!==5)throw Error(r(476));var k=uI(f).queue;cI(f,k,p,Z,_===null?bte:function(){return dI(f),_(S)})}function uI(f){var p=f.memoizedState;if(p!==null)return p;p={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wl,lastRenderedState:Z},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wl,lastRenderedState:_},next:null},f.memoizedState=p,f=f.alternate,f!==null&&(f.memoizedState=p),p}function dI(f){var p=uI(f);p.next===null&&(p=f.alternate.memoizedState),vg(f,p.next.queue,{},sa())}function jE(){return Ui(jg)}function fI(){return Pr().memoizedState}function hI(){return Pr().memoizedState}function vte(f){for(var p=f.return;p!==null;){switch(p.tag){case 24:case 3:var _=sa();f=Vc(_);var S=Gc(p,f,_);S!==null&&(js(S,p,_),pg(S,p,_)),p={cache:dE()},f.payload=p;return}p=p.return}}function yte(f,p,_){var S=sa();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},ov(f)?mI(p,_):(_=eE(f,p,_,S),_!==null&&(js(_,f,S),gI(_,p,S)))}function pI(f,p,_){var S=sa();vg(f,p,_,S)}function vg(f,p,_,S){var k={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(ov(f))mI(p,k);else{var O=f.alternate;if(f.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var Y=p.lastRenderedState,oe=O(Y,_);if(k.hasEagerState=!0,k.eagerState=oe,Js(oe,Y))return Bb(f,p,k,0),Xn===null&&zb(),!1}catch{}finally{}if(_=eE(f,p,k,S),_!==null)return js(_,f,S),gI(_,p,S),!0}return!1}function IE(f,p,_,S){if(S={lane:2,revertLane:m2(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},ov(f)){if(p)throw Error(r(479))}else p=eE(f,_,S,2),p!==null&&js(p,f,2)}function ov(f){var p=f.alternate;return f===en||p!==null&&p===en}function mI(f,p){yh=ev=!0;var _=f.pending;_===null?p.next=p:(p.next=_.next,_.next=p),f.pending=p}function gI(f,p,_){if((_&4194048)!==0){var S=p.lanes;S&=f.pendingLanes,_|=S,p.lanes=_,qn(f,_)}}var yg={readContext:Ui,use:rv,useCallback:wr,useContext:wr,useEffect:wr,useImperativeHandle:wr,useLayoutEffect:wr,useInsertionEffect:wr,useMemo:wr,useReducer:wr,useRef:wr,useState:wr,useDebugValue:wr,useDeferredValue:wr,useTransition:wr,useSyncExternalStore:wr,useId:wr,useHostTransitionStatus:wr,useFormState:wr,useActionState:wr,useOptimistic:wr,useMemoCache:wr,useCacheRefresh:wr};yg.useEffectEvent=wr;var xI={readContext:Ui,use:rv,useCallback:function(f,p){return ps().memoizedState=[f,p===void 0?null:p],f},useContext:Ui,useEffect:eI,useImperativeHandle:function(f,p,_){_=_!=null?_.concat([f]):null,sv(4194308,4,iI.bind(null,p,f),_)},useLayoutEffect:function(f,p){return sv(4194308,4,f,p)},useInsertionEffect:function(f,p){sv(4,2,f,p)},useMemo:function(f,p){var _=ps();p=p===void 0?null:p;var S=f();if(kd){Qe(!0);try{f()}finally{Qe(!1)}}return _.memoizedState=[S,p],S},useReducer:function(f,p,_){var S=ps();if(_!==void 0){var k=_(p);if(kd){Qe(!0);try{_(p)}finally{Qe(!1)}}}else k=p;return S.memoizedState=S.baseState=k,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:k},S.queue=f,f=f.dispatch=yte.bind(null,en,f),[S.memoizedState,f]},useRef:function(f){var p=ps();return f={current:f},p.memoizedState=f},useState:function(f){f=kE(f);var p=f.queue,_=pI.bind(null,en,p);return p.dispatch=_,[f.memoizedState,_]},useDebugValue:DE,useDeferredValue:function(f,p){var _=ps();return OE(_,f,p)},useTransition:function(){var f=kE(!1);return f=cI.bind(null,en,f.queue,!0,!1),ps().memoizedState=f,[!1,f]},useSyncExternalStore:function(f,p,_){var S=en,k=ps();if(yn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Xn===null)throw Error(r(349));(xn&127)!==0||Uj(S,p,_)}k.memoizedState=_;var O={value:_,getSnapshot:p};return k.queue=O,eI(zj.bind(null,S,O,f),[f]),S.flags|=2048,Sh(9,{destroy:void 0},Fj.bind(null,S,O,_,p),null),_},useId:function(){var f=ps(),p=Xn.identifierPrefix;if(yn){var _=Uo,S=Io;_=(S&~(1<<32-He(S)-1)).toString(32)+_,p="_"+p+"R_"+_,_=tv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=hte++,p="_"+p+"r_"+_.toString(32)+"_";return f.memoizedState=p},useHostTransitionStatus:jE,useFormState:Kj,useActionState:Kj,useOptimistic:function(f){var p=ps();p.memoizedState=p.baseState=f;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=IE.bind(null,en,!0,_),_.dispatch=p,[f,p]},useMemoCache:TE,useCacheRefresh:function(){return ps().memoizedState=vte.bind(null,en)},useEffectEvent:function(f){var p=ps(),_={impl:f};return p.memoizedState=_,function(){if((Cn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},UE={readContext:Ui,use:rv,useCallback:aI,useContext:Ui,useEffect:PE,useImperativeHandle:sI,useInsertionEffect:nI,useLayoutEffect:rI,useMemo:oI,useReducer:iv,useRef:Jj,useState:function(){return iv(wl)},useDebugValue:DE,useDeferredValue:function(f,p){var _=Pr();return lI(_,In.memoizedState,f,p)},useTransition:function(){var f=iv(wl)[0],p=Pr().memoizedState;return[typeof f=="boolean"?f:bg(f),p]},useSyncExternalStore:Ij,useId:fI,useHostTransitionStatus:jE,useFormState:Yj,useActionState:Yj,useOptimistic:function(f,p){var _=Pr();return $j(_,In,f,p)},useMemoCache:TE,useCacheRefresh:hI};UE.useEffectEvent=tI;var bI={readContext:Ui,use:rv,useCallback:aI,useContext:Ui,useEffect:PE,useImperativeHandle:sI,useInsertionEffect:nI,useLayoutEffect:rI,useMemo:oI,useReducer:NE,useRef:Jj,useState:function(){return NE(wl)},useDebugValue:DE,useDeferredValue:function(f,p){var _=Pr();return In===null?OE(_,f,p):lI(_,In.memoizedState,f,p)},useTransition:function(){var f=NE(wl)[0],p=Pr().memoizedState;return[typeof f=="boolean"?f:bg(f),p]},useSyncExternalStore:Ij,useId:fI,useHostTransitionStatus:jE,useFormState:Qj,useActionState:Qj,useOptimistic:function(f,p){var _=Pr();return In!==null?$j(_,In,f,p):(_.baseState=f,[f,_.queue.dispatch])},useMemoCache:TE,useCacheRefresh:hI};bI.useEffectEvent=tI;function FE(f,p,_,S){p=f.memoizedState,_=_(S,p),_=_==null?p:h({},p,_),f.memoizedState=_,f.lanes===0&&(f.updateQueue.baseState=_)}var zE={enqueueSetState:function(f,p,_){f=f._reactInternals;var S=sa(),k=Vc(S);k.payload=p,_!=null&&(k.callback=_),p=Gc(f,k,S),p!==null&&(js(p,f,S),pg(p,f,S))},enqueueReplaceState:function(f,p,_){f=f._reactInternals;var S=sa(),k=Vc(S);k.tag=1,k.payload=p,_!=null&&(k.callback=_),p=Gc(f,k,S),p!==null&&(js(p,f,S),pg(p,f,S))},enqueueForceUpdate:function(f,p){f=f._reactInternals;var _=sa(),S=Vc(_);S.tag=2,p!=null&&(S.callback=p),p=Gc(f,S,_),p!==null&&(js(p,f,_),pg(p,f,_))}};function vI(f,p,_,S,k,O,Y){return f=f.stateNode,typeof f.shouldComponentUpdate=="function"?f.shouldComponentUpdate(S,O,Y):p.prototype&&p.prototype.isPureReactComponent?!ag(_,S)||!ag(k,O):!0}function yI(f,p,_,S){f=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,S),p.state!==f&&zE.enqueueReplaceState(p,p.state,null)}function Rd(f,p){var _=p;if("ref"in p){_={};for(var S in p)S!=="ref"&&(_[S]=p[S])}if(f=f.defaultProps){_===p&&(_=h({},_));for(var k in f)_[k]===void 0&&(_[k]=f[k])}return _}function _I(f){Fb(f)}function SI(f){console.error(f)}function wI(f){Fb(f)}function lv(f,p){try{var _=f.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function MI(f,p,_){try{var S=f.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function BE(f,p,_){return _=Vc(_),_.tag=3,_.payload={element:null},_.callback=function(){lv(f,p)},_}function EI(f){return f=Vc(f),f.tag=3,f}function AI(f,p,_,S){var k=_.type.getDerivedStateFromError;if(typeof k=="function"){var O=S.value;f.payload=function(){return k(O)},f.callback=function(){MI(p,_,S)}}var Y=_.stateNode;Y!==null&&typeof Y.componentDidCatch=="function"&&(f.callback=function(){MI(p,_,S),typeof k!="function"&&(Zc===null?Zc=new Set([this]):Zc.add(this));var oe=S.stack;this.componentDidCatch(S.value,{componentStack:oe!==null?oe:""})})}function _te(f,p,_,S,k){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=_.alternate,p!==null&&ph(p,_,k,!0),_=ta.current,_!==null){switch(_.tag){case 31:case 13:return Ta===null?yv():_.alternate===null&&Mr===0&&(Mr=3),_.flags&=-257,_.flags|=65536,_.lanes=k,S===Kb?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([S]):p.add(S),f2(f,S,k)),!1;case 22:return _.flags|=65536,S===Kb?_.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)),f2(f,S,k)),!1}throw Error(r(435,_.tag))}return f2(f,S,k),yv(),!1}if(yn)return p=ta.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=k,S!==aE&&(f=Error(r(422),{cause:S}),cg(wa(f,_)))):(S!==aE&&(p=Error(r(423),{cause:S}),cg(wa(p,_))),f=f.current.alternate,f.flags|=65536,k&=-k,f.lanes|=k,S=wa(S,_),k=BE(f.stateNode,S,k),xE(f,k),Mr!==4&&(Mr=2)),!1;var O=Error(r(520),{cause:S});if(O=wa(O,_),Cg===null?Cg=[O]:Cg.push(O),Mr!==4&&(Mr=2),p===null)return!0;S=wa(S,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,f=k&-k,_.lanes|=f,f=BE(_.stateNode,S,f),xE(_,f),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Zc===null||!Zc.has(O))))return _.flags|=65536,k&=-k,_.lanes|=k,k=EI(k),AI(k,f,_,S),xE(_,k),!1}_=_.return}while(_!==null);return!1}var HE=Error(r(461)),zr=!1;function Fi(f,p,_,S){p.child=f===null?kj(p,null,_,S):Nd(p,f.child,_,S)}function TI(f,p,_,S,k){_=_.render;var O=p.ref;if("ref"in S){var Y={};for(var oe in S)oe!=="ref"&&(Y[oe]=S[oe])}else Y=S;return Ed(p),S=wE(f,p,_,Y,O,k),oe=ME(),f!==null&&!zr?(EE(f,p,k),Ml(f,p,k)):(yn&&oe&&iE(p),p.flags|=1,Fi(f,p,S,k),p.child)}function CI(f,p,_,S,k){if(f===null){var O=_.type;return typeof O=="function"&&!tE(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,NI(f,p,O,S,k)):(f=$b(_.type,null,S,p,p.mode,k),f.ref=p.ref,f.return=p,p.child=f)}if(O=f.child,!YE(f,k)){var Y=O.memoizedProps;if(_=_.compare,_=_!==null?_:ag,_(Y,S)&&f.ref===p.ref)return Ml(f,p,k)}return p.flags|=1,f=bl(O,S),f.ref=p.ref,f.return=p,p.child=f}function NI(f,p,_,S,k){if(f!==null){var O=f.memoizedProps;if(ag(O,S)&&f.ref===p.ref)if(zr=!1,p.pendingProps=S=O,YE(f,k))(f.flags&131072)!==0&&(zr=!0);else return p.lanes=f.lanes,Ml(f,p,k)}return $E(f,p,_,S,k)}function kI(f,p,_,S){var k=S.children,O=f!==null?f.memoizedState:null;if(f===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,f!==null){for(S=p.child=f.child,k=0;S!==null;)k=k|S.lanes|S.childLanes,S=S.sibling;S=k&~O}else S=0,p.child=null;return RI(f,p,O,_,S)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},f!==null&&qb(p,O!==null?O.cachePool:null),O!==null?Dj(p,O):vE(),Oj(p);else return S=p.lanes=536870912,RI(f,p,O!==null?O.baseLanes|_:_,_,S)}else O!==null?(qb(p,O.cachePool),Dj(p,O),qc(),p.memoizedState=null):(f!==null&&qb(p,null),vE(),qc());return Fi(f,p,k,_),p.child}function _g(f,p){return f!==null&&f.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function RI(f,p,_,S,k){var O=hE();return O=O===null?null:{parent:Ur._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},f!==null&&qb(p,null),vE(),Oj(p),f!==null&&ph(f,p,S,!0),p.childLanes=k,null}function cv(f,p){return p=dv({mode:p.mode,children:p.children},f.mode),p.ref=f.ref,f.child=p,p.return=f,p}function PI(f,p,_){return Nd(p,f.child,null,_),f=cv(p,p.pendingProps),f.flags|=2,na(p),p.memoizedState=null,f}function Ste(f,p,_){var S=p.pendingProps,k=(p.flags&128)!==0;if(p.flags&=-129,f===null){if(yn){if(S.mode==="hidden")return f=cv(p,S),p.lanes=536870912,_g(null,f);if(_E(p),(f=rr)?(f=V4(f,Aa),f=f!==null&&f.data==="&"?f:null,f!==null&&(p.memoizedState={dehydrated:f,treeContext:Fc!==null?{id:Io,overflow:Uo}:null,retryLane:536870912,hydrationErrors:null},_=mj(f),_.return=p,p.child=_,Ii=p,rr=null)):f=null,f===null)throw Bc(p);return p.lanes=536870912,null}return cv(p,S)}var O=f.memoizedState;if(O!==null){var Y=O.dehydrated;if(_E(p),k)if(p.flags&256)p.flags&=-257,p=PI(f,p,_);else if(p.memoizedState!==null)p.child=f.child,p.flags|=128,p=null;else throw Error(r(558));else if(zr||ph(f,p,_,!1),k=(_&f.childLanes)!==0,zr||k){if(S=Xn,S!==null&&(Y=bi(S,_),Y!==0&&Y!==O.retryLane))throw O.retryLane=Y,_d(f,Y),js(S,f,Y),HE;yv(),p=PI(f,p,_)}else f=O.treeContext,rr=Ca(Y.nextSibling),Ii=p,yn=!0,zc=null,Aa=!1,f!==null&&bj(p,f),p=cv(p,S),p.flags|=4096;return p}return f=bl(f.child,{mode:S.mode,children:S.children}),f.ref=p.ref,p.child=f,f.return=p,f}function uv(f,p){var _=p.ref;if(_===null)f!==null&&f.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(f===null||f.ref!==_)&&(p.flags|=4194816)}}function $E(f,p,_,S,k){return Ed(p),_=wE(f,p,_,S,void 0,k),S=ME(),f!==null&&!zr?(EE(f,p,k),Ml(f,p,k)):(yn&&S&&iE(p),p.flags|=1,Fi(f,p,_,k),p.child)}function DI(f,p,_,S,k,O){return Ed(p),p.updateQueue=null,_=jj(p,S,_,k),Lj(f),S=ME(),f!==null&&!zr?(EE(f,p,O),Ml(f,p,O)):(yn&&S&&iE(p),p.flags|=1,Fi(f,p,_,O),p.child)}function OI(f,p,_,S,k){if(Ed(p),p.stateNode===null){var O=uh,Y=_.contextType;typeof Y=="object"&&Y!==null&&(O=Ui(Y)),O=new _(S,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=zE,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=S,O.state=p.memoizedState,O.refs={},mE(p),Y=_.contextType,O.context=typeof Y=="object"&&Y!==null?Ui(Y):uh,O.state=p.memoizedState,Y=_.getDerivedStateFromProps,typeof Y=="function"&&(FE(p,_,Y,S),O.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(Y=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),Y!==O.state&&zE.enqueueReplaceState(O,O.state,null),gg(p,S,O,k),mg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(f===null){O=p.stateNode;var oe=p.memoizedProps,we=Rd(_,oe);O.props=we;var Ve=O.context,st=_.contextType;Y=uh,typeof st=="object"&&st!==null&&(Y=Ui(st));var dt=_.getDerivedStateFromProps;st=typeof dt=="function"||typeof O.getSnapshotBeforeUpdate=="function",oe=p.pendingProps!==oe,st||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(oe||Ve!==Y)&&yI(p,O,S,Y),$c=!1;var qe=p.memoizedState;O.state=qe,gg(p,S,O,k),mg(),Ve=p.memoizedState,oe||qe!==Ve||$c?(typeof dt=="function"&&(FE(p,_,dt,S),Ve=p.memoizedState),(we=$c||vI(p,_,we,S,qe,Ve,Y))?(st||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=Ve),O.props=S,O.state=Ve,O.context=Y,S=we):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{O=p.stateNode,gE(f,p),Y=p.memoizedProps,st=Rd(_,Y),O.props=st,dt=p.pendingProps,qe=O.context,Ve=_.contextType,we=uh,typeof Ve=="object"&&Ve!==null&&(we=Ui(Ve)),oe=_.getDerivedStateFromProps,(Ve=typeof oe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(Y!==dt||qe!==we)&&yI(p,O,S,we),$c=!1,qe=p.memoizedState,O.state=qe,gg(p,S,O,k),mg();var nt=p.memoizedState;Y!==dt||qe!==nt||$c||f!==null&&f.dependencies!==null&&Gb(f.dependencies)?(typeof oe=="function"&&(FE(p,_,oe,S),nt=p.memoizedState),(st=$c||vI(p,_,st,S,qe,nt,we)||f!==null&&f.dependencies!==null&&Gb(f.dependencies))?(Ve||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(S,nt,we),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(S,nt,we)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||Y===f.memoizedProps&&qe===f.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||Y===f.memoizedProps&&qe===f.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=nt),O.props=S,O.state=nt,O.context=we,S=st):(typeof O.componentDidUpdate!="function"||Y===f.memoizedProps&&qe===f.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||Y===f.memoizedProps&&qe===f.memoizedState||(p.flags|=1024),S=!1)}return O=S,uv(f,p),S=(p.flags&128)!==0,O||S?(O=p.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,f!==null&&S?(p.child=Nd(p,f.child,null,k),p.child=Nd(p,null,_,k)):Fi(f,p,_,k),p.memoizedState=O.state,f=p.child):f=Ml(f,p,k),f}function LI(f,p,_,S){return wd(),p.flags|=256,Fi(f,p,_,S),p.child}var VE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function GE(f){return{baseLanes:f,cachePool:Mj()}}function WE(f,p,_){return f=f!==null?f.childLanes&~_:0,p&&(f|=ia),f}function jI(f,p,_){var S=p.pendingProps,k=!1,O=(p.flags&128)!==0,Y;if((Y=O)||(Y=f!==null&&f.memoizedState===null?!1:(Rr.current&2)!==0),Y&&(k=!0,p.flags&=-129),Y=(p.flags&32)!==0,p.flags&=-33,f===null){if(yn){if(k?Wc(p):qc(),(f=rr)?(f=V4(f,Aa),f=f!==null&&f.data!=="&"?f:null,f!==null&&(p.memoizedState={dehydrated:f,treeContext:Fc!==null?{id:Io,overflow:Uo}:null,retryLane:536870912,hydrationErrors:null},_=mj(f),_.return=p,p.child=_,Ii=p,rr=null)):f=null,f===null)throw Bc(p);return C2(f)?p.lanes=32:p.lanes=536870912,null}var oe=S.children;return S=S.fallback,k?(qc(),k=p.mode,oe=dv({mode:"hidden",children:oe},k),S=Sd(S,k,_,null),oe.return=p,S.return=p,oe.sibling=S,p.child=oe,S=p.child,S.memoizedState=GE(_),S.childLanes=WE(f,Y,_),p.memoizedState=VE,_g(null,S)):(Wc(p),qE(p,oe))}var we=f.memoizedState;if(we!==null&&(oe=we.dehydrated,oe!==null)){if(O)p.flags&256?(Wc(p),p.flags&=-257,p=XE(f,p,_)):p.memoizedState!==null?(qc(),p.child=f.child,p.flags|=128,p=null):(qc(),oe=S.fallback,k=p.mode,S=dv({mode:"visible",children:S.children},k),oe=Sd(oe,k,_,null),oe.flags|=2,S.return=p,oe.return=p,S.sibling=oe,p.child=S,Nd(p,f.child,null,_),S=p.child,S.memoizedState=GE(_),S.childLanes=WE(f,Y,_),p.memoizedState=VE,p=_g(null,S));else if(Wc(p),C2(oe)){if(Y=oe.nextSibling&&oe.nextSibling.dataset,Y)var Ve=Y.dgst;Y=Ve,S=Error(r(419)),S.stack="",S.digest=Y,cg({value:S,source:null,stack:null}),p=XE(f,p,_)}else if(zr||ph(f,p,_,!1),Y=(_&f.childLanes)!==0,zr||Y){if(Y=Xn,Y!==null&&(S=bi(Y,_),S!==0&&S!==we.retryLane))throw we.retryLane=S,_d(f,S),js(Y,f,S),HE;T2(oe)||yv(),p=XE(f,p,_)}else T2(oe)?(p.flags|=192,p.child=f.child,p=null):(f=we.treeContext,rr=Ca(oe.nextSibling),Ii=p,yn=!0,zc=null,Aa=!1,f!==null&&bj(p,f),p=qE(p,S.children),p.flags|=4096);return p}return k?(qc(),oe=S.fallback,k=p.mode,we=f.child,Ve=we.sibling,S=bl(we,{mode:"hidden",children:S.children}),S.subtreeFlags=we.subtreeFlags&65011712,Ve!==null?oe=bl(Ve,oe):(oe=Sd(oe,k,_,null),oe.flags|=2),oe.return=p,S.return=p,S.sibling=oe,p.child=S,_g(null,S),S=p.child,oe=f.child.memoizedState,oe===null?oe=GE(_):(k=oe.cachePool,k!==null?(we=Ur._currentValue,k=k.parent!==we?{parent:we,pool:we}:k):k=Mj(),oe={baseLanes:oe.baseLanes|_,cachePool:k}),S.memoizedState=oe,S.childLanes=WE(f,Y,_),p.memoizedState=VE,_g(f.child,S)):(Wc(p),_=f.child,f=_.sibling,_=bl(_,{mode:"visible",children:S.children}),_.return=p,_.sibling=null,f!==null&&(Y=p.deletions,Y===null?(p.deletions=[f],p.flags|=16):Y.push(f)),p.child=_,p.memoizedState=null,_)}function qE(f,p){return p=dv({mode:"visible",children:p},f.mode),p.return=f,f.child=p}function dv(f,p){return f=ea(22,f,null,p),f.lanes=0,f}function XE(f,p,_){return Nd(p,f.child,null,_),f=qE(p,p.pendingProps.children),f.flags|=2,p.memoizedState=null,f}function II(f,p,_){f.lanes|=p;var S=f.alternate;S!==null&&(S.lanes|=p),cE(f.return,p,_)}function KE(f,p,_,S,k,O){var Y=f.memoizedState;Y===null?f.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:k,treeForkCount:O}:(Y.isBackwards=p,Y.rendering=null,Y.renderingStartTime=0,Y.last=S,Y.tail=_,Y.tailMode=k,Y.treeForkCount=O)}function UI(f,p,_){var S=p.pendingProps,k=S.revealOrder,O=S.tail;S=S.children;var Y=Rr.current,oe=(Y&2)!==0;if(oe?(Y=Y&1|2,p.flags|=128):Y&=1,te(Rr,Y),Fi(f,p,S,_),S=yn?lg:0,!oe&&f!==null&&(f.flags&128)!==0)e:for(f=p.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&II(f,_,p);else if(f.tag===19)II(f,_,p);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===p)break e;for(;f.sibling===null;){if(f.return===null||f.return===p)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}switch(k){case"forwards":for(_=p.child,k=null;_!==null;)f=_.alternate,f!==null&&Jb(f)===null&&(k=_),_=_.sibling;_=k,_===null?(k=p.child,p.child=null):(k=_.sibling,_.sibling=null),KE(p,!1,k,_,O,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,k=p.child,p.child=null;k!==null;){if(f=k.alternate,f!==null&&Jb(f)===null){p.child=k;break}f=k.sibling,k.sibling=_,_=k,k=f}KE(p,!0,_,null,O,S);break;case"together":KE(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function Ml(f,p,_){if(f!==null&&(p.dependencies=f.dependencies),Yc|=p.lanes,(_&p.childLanes)===0)if(f!==null){if(ph(f,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(f!==null&&p.child!==f.child)throw Error(r(153));if(p.child!==null){for(f=p.child,_=bl(f,f.pendingProps),p.child=_,_.return=p;f.sibling!==null;)f=f.sibling,_=_.sibling=bl(f,f.pendingProps),_.return=p;_.sibling=null}return p.child}function YE(f,p){return(f.lanes&p)!==0?!0:(f=f.dependencies,!!(f!==null&&Gb(f)))}function wte(f,p,_){switch(p.tag){case 3:Ce(p,p.stateNode.containerInfo),Hc(p,Ur,f.memoizedState.cache),wd();break;case 27:case 5:Se(p);break;case 4:Ce(p,p.stateNode.containerInfo);break;case 10:Hc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,_E(p),null;break;case 13:var S=p.memoizedState;if(S!==null)return S.dehydrated!==null?(Wc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?jI(f,p,_):(Wc(p),f=Ml(f,p,_),f!==null?f.sibling:null);Wc(p);break;case 19:var k=(f.flags&128)!==0;if(S=(_&p.childLanes)!==0,S||(ph(f,p,_,!1),S=(_&p.childLanes)!==0),k){if(S)return UI(f,p,_);p.flags|=128}if(k=p.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),te(Rr,Rr.current),S)break;return null;case 22:return p.lanes=0,kI(f,p,_,p.pendingProps);case 24:Hc(p,Ur,f.memoizedState.cache)}return Ml(f,p,_)}function FI(f,p,_){if(f!==null)if(f.memoizedProps!==p.pendingProps)zr=!0;else{if(!YE(f,_)&&(p.flags&128)===0)return zr=!1,wte(f,p,_);zr=(f.flags&131072)!==0}else zr=!1,yn&&(p.flags&1048576)!==0&&xj(p,lg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(f=Td(p.elementType),p.type=f,typeof f=="function")tE(f)?(S=Rd(f,S),p.tag=1,p=OI(null,p,f,S,_)):(p.tag=0,p=$E(null,p,f,S,_));else{if(f!=null){var k=f.$$typeof;if(k===A){p.tag=11,p=TI(null,p,f,S,_);break e}else if(k===C){p.tag=14,p=CI(null,p,f,S,_);break e}}throw p=P(f)||f,Error(r(306,p,""))}}return p;case 0:return $E(f,p,p.type,p.pendingProps,_);case 1:return S=p.type,k=Rd(S,p.pendingProps),OI(f,p,S,k,_);case 3:e:{if(Ce(p,p.stateNode.containerInfo),f===null)throw Error(r(387));S=p.pendingProps;var O=p.memoizedState;k=O.element,gE(f,p),gg(p,S,null,_);var Y=p.memoizedState;if(S=Y.cache,Hc(p,Ur,S),S!==O.cache&&uE(p,[Ur],_,!0),mg(),S=Y.element,O.isDehydrated)if(O={element:S,isDehydrated:!1,cache:Y.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=LI(f,p,S,_);break e}else if(S!==k){k=wa(Error(r(424)),p),cg(k),p=LI(f,p,S,_);break e}else{switch(f=p.stateNode.containerInfo,f.nodeType){case 9:f=f.body;break;default:f=f.nodeName==="HTML"?f.ownerDocument.body:f}for(rr=Ca(f.firstChild),Ii=p,yn=!0,zc=null,Aa=!0,_=kj(p,null,S,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(wd(),S===k){p=Ml(f,p,_);break e}Fi(f,p,S,_)}p=p.child}return p;case 26:return uv(f,p),f===null?(_=Y4(p.type,null,p.pendingProps,null))?p.memoizedState=_:yn||(_=p.type,f=p.pendingProps,S=Tv(re.current).createElement(_),S[mr]=p,S[Nr]=f,zi(S,_,f),Pe(S),p.stateNode=S):p.memoizedState=Y4(p.type,f.memoizedProps,p.pendingProps,f.memoizedState),null;case 27:return Se(p),f===null&&yn&&(S=p.stateNode=q4(p.type,p.pendingProps,re.current),Ii=p,Aa=!0,k=rr,tu(p.type)?(N2=k,rr=Ca(S.firstChild)):rr=k),Fi(f,p,p.pendingProps.children,_),uv(f,p),f===null&&(p.flags|=4194304),p.child;case 5:return f===null&&yn&&((k=S=rr)&&(S=Jte(S,p.type,p.pendingProps,Aa),S!==null?(p.stateNode=S,Ii=p,rr=Ca(S.firstChild),Aa=!1,k=!0):k=!1),k||Bc(p)),Se(p),k=p.type,O=p.pendingProps,Y=f!==null?f.memoizedProps:null,S=O.children,M2(k,O)?S=null:Y!==null&&M2(k,Y)&&(p.flags|=32),p.memoizedState!==null&&(k=wE(f,p,pte,null,null,_),jg._currentValue=k),uv(f,p),Fi(f,p,S,_),p.child;case 6:return f===null&&yn&&((f=_=rr)&&(_=ene(_,p.pendingProps,Aa),_!==null?(p.stateNode=_,Ii=p,rr=null,f=!0):f=!1),f||Bc(p)),null;case 13:return jI(f,p,_);case 4:return Ce(p,p.stateNode.containerInfo),S=p.pendingProps,f===null?p.child=Nd(p,null,S,_):Fi(f,p,S,_),p.child;case 11:return TI(f,p,p.type,p.pendingProps,_);case 7:return Fi(f,p,p.pendingProps,_),p.child;case 8:return Fi(f,p,p.pendingProps.children,_),p.child;case 12:return Fi(f,p,p.pendingProps.children,_),p.child;case 10:return S=p.pendingProps,Hc(p,p.type,S.value),Fi(f,p,S.children,_),p.child;case 9:return k=p.type._context,S=p.pendingProps.children,Ed(p),k=Ui(k),S=S(k),p.flags|=1,Fi(f,p,S,_),p.child;case 14:return CI(f,p,p.type,p.pendingProps,_);case 15:return NI(f,p,p.type,p.pendingProps,_);case 19:return UI(f,p,_);case 31:return Ste(f,p,_);case 22:return kI(f,p,_,p.pendingProps);case 24:return Ed(p),S=Ui(Ur),f===null?(k=hE(),k===null&&(k=Xn,O=dE(),k.pooledCache=O,O.refCount++,O!==null&&(k.pooledCacheLanes|=_),k=O),p.memoizedState={parent:S,cache:k},mE(p),Hc(p,Ur,k)):((f.lanes&_)!==0&&(gE(f,p),gg(p,null,null,_),mg()),k=f.memoizedState,O=p.memoizedState,k.parent!==S?(k={parent:S,cache:S},p.memoizedState=k,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=k),Hc(p,Ur,S)):(S=O.cache,Hc(p,Ur,S),S!==k.cache&&uE(p,[Ur],_,!0))),Fi(f,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function El(f){f.flags|=4}function ZE(f,p,_,S,k){if((p=(f.mode&32)!==0)&&(p=!1),p){if(f.flags|=16777216,(k&335544128)===k)if(f.stateNode.complete)f.flags|=8192;else if(f4())f.flags|=8192;else throw Cd=Kb,pE}else f.flags&=-16777217}function zI(f,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)f.flags&=-16777217;else if(f.flags|=16777216,!tU(p))if(f4())f.flags|=8192;else throw Cd=Kb,pE}function fv(f,p){p!==null&&(f.flags|=4),f.flags&16384&&(p=f.tag!==22?yt():536870912,f.lanes|=p,Ah|=p)}function Sg(f,p){if(!yn)switch(f.tailMode){case"hidden":p=f.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?f.tail=null:_.sibling=null;break;case"collapsed":_=f.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?p||f.tail===null?f.tail=null:f.tail.sibling=null:S.sibling=null}}function ir(f){var p=f.alternate!==null&&f.alternate.child===f.child,_=0,S=0;if(p)for(var k=f.child;k!==null;)_|=k.lanes|k.childLanes,S|=k.subtreeFlags&65011712,S|=k.flags&65011712,k.return=f,k=k.sibling;else for(k=f.child;k!==null;)_|=k.lanes|k.childLanes,S|=k.subtreeFlags,S|=k.flags,k.return=f,k=k.sibling;return f.subtreeFlags|=S,f.childLanes=_,p}function Mte(f,p,_){var S=p.pendingProps;switch(sE(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ir(p),null;case 1:return ir(p),null;case 3:return _=p.stateNode,S=null,f!==null&&(S=f.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),_l(Ur),fe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(f===null||f.child===null)&&(hh(p)?El(p):f===null||f.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,oE())),ir(p),null;case 26:var k=p.type,O=p.memoizedState;return f===null?(El(p),O!==null?(ir(p),zI(p,O)):(ir(p),ZE(p,k,null,S,_))):O?O!==f.memoizedState?(El(p),ir(p),zI(p,O)):(ir(p),p.flags&=-16777217):(f=f.memoizedProps,f!==S&&El(p),ir(p),ZE(p,k,f,S,_)),null;case 27:if(Re(p),_=re.current,k=p.type,f!==null&&p.stateNode!=null)f.memoizedProps!==S&&El(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return ir(p),null}f=ae.current,hh(p)?vj(p):(f=q4(k,S,_),p.stateNode=f,El(p))}return ir(p),null;case 5:if(Re(p),k=p.type,f!==null&&p.stateNode!=null)f.memoizedProps!==S&&El(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return ir(p),null}if(O=ae.current,hh(p))vj(p);else{var Y=Tv(re.current);switch(O){case 1:O=Y.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:O=Y.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":O=Y.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":O=Y.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":O=Y.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof S.is=="string"?Y.createElement("select",{is:S.is}):Y.createElement("select"),S.multiple?O.multiple=!0:S.size&&(O.size=S.size);break;default:O=typeof S.is=="string"?Y.createElement(k,{is:S.is}):Y.createElement(k)}}O[mr]=p,O[Nr]=S;e:for(Y=p.child;Y!==null;){if(Y.tag===5||Y.tag===6)O.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===p)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===p)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}p.stateNode=O;e:switch(zi(O,k,S),k){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&El(p)}}return ir(p),ZE(p,p.type,f===null?null:f.memoizedProps,p.pendingProps,_),null;case 6:if(f&&p.stateNode!=null)f.memoizedProps!==S&&El(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(r(166));if(f=re.current,hh(p)){if(f=p.stateNode,_=p.memoizedProps,S=null,k=Ii,k!==null)switch(k.tag){case 27:case 5:S=k.memoizedProps}f[mr]=p,f=!!(f.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||j4(f.nodeValue,_)),f||Bc(p,!0)}else f=Tv(f).createTextNode(S),f[mr]=p,p.stateNode=f}return ir(p),null;case 31:if(_=p.memoizedState,f===null||f.memoizedState!==null){if(S=hh(p),_!==null){if(f===null){if(!S)throw Error(r(318));if(f=p.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(557));f[mr]=p}else wd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;ir(p),f=!1}else _=oE(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=_),f=!0;if(!f)return p.flags&256?(na(p),p):(na(p),null);if((p.flags&128)!==0)throw Error(r(558))}return ir(p),null;case 13:if(S=p.memoizedState,f===null||f.memoizedState!==null&&f.memoizedState.dehydrated!==null){if(k=hh(p),S!==null&&S.dehydrated!==null){if(f===null){if(!k)throw Error(r(318));if(k=p.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[mr]=p}else wd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;ir(p),k=!1}else k=oE(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=k),k=!0;if(!k)return p.flags&256?(na(p),p):(na(p),null)}return na(p),(p.flags&128)!==0?(p.lanes=_,p):(_=S!==null,f=f!==null&&f.memoizedState!==null,_&&(S=p.child,k=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(k=S.alternate.memoizedState.cachePool.pool),O=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(O=S.memoizedState.cachePool.pool),O!==k&&(S.flags|=2048)),_!==f&&_&&(p.child.flags|=8192),fv(p,p.updateQueue),ir(p),null);case 4:return fe(),f===null&&v2(p.stateNode.containerInfo),ir(p),null;case 10:return _l(p.type),ir(p),null;case 19:if(q(Rr),S=p.memoizedState,S===null)return ir(p),null;if(k=(p.flags&128)!==0,O=S.rendering,O===null)if(k)Sg(S,!1);else{if(Mr!==0||f!==null&&(f.flags&128)!==0)for(f=p.child;f!==null;){if(O=Jb(f),O!==null){for(p.flags|=128,Sg(S,!1),f=O.updateQueue,p.updateQueue=f,fv(p,f),p.subtreeFlags=0,f=_,_=p.child;_!==null;)pj(_,f),_=_.sibling;return te(Rr,Rr.current&1|2),yn&&vl(p,S.treeForkCount),p.child}f=f.sibling}S.tail!==null&&L()>xv&&(p.flags|=128,k=!0,Sg(S,!1),p.lanes=4194304)}else{if(!k)if(f=Jb(O),f!==null){if(p.flags|=128,k=!0,f=f.updateQueue,p.updateQueue=f,fv(p,f),Sg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!yn)return ir(p),null}else 2*L()-S.renderingStartTime>xv&&_!==536870912&&(p.flags|=128,k=!0,Sg(S,!1),p.lanes=4194304);S.isBackwards?(O.sibling=p.child,p.child=O):(f=S.last,f!==null?f.sibling=O:p.child=O,S.last=O)}return S.tail!==null?(f=S.tail,S.rendering=f,S.tail=f.sibling,S.renderingStartTime=L(),f.sibling=null,_=Rr.current,te(Rr,k?_&1|2:_&1),yn&&vl(p,S.treeForkCount),f):(ir(p),null);case 22:case 23:return na(p),yE(),S=p.memoizedState!==null,f!==null?f.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(_&536870912)!==0&&(p.flags&128)===0&&(ir(p),p.subtreeFlags&6&&(p.flags|=8192)):ir(p),_=p.updateQueue,_!==null&&fv(p,_.retryQueue),_=null,f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==_&&(p.flags|=2048),f!==null&&q(Ad),null;case 24:return _=null,f!==null&&(_=f.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),_l(Ur),ir(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function Ete(f,p){switch(sE(p),p.tag){case 1:return f=p.flags,f&65536?(p.flags=f&-65537|128,p):null;case 3:return _l(Ur),fe(),f=p.flags,(f&65536)!==0&&(f&128)===0?(p.flags=f&-65537|128,p):null;case 26:case 27:case 5:return Re(p),null;case 31:if(p.memoizedState!==null){if(na(p),p.alternate===null)throw Error(r(340));wd()}return f=p.flags,f&65536?(p.flags=f&-65537|128,p):null;case 13:if(na(p),f=p.memoizedState,f!==null&&f.dehydrated!==null){if(p.alternate===null)throw Error(r(340));wd()}return f=p.flags,f&65536?(p.flags=f&-65537|128,p):null;case 19:return q(Rr),null;case 4:return fe(),null;case 10:return _l(p.type),null;case 22:case 23:return na(p),yE(),f!==null&&q(Ad),f=p.flags,f&65536?(p.flags=f&-65537|128,p):null;case 24:return _l(Ur),null;case 25:return null;default:return null}}function BI(f,p){switch(sE(p),p.tag){case 3:_l(Ur),fe();break;case 26:case 27:case 5:Re(p);break;case 4:fe();break;case 31:p.memoizedState!==null&&na(p);break;case 13:na(p);break;case 19:q(Rr);break;case 10:_l(p.type);break;case 22:case 23:na(p),yE(),f!==null&&q(Ad);break;case 24:_l(Ur)}}function wg(f,p){try{var _=p.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var k=S.next;_=k;do{if((_.tag&f)===f){S=void 0;var O=_.create,Y=_.inst;S=O(),Y.destroy=S}_=_.next}while(_!==k)}}catch(oe){On(p,p.return,oe)}}function Xc(f,p,_){try{var S=p.updateQueue,k=S!==null?S.lastEffect:null;if(k!==null){var O=k.next;S=O;do{if((S.tag&f)===f){var Y=S.inst,oe=Y.destroy;if(oe!==void 0){Y.destroy=void 0,k=p;var we=_,Ve=oe;try{Ve()}catch(st){On(k,we,st)}}}S=S.next}while(S!==O)}}catch(st){On(p,p.return,st)}}function HI(f){var p=f.updateQueue;if(p!==null){var _=f.stateNode;try{Pj(p,_)}catch(S){On(f,f.return,S)}}}function $I(f,p,_){_.props=Rd(f.type,f.memoizedProps),_.state=f.memoizedState;try{_.componentWillUnmount()}catch(S){On(f,p,S)}}function Mg(f,p){try{var _=f.ref;if(_!==null){switch(f.tag){case 26:case 27:case 5:var S=f.stateNode;break;case 30:S=f.stateNode;break;default:S=f.stateNode}typeof _=="function"?f.refCleanup=_(S):_.current=S}}catch(k){On(f,p,k)}}function Fo(f,p){var _=f.ref,S=f.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(k){On(f,p,k)}finally{f.refCleanup=null,f=f.alternate,f!=null&&(f.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(k){On(f,p,k)}else _.current=null}function VI(f){var p=f.type,_=f.memoizedProps,S=f.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(k){On(f,f.return,k)}}function QE(f,p,_){try{var S=f.stateNode;qte(S,f.type,_,p),S[Nr]=p}catch(k){On(f,f.return,k)}}function GI(f){return f.tag===5||f.tag===3||f.tag===26||f.tag===27&&tu(f.type)||f.tag===4}function JE(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||GI(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.tag===27&&tu(f.type)||f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function e2(f,p,_){var S=f.tag;if(S===5||S===6)f=f.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(f,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(f),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=gl));else if(S!==4&&(S===27&&tu(f.type)&&(_=f.stateNode,p=null),f=f.child,f!==null))for(e2(f,p,_),f=f.sibling;f!==null;)e2(f,p,_),f=f.sibling}function hv(f,p,_){var S=f.tag;if(S===5||S===6)f=f.stateNode,p?_.insertBefore(f,p):_.appendChild(f);else if(S!==4&&(S===27&&tu(f.type)&&(_=f.stateNode),f=f.child,f!==null))for(hv(f,p,_),f=f.sibling;f!==null;)hv(f,p,_),f=f.sibling}function WI(f){var p=f.stateNode,_=f.memoizedProps;try{for(var S=f.type,k=p.attributes;k.length;)p.removeAttributeNode(k[0]);zi(p,S,_),p[mr]=f,p[Nr]=_}catch(O){On(f,f.return,O)}}var Al=!1,Br=!1,t2=!1,qI=typeof WeakSet=="function"?WeakSet:Set,Si=null;function Ate(f,p){if(f=f.containerInfo,S2=Ov,f=sj(f),XM(f)){if("selectionStart"in f)var _={start:f.selectionStart,end:f.selectionEnd};else e:{_=(_=f.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var k=S.anchorOffset,O=S.focusNode;S=S.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var Y=0,oe=-1,we=-1,Ve=0,st=0,dt=f,qe=null;t:for(;;){for(var nt;dt!==_||k!==0&&dt.nodeType!==3||(oe=Y+k),dt!==O||S!==0&&dt.nodeType!==3||(we=Y+S),dt.nodeType===3&&(Y+=dt.nodeValue.length),(nt=dt.firstChild)!==null;)qe=dt,dt=nt;for(;;){if(dt===f)break t;if(qe===_&&++Ve===k&&(oe=Y),qe===O&&++st===S&&(we=Y),(nt=dt.nextSibling)!==null)break;dt=qe,qe=dt.parentNode}dt=nt}_=oe===-1||we===-1?null:{start:oe,end:we}}else _=null}_=_||{start:0,end:0}}else _=null;for(w2={focusedElem:f,selectionRange:_},Ov=!1,Si=p;Si!==null;)if(p=Si,f=p.child,(p.subtreeFlags&1028)!==0&&f!==null)f.return=p,Si=f;else for(;Si!==null;){switch(p=Si,O=p.alternate,f=p.flags,p.tag){case 0:if((f&4)!==0&&(f=p.updateQueue,f=f!==null?f.events:null,f!==null))for(_=0;_<f.length;_++)k=f[_],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((f&1024)!==0&&O!==null){f=void 0,_=p,k=O.memoizedProps,O=O.memoizedState,S=_.stateNode;try{var kt=Rd(_.type,k);f=S.getSnapshotBeforeUpdate(kt,O),S.__reactInternalSnapshotBeforeUpdate=f}catch(Vt){On(_,_.return,Vt)}}break;case 3:if((f&1024)!==0){if(f=p.stateNode.containerInfo,_=f.nodeType,_===9)A2(f);else if(_===1)switch(f.nodeName){case"HEAD":case"HTML":case"BODY":A2(f);break;default:f.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((f&1024)!==0)throw Error(r(163))}if(f=p.sibling,f!==null){f.return=p.return,Si=f;break}Si=p.return}}function XI(f,p,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:Cl(f,_),S&4&&wg(5,_);break;case 1:if(Cl(f,_),S&4)if(f=_.stateNode,p===null)try{f.componentDidMount()}catch(Y){On(_,_.return,Y)}else{var k=Rd(_.type,p.memoizedProps);p=p.memoizedState;try{f.componentDidUpdate(k,p,f.__reactInternalSnapshotBeforeUpdate)}catch(Y){On(_,_.return,Y)}}S&64&&HI(_),S&512&&Mg(_,_.return);break;case 3:if(Cl(f,_),S&64&&(f=_.updateQueue,f!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{Pj(f,p)}catch(Y){On(_,_.return,Y)}}break;case 27:p===null&&S&4&&WI(_);case 26:case 5:Cl(f,_),p===null&&S&4&&VI(_),S&512&&Mg(_,_.return);break;case 12:Cl(f,_);break;case 31:Cl(f,_),S&4&&ZI(f,_);break;case 13:Cl(f,_),S&4&&QI(f,_),S&64&&(f=_.memoizedState,f!==null&&(f=f.dehydrated,f!==null&&(_=Lte.bind(null,_),tne(f,_))));break;case 22:if(S=_.memoizedState!==null||Al,!S){p=p!==null&&p.memoizedState!==null||Br,k=Al;var O=Br;Al=S,(Br=p)&&!O?Nl(f,_,(_.subtreeFlags&8772)!==0):Cl(f,_),Al=k,Br=O}break;case 30:break;default:Cl(f,_)}}function KI(f){var p=f.alternate;p!==null&&(f.alternate=null,KI(p)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(p=f.stateNode,p!==null&&Ze(p)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}var ur=null,Ps=!1;function Tl(f,p,_){for(_=_.child;_!==null;)YI(f,p,_),_=_.sibling}function YI(f,p,_){if(ce&&typeof ce.onCommitFiberUnmount=="function")try{ce.onCommitFiberUnmount(Fe,_)}catch{}switch(_.tag){case 26:Br||Fo(_,p),Tl(f,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Br||Fo(_,p);var S=ur,k=Ps;tu(_.type)&&(ur=_.stateNode,Ps=!1),Tl(f,p,_),Dg(_.stateNode),ur=S,Ps=k;break;case 5:Br||Fo(_,p);case 6:if(S=ur,k=Ps,ur=null,Tl(f,p,_),ur=S,Ps=k,ur!==null)if(Ps)try{(ur.nodeType===9?ur.body:ur.nodeName==="HTML"?ur.ownerDocument.body:ur).removeChild(_.stateNode)}catch(O){On(_,p,O)}else try{ur.removeChild(_.stateNode)}catch(O){On(_,p,O)}break;case 18:ur!==null&&(Ps?(f=ur,H4(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,_.stateNode),Oh(f)):H4(ur,_.stateNode));break;case 4:S=ur,k=Ps,ur=_.stateNode.containerInfo,Ps=!0,Tl(f,p,_),ur=S,Ps=k;break;case 0:case 11:case 14:case 15:Xc(2,_,p),Br||Xc(4,_,p),Tl(f,p,_);break;case 1:Br||(Fo(_,p),S=_.stateNode,typeof S.componentWillUnmount=="function"&&$I(_,p,S)),Tl(f,p,_);break;case 21:Tl(f,p,_);break;case 22:Br=(S=Br)||_.memoizedState!==null,Tl(f,p,_),Br=S;break;default:Tl(f,p,_)}}function ZI(f,p){if(p.memoizedState===null&&(f=p.alternate,f!==null&&(f=f.memoizedState,f!==null))){f=f.dehydrated;try{Oh(f)}catch(_){On(p,p.return,_)}}}function QI(f,p){if(p.memoizedState===null&&(f=p.alternate,f!==null&&(f=f.memoizedState,f!==null&&(f=f.dehydrated,f!==null))))try{Oh(f)}catch(_){On(p,p.return,_)}}function Tte(f){switch(f.tag){case 31:case 13:case 19:var p=f.stateNode;return p===null&&(p=f.stateNode=new qI),p;case 22:return f=f.stateNode,p=f._retryCache,p===null&&(p=f._retryCache=new qI),p;default:throw Error(r(435,f.tag))}}function pv(f,p){var _=Tte(f);p.forEach(function(S){if(!_.has(S)){_.add(S);var k=jte.bind(null,f,S);S.then(k,k)}})}function Ds(f,p){var _=p.deletions;if(_!==null)for(var S=0;S<_.length;S++){var k=_[S],O=f,Y=p,oe=Y;e:for(;oe!==null;){switch(oe.tag){case 27:if(tu(oe.type)){ur=oe.stateNode,Ps=!1;break e}break;case 5:ur=oe.stateNode,Ps=!1;break e;case 3:case 4:ur=oe.stateNode.containerInfo,Ps=!0;break e}oe=oe.return}if(ur===null)throw Error(r(160));YI(O,Y,k),ur=null,Ps=!1,O=k.alternate,O!==null&&(O.return=null),k.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)JI(p,f),p=p.sibling}var lo=null;function JI(f,p){var _=f.alternate,S=f.flags;switch(f.tag){case 0:case 11:case 14:case 15:Ds(p,f),Os(f),S&4&&(Xc(3,f,f.return),wg(3,f),Xc(5,f,f.return));break;case 1:Ds(p,f),Os(f),S&512&&(Br||_===null||Fo(_,_.return)),S&64&&Al&&(f=f.updateQueue,f!==null&&(S=f.callbacks,S!==null&&(_=f.shared.hiddenCallbacks,f.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var k=lo;if(Ds(p,f),Os(f),S&512&&(Br||_===null||Fo(_,_.return)),S&4){var O=_!==null?_.memoizedState:null;if(S=f.memoizedState,_===null)if(S===null)if(f.stateNode===null){e:{S=f.type,_=f.memoizedProps,k=k.ownerDocument||k;t:switch(S){case"title":O=k.getElementsByTagName("title")[0],(!O||O[tt]||O[mr]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=k.createElement(S),k.head.insertBefore(O,k.querySelector("head > title"))),zi(O,S,_),O[mr]=f,Pe(O),S=O;break e;case"link":var Y=J4("link","href",k).get(S+(_.href||""));if(Y){for(var oe=0;oe<Y.length;oe++)if(O=Y[oe],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Y.splice(oe,1);break t}}O=k.createElement(S),zi(O,S,_),k.head.appendChild(O);break;case"meta":if(Y=J4("meta","content",k).get(S+(_.content||""))){for(oe=0;oe<Y.length;oe++)if(O=Y[oe],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Y.splice(oe,1);break t}}O=k.createElement(S),zi(O,S,_),k.head.appendChild(O);break;default:throw Error(r(468,S))}O[mr]=f,Pe(O),S=O}f.stateNode=S}else eU(k,f.type,f.stateNode);else f.stateNode=Q4(k,S,f.memoizedProps);else O!==S?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,S===null?eU(k,f.type,f.stateNode):Q4(k,S,f.memoizedProps)):S===null&&f.stateNode!==null&&QE(f,f.memoizedProps,_.memoizedProps)}break;case 27:Ds(p,f),Os(f),S&512&&(Br||_===null||Fo(_,_.return)),_!==null&&S&4&&QE(f,f.memoizedProps,_.memoizedProps);break;case 5:if(Ds(p,f),Os(f),S&512&&(Br||_===null||Fo(_,_.return)),f.flags&32){k=f.stateNode;try{jo(k,"")}catch(kt){On(f,f.return,kt)}}S&4&&f.stateNode!=null&&(k=f.memoizedProps,QE(f,k,_!==null?_.memoizedProps:k)),S&1024&&(t2=!0);break;case 6:if(Ds(p,f),Os(f),S&4){if(f.stateNode===null)throw Error(r(162));S=f.memoizedProps,_=f.stateNode;try{_.nodeValue=S}catch(kt){On(f,f.return,kt)}}break;case 3:if(kv=null,k=lo,lo=Cv(p.containerInfo),Ds(p,f),lo=k,Os(f),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Oh(p.containerInfo)}catch(kt){On(f,f.return,kt)}t2&&(t2=!1,e4(f));break;case 4:S=lo,lo=Cv(f.stateNode.containerInfo),Ds(p,f),Os(f),lo=S;break;case 12:Ds(p,f),Os(f);break;case 31:Ds(p,f),Os(f),S&4&&(S=f.updateQueue,S!==null&&(f.updateQueue=null,pv(f,S)));break;case 13:Ds(p,f),Os(f),f.child.flags&8192&&f.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(gv=L()),S&4&&(S=f.updateQueue,S!==null&&(f.updateQueue=null,pv(f,S)));break;case 22:k=f.memoizedState!==null;var we=_!==null&&_.memoizedState!==null,Ve=Al,st=Br;if(Al=Ve||k,Br=st||we,Ds(p,f),Br=st,Al=Ve,Os(f),S&8192)e:for(p=f.stateNode,p._visibility=k?p._visibility&-2:p._visibility|1,k&&(_===null||we||Al||Br||Pd(f)),_=null,p=f;;){if(p.tag===5||p.tag===26){if(_===null){we=_=p;try{if(O=we.stateNode,k)Y=O.style,typeof Y.setProperty=="function"?Y.setProperty("display","none","important"):Y.display="none";else{oe=we.stateNode;var dt=we.memoizedProps.style,qe=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;oe.style.display=qe==null||typeof qe=="boolean"?"":(""+qe).trim()}}catch(kt){On(we,we.return,kt)}}}else if(p.tag===6){if(_===null){we=p;try{we.stateNode.nodeValue=k?"":we.memoizedProps}catch(kt){On(we,we.return,kt)}}}else if(p.tag===18){if(_===null){we=p;try{var nt=we.stateNode;k?$4(nt,!0):$4(we.stateNode,!1)}catch(kt){On(we,we.return,kt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===f)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===f)break e;for(;p.sibling===null;){if(p.return===null||p.return===f)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=f.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,pv(f,_))));break;case 19:Ds(p,f),Os(f),S&4&&(S=f.updateQueue,S!==null&&(f.updateQueue=null,pv(f,S)));break;case 30:break;case 21:break;default:Ds(p,f),Os(f)}}function Os(f){var p=f.flags;if(p&2){try{for(var _,S=f.return;S!==null;){if(GI(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var k=_.stateNode,O=JE(f);hv(f,O,k);break;case 5:var Y=_.stateNode;_.flags&32&&(jo(Y,""),_.flags&=-33);var oe=JE(f);hv(f,oe,Y);break;case 3:case 4:var we=_.stateNode.containerInfo,Ve=JE(f);e2(f,Ve,we);break;default:throw Error(r(161))}}catch(st){On(f,f.return,st)}f.flags&=-3}p&4096&&(f.flags&=-4097)}function e4(f){if(f.subtreeFlags&1024)for(f=f.child;f!==null;){var p=f;e4(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),f=f.sibling}}function Cl(f,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)XI(f,p.alternate,p),p=p.sibling}function Pd(f){for(f=f.child;f!==null;){var p=f;switch(p.tag){case 0:case 11:case 14:case 15:Xc(4,p,p.return),Pd(p);break;case 1:Fo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&$I(p,p.return,_),Pd(p);break;case 27:Dg(p.stateNode);case 26:case 5:Fo(p,p.return),Pd(p);break;case 22:p.memoizedState===null&&Pd(p);break;case 30:Pd(p);break;default:Pd(p)}f=f.sibling}}function Nl(f,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,k=f,O=p,Y=O.flags;switch(O.tag){case 0:case 11:case 15:Nl(k,O,_),wg(4,O);break;case 1:if(Nl(k,O,_),S=O,k=S.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(Ve){On(S,S.return,Ve)}if(S=O,k=S.updateQueue,k!==null){var oe=S.stateNode;try{var we=k.shared.hiddenCallbacks;if(we!==null)for(k.shared.hiddenCallbacks=null,k=0;k<we.length;k++)Rj(we[k],oe)}catch(Ve){On(S,S.return,Ve)}}_&&Y&64&&HI(O),Mg(O,O.return);break;case 27:WI(O);case 26:case 5:Nl(k,O,_),_&&S===null&&Y&4&&VI(O),Mg(O,O.return);break;case 12:Nl(k,O,_);break;case 31:Nl(k,O,_),_&&Y&4&&ZI(k,O);break;case 13:Nl(k,O,_),_&&Y&4&&QI(k,O);break;case 22:O.memoizedState===null&&Nl(k,O,_),Mg(O,O.return);break;case 30:break;default:Nl(k,O,_)}p=p.sibling}}function n2(f,p){var _=null;f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),f=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(f=p.memoizedState.cachePool.pool),f!==_&&(f!=null&&f.refCount++,_!=null&&ug(_))}function r2(f,p){f=null,p.alternate!==null&&(f=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==f&&(p.refCount++,f!=null&&ug(f))}function co(f,p,_,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)t4(f,p,_,S),p=p.sibling}function t4(f,p,_,S){var k=p.flags;switch(p.tag){case 0:case 11:case 15:co(f,p,_,S),k&2048&&wg(9,p);break;case 1:co(f,p,_,S);break;case 3:co(f,p,_,S),k&2048&&(f=null,p.alternate!==null&&(f=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==f&&(p.refCount++,f!=null&&ug(f)));break;case 12:if(k&2048){co(f,p,_,S),f=p.stateNode;try{var O=p.memoizedProps,Y=O.id,oe=O.onPostCommit;typeof oe=="function"&&oe(Y,p.alternate===null?"mount":"update",f.passiveEffectDuration,-0)}catch(we){On(p,p.return,we)}}else co(f,p,_,S);break;case 31:co(f,p,_,S);break;case 13:co(f,p,_,S);break;case 23:break;case 22:O=p.stateNode,Y=p.alternate,p.memoizedState!==null?O._visibility&2?co(f,p,_,S):Eg(f,p):O._visibility&2?co(f,p,_,S):(O._visibility|=2,wh(f,p,_,S,(p.subtreeFlags&10256)!==0||!1)),k&2048&&n2(Y,p);break;case 24:co(f,p,_,S),k&2048&&r2(p.alternate,p);break;default:co(f,p,_,S)}}function wh(f,p,_,S,k){for(k=k&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=f,Y=p,oe=_,we=S,Ve=Y.flags;switch(Y.tag){case 0:case 11:case 15:wh(O,Y,oe,we,k),wg(8,Y);break;case 23:break;case 22:var st=Y.stateNode;Y.memoizedState!==null?st._visibility&2?wh(O,Y,oe,we,k):Eg(O,Y):(st._visibility|=2,wh(O,Y,oe,we,k)),k&&Ve&2048&&n2(Y.alternate,Y);break;case 24:wh(O,Y,oe,we,k),k&&Ve&2048&&r2(Y.alternate,Y);break;default:wh(O,Y,oe,we,k)}p=p.sibling}}function Eg(f,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=f,S=p,k=S.flags;switch(S.tag){case 22:Eg(_,S),k&2048&&n2(S.alternate,S);break;case 24:Eg(_,S),k&2048&&r2(S.alternate,S);break;default:Eg(_,S)}p=p.sibling}}var Ag=8192;function Mh(f,p,_){if(f.subtreeFlags&Ag)for(f=f.child;f!==null;)n4(f,p,_),f=f.sibling}function n4(f,p,_){switch(f.tag){case 26:Mh(f,p,_),f.flags&Ag&&f.memoizedState!==null&&hne(_,lo,f.memoizedState,f.memoizedProps);break;case 5:Mh(f,p,_);break;case 3:case 4:var S=lo;lo=Cv(f.stateNode.containerInfo),Mh(f,p,_),lo=S;break;case 22:f.memoizedState===null&&(S=f.alternate,S!==null&&S.memoizedState!==null?(S=Ag,Ag=16777216,Mh(f,p,_),Ag=S):Mh(f,p,_));break;default:Mh(f,p,_)}}function r4(f){var p=f.alternate;if(p!==null&&(f=p.child,f!==null)){p.child=null;do p=f.sibling,f.sibling=null,f=p;while(f!==null)}}function Tg(f){var p=f.deletions;if((f.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];Si=S,s4(S,f)}r4(f)}if(f.subtreeFlags&10256)for(f=f.child;f!==null;)i4(f),f=f.sibling}function i4(f){switch(f.tag){case 0:case 11:case 15:Tg(f),f.flags&2048&&Xc(9,f,f.return);break;case 3:Tg(f);break;case 12:Tg(f);break;case 22:var p=f.stateNode;f.memoizedState!==null&&p._visibility&2&&(f.return===null||f.return.tag!==13)?(p._visibility&=-3,mv(f)):Tg(f);break;default:Tg(f)}}function mv(f){var p=f.deletions;if((f.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];Si=S,s4(S,f)}r4(f)}for(f=f.child;f!==null;){switch(p=f,p.tag){case 0:case 11:case 15:Xc(8,p,p.return),mv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,mv(p));break;default:mv(p)}f=f.sibling}}function s4(f,p){for(;Si!==null;){var _=Si;switch(_.tag){case 0:case 11:case 15:Xc(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:ug(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,Si=S;else e:for(_=f;Si!==null;){S=Si;var k=S.sibling,O=S.return;if(KI(S),S===_){Si=null;break e}if(k!==null){k.return=O,Si=k;break e}Si=O}}}var Cte={getCacheForType:function(f){var p=Ui(Ur),_=p.data.get(f);return _===void 0&&(_=f(),p.data.set(f,_)),_},cacheSignal:function(){return Ui(Ur).controller.signal}},Nte=typeof WeakMap=="function"?WeakMap:Map,Cn=0,Xn=null,hn=null,xn=0,Dn=0,ra=null,Kc=!1,Eh=!1,i2=!1,kl=0,Mr=0,Yc=0,Dd=0,s2=0,ia=0,Ah=0,Cg=null,Ls=null,a2=!1,gv=0,a4=0,xv=1/0,bv=null,Zc=null,ri=0,Qc=null,Th=null,Rl=0,o2=0,l2=null,o4=null,Ng=0,c2=null;function sa(){return(Cn&2)!==0&&xn!==0?xn&-xn:K.T!==null?m2():Li()}function l4(){if(ia===0)if((xn&536870912)===0||yn){var f=be;be<<=1,(be&3932160)===0&&(be=262144),ia=f}else ia=536870912;return f=ta.current,f!==null&&(f.flags|=32),ia}function js(f,p,_){(f===Xn&&(Dn===2||Dn===9)||f.cancelPendingCommit!==null)&&(Ch(f,0),Jc(f,xn,ia,!1)),cn(f,_),((Cn&2)===0||f!==Xn)&&(f===Xn&&((Cn&2)===0&&(Dd|=_),Mr===4&&Jc(f,xn,ia,!1)),zo(f))}function c4(f,p,_){if((Cn&6)!==0)throw Error(r(327));var S=!_&&(p&127)===0&&(p&f.expiredLanes)===0||Ge(f,p),k=S?Pte(f,p):d2(f,p,!0),O=S;do{if(k===0){Eh&&!S&&Jc(f,p,0,!1);break}else{if(_=f.current.alternate,O&&!kte(_)){k=d2(f,p,!1),O=!1;continue}if(k===2){if(O=p,f.errorRecoveryDisabledLanes&O)var Y=0;else Y=f.pendingLanes&-536870913,Y=Y!==0?Y:Y&536870912?536870912:0;if(Y!==0){p=Y;e:{var oe=f;k=Cg;var we=oe.current.memoizedState.isDehydrated;if(we&&(Ch(oe,Y).flags|=256),Y=d2(oe,Y,!1),Y!==2){if(i2&&!we){oe.errorRecoveryDisabledLanes|=O,Dd|=O,k=4;break e}O=Ls,Ls=k,O!==null&&(Ls===null?Ls=O:Ls.push.apply(Ls,O))}k=Y}if(O=!1,k!==2)continue}}if(k===1){Ch(f,0),Jc(f,p,0,!0);break}e:{switch(S=f,O=k,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:Jc(S,p,ia,!Kc);break e;case 2:Ls=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(k=gv+300-L(),10<k)){if(Jc(S,p,ia,!Kc),ye(S,0,!0)!==0)break e;Rl=p,S.timeoutHandle=z4(u4.bind(null,S,_,Ls,bv,a2,p,ia,Dd,Ah,Kc,O,"Throttled",-0,0),k);break e}u4(S,_,Ls,bv,a2,p,ia,Dd,Ah,Kc,O,null,-0,0)}}break}while(!0);zo(f)}function u4(f,p,_,S,k,O,Y,oe,we,Ve,st,dt,qe,nt){if(f.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gl},n4(p,O,dt);var kt=(O&62914560)===O?gv-L():(O&4194048)===O?a4-L():0;if(kt=pne(dt,kt),kt!==null){Rl=O,f.cancelPendingCommit=kt(b4.bind(null,f,p,O,_,S,k,Y,oe,we,st,dt,null,qe,nt)),Jc(f,O,Y,!Ve);return}}b4(f,p,O,_,S,k,Y,oe,we)}function kte(f){for(var p=f;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var k=_[S],O=k.getSnapshot;k=k.value;try{if(!Js(O(),k))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===f)break;for(;p.sibling===null;){if(p.return===null||p.return===f)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Jc(f,p,_,S){p&=~s2,p&=~Dd,f.suspendedLanes|=p,f.pingedLanes&=~p,S&&(f.warmLanes|=p),S=f.expirationTimes;for(var k=p;0<k;){var O=31-He(k),Y=1<<O;S[O]=-1,k&=~Y}_!==0&&Rn(f,_,p)}function vv(){return(Cn&6)===0?(kg(0),!1):!0}function u2(){if(hn!==null){if(Dn===0)var f=hn.return;else f=hn,yl=Md=null,AE(f),bh=null,fg=0,f=hn;for(;f!==null;)BI(f.alternate,f),f=f.return;hn=null}}function Ch(f,p){var _=f.timeoutHandle;_!==-1&&(f.timeoutHandle=-1,Yte(_)),_=f.cancelPendingCommit,_!==null&&(f.cancelPendingCommit=null,_()),Rl=0,u2(),Xn=f,hn=_=bl(f.current,null),xn=p,Dn=0,ra=null,Kc=!1,Eh=Ge(f,p),i2=!1,Ah=ia=s2=Dd=Yc=Mr=0,Ls=Cg=null,a2=!1,(p&8)!==0&&(p|=p&32);var S=f.entangledLanes;if(S!==0)for(f=f.entanglements,S&=p;0<S;){var k=31-He(S),O=1<<k;p|=f[k],S&=~O}return kl=p,zb(),_}function d4(f,p){en=null,K.H=yg,p===xh||p===Xb?(p=Tj(),Dn=3):p===pE?(p=Tj(),Dn=4):Dn=p===HE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,ra=p,hn===null&&(Mr=1,lv(f,wa(p,f.current)))}function f4(){var f=ta.current;return f===null?!0:(xn&4194048)===xn?Ta===null:(xn&62914560)===xn||(xn&536870912)!==0?f===Ta:!1}function h4(){var f=K.H;return K.H=yg,f===null?yg:f}function p4(){var f=K.A;return K.A=Cte,f}function yv(){Mr=4,Kc||(xn&4194048)!==xn&&ta.current!==null||(Eh=!0),(Yc&134217727)===0&&(Dd&134217727)===0||Xn===null||Jc(Xn,xn,ia,!1)}function d2(f,p,_){var S=Cn;Cn|=2;var k=h4(),O=p4();(Xn!==f||xn!==p)&&(bv=null,Ch(f,p)),p=!1;var Y=Mr;e:do try{if(Dn!==0&&hn!==null){var oe=hn,we=ra;switch(Dn){case 8:u2(),Y=6;break e;case 3:case 2:case 9:case 6:ta.current===null&&(p=!0);var Ve=Dn;if(Dn=0,ra=null,Nh(f,oe,we,Ve),_&&Eh){Y=0;break e}break;default:Ve=Dn,Dn=0,ra=null,Nh(f,oe,we,Ve)}}Rte(),Y=Mr;break}catch(st){d4(f,st)}while(!0);return p&&f.shellSuspendCounter++,yl=Md=null,Cn=S,K.H=k,K.A=O,hn===null&&(Xn=null,xn=0,zb()),Y}function Rte(){for(;hn!==null;)m4(hn)}function Pte(f,p){var _=Cn;Cn|=2;var S=h4(),k=p4();Xn!==f||xn!==p?(bv=null,xv=L()+500,Ch(f,p)):Eh=Ge(f,p);e:do try{if(Dn!==0&&hn!==null){p=hn;var O=ra;t:switch(Dn){case 1:Dn=0,ra=null,Nh(f,p,O,1);break;case 2:case 9:if(Ej(O)){Dn=0,ra=null,g4(p);break}p=function(){Dn!==2&&Dn!==9||Xn!==f||(Dn=7),zo(f)},O.then(p,p);break e;case 3:Dn=7;break e;case 4:Dn=5;break e;case 7:Ej(O)?(Dn=0,ra=null,g4(p)):(Dn=0,ra=null,Nh(f,p,O,7));break;case 5:var Y=null;switch(hn.tag){case 26:Y=hn.memoizedState;case 5:case 27:var oe=hn;if(Y?tU(Y):oe.stateNode.complete){Dn=0,ra=null;var we=oe.sibling;if(we!==null)hn=we;else{var Ve=oe.return;Ve!==null?(hn=Ve,_v(Ve)):hn=null}break t}}Dn=0,ra=null,Nh(f,p,O,5);break;case 6:Dn=0,ra=null,Nh(f,p,O,6);break;case 8:u2(),Mr=6;break e;default:throw Error(r(462))}}Dte();break}catch(st){d4(f,st)}while(!0);return yl=Md=null,K.H=S,K.A=k,Cn=_,hn!==null?0:(Xn=null,xn=0,zb(),Mr)}function Dte(){for(;hn!==null&&!se();)m4(hn)}function m4(f){var p=FI(f.alternate,f,kl);f.memoizedProps=f.pendingProps,p===null?_v(f):hn=p}function g4(f){var p=f,_=p.alternate;switch(p.tag){case 15:case 0:p=DI(_,p,p.pendingProps,p.type,void 0,xn);break;case 11:p=DI(_,p,p.pendingProps,p.type.render,p.ref,xn);break;case 5:AE(p);default:BI(_,p),p=hn=pj(p,kl),p=FI(_,p,kl)}f.memoizedProps=f.pendingProps,p===null?_v(f):hn=p}function Nh(f,p,_,S){yl=Md=null,AE(p),bh=null,fg=0;var k=p.return;try{if(_te(f,k,p,_,xn)){Mr=1,lv(f,wa(_,f.current)),hn=null;return}}catch(O){if(k!==null)throw hn=k,O;Mr=1,lv(f,wa(_,f.current)),hn=null;return}p.flags&32768?(yn||S===1?f=!0:Eh||(xn&536870912)!==0?f=!1:(Kc=f=!0,(S===2||S===9||S===3||S===6)&&(S=ta.current,S!==null&&S.tag===13&&(S.flags|=16384))),x4(p,f)):_v(p)}function _v(f){var p=f;do{if((p.flags&32768)!==0){x4(p,Kc);return}f=p.return;var _=Mte(p.alternate,p,kl);if(_!==null){hn=_;return}if(p=p.sibling,p!==null){hn=p;return}hn=p=f}while(p!==null);Mr===0&&(Mr=5)}function x4(f,p){do{var _=Ete(f.alternate,f);if(_!==null){_.flags&=32767,hn=_;return}if(_=f.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(f=f.sibling,f!==null)){hn=f;return}hn=f=_}while(f!==null);Mr=6,hn=null}function b4(f,p,_,S,k,O,Y,oe,we){f.cancelPendingCommit=null;do Sv();while(ri!==0);if((Cn&6)!==0)throw Error(r(327));if(p!==null){if(p===f.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=JM,jt(f,_,O,Y,oe,we),f===Xn&&(hn=Xn=null,xn=0),Th=p,Qc=f,Rl=_,o2=O,l2=k,o4=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(f.callbackNode=null,f.callbackPriority=0,Ite(ge,function(){return w4(),null})):(f.callbackNode=null,f.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=K.T,K.T=null,k=G.p,G.p=2,Y=Cn,Cn|=4;try{Ate(f,p,_)}finally{Cn=Y,G.p=k,K.T=S}}ri=1,v4(),y4(),_4()}}function v4(){if(ri===1){ri=0;var f=Qc,p=Th,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var S=G.p;G.p=2;var k=Cn;Cn|=4;try{JI(p,f);var O=w2,Y=sj(f.containerInfo),oe=O.focusedElem,we=O.selectionRange;if(Y!==oe&&oe&&oe.ownerDocument&&ij(oe.ownerDocument.documentElement,oe)){if(we!==null&&XM(oe)){var Ve=we.start,st=we.end;if(st===void 0&&(st=Ve),"selectionStart"in oe)oe.selectionStart=Ve,oe.selectionEnd=Math.min(st,oe.value.length);else{var dt=oe.ownerDocument||document,qe=dt&&dt.defaultView||window;if(qe.getSelection){var nt=qe.getSelection(),kt=oe.textContent.length,Vt=Math.min(we.start,kt),Fn=we.end===void 0?Vt:Math.min(we.end,kt);!nt.extend&&Vt>Fn&&(Y=Fn,Fn=Vt,Vt=Y);var Oe=rj(oe,Vt),Ne=rj(oe,Fn);if(Oe&&Ne&&(nt.rangeCount!==1||nt.anchorNode!==Oe.node||nt.anchorOffset!==Oe.offset||nt.focusNode!==Ne.node||nt.focusOffset!==Ne.offset)){var $e=dt.createRange();$e.setStart(Oe.node,Oe.offset),nt.removeAllRanges(),Vt>Fn?(nt.addRange($e),nt.extend(Ne.node,Ne.offset)):($e.setEnd(Ne.node,Ne.offset),nt.addRange($e))}}}}for(dt=[],nt=oe;nt=nt.parentNode;)nt.nodeType===1&&dt.push({element:nt,left:nt.scrollLeft,top:nt.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<dt.length;oe++){var ot=dt[oe];ot.element.scrollLeft=ot.left,ot.element.scrollTop=ot.top}}Ov=!!S2,w2=S2=null}finally{Cn=k,G.p=S,K.T=_}}f.current=p,ri=2}}function y4(){if(ri===2){ri=0;var f=Qc,p=Th,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var S=G.p;G.p=2;var k=Cn;Cn|=4;try{XI(f,p.alternate,p)}finally{Cn=k,G.p=S,K.T=_}}ri=3}}function _4(){if(ri===4||ri===3){ri=0,U();var f=Qc,p=Th,_=Rl,S=o4;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?ri=5:(ri=0,Th=Qc=null,S4(f,f.pendingLanes));var k=f.pendingLanes;if(k===0&&(Zc=null),vi(_),p=p.stateNode,ce&&typeof ce.onCommitFiberRoot=="function")try{ce.onCommitFiberRoot(Fe,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=K.T,k=G.p,G.p=2,K.T=null;try{for(var O=f.onRecoverableError,Y=0;Y<S.length;Y++){var oe=S[Y];O(oe.value,{componentStack:oe.stack})}}finally{K.T=p,G.p=k}}(Rl&3)!==0&&Sv(),zo(f),k=f.pendingLanes,(_&261930)!==0&&(k&42)!==0?f===c2?Ng++:(Ng=0,c2=f):Ng=0,kg(0)}}function S4(f,p){(f.pooledCacheLanes&=p)===0&&(p=f.pooledCache,p!=null&&(f.pooledCache=null,ug(p)))}function Sv(){return v4(),y4(),_4(),w4()}function w4(){if(ri!==5)return!1;var f=Qc,p=o2;o2=0;var _=vi(Rl),S=K.T,k=G.p;try{G.p=32>_?32:_,K.T=null,_=l2,l2=null;var O=Qc,Y=Rl;if(ri=0,Th=Qc=null,Rl=0,(Cn&6)!==0)throw Error(r(331));var oe=Cn;if(Cn|=4,i4(O.current),t4(O,O.current,Y,_),Cn=oe,kg(0,!1),ce&&typeof ce.onPostCommitFiberRoot=="function")try{ce.onPostCommitFiberRoot(Fe,O)}catch{}return!0}finally{G.p=k,K.T=S,S4(f,p)}}function M4(f,p,_){p=wa(_,p),p=BE(f.stateNode,p,2),f=Gc(f,p,2),f!==null&&(cn(f,2),zo(f))}function On(f,p,_){if(f.tag===3)M4(f,f,_);else for(;p!==null;){if(p.tag===3){M4(p,f,_);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(Zc===null||!Zc.has(S))){f=wa(_,f),_=EI(2),S=Gc(p,_,2),S!==null&&(AI(_,S,p,f),cn(S,2),zo(S));break}}p=p.return}}function f2(f,p,_){var S=f.pingCache;if(S===null){S=f.pingCache=new Nte;var k=new Set;S.set(p,k)}else k=S.get(p),k===void 0&&(k=new Set,S.set(p,k));k.has(_)||(i2=!0,k.add(_),f=Ote.bind(null,f,p,_),p.then(f,f))}function Ote(f,p,_){var S=f.pingCache;S!==null&&S.delete(p),f.pingedLanes|=f.suspendedLanes&_,f.warmLanes&=~_,Xn===f&&(xn&_)===_&&(Mr===4||Mr===3&&(xn&62914560)===xn&&300>L()-gv?(Cn&2)===0&&Ch(f,0):s2|=_,Ah===xn&&(Ah=0)),zo(f)}function E4(f,p){p===0&&(p=yt()),f=_d(f,p),f!==null&&(cn(f,p),zo(f))}function Lte(f){var p=f.memoizedState,_=0;p!==null&&(_=p.retryLane),E4(f,_)}function jte(f,p){var _=0;switch(f.tag){case 31:case 13:var S=f.stateNode,k=f.memoizedState;k!==null&&(_=k.retryLane);break;case 19:S=f.stateNode;break;case 22:S=f.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(p),E4(f,_)}function Ite(f,p){return Ae(f,p)}var wv=null,kh=null,h2=!1,Mv=!1,p2=!1,eu=0;function zo(f){f!==kh&&f.next===null&&(kh===null?wv=kh=f:kh=kh.next=f),Mv=!0,h2||(h2=!0,Fte())}function kg(f,p){if(!p2&&Mv){p2=!0;do for(var _=!1,S=wv;S!==null;){if(f!==0){var k=S.pendingLanes;if(k===0)var O=0;else{var Y=S.suspendedLanes,oe=S.pingedLanes;O=(1<<31-He(42|f)+1)-1,O&=k&~(Y&~oe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,N4(S,O))}else O=xn,O=ye(S,S===Xn?O:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(O&3)===0||Ge(S,O)||(_=!0,N4(S,O));S=S.next}while(_);p2=!1}}function Ute(){A4()}function A4(){Mv=h2=!1;var f=0;eu!==0&&Kte()&&(f=eu);for(var p=L(),_=null,S=wv;S!==null;){var k=S.next,O=T4(S,p);O===0?(S.next=null,_===null?wv=k:_.next=k,k===null&&(kh=_)):(_=S,(f!==0||(O&3)!==0)&&(Mv=!0)),S=k}ri!==0&&ri!==5||kg(f),eu!==0&&(eu=0)}function T4(f,p){for(var _=f.suspendedLanes,S=f.pingedLanes,k=f.expirationTimes,O=f.pendingLanes&-62914561;0<O;){var Y=31-He(O),oe=1<<Y,we=k[Y];we===-1?((oe&_)===0||(oe&S)!==0)&&(k[Y]=ft(oe,p)):we<=p&&(f.expiredLanes|=oe),O&=~oe}if(p=Xn,_=xn,_=ye(f,f===p?_:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),S=f.callbackNode,_===0||f===p&&(Dn===2||Dn===9)||f.cancelPendingCommit!==null)return S!==null&&S!==null&&Ee(S),f.callbackNode=null,f.callbackPriority=0;if((_&3)===0||Ge(f,_)){if(p=_&-_,p===f.callbackPriority)return p;switch(S!==null&&Ee(S),vi(_)){case 2:case 8:_=ve;break;case 32:_=ge;break;case 268435456:_=Ie;break;default:_=ge}return S=C4.bind(null,f),_=Ae(_,S),f.callbackPriority=p,f.callbackNode=_,p}return S!==null&&S!==null&&Ee(S),f.callbackPriority=2,f.callbackNode=null,2}function C4(f,p){if(ri!==0&&ri!==5)return f.callbackNode=null,f.callbackPriority=0,null;var _=f.callbackNode;if(Sv()&&f.callbackNode!==_)return null;var S=xn;return S=ye(f,f===Xn?S:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),S===0?null:(c4(f,S,p),T4(f,L()),f.callbackNode!=null&&f.callbackNode===_?C4.bind(null,f):null)}function N4(f,p){if(Sv())return null;c4(f,p,!0)}function Fte(){Zte(function(){(Cn&6)!==0?Ae(me,Ute):A4()})}function m2(){if(eu===0){var f=mh;f===0&&(f=Je,Je<<=1,(Je&261888)===0&&(Je=256)),eu=f}return eu}function k4(f){return f==null||typeof f=="symbol"||typeof f=="boolean"?null:typeof f=="function"?f:Pb(""+f)}function R4(f,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,f.id&&_.setAttribute("form",f.id),p.parentNode.insertBefore(_,p),f=new FormData(f),_.parentNode.removeChild(_),f}function zte(f,p,_,S,k){if(p==="submit"&&_&&_.stateNode===k){var O=k4((k[Nr]||null).action),Y=S.submitter;Y&&(p=(p=Y[Nr]||null)?k4(p.formAction):Y.getAttribute("formAction"),p!==null&&(O=p,Y=null));var oe=new jb("action","action",null,S,k);f.push({event:oe,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(eu!==0){var we=Y?R4(k,Y):new FormData(k);LE(_,{pending:!0,data:we,method:k.method,action:O},null,we)}}else typeof O=="function"&&(oe.preventDefault(),we=Y?R4(k,Y):new FormData(k),LE(_,{pending:!0,data:we,method:k.method,action:O},O,we))},currentTarget:k}]})}}for(var g2=0;g2<QM.length;g2++){var x2=QM[g2],Bte=x2.toLowerCase(),Hte=x2[0].toUpperCase()+x2.slice(1);oo(Bte,"on"+Hte)}oo(lj,"onAnimationEnd"),oo(cj,"onAnimationIteration"),oo(uj,"onAnimationStart"),oo("dblclick","onDoubleClick"),oo("focusin","onFocus"),oo("focusout","onBlur"),oo(ite,"onTransitionRun"),oo(ste,"onTransitionStart"),oo(ate,"onTransitionCancel"),oo(dj,"onTransitionEnd"),bt("onMouseEnter",["mouseout","mouseover"]),bt("onMouseLeave",["mouseout","mouseover"]),bt("onPointerEnter",["pointerout","pointerover"]),bt("onPointerLeave",["pointerout","pointerover"]),ht("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ht("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ht("onBeforeInput",["compositionend","keypress","textInput","paste"]),ht("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),$te=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Rg));function P4(f,p){p=(p&4)!==0;for(var _=0;_<f.length;_++){var S=f[_],k=S.event;S=S.listeners;e:{var O=void 0;if(p)for(var Y=S.length-1;0<=Y;Y--){var oe=S[Y],we=oe.instance,Ve=oe.currentTarget;if(oe=oe.listener,we!==O&&k.isPropagationStopped())break e;O=oe,k.currentTarget=Ve;try{O(k)}catch(st){Fb(st)}k.currentTarget=null,O=we}else for(Y=0;Y<S.length;Y++){if(oe=S[Y],we=oe.instance,Ve=oe.currentTarget,oe=oe.listener,we!==O&&k.isPropagationStopped())break e;O=oe,k.currentTarget=Ve;try{O(k)}catch(st){Fb(st)}k.currentTarget=null,O=we}}}}function pn(f,p){var _=p[Ic];_===void 0&&(_=p[Ic]=new Set);var S=f+"__bubble";_.has(S)||(D4(p,f,2,!1),_.add(S))}function b2(f,p,_){var S=0;p&&(S|=4),D4(_,f,S,p)}var Ev="_reactListening"+Math.random().toString(36).slice(2);function v2(f){if(!f[Ev]){f[Ev]=!0,Me.forEach(function(_){_!=="selectionchange"&&($te.has(_)||b2(_,!1,f),b2(_,!0,f))});var p=f.nodeType===9?f:f.ownerDocument;p===null||p[Ev]||(p[Ev]=!0,b2("selectionchange",!1,p))}}function D4(f,p,_,S){switch(lU(p)){case 2:var k=xne;break;case 8:k=bne;break;default:k=O2}_=k.bind(null,p,_,f),k=void 0,!FM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(k=!0),S?k!==void 0?f.addEventListener(p,_,{capture:!0,passive:k}):f.addEventListener(p,_,!0):k!==void 0?f.addEventListener(p,_,{passive:k}):f.addEventListener(p,_,!1)}function y2(f,p,_,S,k){var O=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var Y=S.tag;if(Y===3||Y===4){var oe=S.stateNode.containerInfo;if(oe===k)break;if(Y===4)for(Y=S.return;Y!==null;){var we=Y.tag;if((we===3||we===4)&&Y.stateNode.containerInfo===k)return;Y=Y.return}for(;oe!==null;){if(Y=_t(oe),Y===null)return;if(we=Y.tag,we===5||we===6||we===26||we===27){S=O=Y;continue e}oe=oe.parentNode}}S=S.return}UL(function(){var Ve=O,st=IM(_),dt=[];e:{var qe=fj.get(f);if(qe!==void 0){var nt=jb,kt=f;switch(f){case"keypress":if(Ob(_)===0)break e;case"keydown":case"keyup":nt=jee;break;case"focusin":kt="focus",nt=$M;break;case"focusout":kt="blur",nt=$M;break;case"beforeblur":case"afterblur":nt=$M;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":nt=BL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":nt=Mee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":nt=Fee;break;case lj:case cj:case uj:nt=Tee;break;case dj:nt=Bee;break;case"scroll":case"scrollend":nt=See;break;case"wheel":nt=$ee;break;case"copy":case"cut":case"paste":nt=Nee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":nt=$L;break;case"toggle":case"beforetoggle":nt=Gee}var Vt=(p&4)!==0,Fn=!Vt&&(f==="scroll"||f==="scrollend"),Oe=Vt?qe!==null?qe+"Capture":null:qe;Vt=[];for(var Ne=Ve,$e;Ne!==null;){var ot=Ne;if($e=ot.stateNode,ot=ot.tag,ot!==5&&ot!==26&&ot!==27||$e===null||Oe===null||(ot=Jm(Ne,Oe),ot!=null&&Vt.push(Pg(Ne,ot,$e))),Fn)break;Ne=Ne.return}0<Vt.length&&(qe=new nt(qe,kt,null,_,st),dt.push({event:qe,listeners:Vt}))}}if((p&7)===0){e:{if(qe=f==="mouseover"||f==="pointerover",nt=f==="mouseout"||f==="pointerout",qe&&_!==jM&&(kt=_.relatedTarget||_.fromElement)&&(_t(kt)||kt[so]))break e;if((nt||qe)&&(qe=st.window===st?st:(qe=st.ownerDocument)?qe.defaultView||qe.parentWindow:window,nt?(kt=_.relatedTarget||_.toElement,nt=Ve,kt=kt?_t(kt):null,kt!==null&&(Fn=s(kt),Vt=kt.tag,kt!==Fn||Vt!==5&&Vt!==27&&Vt!==6)&&(kt=null)):(nt=null,kt=Ve),nt!==kt)){if(Vt=BL,ot="onMouseLeave",Oe="onMouseEnter",Ne="mouse",(f==="pointerout"||f==="pointerover")&&(Vt=$L,ot="onPointerLeave",Oe="onPointerEnter",Ne="pointer"),Fn=nt==null?qe:_e(nt),$e=kt==null?qe:_e(kt),qe=new Vt(ot,Ne+"leave",nt,_,st),qe.target=Fn,qe.relatedTarget=$e,ot=null,_t(st)===Ve&&(Vt=new Vt(Oe,Ne+"enter",kt,_,st),Vt.target=$e,Vt.relatedTarget=Fn,ot=Vt),Fn=ot,nt&&kt)t:{for(Vt=Vte,Oe=nt,Ne=kt,$e=0,ot=Oe;ot;ot=Vt(ot))$e++;ot=0;for(var zt=Ne;zt;zt=Vt(zt))ot++;for(;0<$e-ot;)Oe=Vt(Oe),$e--;for(;0<ot-$e;)Ne=Vt(Ne),ot--;for(;$e--;){if(Oe===Ne||Ne!==null&&Oe===Ne.alternate){Vt=Oe;break t}Oe=Vt(Oe),Ne=Vt(Ne)}Vt=null}else Vt=null;nt!==null&&O4(dt,qe,nt,Vt,!1),kt!==null&&Fn!==null&&O4(dt,Fn,kt,Vt,!0)}}e:{if(qe=Ve?_e(Ve):window,nt=qe.nodeName&&qe.nodeName.toLowerCase(),nt==="select"||nt==="input"&&qe.type==="file")var wn=ZL;else if(KL(qe))if(QL)wn=tte;else{wn=Jee;var Dt=Qee}else nt=qe.nodeName,!nt||nt.toLowerCase()!=="input"||qe.type!=="checkbox"&&qe.type!=="radio"?Ve&&LM(Ve.elementType)&&(wn=ZL):wn=ete;if(wn&&(wn=wn(f,Ve))){YL(dt,wn,_,st);break e}Dt&&Dt(f,qe,Ve),f==="focusout"&&Ve&&qe.type==="number"&&Ve.memoizedProps.value!=null&&yi(qe,"number",qe.value)}switch(Dt=Ve?_e(Ve):window,f){case"focusin":(KL(Dt)||Dt.contentEditable==="true")&&(oh=Dt,KM=Ve,og=null);break;case"focusout":og=KM=oh=null;break;case"mousedown":YM=!0;break;case"contextmenu":case"mouseup":case"dragend":YM=!1,aj(dt,_,st);break;case"selectionchange":if(rte)break;case"keydown":case"keyup":aj(dt,_,st)}var tn;if(GM)e:{switch(f){case"compositionstart":var bn="onCompositionStart";break e;case"compositionend":bn="onCompositionEnd";break e;case"compositionupdate":bn="onCompositionUpdate";break e}bn=void 0}else ah?qL(f,_)&&(bn="onCompositionEnd"):f==="keydown"&&_.keyCode===229&&(bn="onCompositionStart");bn&&(VL&&_.locale!=="ko"&&(ah||bn!=="onCompositionStart"?bn==="onCompositionEnd"&&ah&&(tn=FL()):(Uc=st,zM="value"in Uc?Uc.value:Uc.textContent,ah=!0)),Dt=Av(Ve,bn),0<Dt.length&&(bn=new HL(bn,f,null,_,st),dt.push({event:bn,listeners:Dt}),tn?bn.data=tn:(tn=XL(_),tn!==null&&(bn.data=tn)))),(tn=qee?Xee(f,_):Kee(f,_))&&(bn=Av(Ve,"onBeforeInput"),0<bn.length&&(Dt=new HL("onBeforeInput","beforeinput",null,_,st),dt.push({event:Dt,listeners:bn}),Dt.data=tn)),zte(dt,f,Ve,_,st)}P4(dt,p)})}function Pg(f,p,_){return{instance:f,listener:p,currentTarget:_}}function Av(f,p){for(var _=p+"Capture",S=[];f!==null;){var k=f,O=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||O===null||(k=Jm(f,_),k!=null&&S.unshift(Pg(f,k,O)),k=Jm(f,p),k!=null&&S.push(Pg(f,k,O))),f.tag===3)return S;f=f.return}return[]}function Vte(f){if(f===null)return null;do f=f.return;while(f&&f.tag!==5&&f.tag!==27);return f||null}function O4(f,p,_,S,k){for(var O=p._reactName,Y=[];_!==null&&_!==S;){var oe=_,we=oe.alternate,Ve=oe.stateNode;if(oe=oe.tag,we!==null&&we===S)break;oe!==5&&oe!==26&&oe!==27||Ve===null||(we=Ve,k?(Ve=Jm(_,O),Ve!=null&&Y.unshift(Pg(_,Ve,we))):k||(Ve=Jm(_,O),Ve!=null&&Y.push(Pg(_,Ve,we)))),_=_.return}Y.length!==0&&f.push({event:p,listeners:Y})}var Gte=/\r\n?/g,Wte=/\u0000|\uFFFD/g;function L4(f){return(typeof f=="string"?f:""+f).replace(Gte,`
  9. `).replace(Wte,"")}function j4(f,p){return p=L4(p),L4(f)===p}function Un(f,p,_,S,k,O){switch(_){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||jo(f,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&jo(f,""+S);break;case"className":Ut(f,"class",S);break;case"tabIndex":Ut(f,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Ut(f,_,S);break;case"style":jL(f,S,O);break;case"data":if(p!=="object"){Ut(f,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||_!=="href")){f.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){f.removeAttribute(_);break}S=Pb(""+S),f.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){f.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&Un(f,p,"name",k.name,k,null),Un(f,p,"formEncType",k.formEncType,k,null),Un(f,p,"formMethod",k.formMethod,k,null),Un(f,p,"formTarget",k.formTarget,k,null)):(Un(f,p,"encType",k.encType,k,null),Un(f,p,"method",k.method,k,null),Un(f,p,"target",k.target,k,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){f.removeAttribute(_);break}S=Pb(""+S),f.setAttribute(_,S);break;case"onClick":S!=null&&(f.onclick=gl);break;case"onScroll":S!=null&&pn("scroll",f);break;case"onScrollEnd":S!=null&&pn("scrollend",f);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(k.children!=null)throw Error(r(60));f.innerHTML=_}}break;case"multiple":f.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":f.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"){f.removeAttribute("xlink:href");break}_=Pb(""+S),f.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"?f.setAttribute(_,""+S):f.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"?f.setAttribute(_,""):f.removeAttribute(_);break;case"capture":case"download":S===!0?f.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?f.setAttribute(_,S):f.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?f.setAttribute(_,S):f.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?f.removeAttribute(_):f.setAttribute(_,S);break;case"popover":pn("beforetoggle",f),pn("toggle",f),qt(f,"popover",S);break;case"xlinkActuate":nn(f,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":nn(f,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":nn(f,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":nn(f,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":nn(f,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":nn(f,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":nn(f,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":nn(f,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":nn(f,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":qt(f,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=yee.get(_)||_,qt(f,_,S))}}function _2(f,p,_,S,k,O){switch(_){case"style":jL(f,S,O);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(k.children!=null)throw Error(r(60));f.innerHTML=_}}break;case"children":typeof S=="string"?jo(f,S):(typeof S=="number"||typeof S=="bigint")&&jo(f,""+S);break;case"onScroll":S!=null&&pn("scroll",f);break;case"onScrollEnd":S!=null&&pn("scrollend",f);break;case"onClick":S!=null&&(f.onclick=gl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!it.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(k=_.endsWith("Capture"),p=_.slice(2,k?_.length-7:void 0),O=f[Nr]||null,O=O!=null?O[_]:null,typeof O=="function"&&f.removeEventListener(p,O,k),typeof S=="function")){typeof O!="function"&&O!==null&&(_ in f?f[_]=null:f.hasAttribute(_)&&f.removeAttribute(_)),f.addEventListener(p,S,k);break e}_ in f?f[_]=S:S===!0?f.setAttribute(_,""):qt(f,_,S)}}}function zi(f,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",f),pn("load",f);var S=!1,k=!1,O;for(O in _)if(_.hasOwnProperty(O)){var Y=_[O];if(Y!=null)switch(O){case"src":S=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(f,p,O,Y,_,null)}}k&&Un(f,p,"srcSet",_.srcSet,_,null),S&&Un(f,p,"src",_.src,_,null);return;case"input":pn("invalid",f);var oe=O=Y=k=null,we=null,Ve=null;for(S in _)if(_.hasOwnProperty(S)){var st=_[S];if(st!=null)switch(S){case"name":k=st;break;case"type":Y=st;break;case"checked":we=st;break;case"defaultChecked":Ve=st;break;case"value":O=st;break;case"defaultValue":oe=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,p));break;default:Un(f,p,S,st,_,null)}}Pn(f,O,oe,we,Ve,Y,k,!1);return;case"select":pn("invalid",f),S=Y=O=null;for(k in _)if(_.hasOwnProperty(k)&&(oe=_[k],oe!=null))switch(k){case"value":O=oe;break;case"defaultValue":Y=oe;break;case"multiple":S=oe;default:Un(f,p,k,oe,_,null)}p=O,_=Y,f.multiple=!!S,p!=null?ni(f,!!S,p,!1):_!=null&&ni(f,!!S,_,!0);return;case"textarea":pn("invalid",f),O=k=S=null;for(Y in _)if(_.hasOwnProperty(Y)&&(oe=_[Y],oe!=null))switch(Y){case"value":S=oe;break;case"defaultValue":k=oe;break;case"children":O=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:Un(f,p,Y,oe,_,null)}ji(f,S,k,O);return;case"option":for(we in _)if(_.hasOwnProperty(we)&&(S=_[we],S!=null))switch(we){case"selected":f.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Un(f,p,we,S,_,null)}return;case"dialog":pn("beforetoggle",f),pn("toggle",f),pn("cancel",f),pn("close",f);break;case"iframe":case"object":pn("load",f);break;case"video":case"audio":for(S=0;S<Rg.length;S++)pn(Rg[S],f);break;case"image":pn("error",f),pn("load",f);break;case"details":pn("toggle",f);break;case"embed":case"source":case"link":pn("error",f),pn("load",f);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ve in _)if(_.hasOwnProperty(Ve)&&(S=_[Ve],S!=null))switch(Ve){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(f,p,Ve,S,_,null)}return;default:if(LM(p)){for(st in _)_.hasOwnProperty(st)&&(S=_[st],S!==void 0&&_2(f,p,st,S,_,void 0));return}}for(oe in _)_.hasOwnProperty(oe)&&(S=_[oe],S!=null&&Un(f,p,oe,S,_,null))}function qte(f,p,_,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,O=null,Y=null,oe=null,we=null,Ve=null,st=null;for(nt in _){var dt=_[nt];if(_.hasOwnProperty(nt)&&dt!=null)switch(nt){case"checked":break;case"value":break;case"defaultValue":we=dt;default:S.hasOwnProperty(nt)||Un(f,p,nt,null,S,dt)}}for(var qe in S){var nt=S[qe];if(dt=_[qe],S.hasOwnProperty(qe)&&(nt!=null||dt!=null))switch(qe){case"type":O=nt;break;case"name":k=nt;break;case"checked":Ve=nt;break;case"defaultChecked":st=nt;break;case"value":Y=nt;break;case"defaultValue":oe=nt;break;case"children":case"dangerouslySetInnerHTML":if(nt!=null)throw Error(r(137,p));break;default:nt!==dt&&Un(f,p,qe,nt,S,dt)}}ao(f,Y,oe,we,Ve,st,O,k);return;case"select":nt=Y=oe=qe=null;for(O in _)if(we=_[O],_.hasOwnProperty(O)&&we!=null)switch(O){case"value":break;case"multiple":nt=we;default:S.hasOwnProperty(O)||Un(f,p,O,null,S,we)}for(k in S)if(O=S[k],we=_[k],S.hasOwnProperty(k)&&(O!=null||we!=null))switch(k){case"value":qe=O;break;case"defaultValue":oe=O;break;case"multiple":Y=O;default:O!==we&&Un(f,p,k,O,S,we)}p=oe,_=Y,S=nt,qe!=null?ni(f,!!_,qe,!1):!!S!=!!_&&(p!=null?ni(f,!!_,p,!0):ni(f,!!_,_?[]:"",!1));return;case"textarea":nt=qe=null;for(oe in _)if(k=_[oe],_.hasOwnProperty(oe)&&k!=null&&!S.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:Un(f,p,oe,null,S,k)}for(Y in S)if(k=S[Y],O=_[Y],S.hasOwnProperty(Y)&&(k!=null||O!=null))switch(Y){case"value":qe=k;break;case"defaultValue":nt=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(r(91));break;default:k!==O&&Un(f,p,Y,k,S,O)}_i(f,qe,nt);return;case"option":for(var kt in _)if(qe=_[kt],_.hasOwnProperty(kt)&&qe!=null&&!S.hasOwnProperty(kt))switch(kt){case"selected":f.selected=!1;break;default:Un(f,p,kt,null,S,qe)}for(we in S)if(qe=S[we],nt=_[we],S.hasOwnProperty(we)&&qe!==nt&&(qe!=null||nt!=null))switch(we){case"selected":f.selected=qe&&typeof qe!="function"&&typeof qe!="symbol";break;default:Un(f,p,we,qe,S,nt)}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 Vt in _)qe=_[Vt],_.hasOwnProperty(Vt)&&qe!=null&&!S.hasOwnProperty(Vt)&&Un(f,p,Vt,null,S,qe);for(Ve in S)if(qe=S[Ve],nt=_[Ve],S.hasOwnProperty(Ve)&&qe!==nt&&(qe!=null||nt!=null))switch(Ve){case"children":case"dangerouslySetInnerHTML":if(qe!=null)throw Error(r(137,p));break;default:Un(f,p,Ve,qe,S,nt)}return;default:if(LM(p)){for(var Fn in _)qe=_[Fn],_.hasOwnProperty(Fn)&&qe!==void 0&&!S.hasOwnProperty(Fn)&&_2(f,p,Fn,void 0,S,qe);for(st in S)qe=S[st],nt=_[st],!S.hasOwnProperty(st)||qe===nt||qe===void 0&&nt===void 0||_2(f,p,st,qe,S,nt);return}}for(var Oe in _)qe=_[Oe],_.hasOwnProperty(Oe)&&qe!=null&&!S.hasOwnProperty(Oe)&&Un(f,p,Oe,null,S,qe);for(dt in S)qe=S[dt],nt=_[dt],!S.hasOwnProperty(dt)||qe===nt||qe==null&&nt==null||Un(f,p,dt,qe,S,nt)}function I4(f){switch(f){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Xte(){if(typeof performance.getEntriesByType=="function"){for(var f=0,p=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var k=_[S],O=k.transferSize,Y=k.initiatorType,oe=k.duration;if(O&&oe&&I4(Y)){for(Y=0,oe=k.responseEnd,S+=1;S<_.length;S++){var we=_[S],Ve=we.startTime;if(Ve>oe)break;var st=we.transferSize,dt=we.initiatorType;st&&I4(dt)&&(we=we.responseEnd,Y+=st*(we<oe?1:(oe-Ve)/(we-Ve)))}if(--S,p+=8*(O+Y)/(k.duration/1e3),f++,10<f)break}}if(0<f)return p/f/1e6}return navigator.connection&&(f=navigator.connection.downlink,typeof f=="number")?f:5}var S2=null,w2=null;function Tv(f){return f.nodeType===9?f:f.ownerDocument}function U4(f){switch(f){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function F4(f,p){if(f===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return f===1&&p==="foreignObject"?0:f}function M2(f,p){return f==="textarea"||f==="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 E2=null;function Kte(){var f=window.event;return f&&f.type==="popstate"?f===E2?!1:(E2=f,!0):(E2=null,!1)}var z4=typeof setTimeout=="function"?setTimeout:void 0,Yte=typeof clearTimeout=="function"?clearTimeout:void 0,B4=typeof Promise=="function"?Promise:void 0,Zte=typeof queueMicrotask=="function"?queueMicrotask:typeof B4<"u"?function(f){return B4.resolve(null).then(f).catch(Qte)}:z4;function Qte(f){setTimeout(function(){throw f})}function tu(f){return f==="head"}function H4(f,p){var _=p,S=0;do{var k=_.nextSibling;if(f.removeChild(_),k&&k.nodeType===8)if(_=k.data,_==="/$"||_==="/&"){if(S===0){f.removeChild(k),Oh(p);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Dg(f.ownerDocument.documentElement);else if(_==="head"){_=f.ownerDocument.head,Dg(_);for(var O=_.firstChild;O;){var Y=O.nextSibling,oe=O.nodeName;O[tt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=Y}}else _==="body"&&Dg(f.ownerDocument.body);_=k}while(_);Oh(p)}function $4(f,p){var _=f;f=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(f===0)break;f--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||f++;_=S}while(_)}function A2(f){var p=f.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":A2(_),Ze(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}f.removeChild(_)}}function Jte(f,p,_,S){for(;f.nodeType===1;){var k=_;if(f.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(f.nodeName!=="INPUT"||f.type!=="hidden"))break}else if(S){if(!f[tt])switch(p){case"meta":if(!f.hasAttribute("itemprop"))break;return f;case"link":if(O=f.getAttribute("rel"),O==="stylesheet"&&f.hasAttribute("data-precedence"))break;if(O!==k.rel||f.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||f.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||f.getAttribute("title")!==(k.title==null?null:k.title))break;return f;case"style":if(f.hasAttribute("data-precedence"))break;return f;case"script":if(O=f.getAttribute("src"),(O!==(k.src==null?null:k.src)||f.getAttribute("type")!==(k.type==null?null:k.type)||f.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&O&&f.hasAttribute("async")&&!f.hasAttribute("itemprop"))break;return f;default:return f}}else if(p==="input"&&f.type==="hidden"){var O=k.name==null?null:""+k.name;if(k.type==="hidden"&&f.getAttribute("name")===O)return f}else return f;if(f=Ca(f.nextSibling),f===null)break}return null}function ene(f,p,_){if(p==="")return null;for(;f.nodeType!==3;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!_||(f=Ca(f.nextSibling),f===null))return null;return f}function V4(f,p){for(;f.nodeType!==8;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!p||(f=Ca(f.nextSibling),f===null))return null;return f}function T2(f){return f.data==="$?"||f.data==="$~"}function C2(f){return f.data==="$!"||f.data==="$?"&&f.ownerDocument.readyState!=="loading"}function tne(f,p){var _=f.ownerDocument;if(f.data==="$~")f._reactRetry=p;else if(f.data!=="$?"||_.readyState!=="loading")p();else{var S=function(){p(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),f._reactRetry=S}}function Ca(f){for(;f!=null;f=f.nextSibling){var p=f.nodeType;if(p===1||p===3)break;if(p===8){if(p=f.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return f}var N2=null;function G4(f){f=f.nextSibling;for(var p=0;f;){if(f.nodeType===8){var _=f.data;if(_==="/$"||_==="/&"){if(p===0)return Ca(f.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}f=f.nextSibling}return null}function W4(f){f=f.previousSibling;for(var p=0;f;){if(f.nodeType===8){var _=f.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return f;p--}else _!=="/$"&&_!=="/&"||p++}f=f.previousSibling}return null}function q4(f,p,_){switch(p=Tv(_),f){case"html":if(f=p.documentElement,!f)throw Error(r(452));return f;case"head":if(f=p.head,!f)throw Error(r(453));return f;case"body":if(f=p.body,!f)throw Error(r(454));return f;default:throw Error(r(451))}}function Dg(f){for(var p=f.attributes;p.length;)f.removeAttributeNode(p[0]);Ze(f)}var Na=new Map,X4=new Set;function Cv(f){return typeof f.getRootNode=="function"?f.getRootNode():f.nodeType===9?f:f.ownerDocument}var Pl=G.d;G.d={f:nne,r:rne,D:ine,C:sne,L:ane,m:one,X:cne,S:lne,M:une};function nne(){var f=Pl.f(),p=vv();return f||p}function rne(f){var p=ne(f);p!==null&&p.tag===5&&p.type==="form"?dI(p):Pl.r(f)}var Rh=typeof document>"u"?null:document;function K4(f,p,_){var S=Rh;if(S&&typeof p=="string"&&p){var k=kn(p);k='link[rel="'+f+'"][href="'+k+'"]',typeof _=="string"&&(k+='[crossorigin="'+_+'"]'),X4.has(k)||(X4.add(k),f={rel:f,crossOrigin:_,href:p},S.querySelector(k)===null&&(p=S.createElement("link"),zi(p,"link",f),Pe(p),S.head.appendChild(p)))}}function ine(f){Pl.D(f),K4("dns-prefetch",f,null)}function sne(f,p){Pl.C(f,p),K4("preconnect",f,p)}function ane(f,p,_){Pl.L(f,p,_);var S=Rh;if(S&&f&&p){var k='link[rel="preload"][as="'+kn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(k+='[imagesrcset="'+kn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(k+='[imagesizes="'+kn(_.imageSizes)+'"]')):k+='[href="'+kn(f)+'"]';var O=k;switch(p){case"style":O=Ph(f);break;case"script":O=Dh(f)}Na.has(O)||(f=h({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:f,as:p},_),Na.set(O,f),S.querySelector(k)!==null||p==="style"&&S.querySelector(Og(O))||p==="script"&&S.querySelector(Lg(O))||(p=S.createElement("link"),zi(p,"link",f),Pe(p),S.head.appendChild(p)))}}function one(f,p){Pl.m(f,p);var _=Rh;if(_&&f){var S=p&&typeof p.as=="string"?p.as:"script",k='link[rel="modulepreload"][as="'+kn(S)+'"][href="'+kn(f)+'"]',O=k;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Dh(f)}if(!Na.has(O)&&(f=h({rel:"modulepreload",href:f},p),Na.set(O,f),_.querySelector(k)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Lg(O)))return}S=_.createElement("link"),zi(S,"link",f),Pe(S),_.head.appendChild(S)}}}function lne(f,p,_){Pl.S(f,p,_);var S=Rh;if(S&&f){var k=De(S).hoistableStyles,O=Ph(f);p=p||"default";var Y=k.get(O);if(!Y){var oe={loading:0,preload:null};if(Y=S.querySelector(Og(O)))oe.loading=5;else{f=h({rel:"stylesheet",href:f,"data-precedence":p},_),(_=Na.get(O))&&k2(f,_);var we=Y=S.createElement("link");Pe(we),zi(we,"link",f),we._p=new Promise(function(Ve,st){we.onload=Ve,we.onerror=st}),we.addEventListener("load",function(){oe.loading|=1}),we.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,Nv(Y,p,S)}Y={type:"stylesheet",instance:Y,count:1,state:oe},k.set(O,Y)}}}function cne(f,p){Pl.X(f,p);var _=Rh;if(_&&f){var S=De(_).hoistableScripts,k=Dh(f),O=S.get(k);O||(O=_.querySelector(Lg(k)),O||(f=h({src:f,async:!0},p),(p=Na.get(k))&&R2(f,p),O=_.createElement("script"),Pe(O),zi(O,"link",f),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(k,O))}}function une(f,p){Pl.M(f,p);var _=Rh;if(_&&f){var S=De(_).hoistableScripts,k=Dh(f),O=S.get(k);O||(O=_.querySelector(Lg(k)),O||(f=h({src:f,async:!0,type:"module"},p),(p=Na.get(k))&&R2(f,p),O=_.createElement("script"),Pe(O),zi(O,"link",f),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(k,O))}}function Y4(f,p,_,S){var k=(k=re.current)?Cv(k):null;if(!k)throw Error(r(446));switch(f){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Ph(_.href),_=De(k).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"){f=Ph(_.href);var O=De(k).hoistableStyles,Y=O.get(f);if(Y||(k=k.ownerDocument||k,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(f,Y),(O=k.querySelector(Og(f)))&&!O._p&&(Y.instance=O,Y.state.loading=5),Na.has(f)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Na.set(f,_),O||dne(k,f,_,Y.state))),p&&S===null)throw Error(r(528,""));return Y}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=Dh(_),_=De(k).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,f))}}function Ph(f){return'href="'+kn(f)+'"'}function Og(f){return'link[rel="stylesheet"]['+f+"]"}function Z4(f){return h({},f,{"data-precedence":f.precedence,precedence:null})}function dne(f,p,_,S){f.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=f.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),zi(p,"link",_),Pe(p),f.head.appendChild(p))}function Dh(f){return'[src="'+kn(f)+'"]'}function Lg(f){return"script[async]"+f}function Q4(f,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var S=f.querySelector('style[data-href~="'+kn(_.href)+'"]');if(S)return p.instance=S,Pe(S),S;var k=h({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(f.ownerDocument||f).createElement("style"),Pe(S),zi(S,"style",k),Nv(S,_.precedence,f),p.instance=S;case"stylesheet":k=Ph(_.href);var O=f.querySelector(Og(k));if(O)return p.state.loading|=4,p.instance=O,Pe(O),O;S=Z4(_),(k=Na.get(k))&&k2(S,k),O=(f.ownerDocument||f).createElement("link"),Pe(O);var Y=O;return Y._p=new Promise(function(oe,we){Y.onload=oe,Y.onerror=we}),zi(O,"link",S),p.state.loading|=4,Nv(O,_.precedence,f),p.instance=O;case"script":return O=Dh(_.src),(k=f.querySelector(Lg(O)))?(p.instance=k,Pe(k),k):(S=_,(k=Na.get(O))&&(S=h({},_),R2(S,k)),f=f.ownerDocument||f,k=f.createElement("script"),Pe(k),zi(k,"link",S),f.head.appendChild(k),p.instance=k);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,Nv(S,_.precedence,f));return p.instance}function Nv(f,p,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=S.length?S[S.length-1]:null,O=k,Y=0;Y<S.length;Y++){var oe=S[Y];if(oe.dataset.precedence===p)O=oe;else if(O!==k)break}O?O.parentNode.insertBefore(f,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(f,p.firstChild))}function k2(f,p){f.crossOrigin==null&&(f.crossOrigin=p.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=p.referrerPolicy),f.title==null&&(f.title=p.title)}function R2(f,p){f.crossOrigin==null&&(f.crossOrigin=p.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=p.referrerPolicy),f.integrity==null&&(f.integrity=p.integrity)}var kv=null;function J4(f,p,_){if(kv===null){var S=new Map,k=kv=new Map;k.set(_,S)}else k=kv,S=k.get(_),S||(S=new Map,k.set(_,S));if(S.has(f))return S;for(S.set(f,null),_=_.getElementsByTagName(f),k=0;k<_.length;k++){var O=_[k];if(!(O[tt]||O[mr]||f==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var Y=O.getAttribute(p)||"";Y=f+Y;var oe=S.get(Y);oe?oe.push(O):S.set(Y,[O])}}return S}function eU(f,p,_){f=f.ownerDocument||f,f.head.insertBefore(_,p==="title"?f.querySelector("head > title"):null)}function fne(f,p,_){if(_===1||p.itemProp!=null)return!1;switch(f){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 f=p.disabled,typeof p.precedence=="string"&&f==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 tU(f){return!(f.type==="stylesheet"&&(f.state.loading&3)===0)}function hne(f,p,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var k=Ph(S.href),O=p.querySelector(Og(k));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(f.count++,f=Rv.bind(f),p.then(f,f)),_.state.loading|=4,_.instance=O,Pe(O);return}O=p.ownerDocument||p,S=Z4(S),(k=Na.get(k))&&k2(S,k),O=O.createElement("link"),Pe(O);var Y=O;Y._p=new Promise(function(oe,we){Y.onload=oe,Y.onerror=we}),zi(O,"link",S),_.instance=O}f.stylesheets===null&&(f.stylesheets=new Map),f.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(f.count++,_=Rv.bind(f),p.addEventListener("load",_),p.addEventListener("error",_))}}var P2=0;function pne(f,p){return f.stylesheets&&f.count===0&&Dv(f,f.stylesheets),0<f.count||0<f.imgCount?function(_){var S=setTimeout(function(){if(f.stylesheets&&Dv(f,f.stylesheets),f.unsuspend){var O=f.unsuspend;f.unsuspend=null,O()}},6e4+p);0<f.imgBytes&&P2===0&&(P2=62500*Xte());var k=setTimeout(function(){if(f.waitingForImages=!1,f.count===0&&(f.stylesheets&&Dv(f,f.stylesheets),f.unsuspend)){var O=f.unsuspend;f.unsuspend=null,O()}},(f.imgBytes>P2?50:800)+p);return f.unsuspend=_,function(){f.unsuspend=null,clearTimeout(S),clearTimeout(k)}}:null}function Rv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Dv(this,this.stylesheets);else if(this.unsuspend){var f=this.unsuspend;this.unsuspend=null,f()}}}var Pv=null;function Dv(f,p){f.stylesheets=null,f.unsuspend!==null&&(f.count++,Pv=new Map,p.forEach(mne,f),Pv=null,Rv.call(f))}function mne(f,p){if(!(p.state.loading&4)){var _=Pv.get(f);if(_)var S=_.get(null);else{_=new Map,Pv.set(f,_);for(var k=f.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<k.length;O++){var Y=k[O];(Y.nodeName==="LINK"||Y.getAttribute("media")!=="not all")&&(_.set(Y.dataset.precedence,Y),S=Y)}S&&_.set(null,S)}k=p.instance,Y=k.getAttribute("data-precedence"),O=_.get(Y)||S,O===S&&_.set(null,k),_.set(Y,k),this.count++,S=Rv.bind(this),k.addEventListener("load",S),k.addEventListener("error",S),O?O.parentNode.insertBefore(k,O.nextSibling):(f=f.nodeType===9?f.head:f,f.insertBefore(k,f.firstChild)),p.state.loading|=4}}var jg={$$typeof:w,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function gne(f,p,_,S,k,O,Y,oe,we){this.tag=1,this.containerInfo=f,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=k,this.onCaughtError=O,this.onRecoverableError=Y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=we,this.incompleteTransitions=new Map}function nU(f,p,_,S,k,O,Y,oe,we,Ve,st,dt){return f=new gne(f,p,_,Y,we,Ve,st,dt,oe),p=1,O===!0&&(p|=24),O=ea(3,null,null,p),f.current=O,O.stateNode=f,p=dE(),p.refCount++,f.pooledCache=p,p.refCount++,O.memoizedState={element:S,isDehydrated:_,cache:p},mE(O),f}function rU(f){return f?(f=uh,f):uh}function iU(f,p,_,S,k,O){k=rU(k),S.context===null?S.context=k:S.pendingContext=k,S=Vc(p),S.payload={element:_},O=O===void 0?null:O,O!==null&&(S.callback=O),_=Gc(f,S,p),_!==null&&(js(_,f,p),pg(_,f,p))}function sU(f,p){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var _=f.retryLane;f.retryLane=_!==0&&_<p?_:p}}function D2(f,p){sU(f,p),(f=f.alternate)&&sU(f,p)}function aU(f){if(f.tag===13||f.tag===31){var p=_d(f,67108864);p!==null&&js(p,f,67108864),D2(f,67108864)}}function oU(f){if(f.tag===13||f.tag===31){var p=sa();p=ti(p);var _=_d(f,p);_!==null&&js(_,f,p),D2(f,p)}}var Ov=!0;function xne(f,p,_,S){var k=K.T;K.T=null;var O=G.p;try{G.p=2,O2(f,p,_,S)}finally{G.p=O,K.T=k}}function bne(f,p,_,S){var k=K.T;K.T=null;var O=G.p;try{G.p=8,O2(f,p,_,S)}finally{G.p=O,K.T=k}}function O2(f,p,_,S){if(Ov){var k=L2(S);if(k===null)y2(f,p,S,Lv,_),cU(f,S);else if(yne(k,f,p,_,S))S.stopPropagation();else if(cU(f,S),p&4&&-1<vne.indexOf(f)){for(;k!==null;){var O=ne(k);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var Y=Te(O.pendingLanes);if(Y!==0){var oe=O;for(oe.pendingLanes|=2,oe.entangledLanes|=2;Y;){var we=1<<31-He(Y);oe.entanglements[1]|=we,Y&=~we}zo(O),(Cn&6)===0&&(xv=L()+500,kg(0))}}break;case 31:case 13:oe=_d(O,2),oe!==null&&js(oe,O,2),vv(),D2(O,2)}if(O=L2(S),O===null&&y2(f,p,S,Lv,_),O===k)break;k=O}k!==null&&S.stopPropagation()}else y2(f,p,S,null,_)}}function L2(f){return f=IM(f),j2(f)}var Lv=null;function j2(f){if(Lv=null,f=_t(f),f!==null){var p=s(f);if(p===null)f=null;else{var _=p.tag;if(_===13){if(f=a(p),f!==null)return f;f=null}else if(_===31){if(f=o(p),f!==null)return f;f=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;f=null}else p!==f&&(f=null)}}return Lv=f,null}function lU(f){switch(f){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(X()){case me:return 2;case ve:return 8;case ge:case Ke:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var I2=!1,nu=null,ru=null,iu=null,Ig=new Map,Ug=new Map,su=[],vne="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 cU(f,p){switch(f){case"focusin":case"focusout":nu=null;break;case"dragenter":case"dragleave":ru=null;break;case"mouseover":case"mouseout":iu=null;break;case"pointerover":case"pointerout":Ig.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ug.delete(p.pointerId)}}function Fg(f,p,_,S,k,O){return f===null||f.nativeEvent!==O?(f={blockedOn:p,domEventName:_,eventSystemFlags:S,nativeEvent:O,targetContainers:[k]},p!==null&&(p=ne(p),p!==null&&aU(p)),f):(f.eventSystemFlags|=S,p=f.targetContainers,k!==null&&p.indexOf(k)===-1&&p.push(k),f)}function yne(f,p,_,S,k){switch(p){case"focusin":return nu=Fg(nu,f,p,_,S,k),!0;case"dragenter":return ru=Fg(ru,f,p,_,S,k),!0;case"mouseover":return iu=Fg(iu,f,p,_,S,k),!0;case"pointerover":var O=k.pointerId;return Ig.set(O,Fg(Ig.get(O)||null,f,p,_,S,k)),!0;case"gotpointercapture":return O=k.pointerId,Ug.set(O,Fg(Ug.get(O)||null,f,p,_,S,k)),!0}return!1}function uU(f){var p=_t(f.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){f.blockedOn=p,Qi(f.priority,function(){oU(_)});return}}else if(p===31){if(p=o(_),p!==null){f.blockedOn=p,Qi(f.priority,function(){oU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){f.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}f.blockedOn=null}function jv(f){if(f.blockedOn!==null)return!1;for(var p=f.targetContainers;0<p.length;){var _=L2(f.nativeEvent);if(_===null){_=f.nativeEvent;var S=new _.constructor(_.type,_);jM=S,_.target.dispatchEvent(S),jM=null}else return p=ne(_),p!==null&&aU(p),f.blockedOn=_,!1;p.shift()}return!0}function dU(f,p,_){jv(f)&&_.delete(p)}function _ne(){I2=!1,nu!==null&&jv(nu)&&(nu=null),ru!==null&&jv(ru)&&(ru=null),iu!==null&&jv(iu)&&(iu=null),Ig.forEach(dU),Ug.forEach(dU)}function Iv(f,p){f.blockedOn===p&&(f.blockedOn=null,I2||(I2=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,_ne)))}var Uv=null;function fU(f){Uv!==f&&(Uv=f,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Uv===f&&(Uv=null);for(var p=0;p<f.length;p+=3){var _=f[p],S=f[p+1],k=f[p+2];if(typeof S!="function"){if(j2(S||_)===null)continue;break}var O=ne(_);O!==null&&(f.splice(p,3),p-=3,LE(O,{pending:!0,data:k,method:_.method,action:S},S,k))}}))}function Oh(f){function p(we){return Iv(we,f)}nu!==null&&Iv(nu,f),ru!==null&&Iv(ru,f),iu!==null&&Iv(iu,f),Ig.forEach(p),Ug.forEach(p);for(var _=0;_<su.length;_++){var S=su[_];S.blockedOn===f&&(S.blockedOn=null)}for(;0<su.length&&(_=su[0],_.blockedOn===null);)uU(_),_.blockedOn===null&&su.shift();if(_=(f.ownerDocument||f).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var k=_[S],O=_[S+1],Y=k[Nr]||null;if(typeof O=="function")Y||fU(_);else if(Y){var oe=null;if(O&&O.hasAttribute("formAction")){if(k=O,Y=O[Nr]||null)oe=Y.formAction;else if(j2(k)!==null)continue}else oe=Y.action;typeof oe=="function"?_[S+1]=oe:(_.splice(S,3),S-=3),fU(_)}}}function hU(){function f(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(Y){return k=Y})},focusReset:"manual",scroll:"manual"})}function p(){k!==null&&(k(),k=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,k=null;return navigation.addEventListener("navigate",f),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",f),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),k!==null&&(k(),k=null)}}}function U2(f){this._internalRoot=f}Fv.prototype.render=U2.prototype.render=function(f){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,S=sa();iU(_,S,f,p,null,null)},Fv.prototype.unmount=U2.prototype.unmount=function(){var f=this._internalRoot;if(f!==null){this._internalRoot=null;var p=f.containerInfo;iU(f.current,2,null,f,null,null),vv(),p[so]=null}};function Fv(f){this._internalRoot=f}Fv.prototype.unstable_scheduleHydration=function(f){if(f){var p=Li();f={blockedOn:null,target:f,priority:p};for(var _=0;_<su.length&&p!==0&&p<su[_].priority;_++);su.splice(_,0,f),_===0&&uU(f)}};var pU=e.version;if(pU!=="19.2.0")throw Error(r(527,pU,"19.2.0"));G.findDOMNode=function(f){var p=f._reactInternals;if(p===void 0)throw typeof f.render=="function"?Error(r(188)):(f=Object.keys(f).join(","),Error(r(268,f)));return f=c(p),f=f!==null?d(f):null,f=f===null?null:f.stateNode,f};var Sne={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zv.isDisabled&&zv.supportsFiber)try{Fe=zv.inject(Sne),ce=zv}catch{}}return Bg.createRoot=function(f,p){if(!i(f))throw Error(r(299));var _=!1,S="",k=_I,O=SI,Y=wI;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(k=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(Y=p.onRecoverableError)),p=nU(f,1,!1,null,null,_,S,null,k,O,Y,hU),f[so]=p.current,v2(f),new U2(p)},Bg.hydrateRoot=function(f,p,_){if(!i(f))throw Error(r(299));var S=!1,k="",O=_I,Y=SI,oe=wI,we=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(k=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(Y=_.onCaughtError),_.onRecoverableError!==void 0&&(oe=_.onRecoverableError),_.formState!==void 0&&(we=_.formState)),p=nU(f,1,!0,p,_??null,S,k,we,O,Y,oe,hU),p.context=rU(null),_=p.current,S=sa(),S=ti(S),k=Vc(S),k.callback=null,Gc(_,k,S),_=S,p.current.lanes=_,cn(p,_),zo(p),f[so]=p.current,v2(f),new Fv(p)},Bg.version="19.2.0",Bg}var MU;function Dne(){if(MU)return B2.exports;MU=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(),B2.exports=Pne(),B2.exports}var One=Dne();const Gt=t=>typeof t=="string",Hg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},EU=t=>t==null?"":""+t,Lne=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},jne=/###/g,AU=t=>t&&t.indexOf("###")>-1?t.replace(jne,"."):t,TU=t=>!t||Gt(t),Ax=(t,e,n)=>{const r=Gt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(TU(t))return{};const s=AU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return TU(t)?{}:{obj:t,k:AU(r[i])}},CU=(t,e,n)=>{const{obj:r,k:i}=Ax(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),o=Ax(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=Ax(t,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=n},Ine=(t,e,n,r)=>{const{obj:i,k:s}=Ax(t,e,Object);i[s]=i[s]||[],i[s].push(n)},q_=(t,e)=>{const{obj:n,k:r}=Ax(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Une=(t,e,n)=>{const r=q_(t,n);return r!==void 0?r:q_(e,n)},PG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Gt(t[r])||t[r]instanceof String||Gt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):PG(t[r],e[r],n):t[r]=e[r]);return t},Lh=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Fne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const zne=t=>Gt(t)?t.replace(/[&<>"'\/]/g,e=>Fne[e]):t;class Bne{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 Hne=[" ",",","?","!",";"],$ne=new Bne(20),Vne=(t,e,n)=>{e=e||"",n=n||"";const r=Hne.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=$ne.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},LN=(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 s=0;s<r.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=s;l<r.length;++l)if(l!==s&&(o+=n),o+=r[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},Zx=t=>t?.replace("_","-"),Gne={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 X_{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Gne,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:(Gt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new X_(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new X_(this.logger,e)}}var Zo=new X_;let iw=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,s])=>{for(let a=0;a<s;a++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i.apply(i,[e,...n])})}};class NU extends iw{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 s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=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):Gt(r)&&s?o.push(...r.split(s)):o.push(r)));const l=q_(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!a||!Gt(r)?l:LN(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),CU(this.data,o,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(Gt(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,a={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=q_(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?PG(l,r,s):l={...l,...r},CU(this.data,o,l),a.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 DG={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const OG=Symbol("i18next/PATH_KEY");function Wne(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===OG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function jN(t,e){const{[OG]:n}=t(Wne());return n.join(e?.keySeparator??".")}const kU={},G2=t=>!Gt(t)&&typeof t!="boolean"&&typeof t!="number";class K_ extends iw{constructor(e,n={}){super(),Lne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Zo.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 s=G2(i.res);return!(r.returnObjects===!1&&s)}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 s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Vne(e,r,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Gt(s)?[s]:s};const c=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),e=c.join(i)}return{key:e,namespaces:Gt(s)?[s]:s}}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=jN(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=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 d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const h=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return g?s?{res:`${c}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${d}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let v=m?.res;const y=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&&!Gt(i.count),T=K_.hasDefaultValue(i),R=A?this.pluralResolver.getSuffix(h,i.count,i):"",C=i.ordinal&&A?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",I=A&&!i.ordinal&&i.count===0,N=I&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${R}`]||i[`defaultValue${C}`]||i.defaultValue;let D=v;w&&!v&&T&&(D=N);const z=G2(D),j=Object.prototype.toString.apply(D);if(w&&D&&z&&x.indexOf(j)<0&&!(Gt(M)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=W,m.usedParams=this.getUsedParamsDetails(i),m):W}if(a){const W=Array.isArray(D),P=W?[]:{},$=W?b:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const G=`${$}${a}${K}`;T&&!v?P[K]=this.translate(G,{...i,defaultValue:G2(N)?N[K]:void 0,joinArrays:!1,ns:l}):P[K]=this.translate(G,{...i,joinArrays:!1,ns:l}),P[K]===G&&(P[K]=D[K])}v=P}}else if(w&&Gt(M)&&Array.isArray(v))v=v.join(M),v&&(v=this.extendTranslation(v,e,i,r));else{let W=!1,P=!1;!this.isValidLookup(v)&&T&&(W=!0,v=N),this.isValidLookup(v)||(P=!0,v=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:v,G=T&&N!==v&&this.options.updateMissing;if(P||W||G){if(this.logger.log(G?"updateKey":"missingKey",h,c,o,G?N:v),a){const H=this.resolve(o,{...i,keySeparator:!1});H&&H.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 Z=[];const Q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Q&&Q[0])for(let H=0;H<Q.length;H++)Z.push(Q[H]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ee=(H,q,te)=>{const ae=T&&te!==v?te:K;this.options.missingKeyHandler?this.options.missingKeyHandler(H,c,q,ae,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,c,q,ae,G,i),this.emit("missingKey",H,c,q,v)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Z.forEach(H=>{const q=this.pluralResolver.getSuffixes(H,i);I&&i[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(te=>{ee([H],o+te,i[`defaultValue${te}`]||N)})}):ee(Z,o,N))}v=this.extendTranslation(v,e,i,m,r),P&&v===o&&this.options.appendNamespaceToMissingKey&&(v=`${c}${d}${o}`),(P||W)&&this.options.parseMissingKeyHandler&&(v=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${d}${o}`:o,W?v:void 0,i))}return s?(m.res=v,m.usedParams=this.getUsedParamsDetails(i),m):v}extendTranslation(e,n,r,i,s){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=Gt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const h=e.match(this.interpolator.nestingRegexp);c=h&&h.length}let d=r.replace&&!Gt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),l){const h=e.match(this.interpolator.nestingRegexp),g=h&&h.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,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,o=Gt(a)?[a]:a;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=DG.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,s,a,o;return Gt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(l,n),d=c.key;i=d;let h=c.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Gt(n.count),m=g&&!n.ordinal&&n.count===0,v=n.context!==void 0&&(Gt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(b=>{this.isValidLookup(r)||(o=b,!kU[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(kU[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(x=>{if(this.isValidLookup(r))return;a=x;const M=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,d,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(d+A.replace(R,this.options.pluralSeparator)),M.push(d+A),m&&M.push(d+T)),v){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;M.push(C),g&&(n.ordinal&&A.indexOf(R)===0&&M.push(C+A.replace(R,this.options.pluralSeparator)),M.push(C+A),m&&M.push(C+T))}}let w;for(;w=M.pop();)this.isValidLookup(r)||(s=w,r=this.getResource(x,b,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,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&&!Gt(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 s of n)delete i[s]}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 RU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Zo.create("languageUtils")}getScriptPartFromCode(e){if(e=Zx(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=Zx(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Gt(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 s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Gt(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=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return Gt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):Gt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const PU={zero:0,one:1,two:2,few:3,many:4,other:5},DU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class qne{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Zo.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=Zx(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),DU;if(!e.match(/-|_/))return DU;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}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,s)=>PU[i]-PU[s]).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 OU=(t,e,n,r=".",i=!0)=>{let s=Une(t,e,n);return!s&&i&&Gt(n)&&(s=LN(t,n,r),s===void 0&&(s=LN(e,n,r))),s},W2=t=>t.replace(/\$/g,"$$$$");class Xne{constructor(e={}){this.logger=Zo.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:s,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:v,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:zne,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Lh(s):a||"{{",this.suffix=o?Lh(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Lh(g):m||Lh("$t("),this.nestingSuffix=v?Lh(v):y||Lh(")"),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 s,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=m=>{if(m.indexOf(this.formatSeparator)<0){const x=OU(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:m}):x}const v=m.split(this.formatSeparator),y=v.shift().trim(),b=v.join(this.formatSeparator).trim();return this.format(OU(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>W2(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?W2(this.escape(m)):W2(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const v=s[1].trim();if(a=c(v),a===void 0)if(typeof d=="function"){const b=d(e,s,i);a=Gt(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,v))a="";else if(h){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${v} for interpolating ${e}`),a="";else!Gt(a)&&!this.useRawValueToEscape&&(a=EU(a));const y=m.safeValue(a);if(e=e.replace(s[0],y),h?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,a;const o=(l,c)=>{const d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;const h=l.split(new RegExp(`${d}[ ]*{`));let g=`{${h[1]}`;l=h[0],g=this.interpolate(g,a);const m=g.match(/'/g),v=g.match(/"/g);((m?.length??0)%2===0&&!v||v.length%2!==0)&&(g=g.replace(/'/g,'"'));try{a=JSON.parse(g),c&&(a={...c,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${d}${g}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!Gt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.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(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),s=n(o.call(this,i[1].trim(),a),a),s&&i[0]===e&&!Gt(s))return s;Gt(s)||(s=EU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l.length&&(s=l.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Kne=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(a=>{if(a){const[o,...l]=a.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=c),c==="false"&&(n[d]=!1),c==="true"&&(n[d]=!0),isNaN(c)||(n[d]=parseInt(c,10))}})}return{formatName:e,formatOptions:n}},LU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let o=e[a];return o||(o=t(Zx(r),i),e[a]=o),o(n)}},Yne=t=>(e,n,r)=>t(Zx(n),r)(e);class Zne{constructor(e={}){this.logger=Zo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?LU:Yne;this.formats={number:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s});return o=>a.format(o)}),currency:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s,style:"currency"});return o=>a.format(o)}),datetime:r((i,s)=>{const a=new Intl.DateTimeFormat(i,{...s});return o=>a.format(o)}),relativetime:r((i,s)=>{const a=new Intl.RelativeTimeFormat(i,{...s});return o=>a.format(o,s.range||"day")}),list:r((i,s)=>{const a=new Intl.ListFormat(i,{...s});return o=>a.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=LU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(o=>o.indexOf(")")>-1)){const o=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,l)=>{const{formatName:c,formatOptions:d}=Kne(l);if(this.formats[c]){let h=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;h=this.formats[c](o,m,{...d,...i,...g})}catch(g){this.logger.warn(g)}return h}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const Qne=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Jne extends iw{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Zo.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 s={},a={},o={},l={};return e.forEach(c=>{let d=!0;n.forEach(h=>{const g=`${c}|${h}`;!r.reload&&this.store.hasResourceBundle(c,h)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?a[g]===void 0&&(a[g]=!0):(this.state[g]=1,d=!1,a[g]===void 0&&(a[g]=!0),s[g]===void 0&&(s[g]=!0),l[h]===void 0&&(l[h]=!0)))}),d||(o[c]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,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=>{Ine(l.loaded,[s],a),Qne(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const d=l.loaded[c];d.length&&d.forEach(h=>{o[c][h]===void 0&&(o[c][h]=!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,s=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const o=(c,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(c&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(c,d)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const c=l(e,n);c&&typeof c.then=="function"?c.then(d=>o(null,d)).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();Gt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Gt(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}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],s=r[1];this.read(i,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&o&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,n,r,i,s,a={},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={...a,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let d;c.length===5?d=c(e,n,r,i,l):d=c(e,n,r,i),d&&typeof d.then=="function"?d.then(h=>o(null,h)).catch(o):o(null,d)}catch(d){o(d)}else c(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const jU=()=>({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]),Gt(t[1])&&(e.defaultValue=t[1]),Gt(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}),IU=t=>(Gt(t.ns)&&(t.ns=[t.ns]),Gt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Gt(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),Hv=()=>{},ere=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Tx extends iw{constructor(e={},n){if(super(),this.options=IU(e),this.services={},this.logger=Zo,this.modules={external:[]},ere(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&&(Gt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=jU();this.options={...r,...this.options,...IU(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?Zo.init(i(this.modules.logger),this.options):Zo.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=Zne;const d=new RU(this.options);this.store=new NU(this.options.resources,this.options);const h=this.services;h.logger=Zo,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new qne(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(h.formatter=i(c),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Xne(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Jne(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...v)=>{this.emit(m,...v)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new K_(this.services,this.options),this.translator.on("*",(m,...v)=>{this.emit(m,...v)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Hv),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]=(...d)=>this.store[c](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...d)=>(this.store[c](...d),this)});const o=Hg(),l=()=>{const c=(d,h)=>{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(h),n(d,h)};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=Hv){let r=n;const i=Gt(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 s=[],a=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>a(l)),this.options.preload?.forEach?.(o=>a(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=Hg();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=Hv),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),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"&&DG.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=Hg();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},s=(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))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Gt(o)?o:o&&o[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Gt(o)?[o]:o);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,d=>{s(d,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),r}getFixedT(e,n,r){const i=(s,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([s,a].concat(o)):l={...a},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 d;return l.keyPrefix&&Array.isArray(s)?d=s.map(h=>(typeof h=="function"&&(h=jN(h,{...this.options,...a})),`${l.keyPrefix}${c}${h}`)):(typeof s=="function"&&(s=jN(s,{...this.options,...a})),d=l.keyPrefix?`${l.keyPrefix}${c}${s}`:s),this.t(d,l)};return Gt(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,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(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,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Hg();return this.options.ns?(Gt(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=Hg();Gt(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),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 s=i.getTextInfo();if(s&&s.direction)return s.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 RU(jU());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 Tx(e,n);return r.createInstance=Tx.createInstance,r}cloneInstance(e={},n=Hv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Tx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(o=>{s[o]=this[o]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const o=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((d,h)=>(d[h]={...l[c][h]},d),l[c]),l),{});s.store=new NU(o,i),s.services.resourceStore=s.store}return s.translator=new K_(s.services,i),s.translator.on("*",(o,...l)=>{s.emit(o,...l)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ks=Tx.createInstance();ks.createInstance;ks.dir;ks.init;ks.loadResources;ks.reloadResources;ks.use;ks.changeLanguage;ks.getFixedT;ks.t;ks.exists;ks.setDefaultNamespace;ks.hasLoadedNamespace;ks.loadNamespaces;ks.loadLanguages;const tre=(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);Af(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},UU={},LG=(t,e,n,r)=>{Af(n)&&UU[n]||(Af(n)&&(UU[n]=new Date),tre(t,e,n,r))},jG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},IN=(t,e,n)=>{t.loadNamespaces(e,jG(t,n))},FU=(t,e,n,r)=>{if(Af(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return IN(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,jG(t,r))},nre=(t,e,n={})=>!e.languages||!e.languages.length?(LG(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}}),Af=t=>typeof t=="string",rre=t=>typeof t=="object"&&t!==null,ire=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,sre={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},are=t=>sre[t],ore=t=>t.replace(ire,are);let UN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ore};const lre=(t={})=>{UN={...UN,...t}},cre=()=>UN;let IG;const ure=t=>{IG=t},dre=()=>IG,fre={type:"3rdParty",init(t){lre(t.options.react),ure(t)}},hre=E.createContext();class pre{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var q2={exports:{}},X2={};var zU;function mre(){if(zU)return X2;zU=1;var t=Tm();function e(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,a=t.useDebugValue;function o(h,g){var m=g(),v=r({inst:{value:m,getSnapshot:g}}),y=v[0].inst,b=v[1];return s(function(){y.value=m,y.getSnapshot=g,l(y)&&b({inst:y})},[h,m,g]),i(function(){return l(y)&&b({inst:y}),h(function(){l(y)&&b({inst:y})})},[h]),a(m),m}function l(h){var g=h.getSnapshot;h=h.value;try{var m=g();return!n(h,m)}catch{return!0}}function c(h,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return X2.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,X2}var BU;function UG(){return BU||(BU=1,q2.exports=mre()),q2.exports}var $R=UG();const gre=(t,e)=>Af(e)?e:rre(e)&&Af(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,xre={t:gre,ready:!1},bre=()=>()=>{},sw=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(hre)||{},s=n||r||dre();s&&!s.reportNamespaces&&(s.reportNamespaces=new pre),s||LG(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const a=E.useMemo(()=>({...cre(),...s?.options?.react,...e}),[s,e]),{useSuspense:o,keyPrefix:l}=a,c=i||s?.options?.defaultNS,d=Af(c)?[c]:c||["translation"],h=E.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(h);const g=E.useRef(0),m=E.useCallback(N=>{if(!s)return bre;const{bindI18n:D,bindI18nStore:z}=a,j=()=>{g.current+=1,N()};return D&&s.on(D,j),z&&s.store.on(z,j),()=>{D&&D.split(" ").forEach(W=>s.off(W,j)),z&&z.split(" ").forEach(W=>s.store.off(W,j))}},[s,a]),v=E.useRef(),y=E.useCallback(()=>{if(!s)return xre;const N=!!(s.isInitialized||s.initializedStoreOnce)&&h.every($=>nre($,s,a)),D=e.lng||s.language,z=g.current,j=v.current;if(j&&j.ready===N&&j.lng===D&&j.keyPrefix===l&&j.revision===z)return j;const P={t:s.getFixedT(D,a.nsMode==="fallback"?h:h[0],l),ready:N,lng:D,keyPrefix:l,revision:z};return v.current=P,P},[s,h,l,a,e.lng]),[b,x]=E.useState(0),{t:M,ready:w}=$R.useSyncExternalStore(m,y,y);E.useEffect(()=>{if(s&&!w&&!o){const N=()=>x(D=>D+1);e.lng?FU(s,e.lng,h,N):IN(s,h,N)}},[s,e.lng,h,w,o,b]);const A=s||{},T=E.useRef(null),R=E.useRef(),C=N=>{const D=Object.getOwnPropertyDescriptors(N);D.__original&&delete D.__original;const z=Object.create(Object.getPrototypeOf(N),D);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},I=E.useMemo(()=>{const N=A,D=N?.language;let z=N;N&&(T.current&&T.current.__original===N?R.current!==D?(z=C(N),T.current=z,R.current=D):z=T.current:(z=C(N),T.current=z,R.current=D));const j=[M,z,w];return j.t=M,j.i18n=z,j.ready=w,j},[M,A,w,A.resolvedLanguage,A.language,A.languages]);if(s&&o&&!w)throw new Promise(N=>{const D=()=>N();e.lng?FU(s,e.lng,h,D):IN(s,h,D)});return I},{slice:vre,forEach:yre}=[];function _re(t){return yre.call(vre.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Sre(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 HU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,wre=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(a)}`}if(r.domain){if(!HU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!HU.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},$U={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=wre(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 Mre={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return $U.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&$U.create(n,t,r,i,s)}},Ere={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 s=r.substring(1).split("&");for(let a=0;a<s.length;a++){const o=s[a].indexOf("=");o>0&&s[a].substring(0,o)===e&&(n=s[a].substring(o+1))}}return n}},Are={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 s=i.substring(1);if(e){const a=s.split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(r=a[o].substring(l+1))}}if(r)return r;if(!r&&n>-1){const a=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?a[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let jh=null;const VU=()=>{if(jh!==null)return jh;try{if(jh=typeof window<"u"&&window.localStorage!==null,!jh)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{jh=!1}return jh};var Tre={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&VU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&VU()&&window.localStorage.setItem(n,t)}};let Ih=null;const GU=()=>{if(Ih!==null)return Ih;try{if(Ih=typeof window<"u"&&window.sessionStorage!==null,!Ih)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ih=!1}return Ih};var Cre={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&GU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&GU()&&window.sessionStorage.setItem(n,t)}},Nre={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},kre={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}},Rre={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}},Pre={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 FG=!1;try{document.cookie,FG=!0}catch{}const zG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];FG||zG.splice(1,1);const Dre=()=>({order:zG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class BG{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=_re(n,this.options||{},Dre()),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(Mre),this.addDetector(Ere),this.addDetector(Tre),this.addDetector(Cre),this.addDetector(Nre),this.addDetector(kre),this.addDetector(Rre),this.addDetector(Pre),this.addDetector(Are)}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&&!Sre(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)}))}}BG.type="languageDetector";const Ore={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",settings:"Settings",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Lre={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",settings:"Einstellungen",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},jre={en:{translation:Ore},de:{translation:Lre}};ks.use(BG).use(fre).init({resources:jre,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const WU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var qU="popstate";function Ire(t={}){function e(r,i){let{pathname:s,search:a,hash:o}=r.location;return FN("",{pathname:s,search:a,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Qx(i)}return Fre(e,n,null,t)}function br(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Co(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Ure(){return Math.random().toString(36).substring(2,10)}function XU(t,e){return{usr:t.state,key:t.key,idx:e}}function FN(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Cm(e):e,state:n,key:e&&e.key||r||Ure()}}function Qx({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 Cm(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 Fre(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,o="POP",l=null,c=d();c==null&&(c=0,a.replaceState({...a.state,idx:c},""));function d(){return(a.state||{idx:null}).idx}function h(){o="POP";let b=d(),x=b==null?null:b-c;c=b,l&&l({action:o,location:y.location,delta:x})}function g(b,x){o="PUSH";let M=FN(y.location,b,x);c=d()+1;let w=XU(M,c),A=y.createHref(M);try{a.pushState(w,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}s&&l&&l({action:o,location:y.location,delta:1})}function m(b,x){o="REPLACE";let M=FN(y.location,b,x);c=d();let w=XU(M,c),A=y.createHref(M);a.replaceState(w,"",A),s&&l&&l({action:o,location:y.location,delta:0})}function v(b){return zre(b)}let y={get action(){return o},get location(){return t(i,a)},listen(b){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(qU,h),l=b,()=>{i.removeEventListener(qU,h),l=null}},createHref(b){return e(i,b)},createURL:v,encodeLocation(b){let x=v(b);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:g,replace:m,go(b){return a.go(b)}};return y}function zre(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),br(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Qx(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function HG(t,e,n="/"){return Bre(t,e,n,!1)}function Bre(t,e,n,r){let i=typeof e=="string"?Cm(e):e,s=bc(i.pathname||"/",n);if(s==null)return null;let a=$G(t);Hre(a);let o=null;for(let l=0;o==null&&l<a.length;++l){let c=Jre(s);o=Zre(a[l],c,r)}return o}function $G(t,e=[],n=[],r="",i=!1){let s=(a,o,l=i,c)=>{let d={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&l)return;br(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let h=uc([r,d.relativePath]),g=n.concat(d);a.children&&a.children.length>0&&(br(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),$G(a.children,e,g,h,l)),!(a.path==null&&!a.index)&&e.push({path:h,score:Kre(h,a.index),routesMeta:g})};return t.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))s(a,o);else for(let l of VG(a.path))s(a,o,!0,l)}),e}function VG(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=VG(r.join("/")),o=[];return o.push(...a.map(l=>l===""?s:[s,l].join("/"))),i&&o.push(...a),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function Hre(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Yre(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var $re=/^:[\w-]+$/,Vre=3,Gre=2,Wre=1,qre=10,Xre=-2,KU=t=>t==="*";function Kre(t,e){let n=t.split("/"),r=n.length;return n.some(KU)&&(r+=Xre),e&&(r+=Gre),n.filter(i=>!KU(i)).reduce((i,s)=>i+($re.test(s)?Vre:s===""?Wre:qre),r)}function Yre(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 Zre(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let o=0;o<r.length;++o){let l=r[o],c=o===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",h=Y_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},d),g=l.route;if(!h&&c&&n&&!r[r.length-1].route.index&&(h=Y_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!h)return null;Object.assign(i,h.params),a.push({params:i,pathname:uc([s,h.pathname]),pathnameBase:iie(uc([s,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(s=uc([s,h.pathnameBase]))}return a}function Y_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Qre(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((c,{paramName:d,isOptional:h},g)=>{if(d==="*"){let v=o[g]||"";a=s.slice(0,s.length-v.length).replace(/(.)\/+$/,"$1")}const m=o[g];return h&&!m?c[d]=void 0:c[d]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:s,pathnameBase:a,pattern:t}}function Qre(t,e=!1,n=!0){Co(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,(a,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 Jre(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Co(!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 bc(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 eie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tie=t=>eie.test(t);function nie(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Cm(t):t,s;if(n)if(tie(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Co(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=YU(n.substring(1),"/"):s=YU(n,e)}else s=e;return{pathname:s,search:sie(r),hash:aie(i)}}function YU(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 K2(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 rie(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function GG(t){let e=rie(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function WG(t,e,n,r=!1){let i;typeof t=="string"?i=Cm(t):(i={...t},br(!i.pathname||!i.pathname.includes("?"),K2("?","pathname","search",i)),br(!i.pathname||!i.pathname.includes("#"),K2("#","pathname","hash",i)),br(!i.search||!i.search.includes("#"),K2("#","search","hash",i)));let s=t===""||i.pathname==="",a=s?"/":i.pathname,o;if(a==null)o=n;else{let h=e.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),h-=1;i.pathname=g.join("/")}o=h>=0?e[h]:"/"}let l=nie(i,o),c=a&&a!=="/"&&a.endsWith("/"),d=(s||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||d)&&(l.pathname+="/"),l}var uc=t=>t.join("/").replace(/\/\/+/g,"/"),iie=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),sie=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,aie=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function oie(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 qG=["POST","PUT","PATCH","DELETE"];new Set(qG);var lie=["GET",...qG];new Set(lie);var Nm=E.createContext(null);Nm.displayName="DataRouter";var aw=E.createContext(null);aw.displayName="DataRouterState";E.createContext(!1);var XG=E.createContext({isTransitioning:!1});XG.displayName="ViewTransition";var cie=E.createContext(new Map);cie.displayName="Fetchers";var uie=E.createContext(null);uie.displayName="Await";var hl=E.createContext(null);hl.displayName="Navigation";var G0=E.createContext(null);G0.displayName="Location";var Do=E.createContext({outlet:null,matches:[],isDataRoute:!1});Do.displayName="Route";var VR=E.createContext(null);VR.displayName="RouteError";function die(t,{relative:e}={}){br(W0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(hl),{hash:i,pathname:s,search:a}=q0(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:uc([n,s])),r.createHref({pathname:o,search:a,hash:i})}function W0(){return E.useContext(G0)!=null}function cd(){return br(W0(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(G0).location}var KG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function YG(t){E.useContext(hl).static||E.useLayoutEffect(t)}function GR(){let{isDataRoute:t}=E.useContext(Do);return t?Tie():fie()}function fie(){br(W0(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(Nm),{basename:e,navigator:n}=E.useContext(hl),{matches:r}=E.useContext(Do),{pathname:i}=cd(),s=JSON.stringify(GG(r)),a=E.useRef(!1);return YG(()=>{a.current=!0}),E.useCallback((l,c={})=>{if(Co(a.current,KG),!a.current)return;if(typeof l=="number"){n.go(l);return}let d=WG(l,JSON.parse(s),i,c.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:uc([e,d.pathname])),(c.replace?n.replace:n.push)(d,c.state,c)},[e,n,s,i,t])}var hie=E.createContext(null);function pie(t){let e=E.useContext(Do).outlet;return E.useMemo(()=>e&&E.createElement(hie.Provider,{value:t},e),[e,t])}function mie(){let{matches:t}=E.useContext(Do),e=t[t.length-1];return e?e.params:{}}function q0(t,{relative:e}={}){let{matches:n}=E.useContext(Do),{pathname:r}=cd(),i=JSON.stringify(GG(n));return E.useMemo(()=>WG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function gie(t,e){return ZG(t,e)}function ZG(t,e,n,r,i){br(W0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=E.useContext(hl),{matches:a}=E.useContext(Do),o=a[a.length-1],l=o?o.params:{},c=o?o.pathname:"/",d=o?o.pathnameBase:"/",h=o&&o.route;{let M=h&&h.path||"";QG(c,!h||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=cd(),m;if(e){let M=typeof e=="string"?Cm(e):e;br(d==="/"||M.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=g;let v=m.pathname||"/",y=v;if(d!=="/"){let M=d.replace(/^\//,"").split("/");y="/"+v.replace(/^\//,"").split("/").slice(M.length).join("/")}let b=HG(t,{pathname:y});Co(h||b!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Co(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=_ie(b&&b.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:uc([d,s.encodeLocation?s.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:uc([d,s.encodeLocation?s.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),a,n,r,i);return e&&x?E.createElement(G0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function xie(){let t=Aie(),e=oie(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},s={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",t),a=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:s},"ErrorBoundary")," or"," ",E.createElement("code",{style:s},"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,a)}var bie=E.createElement(xie,null),vie=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(Do.Provider,{value:this.props.routeContext},E.createElement(VR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function yie({routeContext:t,match:e,children:n}){let r=E.useContext(Nm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(Do.Provider,{value:t},n)}function _ie(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 s=t,a=n?.errors;if(a!=null){let d=s.findIndex(h=>h.route.id&&a?.[h.route.id]!==void 0);br(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let o=!1,l=-1;if(n)for(let d=0;d<s.length;d++){let h=s[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=d),h.route.id){let{loaderData:g,errors:m}=n,v=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||v){o=!0,l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}let c=n&&r?(d,h)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:h})}:void 0;return s.reduceRight((d,h,g)=>{let m,v=!1,y=null,b=null;n&&(m=a&&h.route.id?a[h.route.id]:void 0,y=h.route.errorElement||bie,o&&(l<0&&g===0?(QG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,b=null):l===g&&(v=!0,b=h.route.hydrateFallbackElement||null)));let x=e.concat(s.slice(0,g+1)),M=()=>{let w;return m?w=y:v?w=b:h.route.Component?w=E.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=d,E.createElement(yie,{match:h,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?E.createElement(vie,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function WR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sie(t){let e=E.useContext(Nm);return br(e,WR(t)),e}function wie(t){let e=E.useContext(aw);return br(e,WR(t)),e}function Mie(t){let e=E.useContext(Do);return br(e,WR(t)),e}function qR(t){let e=Mie(t),n=e.matches[e.matches.length-1];return br(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Eie(){return qR("useRouteId")}function Aie(){let t=E.useContext(VR),e=wie("useRouteError"),n=qR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Tie(){let{router:t}=Sie("useNavigate"),e=qR("useNavigate"),n=E.useRef(!1);return YG(()=>{n.current=!0}),E.useCallback(async(i,s={})=>{Co(n.current,KG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var ZU={};function QG(t,e,n){!e&&!ZU[t]&&(ZU[t]=!0,Co(!1,n))}E.memo(Cie);function Cie({routes:t,future:e,state:n,unstable_onError:r}){return ZG(t,void 0,n,r,e)}function Nie(t){return pie(t.context)}function Vo(t){br(!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 kie({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1}){br(!W0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:a,navigator:i,static:s,future:{}}),[a,i,s]);typeof n=="string"&&(n=Cm(n));let{pathname:l="/",search:c="",hash:d="",state:h=null,key:g="default"}=n,m=E.useMemo(()=>{let v=bc(l,a);return v==null?null:{location:{pathname:v,search:c,hash:d,state:h,key:g},navigationType:r}},[a,l,c,d,h,g,r]);return Co(m!=null,`<Router basename="${a}"> is not able to match the URL "${l}${c}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:E.createElement(hl.Provider,{value:o},E.createElement(G0.Provider,{children:e,value:m}))}function Rie({children:t,location:e}){return gie(zN(t),e)}function zN(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let s=[...e,i];if(r.type===E.Fragment){n.push.apply(n,zN(r.props.children,s));return}br(r.type===Vo,`[${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>`),br(!r.props.index||!r.props.children,"An index route cannot have child routes.");let a={id:r.props.id||s.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&&(a.children=zN(r.props.children,s)),n.push(a)}),n}var M_="get",E_="application/x-www-form-urlencoded";function ow(t){return t!=null&&typeof t.tagName=="string"}function Pie(t){return ow(t)&&t.tagName.toLowerCase()==="button"}function Die(t){return ow(t)&&t.tagName.toLowerCase()==="form"}function Oie(t){return ow(t)&&t.tagName.toLowerCase()==="input"}function Lie(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function jie(t,e){return t.button===0&&(!e||e==="_self")&&!Lie(t)}var $v=null;function Iie(){if($v===null)try{new FormData(document.createElement("form"),0),$v=!1}catch{$v=!0}return $v}var Uie=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Y2(t){return t!=null&&!Uie.has(t)?(Co(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${E_}"`),null):t}function Fie(t,e){let n,r,i,s,a;if(Die(t)){let o=t.getAttribute("action");r=o?bc(o,e):null,n=t.getAttribute("method")||M_,i=Y2(t.getAttribute("enctype"))||E_,s=new FormData(t)}else if(Pie(t)||Oie(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?bc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||M_,i=Y2(t.getAttribute("formenctype"))||Y2(o.getAttribute("enctype"))||E_,s=new FormData(o,t),!Iie()){let{name:c,type:d,value:h}=t;if(d==="image"){let g=c?`${c}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else c&&s.append(c,h)}}else{if(ow(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=M_,r=null,i=E_,a=t}return s&&i==="text/plain"&&(a=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function XR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function zie(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&&bc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Bie(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 Hie(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 $ie(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await Bie(s,n);return a.links?a.links():[]}return[]}));return qie(r.flat(1).filter(Hie).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function QU(t,e,n,r,i,s){let a=(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 s==="assets"?e.filter((l,c)=>a(l,c)||o(l,c)):s==="data"?e.filter((l,c)=>{let d=r.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(a(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let h=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 h=="boolean")return h}return!0}):[]}function Vie(t,e,{includeHydrateFallback:n}={}){return Gie(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function Gie(t){return[...new Set(t)]}function Wie(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function qie(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Wie(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function JG(){let t=E.useContext(Nm);return XR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Xie(){let t=E.useContext(aw);return XR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var KR=E.createContext(void 0);KR.displayName="FrameworkContext";function e9(){let t=E.useContext(KR);return XR(t,"You must render this element inside a <HydratedRouter> element"),t}function Kie(t,e){let n=E.useContext(KR),[r,i]=E.useState(!1),[s,a]=E.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:h}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&a(!0),t==="viewport"){let y=x=>{x.forEach(M=>{a(M.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[t]),E.useEffect(()=>{if(r){let y=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},v=()=>{i(!1),a(!1)};return n?t!=="intent"?[s,g,{}]:[s,g,{onFocus:$g(o,m),onBlur:$g(l,v),onMouseEnter:$g(c,m),onMouseLeave:$g(d,v),onTouchStart:$g(h,m)}]:[!1,g,{}]}function $g(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Yie({page:t,...e}){let{router:n}=JG(),r=E.useMemo(()=>HG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(Qie,{page:t,matches:r,...e}):null}function Zie(t){let{manifest:e,routeModules:n}=e9(),[r,i]=E.useState([]);return E.useEffect(()=>{let s=!1;return $ie(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function Qie({page:t,matches:e,...n}){let r=cd(),{manifest:i,routeModules:s}=e9(),{basename:a}=JG(),{loaderData:o,matches:l}=Xie(),c=E.useMemo(()=>QU(t,e,l,i,r,"data"),[t,e,l,i,r]),d=E.useMemo(()=>QU(t,e,l,i,r,"assets"),[t,e,l,i,r]),h=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let v=new Set,y=!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&&s[x.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:v.add(x.route.id))}),v.size===0)return[];let b=zie(t,a,"data");return y&&v.size>0&&b.searchParams.set("_routes",e.filter(x=>v.has(x.route.id)).map(x=>x.route.id).join(",")),[b.pathname+b.search]},[a,o,r,i,c,e,t,s]),g=E.useMemo(()=>Vie(d,i),[d,i]),m=Zie(d);return E.createElement(E.Fragment,null,h.map(v=>E.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),g.map(v=>E.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),m.map(({key:v,link:y})=>E.createElement("link",{key:v,nonce:n.nonce,...y})))}function Jie(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var t9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{t9&&(window.__reactRouterVersion="7.9.6")}catch{}function ese({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=Ire({window:n,v5Compat:!0}));let i=r.current,[s,a]=E.useState({action:i.action,location:i.location}),o=E.useCallback(l=>{E.startTransition(()=>a(l))},[a]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(kie,{basename:t,children:e,location:s.location,navigationType:s.action,navigator:i})}var n9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,lw=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:o,target:l,to:c,preventScrollReset:d,viewTransition:h,...g},m){let{basename:v}=E.useContext(hl),y=typeof c=="string"&&n9.test(c),b,x=!1;if(typeof c=="string"&&y&&(b=c,t9))try{let N=new URL(window.location.href),D=c.startsWith("//")?new URL(N.protocol+c):new URL(c),z=bc(D.pathname,v);D.origin===N.origin&&z!=null?c=z+D.search+D.hash:x=!0}catch{Co(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=die(c,{relative:i}),[w,A,T]=Kie(r,g),R=rse(c,{replace:a,state:o,target:l,preventScrollReset:d,relative:i,viewTransition:h});function C(N){e&&e(N),N.defaultPrevented||R(N)}let I=E.createElement("a",{...g,...T,href:b||M,onClick:x||s?e:C,ref:Jie(m,A),target:l,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?E.createElement(E.Fragment,null,I,E.createElement(Yie,{page:M})):I});lw.displayName="Link";var r9=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:o,children:l,...c},d){let h=q0(a,{relative:c.relative}),g=cd(),m=E.useContext(aw),{navigator:v,basename:y}=E.useContext(hl),b=m!=null&&lse(h)&&o===!0,x=v.encodeLocation?v.encodeLocation(h).pathname:h.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&&y&&(w=bc(w,y)||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)==="/"),C={isActive:T,isPending:R,isTransitioning:b},I=T?e:void 0,N;typeof r=="function"?N=r(C):N=[r,T?"active":null,R?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let D=typeof s=="function"?s(C):s;return E.createElement(lw,{...c,"aria-current":I,className:N,ref:d,style:D,to:a,viewTransition:o},typeof l=="function"?l(C):l)});r9.displayName="NavLink";var tse=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=M_,action:o,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:h,...g},m)=>{let v=ase(),y=ose(o,{relative:c}),b=a.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&n9.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||a;v(A||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:s,relative:c,preventScrollReset:d,viewTransition:h})};return E.createElement("form",{ref:m,method:b,action:y,onSubmit:r?l:M,...g,"data-discover":!x&&t==="render"?"true":void 0})});tse.displayName="Form";function nse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function i9(t){let e=E.useContext(Nm);return br(e,nse(t)),e}function rse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a}={}){let o=GR(),l=cd(),c=q0(t,{relative:s});return E.useCallback(d=>{if(jie(d,e)){d.preventDefault();let h=n!==void 0?n:Qx(l)===Qx(c);o(t,{replace:h,state:r,preventScrollReset:i,relative:s,viewTransition:a})}},[l,o,c,n,r,e,t,i,s,a])}var ise=0,sse=()=>`__${String(++ise)}__`;function ase(){let{router:t}=i9("useSubmit"),{basename:e}=E.useContext(hl),n=Eie();return E.useCallback(async(r,i={})=>{let{action:s,method:a,encType:o,formData:l,body:c}=Fie(r,e);if(i.navigate===!1){let d=i.fetcherKey||sse();await t.fetch(d,n,i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||a,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||a,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function ose(t,{relative:e}={}){let{basename:n}=E.useContext(hl),r=E.useContext(Do);br(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...q0(t||".",{relative:e})},a=cd();if(t==null){s.search=a.search;let o=new URLSearchParams(s.search),l=o.getAll("index");if(l.some(d=>d==="")){o.delete("index"),l.filter(h=>h).forEach(h=>o.append("index",h));let d=o.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:uc([n,s.pathname])),Qx(s)}function lse(t,{relative:e}={}){let n=E.useContext(XG);br(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=i9("useViewTransitionState"),i=q0(t,{relative:e});if(!n.isTransitioning)return!1;let s=bc(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=bc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Y_(i.pathname,a)!=null||Y_(i.pathname,s)!=null}var nc=RG();const cse=ro(nc);var km=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(){}},use={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},dse=class{#e=use;#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)}},nf=new dse;function fse(t){setTimeout(t,0)}var Tf=typeof window>"u"||"Deno"in globalThis;function bs(){}function hse(t,e){return typeof t=="function"?t(e):t}function BN(t){return typeof t=="number"&&t>=0&&t!==1/0}function s9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Bu(t,e){return typeof t=="function"?t(e):t}function Ua(t,e){return typeof t=="function"?t(e):t}function JU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=t;if(a){if(r){if(e.queryHash!==YR(a,e.options))return!1}else if(!Jx(e.queryKey,a))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||s&&!s(e))}function eF(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Cf(e.options.mutationKey)!==Cf(s))return!1}else if(!Jx(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function YR(t,e){return(e?.queryKeyHashFn||Cf)(t)}function Cf(t){return JSON.stringify(t,(e,n)=>HN(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Jx(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Jx(t[n],e[n])):!1}var pse=Object.prototype.hasOwnProperty;function a9(t,e){if(t===e)return t;const n=tF(t)&&tF(e);if(!n&&!(HN(t)&&HN(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),a=s.length,o=n?new Array(a):{};let l=0;for(let c=0;c<a;c++){const d=n?c:s[c],h=t[d],g=e[d];if(h===g){o[d]=h,(n?c<i:pse.call(t,d))&&l++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){o[d]=g;continue}const m=a9(h,g);o[d]=m,m===h&&l++}return i===a&&l===i?t:o}function Z_(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function tF(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function HN(t){if(!nF(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!nF(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function nF(t){return Object.prototype.toString.call(t)==="[object Object]"}function mse(t){return new Promise(e=>{nf.setTimeout(e,t)})}function $N(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?a9(t,e):e}function gse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function xse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var ZR=Symbol();function o9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===ZR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function l9(t,e){return typeof t=="function"?t(...e):!!t}var bse=class extends km{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Tf&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},QR=new bse;function VN(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});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 vse=fse;function yse(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=vse;const s=o=>{e?t.push(o):i(()=>{n(o)})},a=()=>{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||a()}return l},batchCalls:o=>(...l)=>{s(()=>{o(...l)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var oi=yse(),_se=class extends km{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Tf&&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}},Q_=new _se;function Sse(t){return Math.min(1e3*2**t,3e4)}function c9(t){return(t??"online")==="online"?Q_.isOnline():!0}var GN=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function u9(t){let e=!1,n=0,r;const i=VN(),s=()=>i.status!=="pending",a=y=>{if(!s()){const b=new GN(y);g(b),t.onCancel?.(b)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>QR.isFocused()&&(t.networkMode==="always"||Q_.isOnline())&&t.canRun(),d=()=>c9(t.networkMode)&&t.canRun(),h=y=>{s()||(r?.(),i.resolve(y))},g=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=b=>{(s()||c())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),v=()=>{if(s())return;let y;const b=n===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(h).catch(x=>{if(s())return;const M=t.retry??(Tf?0:3),w=t.retryDelay??Sse,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),mse(A).then(()=>c()?void 0:m()).then(()=>{e?g(x):v()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:d,start:()=>(d()?v():m().then(v),i)}}var d9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),BN(this.gcTime)&&(this.#e=nf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Tf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(nf.clearTimeout(this.#e),this.#e=void 0)}},wse=class extends d9{#e;#t;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=iF(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.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=iF(this.options);e.data!==void 0&&(this.setState(rF(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=$N(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(bs).catch(bs):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ua(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ZR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Bu(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:!s9(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const 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=o9(this.options,e),c=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},a=(()=>{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(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:"fetch",meta:a.fetchOptions?.meta}),this.#r=u9({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof GN&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#s({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.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 GN){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#s({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...f9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...rF(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),oi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function f9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:c9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function rF(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function iF(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 Mse=class extends km{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#o=VN(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#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),sF(this.#t,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return WN(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return WN(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 Ua(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!Z_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&aF(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ua(this.options.enabled,this.#t)!==Ua(e.enabled,this.#t)||Bu(this.options.staleTime,this.#t)!==Bu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ua(this.options.enabled,this.#t)!==Ua(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return Ase(this,n)&&(this.#i=n,this.#a=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(bs)),e}#g(){this.#y();const t=Bu(this.options.staleTime,this.#t);if(Tf||this.#i.isStale||!BN(t))return;const n=s9(this.#i.dataUpdatedAt,t)+1;this.#c=nf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Tf||Ua(this.options.enabled,this.#t)===!1||!BN(this.#l)||this.#l===0)&&(this.#u=nf.setInterval(()=>{(this.options.refetchIntervalInBackground||QR.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(nf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(nf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,s=this.#r,a=this.#a,l=t!==n?t.state:this.#n,{state:c}=t;let d={...c},h=!1,g;if(e._optimisticResults){const I=this.hasListeners(),N=!I&&sF(t,e),D=I&&aF(t,n,e,r);(N||D)&&(d={...d,...f9(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:v,status:y}=d;g=d.data;let b=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(I=i.data,b=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,I!==void 0&&(y="success",g=$N(i?.data,I,e),h=!0)}if(e.select&&g!==void 0&&!b)if(i&&g===s?.data&&e.select===this.#m)g=this.#f;else try{this.#m=e.select,g=e.select(g),g=$N(i?.data,g,e),this.#f=g,this.#s=null}catch(I){this.#s=I}this.#s&&(m=this.#s,g=this.#f,v=Date.now(),y="error");const x=d.fetchStatus==="fetching",M=y==="pending",w=y==="error",A=M&&x,T=g!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:M,isSuccess:y==="success",isError:w,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&T,isStale:JR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ua(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=z=>{C.status==="error"?z.reject(C.error):C.data!==void 0&&z.resolve(C.data)},N=()=>{const z=this.#o=C.promise=VN();I(z)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&I(D);break;case"fulfilled":(C.status==="error"||C.data!==D.value)&&N();break;case"rejected":(C.status!=="error"||C.error!==D.reason)&&N();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#t),Z_(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 s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(a=>{const o=a;return this.#i[o]!==t[o]&&s.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.#v()}#w(t){oi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ese(t,e){return Ua(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function sF(t,e){return Ese(t,e)||t.state.data!==void 0&&WN(t,e,e.refetchOnMount)}function WN(t,e,n){if(Ua(e.enabled,t)!==!1&&Bu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&JR(t,e)}return!1}function aF(t,e,n,r){return(t!==e||Ua(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&JR(t,n)}function JR(t,e){return Ua(e.enabled,t)!==!1&&t.isStaleByTime(Bu(e.staleTime,t))}function Ase(t,e){return!Z_(t.getCurrentResult(),e)}function oF(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let d=!1;const h=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=o9(e.options,e.fetchOptions),m=async(v,y,b)=>{if(d)return Promise.reject();if(y==null&&v.pages.length)return Promise.resolve(v);const M=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return h(R),R})(),w=await g(M),{maxPages:A}=e.options,T=b?xse:gse;return{pages:T(v.pages,w,A),pageParams:T(v.pageParams,y,A)}};if(i&&s.length){const v=i==="backward",y=v?Tse:lF,b={pages:s,pageParams:a},x=y(r,b);o=await m(b,x,v)}else{const v=t??s.length;do{const y=l===0?a[0]??r.initialPageParam:lF(r,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(l<v)}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 lF(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 Tse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Cse=class extends d9{#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||h9(),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=u9({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,a)=>{this.#r({type:"failed",failureCount:s,error:a})},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 a=await this.options.onMutate?.(t,n);a!==this.state.context&&this.#r({type:"pending",context:a,variables:t,isPaused:i})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}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),oi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function h9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nse=class extends km{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 Cse({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=Vv(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=Vv(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=Vv(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=Vv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){oi.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=>eF(e,n))}findAll(t={}){return this.getAll().filter(e=>eF(t,e))}notify(t){oi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return oi.batch(()=>Promise.all(t.map(e=>e.continue().catch(bs))))}};function Vv(t){return t.options.scope?.id}var kse=class extends km{#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),Z_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Cf(n.mutationKey)!==Cf(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??h9();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}}#a(e){oi.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)})})}},Rse=class extends km{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??YR(r,e);let s=this.get(i);return s||(s=new wse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}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(){oi.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=>JU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>JU(t,n)):e}notify(t){oi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){oi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){oi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Pse=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#e=t.queryCache||new Rse,this.#t=t.mutationCache||new Nse,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=QR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Q_.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=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(Bu(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}),s=this.#e.get(r.queryHash)?.state.data,a=hse(e,s);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return oi.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;oi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return oi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=oi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(bs).catch(bs)}invalidateQueries(t,e={}){return oi.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=oi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(bs)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(bs)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Bu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(bs).catch(bs)}fetchInfiniteQuery(t){return t.behavior=oF(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(bs).catch(bs)}ensureInfiniteQueryData(t){return t.behavior=oF(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Q_.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(Cf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{Jx(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Cf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{Jx(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=YR(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ZR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},p9=E.createContext(void 0),Nn=t=>{const e=E.useContext(p9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Dse=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),u.jsx(p9.Provider,{value:t,children:e})),m9=E.createContext(!1),Ose=()=>E.useContext(m9);m9.Provider;function Lse(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var jse=E.createContext(Lse()),Ise=()=>E.useContext(jse),Use=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Fse=t=>{E.useEffect(()=>{t.clearReset()},[t])},zse=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||l9(n,[t.error,r])),Bse=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))}},Hse=(t,e)=>t.isLoading&&t.isFetching&&!e,$se=(t,e)=>t?.suspense&&e.isPending,cF=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Vse(t,e,n){const r=Ose(),i=Ise(),s=Nn(),a=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",Bse(a),Use(a,i),Fse(i);const o=!s.getQueryCache().get(a.queryHash),[l]=E.useState(()=>new e(s,a)),c=l.getOptimisticResult(a),d=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(h=>{const g=d?l.subscribe(oi.batchCalls(h)):bs;return l.updateResult(),g},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),E.useEffect(()=>{l.setOptions(a)},[a,l]),$se(a,c))throw cF(a,l,i);if(zse({result:c,errorResetBoundary:i,throwOnError:a.throwOnError,query:s.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw c.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(a,c),a.experimental_prefetchInRender&&!Tf&&Hse(c,r)&&(o?cF(a,l,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(bs).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?c:l.trackResult(c)}function Mt(t,e){return Vse(t,Mse)}function At(t,e){const n=Nn(),[r]=E.useState(()=>new kse(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(a=>r.subscribe(oi.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=E.useCallback((a,o)=>{r.mutate(a,o).catch(bs)},[r]);if(i.error&&l9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Gse=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wse=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),uF=t=>{const e=Wse(t);return e.charAt(0).toUpperCase()+e.slice(1)},g9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),qse=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Xse={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 Kse=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...o},l)=>E.createElement("svg",{ref:l,...Xse,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:g9("lucide",i),...!s&&!qse(o)&&{"aria-hidden":"true"},...o},[...a.map(([c,d])=>E.createElement(c,d)),...Array.isArray(s)?s:[s]]));const rt=(t,e)=>{const n=E.forwardRef(({className:r,...i},s)=>E.createElement(Kse,{ref:s,iconNode:e,className:g9(`lucide-${Gse(uF(t))}`,`lucide-${t}`,r),...i}));return n.displayName=uF(t),n};const Yse=[["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"}]],eP=rt("archive",Yse);const Zse=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],e0=rt("arrow-down",Zse);const Qse=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],qN=rt("arrow-right",Qse);const Jse=[["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"}]],eae=rt("arrow-up-down",Jse);const tae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Yp=rt("arrow-up",tae);const nae=[["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"}]],ff=rt("bell",nae);const rae=[["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"}]],iae=rt("bold",rae);const sae=[["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"}]],Zp=rt("box",sae);const aae=[["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"}]],oae=rt("cable",aae);const lae=[["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"}]],cae=rt("calendar-days",lae);const uae=[["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"}]],Wr=rt("calendar",uae);const dae=[["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"}]],J_=rt("camera",dae);const fae=[["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"}]],hae=rt("chart-column",fae);const pae=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Qp=rt("check",pae);const mae=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qf=rt("chevron-down",mae);const gae=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rm=rt("chevron-right",gae);const xae=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Nf=rt("chevron-left",xae);const bae=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],cw=rt("chevron-up",bae);const vae=[["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"}]],No=rt("circle-alert",vae);const yae=[["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"}]],Z2=rt("circle-arrow-up",yae);const _ae=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ss=rt("circle-check-big",_ae);const Sae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],wae=rt("circle-dot",Sae);const Mae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Eae=rt("circle-stop",Mae);const Aae=[["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"}]],ud=rt("circle-x",Aae);const Tae=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qr=rt("clock",Tae);const Cae=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],tP=rt("cloud",Cae);const Nae=[["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"}]],kae=rt("code-xml",Nae);const Rae=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Pae=rt("code",Rae);const Dae=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],Oae=rt("cog",Dae);const Lae=[["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"}]],Jp=rt("copy",Lae);const jae=[["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"}]],dF=rt("database",jae);const Iae=[["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"}]],XN=rt("dollar-sign",Iae);const Uae=[["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"}]],va=rt("download",Uae);const Fae=[["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"}]],nP=rt("droplet",Fae);const zae=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],Bae=rt("droplets",zae);const Hae=[["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"}]],$ae=rt("ellipsis-vertical",Hae);const Vae=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Q2=rt("equal",Vae);const Gae=[["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"}]],vc=rt("external-link",Gae);const Wae=[["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"}]],rP=rt("eye-off",Wae);const qae=[["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"}]],t0=rt("eye",qae);const Xae=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],Kae=rt("fan",Xae);const Yae=[["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"}]],Zae=rt("file-box",Yae);const Qae=[["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"}]],fF=rt("file-code",Qae);const Jae=[["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"}]],eoe=rt("file-exclamation-point",Jae);const toe=[["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"}]],rc=rt("file-text",toe);const noe=[["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"}]],x9=rt("file",noe);const roe=[["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"}]],jp=rt("film",roe);const ioe=[["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"}]],soe=rt("flame",ioe);const aoe=[["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"}]],ooe=rt("folder-open",aoe);const loe=[["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"}]],coe=rt("folder",loe);const uoe=[["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"}]],iP=rt("funnel",uoe);const doe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],sP=rt("gauge",doe);const foe=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Cx=rt("git-compare",foe);const hoe=[["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"}]],hF=rt("github",hoe);const poe=[["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"}]],e1=rt("globe",poe);const moe=[["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"}]],aP=rt("grip-vertical",moe);const goe=[["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"}]],b9=rt("hard-drive",goe);const xoe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],KN=rt("history",xoe);const boe=[["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"}]],uw=rt("image",boe);const voe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],v9=rt("info",voe);const yoe=[["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"}]],_oe=rt("italic",yoe);const Soe=[["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"}]],y9=rt("key",Soe);const woe=[["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"}]],YN=rt("keyboard",woe);const Moe=[["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"}]],kf=rt("layers",Moe);const Eoe=[["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"}]],_9=rt("layout-grid",Eoe);const Aoe=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],Toe=rt("layout-list",Aoe);const Coe=[["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"}]],Noe=rt("link-2-off",Coe);const koe=[["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"}]],Roe=rt("link-2",koe);const Poe=[["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"}]],S9=rt("link",Poe);const Doe=[["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"}]],w9=rt("list-ordered",Doe);const Ooe=[["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"}]],oP=rt("list",Ooe);const Loe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ot=rt("loader-circle",Loe);const joe=[["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"}]],pF=rt("log-in",joe);const Ioe=[["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"}]],Uoe=rt("log-out",Ioe);const Foe=[["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"}]],zoe=rt("maximize-2",Foe);const Boe=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Hoe=rt("maximize",Boe);const $oe=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Voe=rt("minimize-2",$oe);const Goe=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],Woe=rt("minimize",Goe);const qoe=[["path",{d:"M5 12h14",key:"1ays0h"}]],mF=rt("minus",qoe);const Xoe=[["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"}]],t1=rt("moon",Xoe);const Koe=[["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"}]],n1=rt("package",Koe);const Yoe=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Zoe=rt("palette",Yoe);const Qoe=[["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"}]],Joe=rt("pause",Qoe);const ele=[["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"}]],r1=rt("pen-line",ele);const tle=[["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"}]],lP=rt("pen",tle);const nle=[["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"}]],Rf=rt("pencil",nle);const rle=[["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"}]],dw=rt("play",rle);const ile=[["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"}]],Nx=rt("plug",ile);const sle=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],li=rt("plus",sle);const ale=[["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"}]],cP=rt("power-off",ale);const ole=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],dd=rt("power",ole);const lle=[["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"}]],ko=rt("printer",lle);const cle=[["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"}]],ule=rt("qr-code",cle);const dle=[["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"}]],qs=rt("refresh-cw",dle);const fle=[["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"}]],X0=rt("rotate-ccw",fle);const hle=[["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"}]],ple=rt("ruler",hle);const mle=[["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"}]],Qo=rt("save",mle);const gle=[["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"}]],xle=rt("scan-search",gle);const ble=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Zu=rt("search",ble);const vle=[["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"}]],uP=rt("send",vle);const yle=[["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"}]],fw=rt("settings-2",yle);const _le=[["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"}]],dP=rt("settings",_le);const Sle=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],wle=rt("signal",Sle);const Mle=[["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"}]],Ele=rt("skip-back",Mle);const Ale=[["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"}]],i1=rt("skip-forward",Ale);const Tle=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],gF=rt("sliders-vertical",Tle);const Cle=[["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"}]],n0=rt("sparkles",Cle);const Nle=[["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"}]],Pf=rt("square-check-big",Nle);const kle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],em=rt("square",kle);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"}]],r0=rt("star",Rle);const Ple=[["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"}]],M9=rt("sticky-note",Ple);const Dle=[["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"}]],xF=rt("sun",Dle);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"}]],i0=rt("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"}]],E9=rt("target",Lle);const jle=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ile=rt("terminal",jle);const Ule=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Fle=rt("text-align-center",Ule);const zle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Ble=rt("text-align-end",zle);const Hle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],$le=rt("text-align-start",Hle);const Vle=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ip=rt("thermometer",Vle);const Gle=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ou=rt("timer",Gle);const Wle=[["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"}]],Qn=rt("trash-2",Wle);const qle=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Xle=rt("trending-up",qle);const Kle=[["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"}]],ws=rt("triangle-alert",Kle);const Yle=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Zle=rt("underline",Yle);const Qle=[["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"}]],A9=rt("unlink",Qle);const Jle=[["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"}]],Ka=rt("upload",Jle);const ece=[["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"}]],bF=rt("user",ece);const tce=[["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"}]],nce=rt("video",tce);const rce=[["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"}]],fP=rt("wifi-off",rce);const ice=[["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"}]],T9=rt("wifi",ice);const sce=[["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"}]],ace=rt("wind",sce);const oce=[["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"}]],Df=rt("wrench",oce);const lce=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qt=rt("x",lce);const cce=[["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"}]],uce=rt("zoom-in",cce);const dce=[["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"}]],s0=rt("zap",dce);const fce=[["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"}]],hce=rt("zoom-out",fce),C9=E.createContext(void 0);function pce({children:t}){const[e,n]=E.useState(()=>{const s=localStorage.getItem("theme");return s||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});E.useEffect(()=>{const s=document.documentElement;e==="dark"?s.classList.add("dark"):s.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(s=>s==="dark"?"light":"dark")},i=s=>{n(s)};return u.jsx(C9.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function N9(){const t=E.useContext(C9);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Lt({children:t,className:e="",onClick:n,onContextMenu:r}){return u.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Yl({children:t,className:e=""}){return u.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Ft({children:t,className:e=""}){return u.jsx("div",{className:`p-6 ${e}`,children:t})}function mce(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:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles"},{keys:["N"],description:"New profile"},{keys:["Esc"],description:"Exit selection mode"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function vF({children:t}){return u.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 gce({onClose:t,navItems:e}){const{t:n}=sw(),r=mce(e,n);return E.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(YN,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:r.map(i=>u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:i.category}),u.jsx("div",{className:"space-y-2",children:i.items.map(s=>u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-white text-sm",children:s.description}),u.jsx("div",{className:"flex gap-1",children:s.keys.map(a=>u.jsx(vF,{children:a},a))})]},s.description))})]},i.category))}),u.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:u.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",u.jsx(vF,{children:"Esc"})," or click outside to close"]})})]})})})}const gr="/api/v1";async function lt(t,e={}){const n=await fetch(`${gr}${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()}const Le={getPrinters:()=>lt("/printers/"),getPrinter:t=>lt(`/printers/${t}`),createPrinter:t=>lt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>lt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>lt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>lt(`/printers/${t}/status`),connectPrinter:t=>lt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>lt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>lt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>lt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>lt(`/printers/${t}/logging`),clearMQTTLogs:t=>lt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>lt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${gr}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>lt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>lt(`/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)),lt(`/archives/?${r}`)},getArchive:t=>lt(`/archives/${t}`),updateArchive:(t,e)=>lt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>lt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>lt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>lt("/archives/stats"),getArchiveDuplicates:t=>lt(`/archives/${t}/duplicates`),backfillContentHashes:()=>lt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${gr}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${gr}/archives/${t}/download`,getArchiveGcode:t=>`${gr}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${gr}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>lt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>lt(`/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(`${gr}/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)=>`${gr}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${gr}/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)=>lt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${gr}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${gr}/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(`${gr}/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=>lt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${gr}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>lt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>lt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>lt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${gr}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${gr}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>lt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${gr}/archives/upload?printer_id=${e}`:`${gr}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(s=>n.append("files",s));const r=e?`${gr}/archives/upload-bulk?printer_id=${e}`:`${gr}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>lt("/settings/"),updateSettings:t=>lt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>lt("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)));const n=`${gr}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let s="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(s=o[1].trim())}return{blob:await r.blob(),filename:s}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${gr}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>lt("/settings/check-ffmpeg"),getCloudStatus:()=>lt("/cloud/status"),cloudLogin:(t,e,n="global")=>lt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>lt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>lt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>lt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>lt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>lt(`/cloud/settings/${t}`),createCloudSetting:t=>lt("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>lt(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>lt(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>lt("/cloud/devices"),getCloudFields:t=>lt(`/cloud/fields/${t}`),getAllCloudFields:()=>lt("/cloud/fields"),getSmartPlugs:()=>lt("/smart-plugs/"),getSmartPlug:t=>lt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>lt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>lt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>lt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>lt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>lt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>lt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>lt("/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),lt(`/queue/?${n}`)},getQueueItem:t=>lt(`/queue/${t}`),addToQueue:t=>lt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>lt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>lt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>lt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>lt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>lt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>lt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>lt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>lt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>lt(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>lt(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>lt(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>lt(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>lt(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>lt(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>lt(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>lt(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>lt("/filaments/"),getFilament:t=>lt(`/filaments/${t}`),getFilamentsByType:t=>lt(`/filaments/by-type/${t}`),getNotificationProviders:()=>lt("/notifications/"),getNotificationProvider:t=>lt(`/notifications/${t}`),createNotificationProvider:t=>lt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>lt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>lt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>lt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>lt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>lt("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>lt("/notification-templates"),getNotificationTemplate:t=>lt(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>lt(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>lt(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>lt("/notification-templates/variables"),previewTemplate:t=>lt("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),lt(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>lt(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>lt(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>lt("/spoolman/status"),connectSpoolman:()=>lt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>lt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>lt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>lt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>lt("/spoolman/spools"),getSpoolmanFilaments:()=>lt("/spoolman/filaments"),getVersion:()=>lt("/updates/version"),checkForUpdates:()=>lt("/updates/check"),applyUpdate:()=>lt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>lt("/updates/status"),getMaintenanceTypes:()=>lt("/maintenance/types"),createMaintenanceType:t=>lt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>lt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>lt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>lt("/maintenance/overview"),getPrinterMaintenance:t=>lt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>lt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>lt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>lt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>lt("/maintenance/summary"),setPrinterHours:(t,e)=>lt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${gr}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${gr}/printers/${t}/camera/snapshot`,testCameraConnection:t=>lt(`/printers/${t}/camera/test`)},A_=[{id:"printers",to:"/",icon:ko,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:eP,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Wr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:hae,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:tP,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Df,labelKey:"nav.maintenance"},{id:"settings",to:"/settings",icon:dP,labelKey:"nav.settings"}];function xce(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map(A_.map(i=>[i.id,i])),r=[];for(const i of e){const s=n.get(i);s&&(r.push(s),n.delete(i))}for(const i of n.values())r.push(i);return r}catch{return A_}return A_}function bce(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function k9(){return localStorage.getItem("defaultView")||"/"}function vce(t){localStorage.setItem("defaultView",t)}function yce(){const t=GR(),e=cd(),{theme:n,toggleTheme:r}=N9(),{t:i}=sw(),[s,a]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[o,l]=E.useState(!1),[c,d]=E.useState(xce),[h,g]=E.useState(null),[m,v]=E.useState(null),y=E.useRef(!1),[b,x]=E.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:M}=Mt({queryKey:["version"],queryFn:Le.getVersion,staleTime:1/0}),{data:w}=Mt({queryKey:["settings"],queryFn:Le.getSettings,staleTime:300*1e3}),{data:A}=Mt({queryKey:["updateCheck"],queryFn:Le.checkForUpdates,enabled:w?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),T=A?.update_available&&A.latest_version&&A.latest_version!==b,R=()=>{A?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",A.latest_version),x(A.latest_version))};E.useEffect(()=>{if(!y.current&&e.pathname==="/"){const W=k9();W!=="/"&&(y.current=!0,t(W,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]);const C=(W,P)=>{g(P),W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("text/plain",String(P))},I=(W,P)=>{W.preventDefault(),W.dataTransfer.dropEffect="move",v(P)},N=()=>{v(null)},D=(W,P)=>{if(W.preventDefault(),h===null||h===P){g(null),v(null);return}const $=[...c],[K]=$.splice(h,1);$.splice(P,0,K),d($),bce($),g(null),v(null)},z=()=>{g(null),v(null)},j=E.useCallback(W=>{const P=W.target;if(!(P.tagName==="INPUT"||P.tagName==="TEXTAREA"||P.isContentEditable)&&!W.metaKey&&!W.ctrlKey&&!W.altKey){const $=parseInt(W.key);if($>=1&&$<=c.length){W.preventDefault(),t(c[$-1].to);return}switch(W.key){case"?":W.preventDefault(),l(!0);break;case"Escape":l(!1);break}}},[t,c]);return E.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),u.jsxs("div",{className:"flex min-h-screen",children:[u.jsxs("aside",{className:`${s?"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:[u.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s?"p-4":"p-2"}`,children:u.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),u.jsx("nav",{className:"flex-1 p-2",children:u.jsx("ul",{className:"space-y-2",children:c.map(({id:W,to:P,icon:$,labelKey:K},G)=>u.jsx("li",{draggable:!0,onDragStart:Z=>C(Z,G),onDragOver:Z=>I(Z,G),onDragLeave:N,onDrop:Z=>D(Z,G),onDragEnd:z,className:`relative ${h===G?"opacity-50":""} ${m===G&&h!==G?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:u.jsxs(r9,{to:P,className:({isActive:Z})=>`flex items-center ${s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Z?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:s?void 0:i(K),children:[s&&u.jsx(aP,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),u.jsx($,{className:"w-5 h-5 flex-shrink-0"}),s&&u.jsx("span",{children:i(K)})]})},W))})}),u.jsx("button",{onClick:()=>a(!s),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(s?"nav.collapseSidebar":"nav.expandSidebar"),children:s?u.jsx(Nf,{className:"w-5 h-5"}):u.jsx(Rm,{className:"w-5 h-5"})}),u.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s?u.jsxs("div",{className:"flex items-center justify-between px-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",M?.version||"..."]}),A?.update_available&&u.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:A.latest_version}),children:[u.jsx(Z2,{className:"w-4 h-4"}),u.jsx("span",{children:i("nav.update")})]})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:u.jsx(hF,{className:"w-5 h-5"})}),u.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:u.jsx(YN,{className:"w-5 h-5"})}),u.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"?u.jsx(xF,{className:"w-5 h-5"}):u.jsx(t1,{className:"w-5 h-5"})})]})]}):u.jsxs("div",{className:"flex flex-col items-center gap-1",children:[A?.update_available&&u.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:A.latest_version}),children:u.jsx(Z2,{className:"w-5 h-5"})}),u.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:u.jsx(hF,{className:"w-5 h-5"})}),u.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:u.jsx(YN,{className:"w-5 h-5"})}),u.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"?u.jsx(xF,{className:"w-5 h-5"}):u.jsx(t1,{className:"w-5 h-5"})})]})})]}),u.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto ${s?"ml-64":"ml-16"} transition-all duration-300`,children:[T&&u.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx(Z2,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{children:i("nav.updateAvailableBanner",{version:A?.latest_version,defaultValue:`Version ${A?.latest_version} is available!`})}),u.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),u.jsx("button",{onClick:R,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:u.jsx(Qt,{className:"w-4 h-4"})})]}),u.jsx(Nie,{})]}),o&&u.jsx(gce,{onClose:()=>l(!1),navItems:c})]})}function Ue({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="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",a={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 u.jsx("button",{className:`${s} ${a[t]} ${o[e]} ${n}`,...i,children:r})}function Zi({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:s,onCancel:a}){E.useEffect(()=>{const c=d=>{d.key==="Escape"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]);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 u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:u.jsx(ws,{className:"w-6 h-6"})}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),u.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),u.jsxs("div",{className:"flex gap-3 mt-6",children:[u.jsx(Ue,{variant:"secondary",onClick:a,className:"flex-1",children:r}),u.jsx(Ue,{onClick:s,className:`flex-1 ${l.button}`,children:n})]})]})})})}const R9=E.createContext(void 0);function Di(){const t=E.useContext(R9);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const _ce={success:u.jsx(Ss,{className:"w-5 h-5 text-green-400"}),error:u.jsx(ud,{className:"w-5 h-5 text-red-400"}),warning:u.jsx(No,{className:"w-5 h-5 text-yellow-400"}),info:u.jsx(v9,{className:"w-5 h-5 text-blue-400"})},Sce={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 wce({children:t}){const[e,n]=E.useState([]),r=E.useCallback((s,a="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:s,type:a}]),setTimeout(()=>{n(l=>l.filter(c=>c.id!==o))},3e3)},[]),i=E.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return u.jsxs(R9.Provider,{value:{showToast:r},children:[t,u.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>u.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Sce[s.type]}`,children:[_ce[s.type],u.jsx("span",{className:"text-white text-sm",children:s.message}),u.jsx("button",{onClick:()=>i(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-4 h-4"})})]},s.id))})]})}function Mce(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 yF(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 Ece(t,e){if(e)return coe;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Zae;case"gcode":return rc;case"mp4":case"avi":return jp;case"png":case"jpg":case"jpeg":return uw;default:return x9}}function Ace({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Di(),i=Nn(),[s,a]=E.useState("/"),[o,l]=E.useState(null),[c,d]=E.useState(""),[h,g]=E.useState(null);E.useEffect(()=>{const C=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]);const{data:m,isLoading:v,refetch:y}=Mt({queryKey:["printerFiles",t,s],queryFn:()=>Le.getPrinterFiles(t,s)}),{data:b}=Mt({queryKey:["printerStorage",t],queryFn:()=>Le.getPrinterStorage(t),staleTime:3e4}),x=At({mutationFn:C=>Le.deletePrinterFile(t,C),onSuccess:(C,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:C=>{r(`Delete failed: ${C.message}`,"error")}}),M=C=>{a(C),l(null)},w=()=>{if(s==="/")return;const C=s.split("/").filter(Boolean);C.pop(),a(C.length?"/"+C.join("/"):"/"),l(null)},A=C=>{window.open(Le.getPrinterFileDownloadUrl(t,C),"_blank")},T=C=>{g(C)},R=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[u.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:C=>C.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(b9,{className:"w-5 h-5 text-bambu-green"}),u.jsxs("div",{children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),u.jsxs("div",{className:"flex items-center gap-4",children:[b&&(b.used_bytes!=null||b.free_bytes!=null)&&u.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[b.used_bytes!=null&&u.jsxs("span",{children:["Used: ",yF(b.used_bytes)]}),b.used_bytes!=null&&b.free_bytes!=null&&u.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),b.free_bytes!=null&&u.jsxs("span",{children:["Free: ",yF(b.free_bytes)]})]}),u.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]})]}),u.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(C=>u.jsx("button",{onClick:()=>{M(C.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===C.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:C.label},C.path)),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"relative",children:[u.jsx(Zu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:C=>d(C.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"})]}),u.jsx(Ue,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:v,children:u.jsx(qs,{className:`w-4 h-4 ${v?"animate-spin":""}`})})]}),u.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[u.jsx("button",{onClick:w,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:u.jsx(Nf,{className:"w-4 h-4"})}),u.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:v?u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?u.jsx("div",{className:"space-y-1",children:[...m.files].filter(C=>!c||C.name.toLowerCase().includes(c.toLowerCase())).sort((C,I)=>C.is_directory&&!I.is_directory?-1:!C.is_directory&&I.is_directory?1:C.name.localeCompare(I.name)).map(C=>{const I=Ece(C.name,C.is_directory),N=o===C.path;return u.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${N?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{C.is_directory?M(C.path):l(N?null:C.path)},children:[u.jsx(I,{className:`w-5 h-5 flex-shrink-0 ${C.is_directory?"text-bambu-green":"text-bambu-gray"}`}),u.jsx("span",{className:"flex-1 text-white truncate",children:C.name}),!C.is_directory&&u.jsx("span",{className:"text-sm text-bambu-gray",children:Mce(C.size)}),C.is_directory&&u.jsx(Nf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},C.path)})}):u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[u.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${m?.files?.filter(C=>C.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs(Ue,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[u.jsx(va,{className:"w-4 h-4"}),"Download"]}),u.jsxs(Ue,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),h&&u.jsx(Zi,{title:"Delete File",message:`Delete "${h.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(h),g(null)},onCancel:()=>g(null)})]})}function Tce({printerId:t,printerName:e,onClose:n}){const r=Nn(),[i,s]=E.useState(!0),[a,o]=E.useState(new Set),[l,c]=E.useState(""),[d,h]=E.useState("all"),g=E.useRef(null),{data:m,isLoading:v,refetch:y}=Mt({queryKey:["mqtt-logs",t],queryFn:()=>Le.getMQTTLogs(t),refetchInterval:1e3}),b=At({mutationFn:()=>Le.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),x=At({mutationFn:()=>Le.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=At({mutationFn:()=>Le.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const N=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),E.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const w=N=>{o(D=>{const z=new Set(D);return z.has(N)?z.delete(N):z.add(N),z})},A=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(N,D)=>{if(N==null)return"<empty>";const z=typeof N=="string"?JSON.parse(N):N,j=JSON.stringify(z,null,D?2:0);return!D&&j.length>100?j.substring(0,100)+"...":j},R=m?.logging_enabled??!1,C=m?.logs??[],I=E.useMemo(()=>C.filter(N=>{if(d!=="all"&&N.direction!==d)return!1;if(l.trim()){const D=l.toLowerCase(),z=N.topic.toLowerCase().includes(D),W=JSON.stringify(N.payload).toLowerCase().includes(D);return z||W}return!0}),[C,l,d]);return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),u.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[R?u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,children:[u.jsx(em,{className:"w-4 h-4"}),"Stop"]}):u.jsxs(Ue,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[u.jsx(dw,{className:"w-4 h-4"}),"Start Logging"]}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||C.length===0,children:[u.jsx(Qn,{className:"w-4 h-4"}),"Clear"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:v,children:u.jsx(qs,{className:`w-4 h-4 ${v?"animate-spin":""}`})}),u.jsx("div",{className:"flex-1"}),u.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i,onChange:N=>s(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),u.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",C.length]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1",children:[u.jsx(Zu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:N=>c(N.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),l&&u.jsx("button",{onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:u.jsx(Qt,{className:"w-4 h-4"})})]}),u.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[u.jsx("button",{onClick:()=>h("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),u.jsxs("button",{onClick:()=>h("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[u.jsx(e0,{className:"w-3 h-3"}),"In"]}),u.jsxs("button",{onClick:()=>h("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[u.jsx(Yp,{className:"w-3 h-3"}),"Out"]})]})]})]}),u.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[u.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!R&&u.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[u.jsx("p",{className:"mb-2",children:"No messages match your filter"}),u.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):u.jsx("div",{className:"space-y-1",children:I.map((N,D)=>{const z=a.has(D),j=N.direction==="in";return u.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${z?"bg-bambu-dark-secondary":""}`,onClick:()=>w(D),children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx("span",{className:"text-bambu-gray shrink-0",children:A(N.timestamp)}),u.jsx("span",{className:`shrink-0 ${j?"text-blue-400":"text-green-400"}`,title:j?"Incoming":"Outgoing",children:j?u.jsx(e0,{className:"w-3 h-3"}):u.jsx(Yp,{className:"w-3 h-3"})}),u.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),z?u.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(N.payload,!0)}):u.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(N.payload,!1)})]},D)})})}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[u.jsx("div",{className:"text-sm text-bambu-gray",children:R?u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):u.jsx("span",{children:"Logging stopped"})}),u.jsx(Ue,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Cce={"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 Nce(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:ws};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:ws};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:No};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:v9}}}function P9(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(),s=(t&255).toString(16).padStart(2,"0").toUpperCase(),a=(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}${s}_${a}${o}_${l}${c}`}function kce(t,e,n){const r=P9(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function Rce({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]),u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ws,{className:"w-5 h-5 text-orange-400"}),u.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),u.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?u.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[u.jsx(No,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{children:"No HMS errors"})]}):u.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:s,color:a,bgColor:o,Icon:l}=Nce(r.severity),c=parseInt(r.code.replace("0x",""),16)||0,d=P9(r.attr,c),h=Cce[d]||"Unknown error. Click the link below for details.",g=kce(r.attr,c,t),m=`HMS_${d.replace(/_/g,"-")}`;return u.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx(l,{className:`w-5 h-5 ${a} flex-shrink-0 mt-0.5`}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u.jsx("span",{className:`font-mono text-sm ${a}`,children:m}),u.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${a}`,children:s})]}),u.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:h}),u.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[u.jsx(vc,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),u.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:u.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 Pce(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 Dce({printerId:t}){const{data:e}=Mt({queryKey:["queue",t,"pending"],queryFn:()=>Le.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:u.jsx(lw,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[u.jsx(Wr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),u.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[u.jsx(Qr,{className:"w-3 h-3"}),Pce(n?.scheduled_time||null)]}),r>1&&u.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),u.jsx(Rm,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function Oce({side:t}){const{theme:e}=N9(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return u.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function Lce({colors:t,className:e}){const n=[{x:9.5,cx:12.5},{x:18.5,cx:21.5},{x:27.5,cx:30.5},{x:36.5,cx:39.5}];return u.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z",fill:"#2F2E33"}),n.map((r,i)=>t[i]?u.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):u.jsxs("g",{children:[u.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),u.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),u.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z",fill:"#767676"}),u.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z",fill:"#BFBFBF"})]})}function jce({color:t,className:e}){return u.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?u.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):u.jsxs("g",{children:[u.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),u.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),u.jsx("path",{d:"M5.88312 4.68555C5.88312 4.13326 6.33083 3.68555 6.88312 3.68555H13.5059C14.0582 3.68555 14.5059 4.13326 14.5059 4.68555V10.3887H5.88312V4.68555Z",stroke:"#6B6B6B"}),u.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),u.jsx("path",{d:"M8.21991 5.65234C8.21991 5.3762 8.44377 5.15234 8.71991 5.15234H11.7288C12.005 5.15234 12.2288 5.3762 12.2288 5.65234V10.3887H8.21991V5.65234Z",stroke:"#6B6B6B"})]})}function _F({className:t}){return u.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function Ice({className:t}){return u.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),u.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function Uce({className:t}){return u.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),u.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function Fce({className:t}){return u.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),u.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function zce({className:t}){return u.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),u.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),u.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Bce({className:t}){return u.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),u.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),u.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Hce({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){const r=typeof t=="string"?parseInt(t,10):t,i=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let a,o;isNaN(r)?(a="#C3C2C1",o="Unknown"):r<=i?(a="#22a352",o="Good"):r<=s?(a="#d4a017",o="Fair"):(a="#c62828",o="Bad");let l;return isNaN(r)||r<=i?l=_F:r<=s?l=Ice:l=Uce,u.jsxs("div",{className:"flex items-center justify-end gap-1",title:`Humidity: ${r}% - ${o}`,children:[u.jsx(l,{className:"w-3 h-4"}),u.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:a},children:[r,"%"]})]})}function $ce({temp:t,goodThreshold:e=28,fairThreshold:n=35}){const r=typeof e=="number"?e:28,i=typeof n=="number"?n:35;let s,a;return t<=r?(s="#22a352",a=Fce):t<=i?(s="#d4a017",a=zce):(s="#c62828",a=Bce),u.jsxs("span",{className:"flex items-center gap-1",title:"Temperature",children:[u.jsx(a,{className:"w-3 h-4"}),u.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function Vce(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,a=String.fromCharCode(65+s);return i?`HT-${a}`:`AMS-${a}`}function Gce(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Wce(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const s=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),a=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return a===0?s:a===1?`Tomorrow ${s}`:n.toLocaleDateString([],{weekday:"short"})+" "+s}function qce(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function Xce(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function Kce({url:t,printName:e}){const[n,r]=E.useState(!1),[i,s]=E.useState(!1),[a,o]=E.useState(!1);return u.jsxs(u.Fragment,{children:[u.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?u.jsxs(u.Fragment,{children:[u.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&u.jsx(Zp,{className:"w-8 h-8 text-bambu-gray"})]}):u.jsx(Zp,{className:"w-8 h-8 text-bambu-gray"})}),a&&t&&u.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:u.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[u.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&u.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function Yce({printers:t}){const e=Nn(),n=E.useMemo(()=>{let i=0,s=0,a=0,o=0;return t?.forEach(l=>{const c=e.getQueryData(["printerStatus",l.id]);c===void 0?o++:c.connected?c.state==="RUNNING"?i++:s++:a++}),{printing:i,idle:s,offline:a,loading:o,total:t?.length||0}},[t,e]),[,r]=E.useState(0);return E.useEffect(()=>{const i=e.getQueryCache().subscribe(()=>{r(s=>s+1)});return()=>i()},[e]),t?.length?u.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),u.jsxs("span",{className:"text-bambu-gray",children:[u.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),u.jsxs("span",{className:"text-bambu-gray",children:[u.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),u.jsxs("span",{className:"text-bambu-gray",children:[u.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function SF({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const s=Nn(),a=GR(),[o,l]=E.useState(!1),[c,d]=E.useState(!1),[h,g]=E.useState(!1),[m,v]=E.useState(!1),[y,b]=E.useState(!1),[x,M]=E.useState(!1),[w,A]=E.useState(!1),[T,R]=E.useState(!1),{data:C}=Mt({queryKey:["printerStatus",t.id],queryFn:()=>Le.getPrinterStatus(t.id),refetchInterval:3e4}),[I,N]=E.useState(null);E.useEffect(()=>{C?.wifi_signal!=null&&N(C.wifi_signal)},[C?.wifi_signal]);const D=C?.wifi_signal??I,z=E.useRef({});E.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(z.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const j=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:z.current,W=E.useRef([]);E.useEffect(()=>{C?.ams&&C.ams.length>0&&(W.current=C.ams)},[C?.ams]);const P=C?.ams&&C.ams.length>0?C.ams:W.current,{data:$}=Mt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Le.getSmartPlugByPrinter(t.id)}),{data:K}=Mt({queryKey:["smartPlugStatus",$?.id],queryFn:()=>$?Le.getSmartPlugStatus($.id):null,enabled:!!$,refetchInterval:1e4}),{data:G}=Mt({queryKey:["queue",t.id,"pending"],queryFn:()=>Le.getQueue(t.id,"pending")}),Z=G?.length||0,{data:Q}=Mt({queryKey:["archives",t.id,"last"],queryFn:()=>Le.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),ee=Q?.[0],H=e&&C&&!C.connected,q=At({mutationFn:()=>Le.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),te=At({mutationFn:()=>Le.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ae=At({mutationFn:re=>$?Le.controlSmartPlug($.id,re):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",$?.id]})}}),xe=At({mutationFn:re=>$?Le.updateSmartPlug($.id,{auto_off:re}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return H?null:u.jsxs(Lt,{className:"relative",children:[u.jsxs(Ft,{children:[u.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[u.jsxs("div",{className:"flex items-start justify-between gap-2",children:[u.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[u.jsx("img",{src:qce(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&u.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&u.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:C.nozzles[0].nozzle_type||"Nozzle",children:["• ",C.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&u.jsxs("span",{className:"ml-2 text-bambu-gray",children:[u.jsx(Qr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),u.jsxs("div",{className:"relative flex-shrink-0",children:[u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:u.jsx($ae,{className:"w-4 h-4"})}),o&&u.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:[u.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),l(!1)},children:[u.jsx(Rf,{className:"w-4 h-4"}),"Edit"]}),u.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{te.mutate(),l(!1)},children:[u.jsx(qs,{className:"w-4 h-4"}),"Reconnect"]}),u.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{b(!0),l(!1)},children:[u.jsx(Ile,{className:"w-4 h-4"}),"MQTT Debug"]}),u.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:()=>{d(!0),l(!1)},children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&u.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[u.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?u.jsx(S9,{className:"w-3 h-3"}):u.jsx(A9,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&D!=null&&u.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${D>=-50||D>=-60?"bg-bambu-green/20 text-bambu-green":D>=-70?"bg-amber-500/20 text-amber-600":D>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${D} dBm - ${Xce(D).label}`,children:[u.jsx(wle,{className:"w-3 h-3"}),D,"dBm"]}),C?.connected&&u.jsxs("button",{onClick:()=>R(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${C.hms_errors&&C.hms_errors.length>0?C.hms_errors.some(re=>re.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:[u.jsx(ws,{className:"w-3 h-3"}),C.hms_errors&&C.hms_errors.length>0?C.hms_errors.length:"OK"]}),n&&u.jsxs("button",{onClick:()=>a("/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:[u.jsx(Df,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Z>0&&u.jsxs("button",{onClick:()=>a("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${Z} print${Z>1?"s":""} in queue`,children:[u.jsx(kf,{className:"w-3 h-3"}),Z]})]})]}),c&&u.jsx(Zi,{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:()=>{q.mutate(),d(!1)},onCancel:()=>d(!1)}),C?.connected&&u.jsxs(u.Fragment,{children:[r==="compact"?u.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:u.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),u.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):u.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:C.state?.toLowerCase()||"Idle"})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Kce,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),u.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),u.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),u.jsxs("div",{className:"flex items-center justify-between text-sm",children:[u.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:u.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),u.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),u.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(Qr,{className:"w-3 h-3"}),Gce(C.remaining_time*60)]}),u.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Wce(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(kf,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),u.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:C.state?.toLowerCase()||"Idle"}),u.jsxs("div",{className:"flex items-center justify-between text-sm",children:[u.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:u.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),u.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ee?u.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ee.print_name||ee.filename,children:["Last: ",ee.print_name||ee.filename,ee.completed_at&&u.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(ee.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):u.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&u.jsx(Dce,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&u.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[u.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[u.jsx(Ip,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),C.temperatures.nozzle_2!==void 0?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),u.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),u.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),u.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[u.jsx(Ip,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),u.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&u.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[u.jsx(Ip,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),u.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]}),P&&P.length>0&&r==="expanded"&&u.jsxs("div",{className:"mt-3 space-y-2",children:[P.map(re=>{const pe=j[String(re.id)],Ce=re.id>=128?re.id-128:re.id,fe=pe!==void 0?pe:Ce,Se=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,Re=fe===1,ue=fe===0,ct=re.tray.map(F=>F.tray_color?`#${F.tray_color}`:F.tray_type?"#333":null),B=re.tray.length===1;return u.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[Se&&(Re||ue)&&u.jsx(Oce,{side:Re?"L":"R"}),B?u.jsx(jce,{color:ct[0],className:"flex-shrink-0"}):u.jsx(Lce,{colors:ct,className:"flex-shrink-0"})]}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:Vce(re.id,re.tray.length)}),(re.humidity!=null||re.temp!=null)&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[re.humidity!=null&&u.jsx(Hce,{humidity:re.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair}),re.temp!=null&&u.jsx($ce,{temp:re.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair})]})]}),u.jsx("div",{className:"flex gap-1 mt-0.5 text-[10px] text-bambu-gray/70 truncate",children:re.tray.map((F,ie)=>u.jsxs("span",{className:"truncate",children:[F.tray_type?F.tray_sub_brands||F.tray_type:"—",ie<re.tray.length-1&&" · "]},ie))})]})]})},re.id)}),C.vt_tray&&C.vt_tray.tray_type&&u.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"}}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),u.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"Spool"})]})]})})]})]}),$&&r==="expanded"&&u.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u.jsx(s0,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),u.jsx("span",{className:"text-sm text-white truncate",children:$.name}),K&&u.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${K.state==="ON"?"bg-bambu-green/20 text-bambu-green":K.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:K.state||"?"}),K?.energy?.power!=null&&K.state==="ON"&&u.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[K.energy.power,"W"]})]}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs("button",{onClick:()=>M(!0),disabled:ae.isPending||K?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${K?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[u.jsx(dd,{className:"w-3 h-3"}),"On"]}),u.jsxs("button",{onClick:()=>A(!0),disabled:ae.isPending||K?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${K?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[u.jsx(cP,{className:"w-3 h-3"}),"Off"]})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u.jsx("span",{className:`text-xs hidden sm:inline ${$.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:$.auto_off_executed?"Auto-off done":"Auto-off"}),u.jsx("button",{onClick:()=>xe.mutate(!$.auto_off),disabled:xe.isPending||$.auto_off_executed,title:$.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 ${$.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":$.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:u.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${$.auto_off||$.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&u.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[u.jsxs("div",{className:"text-xs text-bambu-gray",children:[u.jsx("p",{children:t.ip_address}),u.jsx("p",{className:"truncate",children:t.serial_number})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ue,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:u.jsx(nce,{className:"w-4 h-4"})}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>v(!0),title:"Browse printer files",children:[u.jsx(b9,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&u.jsx(Ace,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),y&&u.jsx(Tce,{printerId:t.id,printerName:t.name,onClose:()=>b(!1)}),x&&$&&u.jsx(Zi,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ae.mutate("on"),M(!1)},onCancel:()=>M(!1)}),w&&$&&u.jsx(Zi,{title:"Power Off Printer",message:C?.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:()=>{ae.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&u.jsx(Rce,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>R(!1)}),h&&u.jsx(Qce,{printer:t,onClose:()=>g(!1)})]})}function Zce({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=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:u.jsxs(Ft,{children:[u.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),u.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),u.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),u.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),u.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),u.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),u.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:[u.jsx("option",{value:"",children:"Select model..."}),u.jsxs("optgroup",{label:"H2 Series",children:[u.jsx("option",{value:"H2C",children:"H2C"}),u.jsx("option",{value:"H2D",children:"H2D"}),u.jsx("option",{value:"H2S",children:"H2S"})]}),u.jsxs("optgroup",{label:"X1 Series",children:[u.jsx("option",{value:"X1E",children:"X1E"}),u.jsx("option",{value:"X1C",children:"X1 Carbon"}),u.jsx("option",{value:"X1",children:"X1"})]}),u.jsxs("optgroup",{label:"P Series",children:[u.jsx("option",{value:"P2S",children:"P2S"}),u.jsx("option",{value:"P1S",children:"P1S"}),u.jsx("option",{value:"P1P",children:"P1P"})]}),u.jsxs("optgroup",{label:"A1 Series",children:[u.jsx("option",{value:"A1",children:"A1"}),u.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.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"}),u.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),u.jsxs("div",{className:"flex gap-3 pt-4",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function Qce({printer:t,onClose:e}){const n=Nn(),[r,i]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=At({mutationFn:o=>Le.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const a=o=>{o.preventDefault();const l={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(l.access_code=r.access_code),s.mutate(l)};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:u.jsxs(Ft,{children:[u.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),u.jsxs("form",{onSubmit:a,className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),u.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),u.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),u.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),u.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),u.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:o=>i({...r,model:o.target.value}),children:[u.jsx("option",{value:"",children:"Select model..."}),u.jsxs("optgroup",{label:"H2 Series",children:[u.jsx("option",{value:"H2C",children:"H2C"}),u.jsx("option",{value:"H2D",children:"H2D"}),u.jsx("option",{value:"H2S",children:"H2S"})]}),u.jsxs("optgroup",{label:"X1 Series",children:[u.jsx("option",{value:"X1E",children:"X1E"}),u.jsx("option",{value:"X1C",children:"X1 Carbon"}),u.jsx("option",{value:"X1",children:"X1"})]}),u.jsxs("optgroup",{label:"P Series",children:[u.jsx("option",{value:"P2S",children:"P2S"}),u.jsx("option",{value:"P1S",children:"P1S"}),u.jsx("option",{value:"P1P",children:"P1P"})]}),u.jsxs("optgroup",{label:"A1 Series",children:[u.jsx("option",{value:"A1",children:"A1"}),u.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),u.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),u.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),u.jsxs("div",{className:"flex gap-3 pt-4",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Jce(t){const{data:e}=Mt({queryKey:["printerStatus",t],queryFn:()=>Le.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function eue({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=Jce(t.id),{data:s}=Mt({queryKey:["smartPlugStatus",e.id],queryFn:()=>Le.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&u.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),u.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[u.jsx(dd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function tue(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=E.useState(!1),[a,o]=E.useState(null),[l,c]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,h]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),v=Nn(),{data:y,isLoading:b}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:x}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),{data:M}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs}),{data:w}=Mt({queryKey:["maintenanceOverview"],queryFn:Le.getMaintenanceOverview,staleTime:60*1e3}),A=w?.reduce((P,$)=>(P[$.printer_id]={due_count:$.due_count,warning_count:$.warning_count,total_print_hours:$.total_print_hours},P),{})||{},T=M?.reduce((P,$)=>($.printer_id&&(P[$.printer_id]=$),P),{})||{},R=At({mutationFn:Le.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),e(!1)}}),C=At({mutationFn:P=>Le.controlSmartPlug(P,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),I=()=>{const P=!n;r(P),localStorage.setItem("hideDisconnectedPrinters",String(P))},N=P=>{c(P),localStorage.setItem("printerSortBy",P)},D=()=>{const P=!d;h(P),localStorage.setItem("printerSortAsc",String(P))},z=()=>{const P=g==="expanded"?"compact":"expanded";m(P),localStorage.setItem("printerViewMode",P)},j=E.useMemo(()=>{if(!y)return[];const P=[...y];switch(l){case"name":P.sort(($,K)=>$.name.localeCompare(K.name));break;case"model":P.sort(($,K)=>($.model||"").localeCompare(K.model||""));break;case"location":P.sort(($,K)=>{const G=$.location||"",Z=K.location||"";return!G&&Z?1:G&&!Z?-1:G.localeCompare(Z)||$.name.localeCompare(K.name)});break;case"status":P.sort(($,K)=>{const G=v.getQueryData(["printerStatus",$.id]),Z=v.getQueryData(["printerStatus",K.id]),Q=ee=>ee?.connected?ee.state==="RUNNING"?0:1:2;return Q(G)-Q(Z)});break}return d||P.reverse(),P},[y,l,d,v]),W=E.useMemo(()=>{if(l!=="location")return null;const P={};return j.forEach($=>{const K=$.location||"Ungrouped";P[K]||(P[K]=[]),P[K].push($)}),P},[l,j]);return u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"flex items-center justify-between mb-6",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),u.jsx(Yce,{printers:y})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs("select",{value:l,onChange:P=>N(P.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"name",children:"Name"}),u.jsx("option",{value:"status",children:"Status"}),u.jsx("option",{value:"model",children:"Model"}),u.jsx("option",{value:"location",children:"Location"})]}),u.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?u.jsx(Yp,{className:"w-4 h-4 text-bambu-gray"}):u.jsx(e0,{className:"w-4 h-4 text-bambu-gray"})})]}),u.jsx("button",{onClick:z,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?u.jsx(Toe,{className:"w-5 h-5 text-bambu-gray"}):u.jsx(_9,{className:"w-5 h-5 text-bambu-gray"})}),u.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),u.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:n,onChange:I,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&u.jsxs("div",{className:"relative",children:[u.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[u.jsx(dd,{className:"w-4 h-4"}),"Power On",u.jsx(Qf,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),u.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[u.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),y?.filter(P=>T[P.id]).map(P=>u.jsx(eue,{printer:P,plug:T[P.id],onPowerOn:$=>{o($),C.mutate($)},isPowering:a===T[P.id]?.id},P.id)),y?.filter(P=>T[P.id]).length===0&&u.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),u.jsxs(Ue,{onClick:()=>e(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Printer"]})]})]}),b?u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"text-center py-12",children:[u.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),u.jsxs(Ue,{onClick:()=>e(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):W?u.jsx("div",{className:"space-y-6",children:Object.entries(W).map(([P,$])=>u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[u.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),P,u.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",$.length,")"]})]}),u.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:$.map(K=>u.jsx(SF,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},K.id))})]},P))}):u.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:j.map(P=>u.jsx(SF,{printer:P,hideIfDisconnected:n,maintenanceInfo:A[P.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},P.id))}),t&&u.jsx(Zce,{onClose:()=>e(!1),onAdd:P=>R.mutate(P)})]})}const hP="181",Up={ROTATE:0,DOLLY:1,PAN:2},kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},nue=0,wF=1,rue=2,D9=1,iue=2,ql=3,Qu=0,$s=1,Ko=2,dc=0,Fp=1,MF=2,EF=3,AF=4,sue=5,Yd=100,aue=101,oue=102,lue=103,cue=104,uue=200,due=201,fue=202,hue=203,ZN=204,QN=205,pue=206,mue=207,gue=208,xue=209,bue=210,vue=211,yue=212,_ue=213,Sue=214,JN=0,e3=1,t3=2,tm=3,n3=4,r3=5,i3=6,s3=7,pP=0,wue=1,Mue=2,Hu=0,Eue=1,Aue=2,Tue=3,Cue=4,Nue=5,kue=6,Rue=7,O9=300,nm=301,rm=302,a3=303,o3=304,hw=306,l3=1e3,ic=1001,c3=1002,ma=1003,Pue=1004,Gv=1005,qa=1006,J2=1007,rf=1008,sl=1009,L9=1010,j9=1011,a0=1012,mP=1013,Of=1014,sc=1015,Pm=1016,gP=1017,xP=1018,o0=1020,I9=35902,U9=35899,F9=1021,z9=1022,wo=1023,l0=1026,c0=1027,B9=1028,bP=1029,vP=1030,yP=1031,_P=1033,T_=33776,C_=33777,N_=33778,k_=33779,u3=35840,d3=35841,f3=35842,h3=35843,p3=36196,m3=37492,g3=37496,x3=37808,b3=37809,v3=37810,y3=37811,_3=37812,S3=37813,w3=37814,M3=37815,E3=37816,A3=37817,T3=37818,C3=37819,N3=37820,k3=37821,R3=36492,P3=36494,D3=36495,O3=36283,L3=36284,j3=36285,I3=36286,Due=3200,Oue=3201,H9=0,Lue=1,ku="",Fa="srgb",im="srgb-linear",s1="linear",Bn="srgb",Uh=7680,TF=519,jue=512,Iue=513,Uue=514,$9=515,Fue=516,zue=517,Bue=518,Hue=519,CF=35044,NF="300 es",Jo=2e3,a1=2001;function V9(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function o1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function $ue(){const t=o1("canvas");return t.style.display="block",t}const kF={};function RF(...t){const e="THREE."+t.shift();console.log(e,...t)}function Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Or(...t){const e="THREE."+t.shift();console.error(e,...t)}function u0(...t){const e=t.join(" ");e in kF||(kF[e]=!0,Xt(...t))}function Vue(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let Jf=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 s=i.indexOf(n);s!==-1&&i.splice(s,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 s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}};const es=["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"],R_=Math.PI/180,U3=180/Math.PI;function K0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(es[t&255]+es[t>>8&255]+es[t>>16&255]+es[t>>24&255]+"-"+es[e&255]+es[e>>8&255]+"-"+es[e>>16&15|64]+es[e>>24&255]+"-"+es[n&63|128]+es[n>>8&255]+"-"+es[n>>16&255]+es[n>>24&255]+es[r&255]+es[r>>8&255]+es[r>>16&255]+es[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function Gue(t,e){return(t%e+e)%e}function eA(t,e,n){return(1-n)*t+n*e}function Vg(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 Is(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 Wue={DEG2RAD:R_};let on=class G9{constructor(e=0,n=0){G9.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=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(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(mn(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),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Lf=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,s,a,o){let l=r[i+0],c=r[i+1],d=r[i+2],h=r[i+3],g=s[a+0],m=s[a+1],v=s[a+2],y=s[a+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=d,e[n+3]=h;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=v,e[n+3]=y;return}if(h!==y||l!==g||c!==m||d!==v){let b=l*g+c*m+d*v+h*y;b<0&&(g=-g,m=-m,v=-v,y=-y,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,d=d*x+v*o,h=h*x+y*o}else{l=l*x+g*o,c=c*x+m*o,d=d*x+v*o,h=h*x+y*o;const M=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=M,c*=M,d*=M,h*=M}}e[n]=l,e[n+1]=c,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],d=r[i+3],h=s[a],g=s[a+1],m=s[a+2],v=s[a+3];return e[n]=o*v+d*h+l*m-c*g,e[n+1]=l*v+d*g+c*h-o*m,e[n+2]=c*v+d*m+o*g-l*h,e[n+3]=d*v-o*h-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,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),d=o(i/2),h=o(s/2),g=l(r/2),m=l(i/2),v=l(s/2);switch(a){case"XYZ":this._x=g*d*h+c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h-g*m*v;break;case"YXZ":this._x=g*d*h+c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h+g*m*v;break;case"ZXY":this._x=g*d*h-c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h-g*m*v;break;case"ZYX":this._x=g*d*h-c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h+g*m*v;break;case"YZX":this._x=g*d*h+c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h-g*m*v;break;case"XZY":this._x=g*d*h-c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h+g*m*v;break;default:Xt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}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],s=n[8],a=n[1],o=n[5],l=n[9],c=n[2],d=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-c)*m,this._z=(a-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(s-c)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(a-i)/m,this._x=(s+c)/m,this._y=(l+d)/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(mn(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,s=e._z,a=e._w,o=n._x,l=n._y,c=n._z,d=n._w;return this._x=r*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-r*c,this._z=s*d+a*c+r*l-i*o,this._w=a*d-r*o-i*l-s*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,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-n;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,n=Math.sin(n*c)/d,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*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),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*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}},Xe=class W9{constructor(e=0,n=0,r=0){W9.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(PF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(PF.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);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}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),d=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+l*c+a*h-o*d,this.y=r+l*d+o*c-s*h,this.z=i+l*h+s*d-a*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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[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=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(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,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,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 tA.copy(this).projectOnVector(e),this.sub(tA)}reflect(e){return this.sub(tA.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(mn(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 tA=new Xe,PF=new Lf;let un=class q9{constructor(e,n,r,i,s,a,o,l,c){q9.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c)}set(e,n,r,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[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,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],d=r[4],h=r[7],g=r[2],m=r[5],v=r[8],y=i[0],b=i[3],x=i[6],M=i[1],w=i[4],A=i[7],T=i[2],R=i[5],C=i[8];return s[0]=a*y+o*M+l*T,s[3]=a*b+o*w+l*R,s[6]=a*x+o*A+l*C,s[1]=c*y+d*M+h*T,s[4]=c*b+d*w+h*R,s[7]=c*x+d*A+h*C,s[2]=g*y+m*M+v*T,s[5]=g*b+m*w+v*R,s[8]=g*x+m*A+v*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return n*a*d-n*o*c-r*s*d+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,g=o*l-d*s,m=c*s-a*l,v=n*h+r*g+i*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/v;return e[0]=h*y,e[1]=(i*c-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(nA.makeScale(e,n)),this}rotate(e){return this.premultiply(nA.makeRotation(-e)),this}translate(e,n){return this.premultiply(nA.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 nA=new un,DF=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),OF=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function que(){const t={enabled:!0,workingColorSpace:im,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Bn&&(i.r=fc(i.r),i.g=fc(i.g),i.b=fc(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Bn&&(i.r=zp(i.r),i.g=zp(i.g),i.b=zp(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===ku?s1:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return u0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return u0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[im]:{primaries:e,whitePoint:r,transfer:s1,toXYZ:DF,fromXYZ:OF,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Fa},outputColorSpaceConfig:{drawingBufferColorSpace:Fa}},[Fa]:{primaries:e,whitePoint:r,transfer:Bn,toXYZ:DF,fromXYZ:OF,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Fa}}}),t}const En=que();function fc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function zp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Fh,Xue=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{Fh===void 0&&(Fh=o1("canvas")),Fh.width=e.width,Fh.height=e.height;const i=Fh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Fh}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=o1("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),s=i.data;for(let a=0;a<s.length;a++)s[a]=fc(s[a]/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(fc(n[r]/255)*255):n[r]=fc(n[r]);return{data:n,width:e.width,height:e.height}}else return Xt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Kue=0,SP=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Kue++}),this.uuid=K0(),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 s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(rA(i[a].image)):s.push(rA(i[a]))}else s=rA(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function rA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Xue.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Xt("Texture: Unable to serialize Texture."),{})}let Yue=0;const iA=new Xe;let Oo=class P_ extends Jf{constructor(e=P_.DEFAULT_IMAGE,n=P_.DEFAULT_MAPPING,r=ic,i=ic,s=qa,a=rf,o=wo,l=sl,c=P_.DEFAULT_ANISOTROPY,d=ku){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Yue++}),this.uuid=K0(),this.name="",this.source=new SP(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new on(0,0),this.repeat=new on(1,1),this.center=new on(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(iA).x}get height(){return this.source.getSize(iA).y}get depth(){return this.source.getSize(iA).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){Xt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`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!==O9)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case l3:e.x=e.x-Math.floor(e.x);break;case ic:e.x=e.x<0?0:1;break;case c3: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 l3:e.y=e.y-Math.floor(e.y);break;case ic:e.y=e.y<0?0:1;break;case c3: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++}};Oo.DEFAULT_IMAGE=null;Oo.DEFAULT_MAPPING=O9;Oo.DEFAULT_ANISOTROPY=1;let Gr=class X9{constructor(e=0,n=0,r=0,i=1){X9.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,s=this.w,a=e.elements;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.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,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,s;const l=e.elements,c=l[0],d=l[4],h=l[8],g=l[1],m=l[5],v=l[9],y=l[2],b=l[6],x=l[10];if(Math.abs(d-g)<.01&&Math.abs(h-y)<.01&&Math.abs(v-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(h+y)<.1&&Math.abs(v+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=(d+g)/4,C=(h+y)/4,I=(v+b)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),i=R/r,s=C/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=R/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=C/s,i=I/s),this.set(r,i,s,n),this}let M=Math.sqrt((b-v)*(b-v)+(h-y)*(h-y)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(b-v)/M,this.y=(h-y)/M,this.z=(g-d)/M,this.w=Math.acos((c+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this.w=mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this.w=mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(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}},Zue=class extends Jf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qa,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 Gr(0,0,e,n),this.scissorTest=!1,this.viewport=new Gr(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new Oo(i);this.textures=[];const a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.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:qa,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,s=this.textures.length;i<s;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 SP(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"})}},jf=class extends Zue{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},K9=class extends Oo{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=ma,this.minFilter=ma,this.wrapR=ic,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Que=class extends Oo{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=ma,this.minFilter=ma,this.wrapR=ic,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},If=class{constructor(e=new Xe(1/0,1/0,1/0),n=new Xe(-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 s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,uo):uo.fromBufferAttribute(s,a),uo.applyMatrix4(e.matrixWorld),this.expandByPoint(uo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Wv.copy(r.boundingBox)),Wv.applyMatrix4(e.matrixWorld),this.union(Wv)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],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(Gg),qv.subVectors(this.max,Gg),zh.subVectors(e.a,Gg),Bh.subVectors(e.b,Gg),Hh.subVectors(e.c,Gg),ou.subVectors(Bh,zh),lu.subVectors(Hh,Bh),Od.subVectors(zh,Hh);let n=[0,-ou.z,ou.y,0,-lu.z,lu.y,0,-Od.z,Od.y,ou.z,0,-ou.x,lu.z,0,-lu.x,Od.z,0,-Od.x,-ou.y,ou.x,0,-lu.y,lu.x,0,-Od.y,Od.x,0];return!sA(n,zh,Bh,Hh,qv)||(n=[1,0,0,0,1,0,0,0,1],!sA(n,zh,Bh,Hh,qv))?!1:(Xv.crossVectors(ou,lu),n=[Xv.x,Xv.y,Xv.z],sA(n,zh,Bh,Hh,qv))}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:(Dl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dl),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 Dl=[new Xe,new Xe,new Xe,new Xe,new Xe,new Xe,new Xe,new Xe],uo=new Xe,Wv=new If,zh=new Xe,Bh=new Xe,Hh=new Xe,ou=new Xe,lu=new Xe,Od=new Xe,Gg=new Xe,qv=new Xe,Xv=new Xe,Ld=new Xe;function sA(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Ld.fromArray(t,s);const o=i.x*Math.abs(Ld.x)+i.y*Math.abs(Ld.y)+i.z*Math.abs(Ld.z),l=e.dot(Ld),c=n.dot(Ld),d=r.dot(Ld);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const Jue=new If,Wg=new Xe,aA=new Xe;let pw=class{constructor(e=new Xe,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):Jue.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));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;Wg.subVectors(e,this.center);const n=Wg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Wg,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):(aA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Wg.copy(e.center).add(aA)),this.expandByPoint(Wg.copy(e.center).sub(aA))),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 Ol=new Xe,oA=new Xe,Kv=new Xe,cu=new Xe,lA=new Xe,Yv=new Xe,cA=new Xe;let wP=class{constructor(e=new Xe,n=new Xe(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,Ol)),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=Ol.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ol.copy(this.origin).addScaledVector(this.direction,n),Ol.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){oA.copy(e).add(n).multiplyScalar(.5),Kv.copy(n).sub(e).normalize(),cu.copy(this.origin).sub(oA);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Kv),o=cu.dot(this.direction),l=-cu.dot(Kv),c=cu.lengthSq(),d=Math.abs(1-a*a);let h,g,m,v;if(d>0)if(h=a*l-o,g=a*o-l,v=s*d,h>=0)if(g>=-v)if(g<=v){const y=1/d;h*=y,g*=y,m=h*(h+a*g+2*o)+g*(a*h+g+2*l)+c}else g=s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g=-s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-v?(h=Math.max(0,-(-a*s+o)),g=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c):g<=v?(h=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+c):(h=Math.max(0,-(a*s+o)),g=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c);else g=a>0?-s:s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(oA).addScaledVector(Kv,g),m}intersectSphere(e,n){Ol.subVectors(e.center,this.origin);const r=Ol.dot(this.direction),i=Ol.dot(Ol)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;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,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=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),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),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,Ol)!==null}intersectTriangle(e,n,r,i,s){lA.subVectors(n,e),Yv.subVectors(r,e),cA.crossVectors(lA,Yv);let a=this.direction.dot(cA),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;cu.subVectors(this.origin,e);const l=o*this.direction.dot(Yv.crossVectors(cu,Yv));if(l<0)return null;const c=o*this.direction.dot(lA.cross(cu));if(c<0||l+c>a)return null;const d=-o*cu.dot(cA);return d<0?null:this.at(d/a,s)}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)}},Yr=class F3{constructor(e,n,r,i,s,a,o,l,c,d,h,g,m,v,y,b){F3.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,s,a,o,l,c,d,h,g,m,v,y,b)}set(e,n,r,i,s,a,o,l,c,d,h,g,m,v,y,b){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=s,x[5]=a,x[9]=o,x[13]=l,x[2]=c,x[6]=d,x[10]=h,x[14]=g,x[3]=m,x[7]=v,x[11]=y,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 F3().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/$h.setFromMatrixColumn(e,0).length(),s=1/$h.setFromMatrixColumn(e,1).length(),a=1/$h.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]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,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,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*h,v=o*d,y=o*h;n[0]=l*d,n[4]=-l*h,n[8]=c,n[1]=m+v*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=v+m*c,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*h,v=c*d,y=c*h;n[0]=g+y*o,n[4]=v*o-m,n[8]=a*c,n[1]=a*h,n[5]=a*d,n[9]=-o,n[2]=m*o-v,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*h,v=c*d,y=c*h;n[0]=g-y*o,n[4]=-a*h,n[8]=v+m*o,n[1]=m+v*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*c,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*h,v=o*d,y=o*h;n[0]=l*d,n[4]=v*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-v,n[2]=-c,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*c,v=o*l,y=o*c;n[0]=l*d,n[4]=y-g*h,n[8]=v*h+m,n[1]=h,n[5]=a*d,n[9]=-o*d,n[2]=-c*d,n[6]=m*h+v,n[10]=g-y*h}else if(e.order==="XZY"){const g=a*l,m=a*c,v=o*l,y=o*c;n[0]=l*d,n[4]=-h,n[8]=c*d,n[1]=g*h+y,n[5]=a*d,n[9]=m*h-v,n[2]=v*h-m,n[6]=o*d,n[10]=y*h+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(ede,e,tde)}lookAt(e,n,r){const i=this.elements;return aa.subVectors(e,n),aa.lengthSq()===0&&(aa.z=1),aa.normalize(),uu.crossVectors(r,aa),uu.lengthSq()===0&&(Math.abs(r.z)===1?aa.x+=1e-4:aa.z+=1e-4,aa.normalize(),uu.crossVectors(r,aa)),uu.normalize(),Zv.crossVectors(aa,uu),i[0]=uu.x,i[4]=Zv.x,i[8]=aa.x,i[1]=uu.y,i[5]=Zv.y,i[9]=aa.y,i[2]=uu.z,i[6]=Zv.z,i[10]=aa.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,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],d=r[1],h=r[5],g=r[9],m=r[13],v=r[2],y=r[6],b=r[10],x=r[14],M=r[3],w=r[7],A=r[11],T=r[15],R=i[0],C=i[4],I=i[8],N=i[12],D=i[1],z=i[5],j=i[9],W=i[13],P=i[2],$=i[6],K=i[10],G=i[14],Z=i[3],Q=i[7],ee=i[11],H=i[15];return s[0]=a*R+o*D+l*P+c*Z,s[4]=a*C+o*z+l*$+c*Q,s[8]=a*I+o*j+l*K+c*ee,s[12]=a*N+o*W+l*G+c*H,s[1]=d*R+h*D+g*P+m*Z,s[5]=d*C+h*z+g*$+m*Q,s[9]=d*I+h*j+g*K+m*ee,s[13]=d*N+h*W+g*G+m*H,s[2]=v*R+y*D+b*P+x*Z,s[6]=v*C+y*z+b*$+x*Q,s[10]=v*I+y*j+b*K+x*ee,s[14]=v*N+y*W+b*G+x*H,s[3]=M*R+w*D+A*P+T*Z,s[7]=M*C+w*z+A*$+T*Q,s[11]=M*I+w*j+A*K+T*ee,s[15]=M*N+w*W+A*G+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],g=e[10],m=e[14],v=e[3],y=e[7],b=e[11],x=e[15];return v*(+s*l*h-i*c*h-s*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+s*a*g-i*a*m+i*c*d-s*l*d)+b*(+n*c*h-n*o*m-s*a*h+r*a*m+s*o*d-r*c*d)+x*(-i*o*d-n*l*h+n*o*g+i*a*h-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],g=e[10],m=e[11],v=e[12],y=e[13],b=e[14],x=e[15],M=h*b*c-y*g*c+y*l*m-o*b*m-h*l*x+o*g*x,w=v*g*c-d*b*c-v*l*m+a*b*m+d*l*x-a*g*x,A=d*y*c-v*h*c+v*o*m-a*y*m-d*o*x+a*h*x,T=v*h*l-d*y*l-v*o*g+a*y*g+d*o*b-a*h*b,R=n*M+r*w+i*A+s*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/R;return e[0]=M*C,e[1]=(y*g*s-h*b*s-y*i*m+r*b*m+h*i*x-r*g*x)*C,e[2]=(o*b*s-y*l*s+y*i*c-r*b*c-o*i*x+r*l*x)*C,e[3]=(h*l*s-o*g*s-h*i*c+r*g*c+o*i*m-r*l*m)*C,e[4]=w*C,e[5]=(d*b*s-v*g*s+v*i*m-n*b*m-d*i*x+n*g*x)*C,e[6]=(v*l*s-a*b*s-v*i*c+n*b*c+a*i*x-n*l*x)*C,e[7]=(a*g*s-d*l*s+d*i*c-n*g*c-a*i*m+n*l*m)*C,e[8]=A*C,e[9]=(v*h*s-d*y*s-v*r*m+n*y*m+d*r*x-n*h*x)*C,e[10]=(a*y*s-v*o*s+v*r*c-n*y*c-a*r*x+n*o*x)*C,e[11]=(d*o*s-a*h*s-d*r*c+n*h*c+a*r*m-n*o*m)*C,e[12]=T*C,e[13]=(d*y*i-v*h*i+v*r*g-n*y*g-d*r*b+n*h*b)*C,e[14]=(v*o*i-a*y*i-v*r*l+n*y*l+a*r*b-n*o*b)*C,e[15]=(a*h*i-d*o*i+d*r*l-n*h*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,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),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+r,d*l-i*a,0,c*l-i*o,d*l+i*a,s*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,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,c=s+s,d=a+a,h=o+o,g=s*c,m=s*d,v=s*h,y=a*d,b=a*h,x=o*h,M=l*c,w=l*d,A=l*h,T=r.x,R=r.y,C=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+A)*T,i[2]=(v-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]=(v+w)*C,i[9]=(b-M)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=$h.set(i[0],i[1],i[2]).length();const a=$h.set(i[4],i[5],i[6]).length(),o=$h.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],fo.copy(this);const c=1/s,d=1/a,h=1/o;return fo.elements[0]*=c,fo.elements[1]*=c,fo.elements[2]*=c,fo.elements[4]*=d,fo.elements[5]*=d,fo.elements[6]*=d,fo.elements[8]*=h,fo.elements[9]*=h,fo.elements[10]*=h,n.setFromRotationMatrix(fo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=Jo,l=!1){const c=this.elements,d=2*s/(n-e),h=2*s/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let v,y;if(l)v=s/(a-s),y=a*s/(a-s);else if(o===Jo)v=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===a1)v=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=h,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=v,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=Jo,l=!1){const c=this.elements,d=2/(n-e),h=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let v,y;if(l)v=1/(a-s),y=a/(a-s);else if(o===Jo)v=-2/(a-s),y=-(a+s)/(a-s);else if(o===a1)v=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=h,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=v,c[14]=y,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 $h=new Xe,fo=new Yr,ede=new Xe(0,0,0),tde=new Xe(1,1,1),uu=new Xe,Zv=new Xe,aa=new Xe,LF=new Yr,jF=new Lf;let Ju=class Y9{constructor(e=0,n=0,r=0,i=Y9.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,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-mn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-mn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return LF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(LF,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return jF.setFromEuler(this),this.setFromQuaternion(jF,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}};Ju.DEFAULT_ORDER="XYZ";let Z9=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}},nde=0;const IF=new Xe,Vh=new Lf,Ll=new Yr,Qv=new Xe,qg=new Xe,rde=new Xe,ide=new Lf,UF=new Xe(1,0,0),FF=new Xe(0,1,0),zF=new Xe(0,0,1),BF={type:"added"},sde={type:"removed"},Gh={type:"childadded",child:null},uA={type:"childremoved",child:null};let ya=class D_ extends Jf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:nde++}),this.uuid=K0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=D_.DEFAULT_UP.clone();const e=new Xe,n=new Ju,r=new Lf,i=new Xe(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),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 Yr},normalMatrix:{value:new un}}),this.matrix=new Yr,this.matrixWorld=new Yr,this.matrixAutoUpdate=D_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=D_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Z9,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 Vh.setFromAxisAngle(e,n),this.quaternion.multiply(Vh),this}rotateOnWorldAxis(e,n){return Vh.setFromAxisAngle(e,n),this.quaternion.premultiply(Vh),this}rotateX(e){return this.rotateOnAxis(UF,e)}rotateY(e){return this.rotateOnAxis(FF,e)}rotateZ(e){return this.rotateOnAxis(zF,e)}translateOnAxis(e,n){return IF.copy(e).applyQuaternion(this.quaternion),this.position.add(IF.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(UF,e)}translateY(e){return this.translateOnAxis(FF,e)}translateZ(e){return this.translateOnAxis(zF,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ll.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Qv.copy(e):Qv.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),qg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ll.lookAt(qg,Qv,this.up):Ll.lookAt(Qv,qg,this.up),this.quaternion.setFromRotationMatrix(Ll),i&&(Ll.extractRotation(i.matrixWorld),Vh.setFromRotationMatrix(Ll),this.quaternion.premultiply(Vh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Or("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(BF),Gh.child=e,this.dispatchEvent(Gh),Gh.child=null):Or("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(sde),uA.child=e,this.dispatchEvent(uA),uA.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),Ll.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ll.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ll),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(BF),Gh.child=e,this.dispatchEvent(Gh),Gh.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 a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].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(qg,e,rde),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qg,ide,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 s=0,a=i.length;s<a;s++)i[s].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 s(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=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(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(s(e.materials,this.material[l]));i.material=o}else i.material=s(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(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),g=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),v.length>0&&(r.nodes=v)}return r.object=i,r;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};ya.DEFAULT_UP=new Xe(0,1,0);ya.DEFAULT_MATRIX_AUTO_UPDATE=!0;ya.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ho=new Xe,jl=new Xe,dA=new Xe,Il=new Xe,Wh=new Xe,qh=new Xe,HF=new Xe,fA=new Xe,hA=new Xe,pA=new Xe,mA=new Gr,gA=new Gr,xA=new Gr;let Xg=class Mp{constructor(e=new Xe,n=new Xe,r=new Xe){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 s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){ho.subVectors(i,n),jl.subVectors(r,n),dA.subVectors(e,n);const a=ho.dot(ho),o=ho.dot(jl),l=ho.dot(dA),c=jl.dot(jl),d=jl.dot(dA),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const g=1/h,m=(c*l-o*d)*g,v=(a*d-o*l)*g;return s.set(1-m-v,v,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Il)===null?!1:Il.x>=0&&Il.y>=0&&Il.x+Il.y<=1}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,Il)===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(s,Il.x),l.addScaledVector(a,Il.y),l.addScaledVector(o,Il.z),l)}static getInterpolatedAttribute(e,n,r,i,s,a){return mA.setScalar(0),gA.setScalar(0),xA.setScalar(0),mA.fromBufferAttribute(e,n),gA.fromBufferAttribute(e,r),xA.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(mA,s.x),a.addScaledVector(gA,s.y),a.addScaledVector(xA,s.z),a}static isFrontFacing(e,n,r,i){return ho.subVectors(r,n),jl.subVectors(e,n),ho.cross(jl).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),jl.subVectors(this.a,this.b),ho.cross(jl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Mp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Mp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Mp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Mp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;Wh.subVectors(i,r),qh.subVectors(s,r),fA.subVectors(e,r);const l=Wh.dot(fA),c=qh.dot(fA);if(l<=0&&c<=0)return n.copy(r);hA.subVectors(e,i);const d=Wh.dot(hA),h=qh.dot(hA);if(d>=0&&h<=d)return n.copy(i);const g=l*h-d*c;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(Wh,a);pA.subVectors(e,s);const m=Wh.dot(pA),v=qh.dot(pA);if(v>=0&&m<=v)return n.copy(s);const y=m*c-l*v;if(y<=0&&c>=0&&v<=0)return o=c/(c-v),n.copy(r).addScaledVector(qh,o);const b=d*v-m*h;if(b<=0&&h-d>=0&&m-v>=0)return HF.subVectors(s,i),o=(h-d)/(h-d+(m-v)),n.copy(i).addScaledVector(HF,o);const x=1/(b+y+g);return a=y*x,o=g*x,n.copy(r).addScaledVector(Wh,a).addScaledVector(qh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const Q9={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},du={h:0,s:0,l:0},Jv={h:0,s:0,l:0};function bA(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let vn=class{constructor(e,n,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=Fa){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=Gue(e,1),n=mn(n,0,1),r=mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=bA(a,s,e+1/3),this.g=bA(a,s,e),this.b=bA(a,s,e-1/3)}return En.colorSpaceToWorking(this,i),this}setStyle(e,n=Fa){function r(s){s!==void 0&&parseFloat(s)<1&&Xt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Xt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);Xt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Fa){const r=Q9[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Xt("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=fc(e.r),this.g=fc(e.g),this.b=fc(e.b),this}copyLinearToSRGB(e){return this.r=zp(e.r),this.g=zp(e.g),this.b=zp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fa){return En.workingToColorSpace(ts.copy(this),e),Math.round(mn(ts.r*255,0,255))*65536+Math.round(mn(ts.g*255,0,255))*256+Math.round(mn(ts.b*255,0,255))}getHexString(e=Fa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=En.workingColorSpace){En.workingToColorSpace(ts.copy(this),n);const r=ts.r,i=ts.g,s=ts.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,n=En.workingColorSpace){return En.workingToColorSpace(ts.copy(this),n),e.r=ts.r,e.g=ts.g,e.b=ts.b,e}getStyle(e=Fa){En.workingToColorSpace(ts.copy(this),e);const n=ts.r,r=ts.g,i=ts.b;return e!==Fa?`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(du),this.setHSL(du.h+e,du.s+n,du.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(du),e.getHSL(Jv);const r=eA(du.h,Jv.h,n),i=eA(du.s,Jv.s,n),s=eA(du.l,Jv.l,n);return this.setHSL(r,i,s),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,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[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 ts=new vn;vn.NAMES=Q9;let ade=0,Dm=class extends Jf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ade++}),this.uuid=K0(),this.name="",this.type="Material",this.blending=Fp,this.side=Qu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ZN,this.blendDst=QN,this.blendEquation=Yd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vn(0,0,0),this.blendAlpha=0,this.depthFunc=tm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=TF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Uh,this.stencilZFail=Uh,this.stencilZPass=Uh,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){Xt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`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!==Fp&&(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!==ZN&&(r.blendSrc=this.blendSrc),this.blendDst!==QN&&(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!==tm&&(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!==TF&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Uh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Uh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Uh&&(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(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}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 s=0;s!==i;++s)r[s]=n[s].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++}},MP=class extends Dm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ju,this.combine=pP,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 Hr=new Xe,ey=new on;let ode=0,Ya=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:ode++}),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=sc,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,s=this.itemSize;i<s;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++)ey.fromBufferAttribute(this,n),ey.applyMatrix3(e),this.setXY(n,ey.x,ey.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix3(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix4(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyNormalMatrix(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.transformDirection(e),this.setXYZ(n,Hr.x,Hr.y,Hr.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=Vg(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Is(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Vg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Is(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Vg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Is(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=Vg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Is(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=Vg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Is(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Is(n,this.array),r=Is(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=Is(n,this.array),r=Is(r,this.array),i=Is(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Is(n,this.array),r=Is(r,this.array),i=Is(i,this.array),s=Is(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,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}},J9=class extends Ya{constructor(e,n,r){super(new Uint16Array(e),n,r)}},e7=class extends Ya{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ao=class extends Ya{constructor(e,n,r){super(new Float32Array(e),n,r)}},lde=0;const ka=new Yr,vA=new ya,Xh=new Xe,oa=new If,Kg=new If,wi=new Xe;let pl=class t7 extends Jf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:lde++}),this.uuid=K0(),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(V9(e)?e7:J9)(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 s=new un().getNormalMatrix(e);r.applyNormalMatrix(s),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 ka.makeRotationFromQuaternion(e),this.applyMatrix4(ka),this}rotateX(e){return ka.makeRotationX(e),this.applyMatrix4(ka),this}rotateY(e){return ka.makeRotationY(e),this.applyMatrix4(ka),this}rotateZ(e){return ka.makeRotationZ(e),this.applyMatrix4(ka),this}translate(e,n,r){return ka.makeTranslation(e,n,r),this.applyMatrix4(ka),this}scale(e,n,r){return ka.makeScale(e,n,r),this.applyMatrix4(ka),this}lookAt(e){return vA.lookAt(e),vA.updateMatrix(),this.applyMatrix4(vA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xh).negate(),this.translate(Xh.x,Xh.y,Xh.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ao(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&Xt("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 If);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Or("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Xe(-1/0,-1/0,-1/0),new Xe(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 s=n[r];oa.setFromBufferAttribute(s),this.morphTargetsRelative?(wi.addVectors(this.boundingBox.min,oa.min),this.boundingBox.expandByPoint(wi),wi.addVectors(this.boundingBox.max,oa.max),this.boundingBox.expandByPoint(wi)):(this.boundingBox.expandByPoint(oa.min),this.boundingBox.expandByPoint(oa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Or('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 pw);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Or("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Xe,1/0);return}if(e){const r=this.boundingSphere.center;if(oa.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];Kg.setFromBufferAttribute(o),this.morphTargetsRelative?(wi.addVectors(oa.min,Kg.min),oa.expandByPoint(wi),wi.addVectors(oa.max,Kg.max),oa.expandByPoint(wi)):(oa.expandByPoint(Kg.min),oa.expandByPoint(Kg.max))}oa.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)wi.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(wi));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)wi.fromBufferAttribute(o,c),l&&(Xh.fromBufferAttribute(e,c),wi.add(Xh)),i=Math.max(i,r.distanceToSquared(wi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Or('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){Or("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ya(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<r.count;I++)o[I]=new Xe,l[I]=new Xe;const c=new Xe,d=new Xe,h=new Xe,g=new on,m=new on,v=new on,y=new Xe,b=new Xe;function x(I,N,D){c.fromBufferAttribute(r,I),d.fromBufferAttribute(r,N),h.fromBufferAttribute(r,D),g.fromBufferAttribute(s,I),m.fromBufferAttribute(s,N),v.fromBufferAttribute(s,D),d.sub(c),h.sub(c),m.sub(g),v.sub(g);const z=1/(m.x*v.y-v.x*m.y);isFinite(z)&&(y.copy(d).multiplyScalar(v.y).addScaledVector(h,-m.y).multiplyScalar(z),b.copy(h).multiplyScalar(m.x).addScaledVector(d,-v.x).multiplyScalar(z),o[I].add(y),o[N].add(y),o[D].add(y),l[I].add(b),l[N].add(b),l[D].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let I=0,N=M.length;I<N;++I){const D=M[I],z=D.start,j=D.count;for(let W=z,P=z+j;W<P;W+=3)x(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const w=new Xe,A=new Xe,T=new Xe,R=new Xe;function C(I){T.fromBufferAttribute(i,I),R.copy(T);const N=o[I];w.copy(N),w.sub(T.multiplyScalar(T.dot(N))).normalize(),A.crossVectors(R,N);const z=A.dot(l[I])<0?-1:1;a.setXYZW(I,w.x,w.y,w.z,z)}for(let I=0,N=M.length;I<N;++I){const D=M[I],z=D.start,j=D.count;for(let W=z,P=z+j;W<P;W+=3)C(e.getX(W+0)),C(e.getX(W+1)),C(e.getX(W+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ya(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 Xe,s=new Xe,a=new Xe,o=new Xe,l=new Xe,c=new Xe,d=new Xe,h=new Xe;if(e)for(let g=0,m=e.count;g<m;g+=3){const v=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,b),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(r,v),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,b),o.add(d),l.add(d),c.add(d),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(y,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),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)wi.fromBufferAttribute(e,n),wi.normalize(),e.setXYZ(n,wi.x,wi.y,wi.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,g=new c.constructor(l.length*d);let m=0,v=0;for(let y=0,b=l.length;y<b;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let x=0;x<d;x++)g[v++]=c[m++]}return new Ya(g,d,h)}if(this.index===null)return Xt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new t7,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 s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const g=c[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[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 s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));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 d=i[c];this.setAttribute(c,d.clone(n))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let g=0,m=h.length;g<m;g++)d.push(h[g].clone(n));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.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 $F=new Yr,jd=new wP,ty=new pw,VF=new Xe,ny=new Xe,ry=new Xe,iy=new Xe,yA=new Xe,sy=new Xe,GF=new Xe,ay=new Xe;let al=class extends ya{constructor(e=new pl,n=new MP){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){sy.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(yA.fromBufferAttribute(h,e),a?sy.addScaledVector(yA,d):sy.addScaledVector(yA.sub(n),d))}n.add(sy)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),ty.copy(r.boundingSphere),ty.applyMatrix4(s),jd.copy(e.ray).recast(e.near),!(ty.containsPoint(jd.origin)===!1&&(jd.intersectSphere(ty,VF)===null||jd.origin.distanceToSquared(VF)>(e.far-e.near)**2))&&($F.copy(s).invert(),jd.copy(e.ray).applyMatrix4($F),!(r.boundingBox!==null&&jd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,jd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,y=g.length;v<y;v++){const b=g[v],x=a[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),C=o.getX(A+1),I=o.getX(A+2);i=oy(this,x,e,r,c,d,h,R,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let b=v,x=y;b<x;b+=3){const M=o.getX(b),w=o.getX(b+1),A=o.getX(b+2);i=oy(this,a,e,r,c,d,h,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let v=0,y=g.length;v<y;v++){const b=g[v],x=a[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,C=A+1,I=A+2;i=oy(this,x,e,r,c,d,h,R,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let b=v,x=y;b<x;b+=3){const M=b,w=b+1,A=b+2;i=oy(this,a,e,r,c,d,h,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function cde(t,e,n,r,i,s,a,o){let l;if(e.side===$s?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===Qu,o),l===null)return null;ay.copy(o),ay.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(ay);return c<n.near||c>n.far?null:{distance:c,point:ay.clone(),object:t}}function oy(t,e,n,r,i,s,a,o,l,c){t.getVertexPosition(o,ny),t.getVertexPosition(l,ry),t.getVertexPosition(c,iy);const d=cde(t,e,n,r,ny,ry,iy,GF);if(d){const h=new Xe;Xg.getBarycoord(GF,ny,ry,iy,h),i&&(d.uv=Xg.getInterpolatedAttribute(i,o,l,c,h,new on)),s&&(d.uv1=Xg.getInterpolatedAttribute(s,o,l,c,h,new on)),a&&(d.normal=Xg.getInterpolatedAttribute(a,o,l,c,h,new Xe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:l,c,normal:new Xe,materialIndex:0};Xg.getNormal(ny,ry,iy,g.normal),d.face=g,d.barycoord=h}return d}let EP=class n7 extends pl{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let g=0,m=0;v("z","y","x",-1,-1,r,n,e,a,s,0),v("z","y","x",1,-1,r,n,-e,a,s,1),v("x","z","y",1,1,e,r,n,i,a,2),v("x","z","y",1,-1,e,r,-n,i,a,3),v("x","y","z",1,-1,e,n,r,i,s,4),v("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Ao(c,3)),this.setAttribute("normal",new Ao(d,3)),this.setAttribute("uv",new Ao(h,2));function v(y,b,x,M,w,A,T,R,C,I,N){const D=A/C,z=T/I,j=A/2,W=T/2,P=R/2,$=C+1,K=I+1;let G=0,Z=0;const Q=new Xe;for(let ee=0;ee<K;ee++){const H=ee*z-W;for(let q=0;q<$;q++){const te=q*D-j;Q[y]=te*M,Q[b]=H*w,Q[x]=P,c.push(Q.x,Q.y,Q.z),Q[y]=0,Q[b]=0,Q[x]=R>0?1:-1,d.push(Q.x,Q.y,Q.z),h.push(q/C),h.push(1-ee/I),G+=1}}for(let ee=0;ee<I;ee++)for(let H=0;H<C;H++){const q=g+H+$*ee,te=g+H+$*(ee+1),ae=g+(H+1)+$*(ee+1),xe=g+(H+1)+$*ee;l.push(q,te,xe),l.push(te,ae,xe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n7(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function sm(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?(Xt("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 gs(t){const e={};for(let n=0;n<t.length;n++){const r=sm(t[n]);for(const i in r)e[i]=r[i]}return e}function ude(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function r7(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:En.workingColorSpace}const dde={clone:sm,merge:gs};var fde=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,hde=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let yc=class extends Dm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=fde,this.fragmentShader=hde,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=sm(e.uniforms),this.uniformsGroups=ude(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 a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}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}},i7=class extends ya{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Yr,this.projectionMatrix=new Yr,this.projectionMatrixInverse=new Yr,this.coordinateSystem=Jo,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const fu=new Xe,WF=new on,qF=new on;let Ha=class extends i7{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=U3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(R_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return U3*2*Math.atan(Math.tan(R_*.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){fu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(fu.x,fu.y).multiplyScalar(-e/fu.z),fu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(fu.x,fu.y).multiplyScalar(-e/fu.z)}getViewSize(e,n){return this.getViewBounds(e,WF,qF),n.subVectors(qF,WF)}setViewOffset(e,n,r,i,s,a){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=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(R_*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/c,i*=a.width/l,r*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+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 Kh=-90,Yh=1;let pde=class extends ya{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ha(Kh,Yh,e,n);i.layers=this.layers,this.add(i);const s=new Ha(Kh,Yh,e,n);s.layers=this.layers,this.add(s);const a=new Ha(Kh,Yh,e,n);a.layers=this.layers,this.add(a);const o=new Ha(Kh,Yh,e,n);o.layers=this.layers,this.add(o);const l=new Ha(Kh,Yh,e,n);l.layers=this.layers,this.add(l);const c=new Ha(Kh,Yh,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const c of n)this.remove(c);if(e===Jo)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.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===a1)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.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[s,a,o,l,c,d]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,g,m),e.xr.enabled=v,r.texture.needsPMREMUpdate=!0}},s7=class extends Oo{constructor(e=[],n=nm,r,i,s,a,o,l,c,d){super(e,n,r,i,s,a,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},mde=class extends jf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new s7(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 EP(5,5,5),s=new yc({name:"CubemapFromEquirect",uniforms:sm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:$s,blending:dc});s.uniforms.tEquirect.value=n;const a=new al(i,s),o=n.minFilter;return n.minFilter===rf&&(n.minFilter=qa),new pde(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}},mx=class extends ya{constructor(){super(),this.isGroup=!0,this.type="Group"}};const gde={type:"move"};let _A=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new mx,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 mx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Xe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Xe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new mx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Xe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Xe),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,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),x=this._getHandJoint(c,y);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 d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=d.position.distanceTo(h.position),m=.02,v=.005;c.inputState.pinching&&g>m+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),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(gde)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new mx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},xde=class extends ya{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 Ju,this.environmentIntensity=1,this.environmentRotation=new Ju,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}},bde=class extends Oo{constructor(e=null,n=1,r=1,i,s,a,o,l,c=ma,d=ma,h,g){super(null,a,o,l,c,d,i,s,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const SA=new Xe,vde=new Xe,yde=new un;let Su=class{constructor(e=new Xe(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=SA.subVectors(r,n).cross(vde.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(SA),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}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||yde.getNormalMatrix(e),i=this.coplanarPoint(SA).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Id=new pw,_de=new on(.5,.5),ly=new Xe;let AP=class{constructor(e=new Su,n=new Su,r=new Su,i=new Su,s=new Su,a=new Su){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),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=Jo,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],d=s[4],h=s[5],g=s[6],m=s[7],v=s[8],y=s[9],b=s[10],x=s[11],M=s[12],w=s[13],A=s[14],T=s[15];if(i[0].setComponents(c-a,m-d,x-v,T-M).normalize(),i[1].setComponents(c+a,m+d,x+v,T+M).normalize(),i[2].setComponents(c+o,m+h,x+y,T+w).normalize(),i[3].setComponents(c-o,m-h,x-y,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===Jo)i[5].setComponents(c+l,m+g,x+b,T+A).normalize();else if(n===a1)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(),Id.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Id.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Id)}intersectsSprite(e){Id.center.set(0,0,0);const n=_de.distanceTo(e.center);return Id.radius=.7071067811865476+n,Id.applyMatrix4(e.matrixWorld),this.intersectsSphere(Id)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].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(ly.x=i.normal.x>0?e.max.x:e.min.x,ly.y=i.normal.y>0?e.max.y:e.min.y,ly.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ly)<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)}},a7=class extends Dm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new vn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const l1=new Xe,c1=new Xe,XF=new Yr,Yg=new wP,cy=new pw,wA=new Xe,KF=new Xe;let Sde=class extends ya{constructor(e=new pl,n=new a7){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,s=n.count;i<s;i++)l1.fromBufferAttribute(n,i-1),c1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=l1.distanceTo(c1);e.setAttribute("lineDistance",new Ao(r,1))}else Xt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),cy.copy(r.boundingSphere),cy.applyMatrix4(i),cy.radius+=s,e.ray.intersectsSphere(cy)===!1)return;XF.copy(i).invert(),Yg.copy(e.ray).applyMatrix4(XF);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const m=Math.max(0,a.start),v=Math.min(d.count,a.start+a.count);for(let y=m,b=v-1;y<b;y+=c){const x=d.getX(y),M=d.getX(y+1),w=uy(this,e,Yg,l,x,M,y);w&&n.push(w)}if(this.isLineLoop){const y=d.getX(v-1),b=d.getX(m),x=uy(this,e,Yg,l,y,b,v-1);x&&n.push(x)}}else{const m=Math.max(0,a.start),v=Math.min(g.count,a.start+a.count);for(let y=m,b=v-1;y<b;y+=c){const x=uy(this,e,Yg,l,y,y+1,y);x&&n.push(x)}if(this.isLineLoop){const y=uy(this,e,Yg,l,v-1,m,v-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function uy(t,e,n,r,i,s,a){const o=t.geometry.attributes.position;if(l1.fromBufferAttribute(o,i),c1.fromBufferAttribute(o,s),n.distanceSqToSegment(l1,c1,wA,KF)>r)return;wA.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(wA);if(!(c<e.near||c>e.far))return{distance:c,point:KF.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const YF=new Xe,ZF=new Xe;let wde=class extends Sde{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,s=n.count;i<s;i+=2)YF.fromBufferAttribute(n,i),ZF.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+YF.distanceTo(ZF);e.setAttribute("lineDistance",new Ao(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},o7=class extends Oo{constructor(e,n,r=Of,i,s,a,o=ma,l=ma,c,d=l0,h=1){if(d!==l0&&d!==c0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:h};super(g,i,s,a,o,l,d,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new SP(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 l7 extends Oo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let TP=class c7 extends pl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,d=l+1,h=e/o,g=n/l,m=[],v=[],y=[],b=[];for(let x=0;x<d;x++){const M=x*g-a;for(let w=0;w<c;w++){const A=w*h-s;v.push(A,-M,0),y.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 Ao(v,3)),this.setAttribute("normal",new Ao(y,3)),this.setAttribute("uv",new Ao(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new c7(e.width,e.height,e.widthSegments,e.heightSegments)}};class Mde extends Dm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new vn(16777215),this.specular=new vn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=H9,this.normalScale=new on(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ju,this.combine=pP,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 Ede=class extends Dm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Due,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}},Ade=class extends Dm{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}},u7=class extends ya{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const MA=new Yr,QF=new Xe,JF=new Xe;let Tde=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new on(512,512),this.mapType=sl,this.map=null,this.mapPass=null,this.matrix=new Yr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new AP,this._frameExtents=new on(1,1),this._viewportCount=1,this._viewports=[new Gr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;QF.setFromMatrixPosition(e.matrixWorld),n.position.copy(QF),JF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(JF),n.updateMatrixWorld(),MA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(MA,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(MA)}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}},d7=class extends i7{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=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=s,this.far=a,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,s,a){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=s,this.view.height=a,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 s=r-e,a=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,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,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 Cde extends Tde{constructor(){super(new d7(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class e5 extends u7{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ya.DEFAULT_UP),this.updateMatrix(),this.target=new ya,this.shadow=new Cde}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Nde=class extends u7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},kde=class extends Ha{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},t5=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=mn(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(mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Rde extends wde{constructor(e=10,n=10,r=4473924,i=8947848){r=new vn(r),i=new vn(i);const s=n/2,a=e/n,o=e/2,l=[],c=[];for(let g=0,m=0,v=-o;g<=n;g++,v+=a){l.push(-o,0,v,o,0,v),l.push(v,0,-o,v,0,o);const y=g===s?r:i;y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3}const d=new pl;d.setAttribute("position",new Ao(l,3)),d.setAttribute("color",new Ao(c,3));const h=new a7({vertexColors:!0,toneMapped:!1});super(d,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pde extends Jf{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){Xt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function n5(t,e,n,r){const i=Dde(r);switch(n){case F9:return t*e;case B9:return t*e/i.components*i.byteLength;case bP:return t*e/i.components*i.byteLength;case vP:return t*e*2/i.components*i.byteLength;case yP:return t*e*2/i.components*i.byteLength;case z9:return t*e*3/i.components*i.byteLength;case wo:return t*e*4/i.components*i.byteLength;case _P:return t*e*4/i.components*i.byteLength;case T_:case C_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case N_:case k_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case d3:case h3:return Math.max(t,16)*Math.max(e,8)/4;case u3:case f3:return Math.max(t,8)*Math.max(e,8)/2;case p3:case m3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case g3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case x3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case b3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case v3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case y3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case _3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case S3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case w3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case M3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case E3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case A3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case T3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case C3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case N3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case k3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case R3:case P3:case D3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case O3:case L3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case j3:case I3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Dde(t){switch(t){case sl:case L9:return{byteLength:1,components:1};case a0:case j9:case Pm:return{byteLength:2,components:1};case gP:case xP:return{byteLength:2,components:4};case Of:case mP:case sc:return{byteLength:4,components:1};case I9:case U9:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hP}}));typeof window<"u"&&(window.__THREE__?Xt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hP);function f7(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),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(s){n=s},setContext:function(s){t=s}}}function Ode(t){const e=new WeakMap;function n(o,l){const c=o.array,d=o.usage,h=c.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,c,d),o.onUploadCallback();let m;if(c instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=t.SHORT;else if(c instanceof Uint32Array)m=t.UNSIGNED_INT;else if(c instanceof Int32Array)m=t.INT;else if(c instanceof Int8Array)m=t.BYTE;else if(c instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:g,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function r(o,l,c){const d=l.array,h=l.updateRanges;if(t.bindBuffer(c,o),h.length===0)t.bufferSubData(c,0,d);else{h.sort((m,v)=>m.start-v.start);let g=0;for(let m=1;m<h.length;m++){const v=h[g],y=h[m];y.start<=v.start+v.count+1?v.count=Math.max(v.count,y.start+y.count-v.start):(++g,h[g]=y)}h.length=g+1;for(let m=0,v=h.length;m<v;m++){const y=h[m];t.bufferSubData(c,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}var Lde=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,jde=`#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`,Ide=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,Ude=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,Fde=`#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`,zde=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,Bde=`#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`,Hde=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,$de=`#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`,Vde=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,Gde=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Wde=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,qde=`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`,Xde=`#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`,Kde=`#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`,Yde=`#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`,Zde=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,Qde=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,Jde=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,efe=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,tfe=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,nfe=`#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`,rfe=`#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`,ife=`#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`,sfe=`#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`,afe=`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`,ofe=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,lfe=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,cfe=`#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`,ufe=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,dfe="gl_FragColor = linearToOutputTexel( gl_FragColor );",ffe=`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. }`,hfe=`#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`,pfe=`#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`,mfe=`#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`,gfe=`#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`,xfe=`#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`,bfe=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,vfe=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,yfe=`#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`,_fe=`#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`,Sfe=`#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. }`,wfe=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,Mfe=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,Efe=`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`,Afe=`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`,Tfe=`#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`,Cfe=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,Nfe=`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`,kfe=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,Rfe=`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`,Pfe=`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`,Dfe=`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. }`,Ofe=`
  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`,Lfe=`#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`,jfe=`#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`,Ife=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,Ufe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,Ffe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,zfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,Bfe=`#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`,Hfe=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,$fe=`#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`,Vfe=`#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`,Gfe=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Wfe=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,qfe=`#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`,Xfe=`#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`,Kfe=`#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`,Yfe=`#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`,Zfe=`#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`,Qfe=`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;`,Jfe=`#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`,ehe=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,the=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,nhe=`#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`,rhe=`#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`,ihe=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,she=`#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`,ahe=`#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`,ohe=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,lhe=`#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 );`,che=`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. }`,uhe=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,dhe=`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;`,fhe=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,hhe=`#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`,phe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,mhe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,ghe=`#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`,xhe=`#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`,bhe=`#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`,vhe=`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. }`,yhe=`#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`,_he=`#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`,She=`#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`,whe=`#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`,Mhe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,Ehe=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,Ahe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,The=`#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; }`,Che=`#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`,Nhe=`#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`,khe=`#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`,Rhe=`#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`,Phe=`#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`,Dhe=`#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 Ohe=`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. }`,Lhe=`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. }`,jhe=`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. }`,Ihe=`#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. }`,Uhe=`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. }`,Fhe=`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. }`,zhe=`#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. }`,Bhe=`#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. }`,Hhe=`#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. }`,$he=`#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. }`,Vhe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,Ghe=`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. }`,Whe=`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. }`,qhe=`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. }`,Xhe=`#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. }`,Khe=`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. }`,Yhe=`#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. }`,Zhe=`#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. }`,Qhe=`#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. }`,Jhe=`#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. }`,epe=`#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. }`,tpe=`#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. }`,npe=`#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. }`,rpe=`#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. }`,ipe=`#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. }`,spe=`#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. }`,ape=`#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. }`,ope=`#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. }`,lpe=`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. }`,cpe=`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. }`,upe=`#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. }`,dpe=`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. }`,fpe=`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. }`,hpe=`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. }`,sn={alphahash_fragment:Lde,alphahash_pars_fragment:jde,alphamap_fragment:Ide,alphamap_pars_fragment:Ude,alphatest_fragment:Fde,alphatest_pars_fragment:zde,aomap_fragment:Bde,aomap_pars_fragment:Hde,batching_pars_vertex:$de,batching_vertex:Vde,begin_vertex:Gde,beginnormal_vertex:Wde,bsdfs:qde,iridescence_fragment:Xde,bumpmap_pars_fragment:Kde,clipping_planes_fragment:Yde,clipping_planes_pars_fragment:Zde,clipping_planes_pars_vertex:Qde,clipping_planes_vertex:Jde,color_fragment:efe,color_pars_fragment:tfe,color_pars_vertex:nfe,color_vertex:rfe,common:ife,cube_uv_reflection_fragment:sfe,defaultnormal_vertex:afe,displacementmap_pars_vertex:ofe,displacementmap_vertex:lfe,emissivemap_fragment:cfe,emissivemap_pars_fragment:ufe,colorspace_fragment:dfe,colorspace_pars_fragment:ffe,envmap_fragment:hfe,envmap_common_pars_fragment:pfe,envmap_pars_fragment:mfe,envmap_pars_vertex:gfe,envmap_physical_pars_fragment:Tfe,envmap_vertex:xfe,fog_vertex:bfe,fog_pars_vertex:vfe,fog_fragment:yfe,fog_pars_fragment:_fe,gradientmap_pars_fragment:Sfe,lightmap_pars_fragment:wfe,lights_lambert_fragment:Mfe,lights_lambert_pars_fragment:Efe,lights_pars_begin:Afe,lights_toon_fragment:Cfe,lights_toon_pars_fragment:Nfe,lights_phong_fragment:kfe,lights_phong_pars_fragment:Rfe,lights_physical_fragment:Pfe,lights_physical_pars_fragment:Dfe,lights_fragment_begin:Ofe,lights_fragment_maps:Lfe,lights_fragment_end:jfe,logdepthbuf_fragment:Ife,logdepthbuf_pars_fragment:Ufe,logdepthbuf_pars_vertex:Ffe,logdepthbuf_vertex:zfe,map_fragment:Bfe,map_pars_fragment:Hfe,map_particle_fragment:$fe,map_particle_pars_fragment:Vfe,metalnessmap_fragment:Gfe,metalnessmap_pars_fragment:Wfe,morphinstance_vertex:qfe,morphcolor_vertex:Xfe,morphnormal_vertex:Kfe,morphtarget_pars_vertex:Yfe,morphtarget_vertex:Zfe,normal_fragment_begin:Qfe,normal_fragment_maps:Jfe,normal_pars_fragment:ehe,normal_pars_vertex:the,normal_vertex:nhe,normalmap_pars_fragment:rhe,clearcoat_normal_fragment_begin:ihe,clearcoat_normal_fragment_maps:she,clearcoat_pars_fragment:ahe,iridescence_pars_fragment:ohe,opaque_fragment:lhe,packing:che,premultiplied_alpha_fragment:uhe,project_vertex:dhe,dithering_fragment:fhe,dithering_pars_fragment:hhe,roughnessmap_fragment:phe,roughnessmap_pars_fragment:mhe,shadowmap_pars_fragment:ghe,shadowmap_pars_vertex:xhe,shadowmap_vertex:bhe,shadowmask_pars_fragment:vhe,skinbase_vertex:yhe,skinning_pars_vertex:_he,skinning_vertex:She,skinnormal_vertex:whe,specularmap_fragment:Mhe,specularmap_pars_fragment:Ehe,tonemapping_fragment:Ahe,tonemapping_pars_fragment:The,transmission_fragment:Che,transmission_pars_fragment:Nhe,uv_pars_fragment:khe,uv_pars_vertex:Rhe,uv_vertex:Phe,worldpos_vertex:Dhe,background_vert:Ohe,background_frag:Lhe,backgroundCube_vert:jhe,backgroundCube_frag:Ihe,cube_vert:Uhe,cube_frag:Fhe,depth_vert:zhe,depth_frag:Bhe,distanceRGBA_vert:Hhe,distanceRGBA_frag:$he,equirect_vert:Vhe,equirect_frag:Ghe,linedashed_vert:Whe,linedashed_frag:qhe,meshbasic_vert:Xhe,meshbasic_frag:Khe,meshlambert_vert:Yhe,meshlambert_frag:Zhe,meshmatcap_vert:Qhe,meshmatcap_frag:Jhe,meshnormal_vert:epe,meshnormal_frag:tpe,meshphong_vert:npe,meshphong_frag:rpe,meshphysical_vert:ipe,meshphysical_frag:spe,meshtoon_vert:ape,meshtoon_frag:ope,points_vert:lpe,points_frag:cpe,shadow_vert:upe,shadow_frag:dpe,sprite_vert:fpe,sprite_frag:hpe},St={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},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 un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new on(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new on(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},Xo={basic:{uniforms:gs([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:gs([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new vn(0)}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:gs([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new vn(0)},specular:{value:new vn(1118481)},shininess:{value:30}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:gs([St.common,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.roughnessmap,St.metalnessmap,St.fog,St.lights,{emissive:{value:new vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:gs([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new vn(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:gs([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:gs([St.points,St.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:gs([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:gs([St.common,St.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:gs([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:gs([St.sprite,St.fog]),vertexShader:sn.sprite_vert,fragmentShader:sn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:sn.background_vert,fragmentShader:sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:sn.backgroundCube_vert,fragmentShader:sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:sn.cube_vert,fragmentShader:sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:sn.equirect_vert,fragmentShader:sn.equirect_frag},distanceRGBA:{uniforms:gs([St.common,St.displacementmap,{referencePosition:{value:new Xe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distanceRGBA_vert,fragmentShader:sn.distanceRGBA_frag},shadow:{uniforms:gs([St.lights,St.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};Xo.physical={uniforms:gs([Xo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new on(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new on},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new on},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag};const dy={r:0,b:0,g:0},Ud=new Ju,ppe=new Yr;function mpe(t,e,n,r,i,s,a){const o=new vn(0);let l=s===!0?0:1,c,d,h=null,g=0,m=null;function v(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function y(w){let A=!1;const T=v(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,a):R==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(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=v(A);T&&(T.isCubeTexture||T.mapping===hw)?(d===void 0&&(d=new al(new EP(1,1,1),new yc({name:"BackgroundCubeMaterial",uniforms:sm(Xo.backgroundCube.uniforms),vertexShader:Xo.backgroundCube.vertexShader,fragmentShader:Xo.backgroundCube.fragmentShader,side:$s,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(R,C,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Ud.copy(A.backgroundRotation),Ud.x*=-1,Ud.y*=-1,Ud.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Ud.y*=-1,Ud.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(ppe.makeRotationFromEuler(Ud)),d.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,(h!==T||g!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=T,g=T.version,m=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(c===void 0&&(c=new al(new TP(2,2),new yc({name:"BackgroundMaterial",uniforms:sm(Xo.background.uniforms),vertexShader:Xo.background.vertexShader,fragmentShader:Xo.background.fragmentShader,side:Qu,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),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),(h!==T||g!==T.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=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(dy,r7(t)),r.buffers.color.setClear(dy.r,dy.g,dy.b,A,a)}function M(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,A=1){o.set(w),l=A,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:y,addToRenderList:b,dispose:M}}function gpe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let s=i,a=!1;function o(D,z,j,W,P){let $=!1;const K=h(W,j,z);s!==K&&(s=K,c(s.object)),$=m(D,W,j,P),$&&v(D,W,j,P),P!==null&&e.update(P,t.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,A(D,z,j,W),P!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return t.createVertexArray()}function c(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function h(D,z,j){const W=j.wireframe===!0;let P=r[D.id];P===void 0&&(P={},r[D.id]=P);let $=P[z.id];$===void 0&&($={},P[z.id]=$);let K=$[W];return K===void 0&&(K=g(l()),$[W]=K),K}function g(D){const z=[],j=[],W=[];for(let P=0;P<n;P++)z[P]=0,j[P]=0,W[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:j,attributeDivisors:W,object:D,attributes:{},index:null}}function m(D,z,j,W){const P=s.attributes,$=z.attributes;let K=0;const G=j.getAttributes();for(const Z in G)if(G[Z].location>=0){const ee=P[Z];let H=$[Z];if(H===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(H=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(H=D.instanceColor)),ee===void 0||ee.attribute!==H||H&&ee.data!==H.data)return!0;K++}return s.attributesNum!==K||s.index!==W}function v(D,z,j,W){const P={},$=z.attributes;let K=0;const G=j.getAttributes();for(const Z in G)if(G[Z].location>=0){let ee=$[Z];ee===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(ee=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(ee=D.instanceColor));const H={};H.attribute=ee,ee&&ee.data&&(H.data=ee.data),P[Z]=H,K++}s.attributes=P,s.attributesNum=K,s.index=W}function y(){const D=s.newAttributes;for(let z=0,j=D.length;z<j;z++)D[z]=0}function b(D){x(D,0)}function x(D,z){const j=s.newAttributes,W=s.enabledAttributes,P=s.attributeDivisors;j[D]=1,W[D]===0&&(t.enableVertexAttribArray(D),W[D]=1),P[D]!==z&&(t.vertexAttribDivisor(D,z),P[D]=z)}function M(){const D=s.newAttributes,z=s.enabledAttributes;for(let j=0,W=z.length;j<W;j++)z[j]!==D[j]&&(t.disableVertexAttribArray(j),z[j]=0)}function w(D,z,j,W,P,$,K){K===!0?t.vertexAttribIPointer(D,z,j,P,$):t.vertexAttribPointer(D,z,j,W,P,$)}function A(D,z,j,W){y();const P=W.attributes,$=j.getAttributes(),K=z.defaultAttributeValues;for(const G in $){const Z=$[G];if(Z.location>=0){let Q=P[G];if(Q===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor)),Q!==void 0){const ee=Q.normalized,H=Q.itemSize,q=e.get(Q);if(q===void 0)continue;const te=q.buffer,ae=q.type,xe=q.bytesPerElement,re=ae===t.INT||ae===t.UNSIGNED_INT||Q.gpuType===mP;if(Q.isInterleavedBufferAttribute){const pe=Q.data,Ce=pe.stride,fe=Q.offset;if(pe.isInstancedInterleavedBuffer){for(let Se=0;Se<Z.locationSize;Se++)x(Z.location+Se,pe.meshPerAttribute);D.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let Se=0;Se<Z.locationSize;Se++)b(Z.location+Se);t.bindBuffer(t.ARRAY_BUFFER,te);for(let Se=0;Se<Z.locationSize;Se++)w(Z.location+Se,H/Z.locationSize,ae,ee,Ce*xe,(fe+H/Z.locationSize*Se)*xe,re)}else{if(Q.isInstancedBufferAttribute){for(let pe=0;pe<Z.locationSize;pe++)x(Z.location+pe,Q.meshPerAttribute);D.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let pe=0;pe<Z.locationSize;pe++)b(Z.location+pe);t.bindBuffer(t.ARRAY_BUFFER,te);for(let pe=0;pe<Z.locationSize;pe++)w(Z.location+pe,H/Z.locationSize,ae,ee,H*xe,H/Z.locationSize*pe*xe,re)}}else if(K!==void 0){const ee=K[G];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(Z.location,ee);break;case 3:t.vertexAttrib3fv(Z.location,ee);break;case 4:t.vertexAttrib4fv(Z.location,ee);break;default:t.vertexAttrib1fv(Z.location,ee)}}}}M()}function T(){I();for(const D in r){const z=r[D];for(const j in z){const W=z[j];for(const P in W)d(W[P].object),delete W[P];delete z[j]}delete r[D]}}function R(D){if(r[D.id]===void 0)return;const z=r[D.id];for(const j in z){const W=z[j];for(const P in W)d(W[P].object),delete W[P];delete z[j]}delete r[D.id]}function C(D){for(const z in r){const j=r[z];if(j[D.id]===void 0)continue;const W=j[D.id];for(const P in W)d(W[P].object),delete W[P];delete j[D.id]}}function I(){N(),a=!0,s!==i&&(s=i,c(s.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:I,resetDefaultState:N,dispose:T,releaseStatesOfGeometry:R,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:b,disableUnusedAttributes:M}}function xpe(t,e,n){let r;function i(c){r=c}function s(c,d){t.drawArrays(r,c,d),n.update(d,r,1)}function a(c,d,h){h!==0&&(t.drawArraysInstanced(r,c,d,h),n.update(d,r,h))}function o(c,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,d,0,h);let m=0;for(let v=0;v<h;v++)m+=d[v];n.update(m,r,1)}function l(c,d,h,g){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let v=0;v<c.length;v++)a(c[v],d[v],g[v]);else{m.multiDrawArraysInstancedWEBGL(r,c,0,d,0,g,0,h);let v=0;for(let y=0;y<h;y++)v+=d[y]*g[y];n.update(v,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function bpe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(C){return!(C!==wo&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const I=C===Pm&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==sl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==sc&&!I)}function l(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const d=l(c);d!==c&&(Xt("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=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=v>0,R=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:v,maxTextureSize:y,maxCubemapSize:b,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:R}}function vpe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Su,o=new un,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,g){n=d(h,g,0)},this.setState=function(h,g,m){const v=h.clippingPlanes,y=h.clipIntersection,b=h.clipShadows,x=t.get(h);if(!i||v===null||v.length===0||s&&!b)s?d(null):c();else{const M=s?0:r,w=M*4;let A=x.clippingState||null;l.value=A,A=d(v,g,w,m);for(let T=0;T!==w;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=y?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 d(h,g,m,v){const y=h!==null?h.length:0;let b=null;if(y!==0){if(b=l.value,v!==!0||b===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(b===null||b.length<x)&&(b=new Float32Array(x));for(let w=0,A=m;w!==y;++w,A+=4)a.copy(h[w]).applyMatrix4(M,o),a.normal.toArray(b,A),b[A+3]=a.constant}l.value=b,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function ype(t){let e=new WeakMap;function n(a,o){return o===a3?a.mapping=nm:o===o3&&(a.mapping=rm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===a3||o===o3)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new mde(l.height);return c.fromEquirectangularTexture(t,a),e.set(a,c),a.addEventListener("dispose",i),n(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Lu=4,r5=[.125,.215,.35,.446,.526,.582],Zd=20,_pe=256,Zg=new d7,i5=new vn;let EA=null,AA=0,TA=0,CA=!1;const Spe=new Xe;let s5=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,s={}){const{size:a=256,position:o=Spe}=s;EA=this._renderer.getRenderTarget(),AA=this._renderer.getActiveCubeFace(),TA=this._renderer.getActiveMipmapLevel(),CA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);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=l5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=o5(),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(EA,AA,TA),this._renderer.xr.enabled=CA,e.scissorTest=!1,Zh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===nm||e.mapping===rm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),EA=this._renderer.getRenderTarget(),AA=this._renderer.getActiveCubeFace(),TA=this._renderer.getActiveMipmapLevel(),CA=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:qa,minFilter:qa,generateMipmaps:!1,type:Pm,format:wo,colorSpace:im,depthBuffer:!1},i=a5(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=a5(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=wpe(s)),this._blurMaterial=Epe(s,e,n),this._ggxMaterial=Mpe(s,e,n)}return i}_compileMaterial(e){const n=new al(new pl,e);this._renderer.compile(n,Zg)}_sceneToCubeUV(e,n,r,i,s){const l=new Ha(90,1,n,r),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,g=h.autoClear,m=h.toneMapping;h.getClearColor(i5),h.toneMapping=Hu,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new al(new EP,new MP({name:"PMREM.Background",side:$s,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let x=!1;const M=e.background;M?M.isColor&&(b.color.copy(M),e.background=null,x=!0):(b.color.copy(i5),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(s.x,s.y,s.z),l.lookAt(s.x+d[w],s.y,s.z)):A===1?(l.up.set(0,0,c[w]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[w],s.z)):(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[w]));const T=this._cubeSize;Zh(i,A*T,w>2?T:0,T,T),h.setRenderTarget(i),x&&h.render(y,l),h.render(e,l)}h.toneMapping=m,h.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===nm||e.mapping===rm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=l5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=o5());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Zh(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,Zg)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;const l=a.uniforms,c=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),h=Math.sqrt(c*c-d*d),g=.05+c*.95,m=h*g,{_lodMax:v}=this,y=this._sizeLods[r],b=3*y*(r>v-Lu?r-v+Lu:0),x=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=v-n,Zh(s,b,x,3*y,2*y),i.setRenderTarget(s),i.render(o,Zg),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=v-r,Zh(e,b,x,3*y,2*y),i.setRenderTarget(e),i.render(o,Zg)}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Or("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=c;const g=c.uniforms,m=this._sizeLods[r]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Zd-1),y=s/v,b=isFinite(s)?1+Math.floor(d*y):Zd;b>Zd&&Xt(`sigmaRadians, ${s}, 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 C=0;C<Zd;++C){const I=C/y,N=Math.exp(-I*I/2);x.push(N),C===0?M+=N:C<b&&(M+=2*N)}for(let C=0;C<x.length;C++)x[C]=x[C]/M;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=x,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=v,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Lu?i-w+Lu:0),R=4*(this._cubeSize-A);Zh(n,T,R,3*A,2*A),l.setRenderTarget(n),l.render(h,Zg)}};function wpe(t){const e=[],n=[],r=[];let i=t;const s=t-Lu+1+r5.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>t-Lu?l=r5[a-t+Lu-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),d=-c,h=1+c,g=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,v=6,y=3,b=2,x=1,M=new Float32Array(y*v*m),w=new Float32Array(b*v*m),A=new Float32Array(x*v*m);for(let R=0;R<m;R++){const C=R%3*2/3-1,I=R>2?0:-1,N=[C,I,0,C+2/3,I,0,C+2/3,I+1,0,C,I,0,C+2/3,I+1,0,C,I+1,0];M.set(N,y*v*R),w.set(g,b*v*R);const D=[R,R,R,R,R,R];A.set(D,x*v*R)}const T=new pl;T.setAttribute("position",new Ya(M,y)),T.setAttribute("uv",new Ya(w,b)),T.setAttribute("faceIndex",new Ya(A,x)),r.push(new al(T,null)),i>Lu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function a5(t,e,n){const r=new jf(t,e,n);return r.texture.mapping=hw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Zh(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Mpe(t,e,n){return new yc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:_pe,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:mw(),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:dc,depthTest:!1,depthWrite:!1})}function Epe(t,e,n){const r=new Float32Array(Zd),i=new Xe(0,1,0);return new yc({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:mw(),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:dc,depthTest:!1,depthWrite:!1})}function o5(){return new yc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:mw(),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:dc,depthTest:!1,depthWrite:!1})}function l5(){return new yc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:mw(),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:dc,depthTest:!1,depthWrite:!1})}function mw(){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 Ape(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===a3||l===o3,d=l===nm||l===rm;if(c||d){let h=e.get(o);const g=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new s5(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const m=o.image;return c&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new s5(t)),h=c?n.fromEquirectangular(o):n.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let d=0;d<c;d++)o[d]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function Tpe(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&&u0("WebGLRenderer: "+r+" extension not supported."),i}}}function Cpe(t,e,n,r){const i={},s=new WeakMap;function a(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const v in g.attributes)e.remove(g.attributes[v]);g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function c(h){const g=[],m=h.index,v=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,A=M.length;w<A;w+=3){const T=M[w+0],R=M[w+1],C=M[w+2];g.push(T,R,R,C,C,T)}}else if(v!==void 0){const M=v.array;y=v.version;for(let w=0,A=M.length/3-1;w<A;w+=3){const T=w+0,R=w+1,C=w+2;g.push(T,R,R,C,C,T)}}else return;const b=new(V9(g)?e7:J9)(g,1);b.version=y;const x=s.get(h);x&&e.remove(x),s.set(h,b)}function d(h){const g=s.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:d}}function Npe(t,e,n){let r;function i(g){r=g}let s,a;function o(g){s=g.type,a=g.bytesPerElement}function l(g,m){t.drawElements(r,m,s,g*a),n.update(m,r,1)}function c(g,m,v){v!==0&&(t.drawElementsInstanced(r,m,s,g*a,v),n.update(m,r,v))}function d(g,m,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,g,0,v);let b=0;for(let x=0;x<v;x++)b+=m[x];n.update(b,r,1)}function h(g,m,v,y){if(v===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let x=0;x<g.length;x++)c(g[x]/a,m[x],y[x]);else{b.multiDrawElementsInstancedWEBGL(r,m,0,s,g,0,y,0,v);let x=0;for(let M=0;M<v;M++)x+=m[M]*y[M];n.update(x,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function kpe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:Or("WebGLInfo: Unknown draw mode:",a);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 Rpe(t,e,n){const r=new WeakMap,i=new Gr;function s(a,o,l){const c=a.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==h){let D=function(){I.dispose(),r.delete(o),o.removeEventListener("dispose",D)};var m=D;g!==void 0&&g.texture.dispose();const v=o.morphAttributes.position!==void 0,y=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;v===!0&&(A=1),y===!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 C=new Float32Array(T*R*4*h),I=new K9(C,T,R,h);I.type=sc,I.needsUpdate=!0;const N=A*4;for(let z=0;z<h;z++){const j=x[z],W=M[z],P=w[z],$=T*R*4*z;for(let K=0;K<j.count;K++){const G=K*N;v===!0&&(i.fromBufferAttribute(j,K),C[$+G+0]=i.x,C[$+G+1]=i.y,C[$+G+2]=i.z,C[$+G+3]=0),y===!0&&(i.fromBufferAttribute(W,K),C[$+G+4]=i.x,C[$+G+5]=i.y,C[$+G+6]=i.z,C[$+G+7]=0),b===!0&&(i.fromBufferAttribute(P,K),C[$+G+8]=i.x,C[$+G+9]=i.y,C[$+G+10]=i.z,C[$+G+11]=P.itemSize===4?i.w:1)}}g={count:h,texture:I,size:new on(T,R)},r.set(o,g),o.addEventListener("dispose",D)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let v=0;for(let b=0;b<c.length;b++)v+=c[b];const y=o.morphTargetsRelative?1:1-v;l.getUniforms().setValue(t,"morphTargetBaseInfluence",y),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:s}}function Ppe(t,e,n,r){let i=new WeakMap;function s(l){const c=r.render.frame,d=l.geometry,h=e.get(l,d);if(i.get(h)!==c&&(e.update(h),i.set(h,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 h}function a(){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:s,dispose:a}}const h7=new Oo,c5=new o7(1,1),p7=new K9,m7=new Que,g7=new s7,u5=[],d5=[],f5=new Float32Array(16),h5=new Float32Array(9),p5=new Float32Array(4);function Om(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=u5[i];if(s===void 0&&(s=new Float32Array(i),u5[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function ci(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ui(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function gw(t,e){let n=d5[e];n===void 0&&(n=new Int32Array(e),d5[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Dpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Ope(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2fv(this.addr,e),ui(n,e)}}function Lpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ci(n,e))return;t.uniform3fv(this.addr,e),ui(n,e)}}function jpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4fv(this.addr,e),ui(n,e)}}function Ipe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;p5.set(r),t.uniformMatrix2fv(this.addr,!1,p5),ui(n,r)}}function Upe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;h5.set(r),t.uniformMatrix3fv(this.addr,!1,h5),ui(n,r)}}function Fpe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;f5.set(r),t.uniformMatrix4fv(this.addr,!1,f5),ui(n,r)}}function zpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Bpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2iv(this.addr,e),ui(n,e)}}function Hpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ci(n,e))return;t.uniform3iv(this.addr,e),ui(n,e)}}function $pe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4iv(this.addr,e),ui(n,e)}}function Vpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Gpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2uiv(this.addr,e),ui(n,e)}}function Wpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ci(n,e))return;t.uniform3uiv(this.addr,e),ui(n,e)}}function qpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4uiv(this.addr,e),ui(n,e)}}function Xpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(c5.compareFunction=$9,s=c5):s=h7,n.setTexture2D(e||s,i)}function Kpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||m7,i)}function Ype(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||g7,i)}function Zpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||p7,i)}function Qpe(t){switch(t){case 5126:return Dpe;case 35664:return Ope;case 35665:return Lpe;case 35666:return jpe;case 35674:return Ipe;case 35675:return Upe;case 35676:return Fpe;case 5124:case 35670:return zpe;case 35667:case 35671:return Bpe;case 35668:case 35672:return Hpe;case 35669:case 35673:return $pe;case 5125:return Vpe;case 36294:return Gpe;case 36295:return Wpe;case 36296:return qpe;case 35678:case 36198:case 36298:case 36306:case 35682:return Xpe;case 35679:case 36299:case 36307:return Kpe;case 35680:case 36300:case 36308:case 36293:return Ype;case 36289:case 36303:case 36311:case 36292:return Zpe}}function Jpe(t,e){t.uniform1fv(this.addr,e)}function eme(t,e){const n=Om(e,this.size,2);t.uniform2fv(this.addr,n)}function tme(t,e){const n=Om(e,this.size,3);t.uniform3fv(this.addr,n)}function nme(t,e){const n=Om(e,this.size,4);t.uniform4fv(this.addr,n)}function rme(t,e){const n=Om(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ime(t,e){const n=Om(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function sme(t,e){const n=Om(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function ame(t,e){t.uniform1iv(this.addr,e)}function ome(t,e){t.uniform2iv(this.addr,e)}function lme(t,e){t.uniform3iv(this.addr,e)}function cme(t,e){t.uniform4iv(this.addr,e)}function ume(t,e){t.uniform1uiv(this.addr,e)}function dme(t,e){t.uniform2uiv(this.addr,e)}function fme(t,e){t.uniform3uiv(this.addr,e)}function hme(t,e){t.uniform4uiv(this.addr,e)}function pme(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||h7,s[a])}function mme(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||m7,s[a])}function gme(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||g7,s[a])}function xme(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||p7,s[a])}function bme(t){switch(t){case 5126:return Jpe;case 35664:return eme;case 35665:return tme;case 35666:return nme;case 35674:return rme;case 35675:return ime;case 35676:return sme;case 5124:case 35670:return ame;case 35667:case 35671:return ome;case 35668:case 35672:return lme;case 35669:case 35673:return cme;case 5125:return ume;case 36294:return dme;case 36295:return fme;case 36296:return hme;case 35678:case 36198:case 36298:case 36306:case 35682:return pme;case 35679:case 36299:case 36307:return mme;case 35680:case 36300:case 36308:case 36293:return gme;case 36289:case 36303:case 36311:case 36292:return xme}}let vme=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Qpe(n.type)}},yme=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=bme(n.type)}},_me=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}};const NA=/(\w+)(\])?(\[|\.)?/g;function m5(t,e){t.seq.push(e),t.map[e.id]=e}function Sme(t,e,n){const r=t.name,i=r.length;for(NA.lastIndex=0;;){const s=NA.exec(r),a=NA.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){m5(n,c===void 0?new vme(o,t,e):new yme(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new _me(o),m5(n,h)),n=h}}}let O_=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);Sme(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.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 s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}};function g5(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const wme=37297;let Mme=0;function Eme(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
  3751. `)}const x5=new un;function Ame(t){En._getMatrix(x5,En.workingColorSpace,t);const e=`mat3( ${x5.elements.map(n=>n.toFixed(4))} )`;switch(En.getTransfer(t)){case s1:return[e,"LinearTransferOETF"];case Bn:return[e,"sRGBTransferOETF"];default:return Xt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function b5(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
  3752. `+s+`
  3753. `+Eme(t.getShaderSource(e),o)}else return s}function Tme(t,e){const n=Ame(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function Cme(t,e){let n;switch(e){case Eue:n="Linear";break;case Aue:n="Reinhard";break;case Tue:n="Cineon";break;case Cue:n="ACESFilmic";break;case kue:n="AgX";break;case Rue:n="Neutral";break;case Nue:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const fy=new Xe;function Nme(){En.getLuminanceCoefficients(fy);const t=fy.x.toFixed(4),e=fy.y.toFixed(4),n=fy.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function kme(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gx).join(`
  3756. `)}function Rme(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function Pme(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function gx(t){return t!==""}function v5(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 y5(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Dme=/^[ \t]*#include +<([\w\d./]+)>/gm;function z3(t){return t.replace(Dme,Lme)}const Ome=new Map;function Lme(t,e){let n=sn[e];if(n===void 0){const r=Ome.get(e);if(r!==void 0)n=sn[r],Xt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return z3(n)}const jme=/#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 _5(t){return t.replace(jme,Ime)}function Ime(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function S5(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 Ume(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===D9?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===iue?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ql&&(e="SHADOWMAP_TYPE_VSM"),e}function Fme(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case nm:case rm:e="ENVMAP_TYPE_CUBE";break;case hw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function zme(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case rm:e="ENVMAP_MODE_REFRACTION";break}return e}function Bme(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case pP:e="ENVMAP_BLENDING_MULTIPLY";break;case wue:e="ENVMAP_BLENDING_MIX";break;case Mue:e="ENVMAP_BLENDING_ADD";break}return e}function Hme(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 $me(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=Ume(n),c=Fme(n),d=zme(n),h=Bme(n),g=Hme(n),m=kme(n),v=Rme(s),y=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,v].filter(gx).join(`
  3779. `),b.length>0&&(b+=`
  3780. `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(gx).join(`
  3781. `),x.length>0&&(x+=`
  3782. `)):(b=[S5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3783. `].filter(gx).join(`
  3784. `),x=[S5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+h:"",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!==Hu?"#define TONE_MAPPING":"",n.toneMapping!==Hu?sn.tonemapping_pars_fragment:"",n.toneMapping!==Hu?Cme("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,Tme("linearToOutputTexel",n.outputColorSpace),Nme(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(gx).join(`
  3786. `)),a=z3(a),a=v5(a,n),a=y5(a,n),o=z3(o),o=v5(o,n),o=y5(o,n),a=_5(a),o=_5(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===NF?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===NF?"":"#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+a,A=M+x+o,T=g5(i,i.VERTEX_SHADER,w),R=g5(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,R),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(z){if(t.debug.checkShaderErrors){const j=i.getProgramInfoLog(y)||"",W=i.getShaderInfoLog(T)||"",P=i.getShaderInfoLog(R)||"",$=j.trim(),K=W.trim(),G=P.trim();let Z=!0,Q=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,R);else{const ee=b5(i,T,"vertex"),H=b5(i,R,"fragment");Or("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3792. Material Name: `+z.name+`
  3793. Material Type: `+z.type+`
  3794. Program Info Log: `+$+`
  3795. `+ee+`
  3796. `+H)}else $!==""?Xt("WebGLProgram: Program Info Log:",$):(K===""||G==="")&&(Q=!1);Q&&(z.diagnostics={runnable:Z,programLog:$,vertexShader:{log:K,prefix:b},fragmentShader:{log:G,prefix:x}})}i.deleteShader(T),i.deleteShader(R),I=new O_(i,y),N=Pme(i,y)}let I;this.getUniforms=function(){return I===void 0&&C(this),I};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,wme)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Mme++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=R,this}let Vme=0,Gme=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.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 Wme(e),n.set(e,r)),r}},Wme=class{constructor(e){this.id=Vme++,this.code=e,this.usedTimes=0}};function qme(t,e,n,r,i,s,a){const o=new Z9,l=new Gme,c=new Set,d=[],h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return c.add(N),N===0?"uv":`uv${N}`}function b(N,D,z,j,W){const P=j.fog,$=W.geometry,K=N.isMeshStandardMaterial?j.environment:null,G=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),Z=G&&G.mapping===hw?G.image.height:null,Q=v[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&Xt("WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=ee!==void 0?ee.length:0;let q=0;$.morphAttributes.position!==void 0&&(q=1),$.morphAttributes.normal!==void 0&&(q=2),$.morphAttributes.color!==void 0&&(q=3);let te,ae,xe,re;if(Q){const Rt=Xo[Q];te=Rt.vertexShader,ae=Rt.fragmentShader}else te=N.vertexShader,ae=N.fragmentShader,l.update(N),xe=l.getVertexShaderID(N),re=l.getFragmentShaderID(N);const pe=t.getRenderTarget(),Ce=t.state.buffers.depth.getReversed(),fe=W.isInstancedMesh===!0,Se=W.isBatchedMesh===!0,Re=!!N.map,ue=!!N.matcap,ct=!!G,B=!!N.aoMap,F=!!N.lightMap,ie=!!N.bumpMap,V=!!N.normalMap,J=!!N.displacementMap,le=!!N.emissiveMap,Ae=!!N.metalnessMap,Ee=!!N.roughnessMap,se=N.anisotropy>0,U=N.clearcoat>0,L=N.dispersion>0,X=N.iridescence>0,me=N.sheen>0,ve=N.transmission>0,ge=se&&!!N.anisotropyMap,Ke=U&&!!N.clearcoatMap,Ie=U&&!!N.clearcoatNormalMap,ze=U&&!!N.clearcoatRoughnessMap,at=X&&!!N.iridescenceMap,Fe=X&&!!N.iridescenceThicknessMap,ce=me&&!!N.sheenColorMap,Qe=me&&!!N.sheenRoughnessMap,He=!!N.specularMap,Ye=!!N.specularColorMap,ut=!!N.specularIntensityMap,de=ve&&!!N.transmissionMap,Je=ve&&!!N.thicknessMap,be=!!N.gradientMap,je=!!N.alphaMap,Te=N.alphaTest>0,ye=!!N.alphaHash,Ge=!!N.extensions;let ft=Hu;N.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(ft=t.toneMapping);const yt={shaderID:Q,shaderType:N.type,shaderName:N.name,vertexShader:te,fragmentShader:ae,defines:N.defines,customVertexShaderID:xe,customFragmentShaderID:re,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:Se,batchingColor:Se&&W._colorsTexture!==null,instancing:fe,instancingColor:fe&&W.instanceColor!==null,instancingMorph:fe&&W.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:pe===null?t.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:im,alphaToCoverage:!!N.alphaToCoverage,map:Re,matcap:ue,envMap:ct,envMapMode:ct&&G.mapping,envMapCubeUVHeight:Z,aoMap:B,lightMap:F,bumpMap:ie,normalMap:V,displacementMap:g&&J,emissiveMap:le,normalMapObjectSpace:V&&N.normalMapType===Lue,normalMapTangentSpace:V&&N.normalMapType===H9,metalnessMap:Ae,roughnessMap:Ee,anisotropy:se,anisotropyMap:ge,clearcoat:U,clearcoatMap:Ke,clearcoatNormalMap:Ie,clearcoatRoughnessMap:ze,dispersion:L,iridescence:X,iridescenceMap:at,iridescenceThicknessMap:Fe,sheen:me,sheenColorMap:ce,sheenRoughnessMap:Qe,specularMap:He,specularColorMap:Ye,specularIntensityMap:ut,transmission:ve,transmissionMap:de,thicknessMap:Je,gradientMap:be,opaque:N.transparent===!1&&N.blending===Fp&&N.alphaToCoverage===!1,alphaMap:je,alphaTest:Te,alphaHash:ye,combine:N.combine,mapUv:Re&&y(N.map.channel),aoMapUv:B&&y(N.aoMap.channel),lightMapUv:F&&y(N.lightMap.channel),bumpMapUv:ie&&y(N.bumpMap.channel),normalMapUv:V&&y(N.normalMap.channel),displacementMapUv:J&&y(N.displacementMap.channel),emissiveMapUv:le&&y(N.emissiveMap.channel),metalnessMapUv:Ae&&y(N.metalnessMap.channel),roughnessMapUv:Ee&&y(N.roughnessMap.channel),anisotropyMapUv:ge&&y(N.anisotropyMap.channel),clearcoatMapUv:Ke&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:Ie&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:at&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Qe&&y(N.sheenRoughnessMap.channel),specularMapUv:He&&y(N.specularMap.channel),specularColorMapUv:Ye&&y(N.specularColorMap.channel),specularIntensityMapUv:ut&&y(N.specularIntensityMap.channel),transmissionMapUv:de&&y(N.transmissionMap.channel),thicknessMapUv:Je&&y(N.thicknessMap.channel),alphaMapUv:je&&y(N.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(V||se),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!$.attributes.uv&&(Re||je),fog:!!P,useFog:N.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Ce,skinning:W.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:q,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:Re&&N.map.isVideoTexture===!0&&En.getTransfer(N.map.colorSpace)===Bn,decodeVideoTextureEmissive:le&&N.emissiveMap.isVideoTexture===!0&&En.getTransfer(N.emissiveMap.colorSpace)===Bn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Ko,flipSided:N.side===$s,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:Ge&&N.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ge&&N.extensions.multiDraw===!0||Se)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return yt.vertexUv1s=c.has(1),yt.vertexUv2s=c.has(2),yt.vertexUv3s=c.has(3),c.clear(),yt}function x(N){const D=[];if(N.shaderID?D.push(N.shaderID):(D.push(N.customVertexShaderID),D.push(N.customFragmentShaderID)),N.defines!==void 0)for(const z in N.defines)D.push(z),D.push(N.defines[z]);return N.isRawShaderMaterial===!1&&(M(D,N),w(D,N),D.push(t.outputColorSpace)),D.push(N.customProgramCacheKey),D.join()}function M(N,D){N.push(D.precision),N.push(D.outputColorSpace),N.push(D.envMapMode),N.push(D.envMapCubeUVHeight),N.push(D.mapUv),N.push(D.alphaMapUv),N.push(D.lightMapUv),N.push(D.aoMapUv),N.push(D.bumpMapUv),N.push(D.normalMapUv),N.push(D.displacementMapUv),N.push(D.emissiveMapUv),N.push(D.metalnessMapUv),N.push(D.roughnessMapUv),N.push(D.anisotropyMapUv),N.push(D.clearcoatMapUv),N.push(D.clearcoatNormalMapUv),N.push(D.clearcoatRoughnessMapUv),N.push(D.iridescenceMapUv),N.push(D.iridescenceThicknessMapUv),N.push(D.sheenColorMapUv),N.push(D.sheenRoughnessMapUv),N.push(D.specularMapUv),N.push(D.specularColorMapUv),N.push(D.specularIntensityMapUv),N.push(D.transmissionMapUv),N.push(D.thicknessMapUv),N.push(D.combine),N.push(D.fogExp2),N.push(D.sizeAttenuation),N.push(D.morphTargetsCount),N.push(D.morphAttributeCount),N.push(D.numDirLights),N.push(D.numPointLights),N.push(D.numSpotLights),N.push(D.numSpotLightMaps),N.push(D.numHemiLights),N.push(D.numRectAreaLights),N.push(D.numDirLightShadows),N.push(D.numPointLightShadows),N.push(D.numSpotLightShadows),N.push(D.numSpotLightShadowsWithMaps),N.push(D.numLightProbes),N.push(D.shadowMapType),N.push(D.toneMapping),N.push(D.numClippingPlanes),N.push(D.numClipIntersection),N.push(D.depthPacking)}function w(N,D){o.disableAll(),D.supportsVertexTextures&&o.enable(0),D.instancing&&o.enable(1),D.instancingColor&&o.enable(2),D.instancingMorph&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),D.dispersion&&o.enable(20),D.batchingColor&&o.enable(21),D.gradientMap&&o.enable(22),N.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.reversedDepthBuffer&&o.enable(4),D.skinning&&o.enable(5),D.morphTargets&&o.enable(6),D.morphNormals&&o.enable(7),D.morphColors&&o.enable(8),D.premultipliedAlpha&&o.enable(9),D.shadowMapEnabled&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),D.decodeVideoTextureEmissive&&o.enable(20),D.alphaToCoverage&&o.enable(21),N.push(o.mask)}function A(N){const D=v[N.type];let z;if(D){const j=Xo[D];z=dde.clone(j.uniforms)}else z=N.uniforms;return z}function T(N,D){let z;for(let j=0,W=d.length;j<W;j++){const P=d[j];if(P.cacheKey===D){z=P,++z.usedTimes;break}}return z===void 0&&(z=new $me(t,D,N,s),d.push(z)),z}function R(N){if(--N.usedTimes===0){const D=d.indexOf(N);d[D]=d[d.length-1],d.pop(),N.destroy()}}function C(N){l.remove(N)}function I(){l.dispose()}return{getParameters:b,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:R,releaseShaderCache:C,programs:d,dispose:I}}function Xme(){let t=new WeakMap;function e(a){return t.has(a)}function n(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function r(a){t.delete(a)}function i(a,o,l){t.get(a)[o]=l}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function Kme(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 w5(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 M5(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(h,g,m,v,y,b){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:v,renderOrder:h.renderOrder,z:y,group:b},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=v,x.renderOrder=h.renderOrder,x.z=y,x.group=b),e++,x}function o(h,g,m,v,y,b){const x=a(h,g,m,v,y,b);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,v,y,b){const x=a(h,g,m,v,y,b);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||Kme),r.length>1&&r.sort(g||w5),i.length>1&&i.sort(g||w5)}function d(){for(let h=e,g=t.length;h<g;h++){const m=t[h];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:s,push:o,unshift:l,finish:d,sort:c}}function Yme(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new M5,t.set(r,[a])):i>=s.length?(a=new M5,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function Zme(){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 Xe,color:new vn};break;case"SpotLight":n={position:new Xe,direction:new Xe,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Xe,color:new vn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Xe,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":n={color:new vn,position:new Xe,halfWidth:new Xe,halfHeight:new Xe};break}return t[e.id]=n,n}}}function Qme(){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 on};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Jme=0;function ege(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function tge(t){const e=new Zme,n=Qme(),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 Xe);const i=new Xe,s=new Yr,a=new Yr;function o(c){let d=0,h=0,g=0;for(let N=0;N<9;N++)r.probe[N].set(0,0,0);let m=0,v=0,y=0,b=0,x=0,M=0,w=0,A=0,T=0,R=0,C=0;c.sort(ege);for(let N=0,D=c.length;N<D;N++){const z=c[N],j=z.color,W=z.intensity,P=z.distance,$=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=j.r*W,h+=j.g*W,g+=j.b*W;else if(z.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(z.sh.coefficients[K],W);C++}else if(z.isDirectionalLight){const K=e.get(z);if(K.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const G=z.shadow,Z=n.get(z);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,r.directionalShadow[m]=Z,r.directionalShadowMap[m]=$,r.directionalShadowMatrix[m]=z.shadow.matrix,M++}r.directional[m]=K,m++}else if(z.isSpotLight){const K=e.get(z);K.position.setFromMatrixPosition(z.matrixWorld),K.color.copy(j).multiplyScalar(W),K.distance=P,K.coneCos=Math.cos(z.angle),K.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),K.decay=z.decay,r.spot[y]=K;const G=z.shadow;if(z.map&&(r.spotLightMap[T]=z.map,T++,G.updateMatrices(z),z.castShadow&&R++),r.spotLightMatrix[y]=G.matrix,z.castShadow){const Z=n.get(z);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=$,A++}y++}else if(z.isRectAreaLight){const K=e.get(z);K.color.copy(j).multiplyScalar(W),K.halfWidth.set(z.width*.5,0,0),K.halfHeight.set(0,z.height*.5,0),r.rectArea[b]=K,b++}else if(z.isPointLight){const K=e.get(z);if(K.color.copy(z.color).multiplyScalar(z.intensity),K.distance=z.distance,K.decay=z.decay,z.castShadow){const G=z.shadow,Z=n.get(z);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,r.pointShadow[v]=Z,r.pointShadowMap[v]=$,r.pointShadowMatrix[v]=z.shadow.matrix,w++}r.point[v]=K,v++}else if(z.isHemisphereLight){const K=e.get(z);K.skyColor.copy(z.color).multiplyScalar(W),K.groundColor.copy(z.groundColor).multiplyScalar(W),r.hemi[x]=K,x++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=St.LTC_FLOAT_1,r.rectAreaLTC2=St.LTC_FLOAT_2):(r.rectAreaLTC1=St.LTC_HALF_1,r.rectAreaLTC2=St.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=g;const I=r.hash;(I.directionalLength!==m||I.pointLength!==v||I.spotLength!==y||I.rectAreaLength!==b||I.hemiLength!==x||I.numDirectionalShadows!==M||I.numPointShadows!==w||I.numSpotShadows!==A||I.numSpotMaps!==T||I.numLightProbes!==C)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=b,r.point.length=v,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=C,I.directionalLength=m,I.pointLength=v,I.spotLength=y,I.rectAreaLength=b,I.hemiLength=x,I.numDirectionalShadows=M,I.numPointShadows=w,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=C,r.version=Jme++)}function l(c,d){let h=0,g=0,m=0,v=0,y=0;const b=d.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const A=r.directional[h];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),h++}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[v];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),a.identity(),s.copy(w.matrixWorld),s.premultiply(b),a.extractRotation(s),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),v++}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[y];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(b),y++}}}return{setup:o,setupView:l,state:r}}function E5(t){const e=new tge(t),n=[],r=[];function i(d){c.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function a(d){r.push(d)}function o(){e.setup(n)}function l(d){e.setupView(n,d)}const c={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function nge(t){let e=new WeakMap;function n(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new E5(t),e.set(i,[o])):s>=a.length?(o=new E5(t),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const rge=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,ige=`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 sge(t,e,n){let r=new AP;const i=new on,s=new on,a=new Gr,o=new Ede({depthPacking:Oue}),l=new Ade,c={},d=n.maxTextureSize,h={[Qu]:$s,[$s]:Qu,[Ko]:Ko},g=new yc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new on},radius:{value:4}},vertexShader:rge,fragmentShader:ige}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const v=new pl;v.setAttribute("position",new Ya(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new al(v,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=D9;let x=this.type;this.render=function(R,C,I){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||R.length===0)return;const N=t.getRenderTarget(),D=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),j=t.state;j.setBlending(dc),j.buffers.depth.getReversed()===!0?j.buffers.color.setClear(0,0,0,0):j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const W=x!==ql&&this.type===ql,P=x===ql&&this.type!==ql;for(let $=0,K=R.length;$<K;$++){const G=R[$],Z=G.shadow;if(Z===void 0){Xt("WebGLShadowMap:",G,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const Q=Z.getFrameExtents();if(i.multiply(Q),s.copy(Z.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Q.x),i.x=s.x*Q.x,Z.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Q.y),i.y=s.y*Q.y,Z.mapSize.y=s.y)),Z.map===null||W===!0||P===!0){const H=this.type!==ql?{minFilter:ma,magFilter:ma}:{};Z.map!==null&&Z.map.dispose(),Z.map=new jf(i.x,i.y,H),Z.map.texture.name=G.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const ee=Z.getViewportCount();for(let H=0;H<ee;H++){const q=Z.getViewport(H);a.set(s.x*q.x,s.y*q.y,s.x*q.z,s.y*q.w),j.viewport(a),Z.updateMatrices(G,H),r=Z.getFrustum(),A(C,I,Z.camera,G,this.type)}Z.isPointLightShadow!==!0&&this.type===ql&&M(Z,I),Z.needsUpdate=!1}x=this.type,b.needsUpdate=!1,t.setRenderTarget(N,D,z)};function M(R,C){const I=e.update(y);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 jf(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(C,null,I,g,y,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(C,null,I,m,y,null)}function w(R,C,I,N){let D=null;const z=I.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(z!==void 0)D=z;else if(D=I.isPointLight===!0?l:o,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const j=D.uuid,W=C.uuid;let P=c[j];P===void 0&&(P={},c[j]=P);let $=P[W];$===void 0&&($=D.clone(),P[W]=$,C.addEventListener("dispose",T)),D=$}if(D.visible=C.visible,D.wireframe=C.wireframe,N===ql?D.side=C.shadowSide!==null?C.shadowSide:C.side:D.side=C.shadowSide!==null?C.shadowSide:h[C.side],D.alphaMap=C.alphaMap,D.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,D.map=C.map,D.clipShadows=C.clipShadows,D.clippingPlanes=C.clippingPlanes,D.clipIntersection=C.clipIntersection,D.displacementMap=C.displacementMap,D.displacementScale=C.displacementScale,D.displacementBias=C.displacementBias,D.wireframeLinewidth=C.wireframeLinewidth,D.linewidth=C.linewidth,I.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const j=t.properties.get(D);j.light=I}return D}function A(R,C,I,N,D){if(R.visible===!1)return;if(R.layers.test(C.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&D===ql)&&(!R.frustumCulled||r.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,R.matrixWorld);const W=e.update(R),P=R.material;if(Array.isArray(P)){const $=W.groups;for(let K=0,G=$.length;K<G;K++){const Z=$[K],Q=P[Z.materialIndex];if(Q&&Q.visible){const ee=w(R,Q,N,D);R.onBeforeShadow(t,R,C,I,W,ee,Z),t.renderBufferDirect(I,null,W,ee,R,Z),R.onAfterShadow(t,R,C,I,W,ee,Z)}}}else if(P.visible){const $=w(R,P,N,D);R.onBeforeShadow(t,R,C,I,W,$,null),t.renderBufferDirect(I,null,W,$,R,null),R.onAfterShadow(t,R,C,I,W,$,null)}}const j=R.children;for(let W=0,P=j.length;W<P;W++)A(j[W],C,I,N,D)}function T(R){R.target.removeEventListener("dispose",T);for(const I in c){const N=c[I],D=R.target.uuid;D in N&&(N[D].dispose(),delete N[D])}}}const age={[JN]:e3,[t3]:i3,[n3]:s3,[tm]:r3,[e3]:JN,[i3]:t3,[s3]:n3,[r3]:tm};function oge(t,e){function n(){let de=!1;const Je=new Gr;let be=null;const je=new Gr(0,0,0,0);return{setMask:function(Te){be!==Te&&!de&&(t.colorMask(Te,Te,Te,Te),be=Te)},setLocked:function(Te){de=Te},setClear:function(Te,ye,Ge,ft,yt){yt===!0&&(Te*=ft,ye*=ft,Ge*=ft),Je.set(Te,ye,Ge,ft),je.equals(Je)===!1&&(t.clearColor(Te,ye,Ge,ft),je.copy(Je))},reset:function(){de=!1,be=null,je.set(-1,0,0,0)}}}function r(){let de=!1,Je=!1,be=null,je=null,Te=null;return{setReversed:function(ye){if(Je!==ye){const Ge=e.get("EXT_clip_control");ye?Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.ZERO_TO_ONE_EXT):Ge.clipControlEXT(Ge.LOWER_LEFT_EXT,Ge.NEGATIVE_ONE_TO_ONE_EXT),Je=ye;const ft=Te;Te=null,this.setClear(ft)}},getReversed:function(){return Je},setTest:function(ye){ye?pe(t.DEPTH_TEST):Ce(t.DEPTH_TEST)},setMask:function(ye){be!==ye&&!de&&(t.depthMask(ye),be=ye)},setFunc:function(ye){if(Je&&(ye=age[ye]),je!==ye){switch(ye){case JN:t.depthFunc(t.NEVER);break;case e3:t.depthFunc(t.ALWAYS);break;case t3:t.depthFunc(t.LESS);break;case tm:t.depthFunc(t.LEQUAL);break;case n3:t.depthFunc(t.EQUAL);break;case r3:t.depthFunc(t.GEQUAL);break;case i3:t.depthFunc(t.GREATER);break;case s3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}je=ye}},setLocked:function(ye){de=ye},setClear:function(ye){Te!==ye&&(Je&&(ye=1-ye),t.clearDepth(ye),Te=ye)},reset:function(){de=!1,be=null,je=null,Te=null,Je=!1}}}function i(){let de=!1,Je=null,be=null,je=null,Te=null,ye=null,Ge=null,ft=null,yt=null;return{setTest:function(Rt){de||(Rt?pe(t.STENCIL_TEST):Ce(t.STENCIL_TEST))},setMask:function(Rt){Je!==Rt&&!de&&(t.stencilMask(Rt),Je=Rt)},setFunc:function(Rt,cn,jt){(be!==Rt||je!==cn||Te!==jt)&&(t.stencilFunc(Rt,cn,jt),be=Rt,je=cn,Te=jt)},setOp:function(Rt,cn,jt){(ye!==Rt||Ge!==cn||ft!==jt)&&(t.stencilOp(Rt,cn,jt),ye=Rt,Ge=cn,ft=jt)},setLocked:function(Rt){de=Rt},setClear:function(Rt){yt!==Rt&&(t.clearStencil(Rt),yt=Rt)},reset:function(){de=!1,Je=null,be=null,je=null,Te=null,ye=null,Ge=null,ft=null,yt=null}}}const s=new n,a=new r,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},g=new WeakMap,m=[],v=null,y=!1,b=null,x=null,M=null,w=null,A=null,T=null,R=null,C=new vn(0,0,0),I=0,N=!1,D=null,z=null,j=null,W=null,P=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(Z)[1]),K=G>=1):Z.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),K=G>=2);let Q=null,ee={};const H=t.getParameter(t.SCISSOR_BOX),q=t.getParameter(t.VIEWPORT),te=new Gr().fromArray(H),ae=new Gr().fromArray(q);function xe(de,Je,be,je){const Te=new Uint8Array(4),ye=t.createTexture();t.bindTexture(de,ye),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ge=0;Ge<be;Ge++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(Je,0,t.RGBA,1,1,je,0,t.RGBA,t.UNSIGNED_BYTE,Te):t.texImage2D(Je+Ge,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Te);return ye}const re={};re[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),re[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),re[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),pe(t.DEPTH_TEST),a.setFunc(tm),ie(!1),V(wF),pe(t.CULL_FACE),B(dc);function pe(de){d[de]!==!0&&(t.enable(de),d[de]=!0)}function Ce(de){d[de]!==!1&&(t.disable(de),d[de]=!1)}function fe(de,Je){return h[de]!==Je?(t.bindFramebuffer(de,Je),h[de]=Je,de===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Je),de===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Je),!0):!1}function Se(de,Je){let be=m,je=!1;if(de){be=g.get(Je),be===void 0&&(be=[],g.set(Je,be));const Te=de.textures;if(be.length!==Te.length||be[0]!==t.COLOR_ATTACHMENT0){for(let ye=0,Ge=Te.length;ye<Ge;ye++)be[ye]=t.COLOR_ATTACHMENT0+ye;be.length=Te.length,je=!0}}else be[0]!==t.BACK&&(be[0]=t.BACK,je=!0);je&&t.drawBuffers(be)}function Re(de){return v!==de?(t.useProgram(de),v=de,!0):!1}const ue={[Yd]:t.FUNC_ADD,[aue]:t.FUNC_SUBTRACT,[oue]:t.FUNC_REVERSE_SUBTRACT};ue[lue]=t.MIN,ue[cue]=t.MAX;const ct={[uue]:t.ZERO,[due]:t.ONE,[fue]:t.SRC_COLOR,[ZN]:t.SRC_ALPHA,[bue]:t.SRC_ALPHA_SATURATE,[gue]:t.DST_COLOR,[pue]:t.DST_ALPHA,[hue]:t.ONE_MINUS_SRC_COLOR,[QN]:t.ONE_MINUS_SRC_ALPHA,[xue]:t.ONE_MINUS_DST_COLOR,[mue]:t.ONE_MINUS_DST_ALPHA,[vue]:t.CONSTANT_COLOR,[yue]:t.ONE_MINUS_CONSTANT_COLOR,[_ue]:t.CONSTANT_ALPHA,[Sue]:t.ONE_MINUS_CONSTANT_ALPHA};function B(de,Je,be,je,Te,ye,Ge,ft,yt,Rt){if(de===dc){y===!0&&(Ce(t.BLEND),y=!1);return}if(y===!1&&(pe(t.BLEND),y=!0),de!==sue){if(de!==b||Rt!==N){if((x!==Yd||A!==Yd)&&(t.blendEquation(t.FUNC_ADD),x=Yd,A=Yd),Rt)switch(de){case Fp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case MF:t.blendFunc(t.ONE,t.ONE);break;case EF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case AF:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Or("WebGLState: Invalid blending: ",de);break}else switch(de){case Fp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case MF:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case EF:Or("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case AF:Or("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Or("WebGLState: Invalid blending: ",de);break}M=null,w=null,T=null,R=null,C.set(0,0,0),I=0,b=de,N=Rt}return}Te=Te||Je,ye=ye||be,Ge=Ge||je,(Je!==x||Te!==A)&&(t.blendEquationSeparate(ue[Je],ue[Te]),x=Je,A=Te),(be!==M||je!==w||ye!==T||Ge!==R)&&(t.blendFuncSeparate(ct[be],ct[je],ct[ye],ct[Ge]),M=be,w=je,T=ye,R=Ge),(ft.equals(C)===!1||yt!==I)&&(t.blendColor(ft.r,ft.g,ft.b,yt),C.copy(ft),I=yt),b=de,N=!1}function F(de,Je){de.side===Ko?Ce(t.CULL_FACE):pe(t.CULL_FACE);let be=de.side===$s;Je&&(be=!be),ie(be),de.blending===Fp&&de.transparent===!1?B(dc):B(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),a.setFunc(de.depthFunc),a.setTest(de.depthTest),a.setMask(de.depthWrite),s.setMask(de.colorWrite);const je=de.stencilWrite;o.setTest(je),je&&(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?pe(t.SAMPLE_ALPHA_TO_COVERAGE):Ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(de){D!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),D=de)}function V(de){de!==nue?(pe(t.CULL_FACE),de!==z&&(de===wF?t.cullFace(t.BACK):de===rue?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ce(t.CULL_FACE),z=de}function J(de){de!==j&&(K&&t.lineWidth(de),j=de)}function le(de,Je,be){de?(pe(t.POLYGON_OFFSET_FILL),(W!==Je||P!==be)&&(t.polygonOffset(Je,be),W=Je,P=be)):Ce(t.POLYGON_OFFSET_FILL)}function Ae(de){de?pe(t.SCISSOR_TEST):Ce(t.SCISSOR_TEST)}function Ee(de){de===void 0&&(de=t.TEXTURE0+$-1),Q!==de&&(t.activeTexture(de),Q=de)}function se(de,Je,be){be===void 0&&(Q===null?be=t.TEXTURE0+$-1:be=Q);let je=ee[be];je===void 0&&(je={type:void 0,texture:void 0},ee[be]=je),(je.type!==de||je.texture!==Je)&&(Q!==be&&(t.activeTexture(be),Q=be),t.bindTexture(de,Je||re[de]),je.type=de,je.texture=Je)}function U(){const de=ee[Q];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 X(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function me(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ve(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ge(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ke(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Ie(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ze(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function at(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Fe(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ce(de){te.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),te.copy(de))}function Qe(de){ae.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),ae.copy(de))}function He(de,Je){let be=c.get(Je);be===void 0&&(be=new WeakMap,c.set(Je,be));let je=be.get(de);je===void 0&&(je=t.getUniformBlockIndex(Je,de.name),be.set(de,je))}function Ye(de,Je){const je=c.get(Je).get(de);l.get(Je)!==je&&(t.uniformBlockBinding(Je,je,de.__bindingPointIndex),l.set(Je,je))}function ut(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Q=null,ee={},h={},g=new WeakMap,m=[],v=null,y=!1,b=null,x=null,M=null,w=null,A=null,T=null,R=null,C=new vn(0,0,0),I=0,N=!1,D=null,z=null,j=null,W=null,P=null,te.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:pe,disable:Ce,bindFramebuffer:fe,drawBuffers:Se,useProgram:Re,setBlending:B,setMaterial:F,setFlipSided:ie,setCullFace:V,setLineWidth:J,setPolygonOffset:le,setScissorTest:Ae,activeTexture:Ee,bindTexture:se,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:X,texImage2D:at,texImage3D:Fe,updateUBOMapping:He,uniformBlockBinding:Ye,texStorage2D:Ie,texStorage3D:ze,texSubImage2D:me,texSubImage3D:ve,compressedTexSubImage2D:ge,compressedTexSubImage3D:Ke,scissor:ce,viewport:Qe,reset:ut}}function lge(t,e,n,r,i,s,a){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 on,d=new WeakMap;let h;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(U,L){return m?new OffscreenCanvas(U,L):o1("canvas")}function y(U,L,X){let me=1;const ve=se(U);if((ve.width>X||ve.height>X)&&(me=X/Math.max(ve.width,ve.height)),me<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const ge=Math.floor(me*ve.width),Ke=Math.floor(me*ve.height);h===void 0&&(h=v(ge,Ke));const Ie=L?v(ge,Ke):h;return Ie.width=ge,Ie.height=Ke,Ie.getContext("2d").drawImage(U,0,0,ge,Ke),Xt("WebGLRenderer: Texture has been resized from ("+ve.width+"x"+ve.height+") to ("+ge+"x"+Ke+")."),Ie}else return"data"in U&&Xt("WebGLRenderer: Image in DataTexture is too big ("+ve.width+"x"+ve.height+")."),U;return U}function b(U){return U.generateMipmaps}function x(U){t.generateMipmap(U)}function M(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,L,X,me,ve=!1){if(U!==null){if(t[U]!==void 0)return t[U];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let ge=L;if(L===t.RED&&(X===t.FLOAT&&(ge=t.R32F),X===t.HALF_FLOAT&&(ge=t.R16F),X===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ge=t.R8UI),X===t.UNSIGNED_SHORT&&(ge=t.R16UI),X===t.UNSIGNED_INT&&(ge=t.R32UI),X===t.BYTE&&(ge=t.R8I),X===t.SHORT&&(ge=t.R16I),X===t.INT&&(ge=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ge=t.RG32F),X===t.HALF_FLOAT&&(ge=t.RG16F),X===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RG_INTEGER&&(X===t.UNSIGNED_BYTE&&(ge=t.RG8UI),X===t.UNSIGNED_SHORT&&(ge=t.RG16UI),X===t.UNSIGNED_INT&&(ge=t.RG32UI),X===t.BYTE&&(ge=t.RG8I),X===t.SHORT&&(ge=t.RG16I),X===t.INT&&(ge=t.RG32I)),L===t.RGB_INTEGER&&(X===t.UNSIGNED_BYTE&&(ge=t.RGB8UI),X===t.UNSIGNED_SHORT&&(ge=t.RGB16UI),X===t.UNSIGNED_INT&&(ge=t.RGB32UI),X===t.BYTE&&(ge=t.RGB8I),X===t.SHORT&&(ge=t.RGB16I),X===t.INT&&(ge=t.RGB32I)),L===t.RGBA_INTEGER&&(X===t.UNSIGNED_BYTE&&(ge=t.RGBA8UI),X===t.UNSIGNED_SHORT&&(ge=t.RGBA16UI),X===t.UNSIGNED_INT&&(ge=t.RGBA32UI),X===t.BYTE&&(ge=t.RGBA8I),X===t.SHORT&&(ge=t.RGBA16I),X===t.INT&&(ge=t.RGBA32I)),L===t.RGB&&(X===t.UNSIGNED_INT_5_9_9_9_REV&&(ge=t.RGB9_E5),X===t.UNSIGNED_INT_10F_11F_11F_REV&&(ge=t.R11F_G11F_B10F)),L===t.RGBA){const Ke=ve?s1:En.getTransfer(me);X===t.FLOAT&&(ge=t.RGBA32F),X===t.HALF_FLOAT&&(ge=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ge=Ke===Bn?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function A(U,L){let X;return U?L===null||L===Of||L===o0?X=t.DEPTH24_STENCIL8:L===sc?X=t.DEPTH32F_STENCIL8:L===a0&&(X=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Of||L===o0?X=t.DEPTH_COMPONENT24:L===sc?X=t.DEPTH_COMPONENT32F:L===a0&&(X=t.DEPTH_COMPONENT16),X}function T(U,L){return b(U)===!0||U.isFramebufferTexture&&U.minFilter!==ma&&U.minFilter!==qa?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function R(U){const L=U.target;L.removeEventListener("dispose",R),I(L),L.isVideoTexture&&d.delete(L)}function C(U){const L=U.target;L.removeEventListener("dispose",C),D(L)}function I(U){const L=r.get(U);if(L.__webglInit===void 0)return;const X=U.source,me=g.get(X);if(me){const ve=me[L.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&N(U),Object.keys(me).length===0&&g.delete(X)}r.remove(U)}function N(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const X=U.source,me=g.get(X);delete me[L.__cacheKey],a.memory.textures--}function D(U){const L=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let me=0;me<6;me++){if(Array.isArray(L.__webglFramebuffer[me]))for(let ve=0;ve<L.__webglFramebuffer[me].length;ve++)t.deleteFramebuffer(L.__webglFramebuffer[me][ve]);else t.deleteFramebuffer(L.__webglFramebuffer[me]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[me])}else{if(Array.isArray(L.__webglFramebuffer))for(let me=0;me<L.__webglFramebuffer.length;me++)t.deleteFramebuffer(L.__webglFramebuffer[me]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let me=0;me<L.__webglColorRenderbuffer.length;me++)L.__webglColorRenderbuffer[me]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[me]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const X=U.textures;for(let me=0,ve=X.length;me<ve;me++){const ge=r.get(X[me]);ge.__webglTexture&&(t.deleteTexture(ge.__webglTexture),a.memory.textures--),r.remove(X[me])}r.remove(U)}let z=0;function j(){z=0}function W(){const U=z;return U>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),z+=1,U}function P(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function $(U,L){const X=r.get(U);if(U.isVideoTexture&&Ae(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&X.__version!==U.version){const me=U.image;if(me===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{re(X,U,L);return}}else U.isExternalTexture&&(X.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function K(U,L){const X=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){re(X,U,L);return}else U.isExternalTexture&&(X.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function G(U,L){const X=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){re(X,U,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function Z(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){pe(X,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const Q={[l3]:t.REPEAT,[ic]:t.CLAMP_TO_EDGE,[c3]:t.MIRRORED_REPEAT},ee={[ma]:t.NEAREST,[Pue]:t.NEAREST_MIPMAP_NEAREST,[Gv]:t.NEAREST_MIPMAP_LINEAR,[qa]:t.LINEAR,[J2]:t.LINEAR_MIPMAP_NEAREST,[rf]:t.LINEAR_MIPMAP_LINEAR},H={[jue]:t.NEVER,[Hue]:t.ALWAYS,[Iue]:t.LESS,[$9]:t.LEQUAL,[Uue]:t.EQUAL,[Bue]:t.GEQUAL,[Fue]:t.GREATER,[zue]:t.NOTEQUAL};function q(U,L){if(L.type===sc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===qa||L.magFilter===J2||L.magFilter===Gv||L.magFilter===rf||L.minFilter===qa||L.minFilter===J2||L.minFilter===Gv||L.minFilter===rf)&&Xt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,Q[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,Q[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,Q[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ee[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ee[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,H[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ma||L.minFilter!==Gv&&L.minFilter!==rf||L.type===sc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function te(U,L){let X=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",R));const me=L.source;let ve=g.get(me);ve===void 0&&(ve={},g.set(me,ve));const ge=P(L);if(ge!==U.__cacheKey){ve[ge]===void 0&&(ve[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,X=!0),ve[ge].usedTimes++;const Ke=ve[U.__cacheKey];Ke!==void 0&&(ve[U.__cacheKey].usedTimes--,Ke.usedTimes===0&&N(L)),U.__cacheKey=ge,U.__webglTexture=ve[ge].texture}return X}function ae(U,L,X){return Math.floor(Math.floor(U/X)/L)}function xe(U,L,X,me){const ge=U.updateRanges;if(ge.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,X,me,L.data);else{ge.sort((Fe,ce)=>Fe.start-ce.start);let Ke=0;for(let Fe=1;Fe<ge.length;Fe++){const ce=ge[Ke],Qe=ge[Fe],He=ce.start+ce.count,Ye=ae(Qe.start,L.width,4),ut=ae(ce.start,L.width,4);Qe.start<=He+1&&Ye===ut&&ae(Qe.start+Qe.count-1,L.width,4)===Ye?ce.count=Math.max(ce.count,Qe.start+Qe.count-ce.start):(++Ke,ge[Ke]=Qe)}ge.length=Ke+1;const Ie=t.getParameter(t.UNPACK_ROW_LENGTH),ze=t.getParameter(t.UNPACK_SKIP_PIXELS),at=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Fe=0,ce=ge.length;Fe<ce;Fe++){const Qe=ge[Fe],He=Math.floor(Qe.start/4),Ye=Math.ceil(Qe.count/4),ut=He%L.width,de=Math.floor(He/L.width),Je=Ye,be=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ut),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,ut,de,Je,be,X,me,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ie),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ze),t.pixelStorei(t.UNPACK_SKIP_ROWS,at)}}function re(U,L,X){let me=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(me=t.TEXTURE_3D);const ve=te(U,L),ge=L.source;n.bindTexture(me,U.__webglTexture,t.TEXTURE0+X);const Ke=r.get(ge);if(ge.version!==Ke.__version||ve===!0){n.activeTexture(t.TEXTURE0+X);const Ie=En.getPrimaries(En.workingColorSpace),ze=L.colorSpace===ku?null:En.getPrimaries(L.colorSpace),at=L.colorSpace===ku||Ie===ze?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,at);let Fe=y(L.image,!1,i.maxTextureSize);Fe=Ee(L,Fe);const ce=s.convert(L.format,L.colorSpace),Qe=s.convert(L.type);let He=w(L.internalFormat,ce,Qe,L.colorSpace,L.isVideoTexture);q(me,L);let Ye;const ut=L.mipmaps,de=L.isVideoTexture!==!0,Je=Ke.__version===void 0||ve===!0,be=ge.dataReady,je=T(L,Fe);if(L.isDepthTexture)He=A(L.format===c0,L.type),Je&&(de?n.texStorage2D(t.TEXTURE_2D,1,He,Fe.width,Fe.height):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,ce,Qe,null));else if(L.isDataTexture)if(ut.length>0){de&&Je&&n.texStorage2D(t.TEXTURE_2D,je,He,ut[0].width,ut[0].height);for(let Te=0,ye=ut.length;Te<ye;Te++)Ye=ut[Te],de?be&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,Ye.width,Ye.height,ce,Qe,Ye.data):n.texImage2D(t.TEXTURE_2D,Te,He,Ye.width,Ye.height,0,ce,Qe,Ye.data);L.generateMipmaps=!1}else de?(Je&&n.texStorage2D(t.TEXTURE_2D,je,He,Fe.width,Fe.height),be&&xe(L,Fe,ce,Qe)):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,ce,Qe,Fe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,He,ut[0].width,ut[0].height,Fe.depth);for(let Te=0,ye=ut.length;Te<ye;Te++)if(Ye=ut[Te],L.format!==wo)if(ce!==null)if(de){if(be)if(L.layerUpdates.size>0){const Ge=n5(Ye.width,Ye.height,L.format,L.type);for(const ft of L.layerUpdates){const yt=Ye.data.subarray(ft*Ge/Ye.data.BYTES_PER_ELEMENT,(ft+1)*Ge/Ye.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,ft,Ye.width,Ye.height,1,ce,yt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,Ye.width,Ye.height,Fe.depth,ce,Ye.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Te,He,Ye.width,Ye.height,Fe.depth,0,Ye.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?be&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,Ye.width,Ye.height,Fe.depth,ce,Qe,Ye.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Te,He,Ye.width,Ye.height,Fe.depth,0,ce,Qe,Ye.data)}else{de&&Je&&n.texStorage2D(t.TEXTURE_2D,je,He,ut[0].width,ut[0].height);for(let Te=0,ye=ut.length;Te<ye;Te++)Ye=ut[Te],L.format!==wo?ce!==null?de?be&&n.compressedTexSubImage2D(t.TEXTURE_2D,Te,0,0,Ye.width,Ye.height,ce,Ye.data):n.compressedTexImage2D(t.TEXTURE_2D,Te,He,Ye.width,Ye.height,0,Ye.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?be&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,Ye.width,Ye.height,ce,Qe,Ye.data):n.texImage2D(t.TEXTURE_2D,Te,He,Ye.width,Ye.height,0,ce,Qe,Ye.data)}else if(L.isDataArrayTexture)if(de){if(Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,He,Fe.width,Fe.height,Fe.depth),be)if(L.layerUpdates.size>0){const Te=n5(Fe.width,Fe.height,L.format,L.type);for(const ye of L.layerUpdates){const Ge=Fe.data.subarray(ye*Te/Fe.data.BYTES_PER_ELEMENT,(ye+1)*Te/Fe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ye,Fe.width,Fe.height,1,ce,Qe,Ge)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,ce,Qe,Fe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,He,Fe.width,Fe.height,Fe.depth,0,ce,Qe,Fe.data);else if(L.isData3DTexture)de?(Je&&n.texStorage3D(t.TEXTURE_3D,je,He,Fe.width,Fe.height,Fe.depth),be&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,ce,Qe,Fe.data)):n.texImage3D(t.TEXTURE_3D,0,He,Fe.width,Fe.height,Fe.depth,0,ce,Qe,Fe.data);else if(L.isFramebufferTexture){if(Je)if(de)n.texStorage2D(t.TEXTURE_2D,je,He,Fe.width,Fe.height);else{let Te=Fe.width,ye=Fe.height;for(let Ge=0;Ge<je;Ge++)n.texImage2D(t.TEXTURE_2D,Ge,He,Te,ye,0,ce,Qe,null),Te>>=1,ye>>=1}}else if(ut.length>0){if(de&&Je){const Te=se(ut[0]);n.texStorage2D(t.TEXTURE_2D,je,He,Te.width,Te.height)}for(let Te=0,ye=ut.length;Te<ye;Te++)Ye=ut[Te],de?be&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,ce,Qe,Ye):n.texImage2D(t.TEXTURE_2D,Te,He,ce,Qe,Ye);L.generateMipmaps=!1}else if(de){if(Je){const Te=se(Fe);n.texStorage2D(t.TEXTURE_2D,je,He,Te.width,Te.height)}be&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce,Qe,Fe)}else n.texImage2D(t.TEXTURE_2D,0,He,ce,Qe,Fe);b(L)&&x(me),Ke.__version=ge.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function pe(U,L,X){if(L.image.length!==6)return;const me=te(U,L),ve=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+X);const ge=r.get(ve);if(ve.version!==ge.__version||me===!0){n.activeTexture(t.TEXTURE0+X);const Ke=En.getPrimaries(En.workingColorSpace),Ie=L.colorSpace===ku?null:En.getPrimaries(L.colorSpace),ze=L.colorSpace===ku||Ke===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,ze);const at=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let ye=0;ye<6;ye++)!at&&!Fe?ce[ye]=y(L.image[ye],!0,i.maxCubemapSize):ce[ye]=Fe?L.image[ye].image:L.image[ye],ce[ye]=Ee(L,ce[ye]);const Qe=ce[0],He=s.convert(L.format,L.colorSpace),Ye=s.convert(L.type),ut=w(L.internalFormat,He,Ye,L.colorSpace),de=L.isVideoTexture!==!0,Je=ge.__version===void 0||me===!0,be=ve.dataReady;let je=T(L,Qe);q(t.TEXTURE_CUBE_MAP,L);let Te;if(at){de&&Je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,je,ut,Qe.width,Qe.height);for(let ye=0;ye<6;ye++){Te=ce[ye].mipmaps;for(let Ge=0;Ge<Te.length;Ge++){const ft=Te[Ge];L.format!==wo?He!==null?de?be&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,0,0,ft.width,ft.height,He,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,ut,ft.width,ft.height,0,ft.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,0,0,ft.width,ft.height,He,Ye,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,ut,ft.width,ft.height,0,He,Ye,ft.data)}}}else{if(Te=L.mipmaps,de&&Je){Te.length>0&&je++;const ye=se(ce[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,je,ut,ye.width,ye.height)}for(let ye=0;ye<6;ye++)if(Fe){de?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ce[ye].width,ce[ye].height,He,Ye,ce[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,ut,ce[ye].width,ce[ye].height,0,He,Ye,ce[ye].data);for(let Ge=0;Ge<Te.length;Ge++){const yt=Te[Ge].image[ye].image;de?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,0,0,yt.width,yt.height,He,Ye,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,ut,yt.width,yt.height,0,He,Ye,yt.data)}}else{de?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,He,Ye,ce[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,ut,He,Ye,ce[ye]);for(let Ge=0;Ge<Te.length;Ge++){const ft=Te[Ge];de?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,0,0,He,Ye,ft.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,ut,He,Ye,ft.image[ye])}}}b(L)&&x(t.TEXTURE_CUBE_MAP),ge.__version=ve.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ce(U,L,X,me,ve,ge){const Ke=s.convert(X.format,X.colorSpace),Ie=s.convert(X.type),ze=w(X.internalFormat,Ke,Ie,X.colorSpace),at=r.get(L),Fe=r.get(X);if(Fe.__renderTarget=L,!at.__hasExternalTextures){const ce=Math.max(1,L.width>>ge),Qe=Math.max(1,L.height>>ge);ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY?n.texImage3D(ve,ge,ze,ce,Qe,L.depth,0,Ke,Ie,null):n.texImage2D(ve,ge,ze,ce,Qe,0,Ke,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ve,Fe.__webglTexture,0,J(L)):(ve===t.TEXTURE_2D||ve>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ve<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,ve,Fe.__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const me=L.depthTexture,ve=me&&me.isDepthTexture?me.type:null,ge=A(L.stencilBuffer,ve),Ke=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=J(L);le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ie,ge,L.width,L.height):X?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ie,ge,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ke,t.RENDERBUFFER,U)}else{const me=L.textures;for(let ve=0;ve<me.length;ve++){const ge=me[ve],Ke=s.convert(ge.format,ge.colorSpace),Ie=s.convert(ge.type),ze=w(ge.internalFormat,Ke,Ie,ge.colorSpace),at=J(L);X&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,at,ze,L.width,L.height):le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,at,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Se(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const me=r.get(L.depthTexture);me.__renderTarget=L,(!me.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),$(L.depthTexture,0);const ve=me.__webglTexture,ge=J(L);if(L.depthTexture.format===l0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(L.depthTexture.format===c0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function Re(U){const L=r.get(U),X=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const me=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),me){const ve=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,me.removeEventListener("dispose",ve)};me.addEventListener("dispose",ve),L.__depthDisposeCallback=ve}L.__boundDepthTexture=me}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");const me=U.texture.mipmaps;me&&me.length>0?Se(L.__webglFramebuffer[0],U):Se(L.__webglFramebuffer,U)}else if(X){L.__webglDepthbuffer=[];for(let me=0;me<6;me++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[me]),L.__webglDepthbuffer[me]===void 0)L.__webglDepthbuffer[me]=t.createRenderbuffer(),fe(L.__webglDepthbuffer[me],U,!1);else{const ve=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer[me];t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,ve,t.RENDERBUFFER,ge)}}else{const me=U.texture.mipmaps;if(me&&me.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),fe(L.__webglDepthbuffer,U,!1);else{const ve=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,ve,t.RENDERBUFFER,ge)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(U,L,X){const me=r.get(U);L!==void 0&&Ce(me.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&Re(U)}function ct(U){const L=U.texture,X=r.get(U),me=r.get(L);U.addEventListener("dispose",C);const ve=U.textures,ge=U.isWebGLCubeRenderTarget===!0,Ke=ve.length>1;if(Ke||(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=L.version,a.memory.textures++),ge){X.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Ie]=[];for(let ze=0;ze<L.mipmaps.length;ze++)X.__webglFramebuffer[Ie][ze]=t.createFramebuffer()}else X.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)X.__webglFramebuffer[Ie]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(Ke)for(let Ie=0,ze=ve.length;Ie<ze;Ie++){const at=r.get(ve[Ie]);at.__webglTexture===void 0&&(at.__webglTexture=t.createTexture(),a.memory.textures++)}if(U.samples>0&&le(U)===!1){X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let Ie=0;Ie<ve.length;Ie++){const ze=ve[Ie];X.__webglColorRenderbuffer[Ie]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[Ie]);const at=s.convert(ze.format,ze.colorSpace),Fe=s.convert(ze.type),ce=w(ze.internalFormat,at,Fe,ze.colorSpace,U.isXRRenderTarget===!0),Qe=J(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,ce,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ie,t.RENDERBUFFER,X.__webglColorRenderbuffer[Ie])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(X.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ge){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),q(t.TEXTURE_CUBE_MAP,L);for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)Ce(X.__webglFramebuffer[Ie][ze],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,ze);else Ce(X.__webglFramebuffer[Ie],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);b(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ke){for(let Ie=0,ze=ve.length;Ie<ze;Ie++){const at=ve[Ie],Fe=r.get(at);let ce=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ce=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ce,Fe.__webglTexture),q(ce,at),Ce(X.__webglFramebuffer,U,at,t.COLOR_ATTACHMENT0+Ie,ce,0),b(at)&&x(ce)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ie=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ie,me.__webglTexture),q(Ie,L),L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)Ce(X.__webglFramebuffer[ze],U,L,t.COLOR_ATTACHMENT0,Ie,ze);else Ce(X.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ie,0);b(L)&&x(Ie),n.unbindTexture()}U.depthBuffer&&Re(U)}function B(U){const L=U.textures;for(let X=0,me=L.length;X<me;X++){const ve=L[X];if(b(ve)){const ge=M(U),Ke=r.get(ve).__webglTexture;n.bindTexture(ge,Ke),x(ge),n.unbindTexture()}}}const F=[],ie=[];function V(U){if(U.samples>0){if(le(U)===!1){const L=U.textures,X=U.width,me=U.height;let ve=t.COLOR_BUFFER_BIT;const ge=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ke=r.get(U),Ie=L.length>1;if(Ie)for(let at=0;at<L.length;at++)n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer);const ze=U.texture.mipmaps;ze&&ze.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer);for(let at=0;at<L.length;at++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ve|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ve|=t.STENCIL_BUFFER_BIT)),Ie){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ke.__webglColorRenderbuffer[at]);const Fe=r.get(L[at]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Fe,0)}t.blitFramebuffer(0,0,X,me,0,0,X,me,ve,t.NEAREST),l===!0&&(F.length=0,ie.length=0,F.push(t.COLOR_ATTACHMENT0+at),U.depthBuffer&&U.resolveDepthBuffer===!1&&(F.push(ge),ie.push(ge),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,F))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ie)for(let at=0;at<L.length;at++){n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.RENDERBUFFER,Ke.__webglColorRenderbuffer[at]);const Fe=r.get(L[at]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(U){return Math.min(i.maxSamples,U.samples)}function le(U){const L=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae(U){const L=a.render.frame;d.get(U)!==L&&(d.set(U,L),U.update())}function Ee(U,L){const X=U.colorSpace,me=U.format,ve=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||X!==im&&X!==ku&&(En.getTransfer(X)===Bn?(me!==wo||ve!==sl)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Or("WebGLTextures: Unsupported texture color space:",X)),L}function se(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=j,this.setTexture2D=$,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=ue,this.setupRenderTarget=ct,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=Re,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=le}function cge(t,e){function n(r,i=ku){let s;const a=En.getTransfer(i);if(r===sl)return t.UNSIGNED_BYTE;if(r===gP)return t.UNSIGNED_SHORT_4_4_4_4;if(r===xP)return t.UNSIGNED_SHORT_5_5_5_1;if(r===I9)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===U9)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===L9)return t.BYTE;if(r===j9)return t.SHORT;if(r===a0)return t.UNSIGNED_SHORT;if(r===mP)return t.INT;if(r===Of)return t.UNSIGNED_INT;if(r===sc)return t.FLOAT;if(r===Pm)return t.HALF_FLOAT;if(r===F9)return t.ALPHA;if(r===z9)return t.RGB;if(r===wo)return t.RGBA;if(r===l0)return t.DEPTH_COMPONENT;if(r===c0)return t.DEPTH_STENCIL;if(r===B9)return t.RED;if(r===bP)return t.RED_INTEGER;if(r===vP)return t.RG;if(r===yP)return t.RG_INTEGER;if(r===_P)return t.RGBA_INTEGER;if(r===T_||r===C_||r===N_||r===k_)if(a===Bn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===T_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===C_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===N_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===k_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===T_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===C_)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===N_)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===k_)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===u3||r===d3||r===f3||r===h3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===u3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===d3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===f3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===h3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===p3||r===m3||r===g3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===p3||r===m3)return a===Bn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===g3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===x3||r===b3||r===v3||r===y3||r===_3||r===S3||r===w3||r===M3||r===E3||r===A3||r===T3||r===C3||r===N3||r===k3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===x3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===b3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===v3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===y3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===_3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===S3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===w3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===M3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===E3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===A3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===T3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===C3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===N3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===k3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===R3||r===P3||r===D3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===R3)return a===Bn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===P3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===D3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===O3||r===L3||r===j3||r===I3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===O3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===L3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===j3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===I3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===o0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const uge=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,dge=`
  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 fge{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new l7(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 yc({vertexShader:uge,fragmentShader:dge,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new al(new TP(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let hge=class extends Jf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,g=null,m=null,v=null;const y=typeof XRWebGLBinding<"u",b=new fge,x={},M=n.getContextAttributes();let w=null,A=null;const T=[],R=[],C=new on;let I=null;const N=new Ha;N.viewport=new Gr;const D=new Ha;D.viewport=new Gr;const z=[N,D],j=new kde;let W=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let pe=T[re];return pe===void 0&&(pe=new _A,T[re]=pe),pe.getTargetRaySpace()},this.getControllerGrip=function(re){let pe=T[re];return pe===void 0&&(pe=new _A,T[re]=pe),pe.getGripSpace()},this.getHand=function(re){let pe=T[re];return pe===void 0&&(pe=new _A,T[re]=pe),pe.getHandSpace()};function $(re){const pe=R.indexOf(re.inputSource);if(pe===-1)return;const Ce=T[pe];Ce!==void 0&&(Ce.update(re.inputSource,re.frame,c||a),Ce.dispatchEvent({type:re.type,data:re.inputSource}))}function K(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let re=0;re<T.length;re++){const pe=R[re];pe!==null&&(R[re]=null,T[re].disconnect(pe))}W=null,P=null,b.reset();for(const re in x)delete x[re];e.setRenderTarget(w),m=null,g=null,h=null,i=null,A=null,xe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){s=re,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){o=re,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(re){c=re},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return v},this.getSession=function(){return i},this.setSession=async function(re){if(i=re,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),M.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ce=null,fe=null,Se=null;M.depth&&(Se=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ce=M.stencil?c0:l0,fe=M.stencil?o0:Of);const Re={colorFormat:n.RGBA8,depthFormat:Se,scaleFactor:s};h=this.getBinding(),g=h.createProjectionLayer(Re),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new jf(g.textureWidth,g.textureHeight,{format:wo,type:sl,depthTexture:new o7(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,Ce),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ce={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Ce),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new jf(m.framebufferWidth,m.framebufferHeight,{format:wo,type:sl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=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(re){for(let pe=0;pe<re.removed.length;pe++){const Ce=re.removed[pe],fe=R.indexOf(Ce);fe>=0&&(R[fe]=null,T[fe].disconnect(Ce))}for(let pe=0;pe<re.added.length;pe++){const Ce=re.added[pe];let fe=R.indexOf(Ce);if(fe===-1){for(let Re=0;Re<T.length;Re++)if(Re>=R.length){R.push(Ce),fe=Re;break}else if(R[Re]===null){R[Re]=Ce,fe=Re;break}if(fe===-1)break}const Se=T[fe];Se&&Se.connect(Ce)}}const Z=new Xe,Q=new Xe;function ee(re,pe,Ce){Z.setFromMatrixPosition(pe.matrixWorld),Q.setFromMatrixPosition(Ce.matrixWorld);const fe=Z.distanceTo(Q),Se=pe.projectionMatrix.elements,Re=Ce.projectionMatrix.elements,ue=Se[14]/(Se[10]-1),ct=Se[14]/(Se[10]+1),B=(Se[9]+1)/Se[5],F=(Se[9]-1)/Se[5],ie=(Se[8]-1)/Se[0],V=(Re[8]+1)/Re[0],J=ue*ie,le=ue*V,Ae=fe/(-ie+V),Ee=Ae*-ie;if(pe.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(Ee),re.translateZ(Ae),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert(),Se[10]===-1)re.projectionMatrix.copy(pe.projectionMatrix),re.projectionMatrixInverse.copy(pe.projectionMatrixInverse);else{const se=ue+Ae,U=ct+Ae,L=J-Ee,X=le+(fe-Ee),me=B*ct/U*se,ve=F*ct/U*se;re.projectionMatrix.makePerspective(L,X,me,ve,se,U),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}}function H(re,pe){pe===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(pe.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(i===null)return;let pe=re.near,Ce=re.far;b.texture!==null&&(b.depthNear>0&&(pe=b.depthNear),b.depthFar>0&&(Ce=b.depthFar)),j.near=D.near=N.near=pe,j.far=D.far=N.far=Ce,(W!==j.near||P!==j.far)&&(i.updateRenderState({depthNear:j.near,depthFar:j.far}),W=j.near,P=j.far),j.layers.mask=re.layers.mask|6,N.layers.mask=j.layers.mask&3,D.layers.mask=j.layers.mask&5;const fe=re.parent,Se=j.cameras;H(j,fe);for(let Re=0;Re<Se.length;Re++)H(Se[Re],fe);Se.length===2?ee(j,N,D):j.projectionMatrix.copy(N.projectionMatrix),q(re,j,fe)};function q(re,pe,Ce){Ce===null?re.matrix.copy(pe.matrixWorld):(re.matrix.copy(Ce.matrixWorld),re.matrix.invert(),re.matrix.multiply(pe.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(pe.projectionMatrix),re.projectionMatrixInverse.copy(pe.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=U3*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(re){l=re,g!==null&&(g.fixedFoveation=re),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=re)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(j)},this.getCameraTexture=function(re){return x[re]};let te=null;function ae(re,pe){if(d=pe.getViewerPose(c||a),v=pe,d!==null){const Ce=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let fe=!1;Ce.length!==j.cameras.length&&(j.cameras.length=0,fe=!0);for(let ct=0;ct<Ce.length;ct++){const B=Ce[ct];let F=null;if(m!==null)F=m.getViewport(B);else{const V=h.getViewSubImage(g,B);F=V.viewport,ct===0&&(e.setRenderTargetTextures(A,V.colorTexture,V.depthStencilTexture),e.setRenderTarget(A))}let ie=z[ct];ie===void 0&&(ie=new Ha,ie.layers.enable(ct),ie.viewport=new Gr,z[ct]=ie),ie.matrix.fromArray(B.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(B.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(F.x,F.y,F.width,F.height),ct===0&&(j.matrix.copy(ie.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),fe===!0&&j.cameras.push(ie)}const Se=i.enabledFeatures;if(Se&&Se.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const ct=h.getDepthInformation(Ce[0]);ct&&ct.isValid&&ct.texture&&b.init(ct,i.renderState)}if(Se&&Se.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let ct=0;ct<Ce.length;ct++){const B=Ce[ct].camera;if(B){let F=x[B];F||(F=new l7,x[B]=F);const ie=h.getCameraImage(B);F.sourceTexture=ie}}}}for(let Ce=0;Ce<T.length;Ce++){const fe=R[Ce],Se=T[Ce];fe!==null&&Se!==void 0&&Se.update(fe,pe,c||a)}te&&te(re,pe),pe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:pe}),v=null}const xe=new f7;xe.setAnimationLoop(ae),this.setAnimationLoop=function(re){te=re},this.dispose=function(){}}};const Fd=new Ju,pge=new Yr;function mge(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,r7(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?s(b,x):x.isMeshToonMaterial?(s(b,x),h(b,x)):x.isMeshPhongMaterial?(s(b,x),d(b,x)):x.isMeshStandardMaterial?(s(b,x),g(b,x),x.isMeshPhysicalMaterial&&m(b,x,A)):x.isMeshMatcapMaterial?(s(b,x),v(b,x)):x.isMeshDepthMaterial?s(b,x):x.isMeshDistanceMaterial?(s(b,x),y(b,x)):x.isMeshNormalMaterial?s(b,x):x.isLineBasicMaterial?(a(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 s(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===$s&&(b.bumpScale.value*=-1)),x.normalMap&&(b.normalMap.value=x.normalMap,n(x.normalMap,b.normalMapTransform),b.normalScale.value.copy(x.normalScale),x.side===$s&&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,Fd.copy(A),Fd.x*=-1,Fd.y*=-1,Fd.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Fd.y*=-1,Fd.z*=-1),b.envMapRotation.value.setFromMatrix4(pge.makeRotationFromEuler(Fd)),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 a(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 d(b,x){b.specular.value.copy(x.specular),b.shininess.value=Math.max(x.shininess,1e-4)}function h(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===$s&&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 v(b,x){x.matcap&&(b.matcap.value=x.matcap)}function y(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 gge(t,e,n,r){let i={},s={},a=[];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&&(v(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;s[M.id]!==R&&(g(M),s[M.id]=R)}function d(M){const w=h();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 h(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Or("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,C=A.length;R<C;R++){const I=Array.isArray(A[R])?A[R]:[A[R]];for(let N=0,D=I.length;N<D;N++){const z=I[N];if(m(z,R,N,T)===!0){const j=z.__offset,W=Array.isArray(z.value)?z.value:[z.value];let P=0;for(let $=0;$<W.length;$++){const K=W[$],G=y(K);typeof K=="number"||typeof K=="boolean"?(z.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,j+P,z.__data)):K.isMatrix3?(z.__data[0]=K.elements[0],z.__data[1]=K.elements[1],z.__data[2]=K.elements[2],z.__data[3]=0,z.__data[4]=K.elements[3],z.__data[5]=K.elements[4],z.__data[6]=K.elements[5],z.__data[7]=0,z.__data[8]=K.elements[6],z.__data[9]=K.elements[7],z.__data[10]=K.elements[8],z.__data[11]=0):(K.toArray(z.__data,P),P+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,j,z.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,A,T){const R=M.value,C=w+"_"+A;if(T[C]===void 0)return typeof R=="number"||typeof R=="boolean"?T[C]=R:T[C]=R.clone(),!0;{const I=T[C];if(typeof R=="number"||typeof R=="boolean"){if(I!==R)return T[C]=R,!0}else if(I.equals(R)===!1)return I.copy(R),!0}return!1}function v(M){const w=M.uniforms;let A=0;const T=16;for(let C=0,I=w.length;C<I;C++){const N=Array.isArray(w[C])?w[C]:[w[C]];for(let D=0,z=N.length;D<z;D++){const j=N[D],W=Array.isArray(j.value)?j.value:[j.value];for(let P=0,$=W.length;P<$;P++){const K=W[P],G=y(K),Z=A%T,Q=Z%G.boundary,ee=Z+Q;A+=Q,ee!==0&&T-ee<G.storage&&(A+=T-ee),j.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=A,A+=G.storage}}}const R=A%T;return R>0&&(A+=T-R),M.__size=A,M.__cache={},this}function y(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?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",M),w}function b(M){const w=M.target;w.removeEventListener("dispose",b);const A=a.indexOf(w.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);a=[],i={},s={}}return{bind:l,update:c,dispose:x}}const xge=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 Ul=null;function bge(){return Ul===null&&(Ul=new bde(xge,32,32,vP,Pm),Ul.minFilter=qa,Ul.magFilter=qa,Ul.wrapS=ic,Ul.wrapT=ic,Ul.generateMipmaps=!1,Ul.needsUpdate=!0),Ul}let vge=class{constructor(e={}){const{canvas:n=$ue(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!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=a;const v=new Set([_P,yP,bP]),y=new Set([sl,Of,a0,o0,gP,xP]),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=Hu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const R=this;let C=!1;this._outputColorSpace=Fa;let I=0,N=0,D=null,z=-1,j=null;const W=new Gr,P=new Gr;let $=null;const K=new vn(0);let G=0,Z=n.width,Q=n.height,ee=1,H=null,q=null;const te=new Gr(0,0,Z,Q),ae=new Gr(0,0,Z,Q);let xe=!1;const re=new AP;let pe=!1,Ce=!1;const fe=new Yr,Se=new Xe,Re=new Gr,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function B(){return D===null?ee:1}let F=r;function ie(ne,_e){return n.getContext(ne,_e)}try{const ne={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${hP}`),n.addEventListener("webglcontextlost",Te,!1),n.addEventListener("webglcontextrestored",ye,!1),n.addEventListener("webglcontextcreationerror",Ge,!1),F===null){const _e="webgl2";if(F=ie(_e,ne),F===null)throw ie(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ne){throw ne("WebGLRenderer: "+ne.message),ne}let V,J,le,Ae,Ee,se,U,L,X,me,ve,ge,Ke,Ie,ze,at,Fe,ce,Qe,He,Ye,ut,de,Je;function be(){V=new Tpe(F),V.init(),ut=new cge(F,V),J=new bpe(F,V,e,ut),le=new oge(F,V),J.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),Ae=new kpe(F),Ee=new Xme,se=new lge(F,V,le,Ee,J,ut,Ae),U=new ype(R),L=new Ape(R),X=new Ode(F),de=new gpe(F,X),me=new Cpe(F,X,Ae,de),ve=new Ppe(F,me,X,Ae),Qe=new Rpe(F,J,se),at=new vpe(Ee),ge=new qme(R,U,L,V,J,de,at),Ke=new mge(R,Ee),Ie=new Yme,ze=new nge(V),ce=new mpe(R,U,L,le,ve,m,l),Fe=new sge(R,ve,J),Je=new gge(F,Ae,J,le),He=new xpe(F,V,Ae),Ye=new Npe(F,V,Ae),Ae.programs=ge.programs,R.capabilities=J,R.extensions=V,R.properties=Ee,R.renderLists=Ie,R.shadowMap=Fe,R.state=le,R.info=Ae}be();const je=new hge(R,F);this.xr=je,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){const ne=V.get("WEBGL_lose_context");ne&&ne.loseContext()},this.forceContextRestore=function(){const ne=V.get("WEBGL_lose_context");ne&&ne.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(ne){ne!==void 0&&(ee=ne,this.setSize(Z,Q,!1))},this.getSize=function(ne){return ne.set(Z,Q)},this.setSize=function(ne,_e,De=!0){if(je.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ne,Q=_e,n.width=Math.floor(ne*ee),n.height=Math.floor(_e*ee),De===!0&&(n.style.width=ne+"px",n.style.height=_e+"px"),this.setViewport(0,0,ne,_e)},this.getDrawingBufferSize=function(ne){return ne.set(Z*ee,Q*ee).floor()},this.setDrawingBufferSize=function(ne,_e,De){Z=ne,Q=_e,ee=De,n.width=Math.floor(ne*De),n.height=Math.floor(_e*De),this.setViewport(0,0,ne,_e)},this.getCurrentViewport=function(ne){return ne.copy(W)},this.getViewport=function(ne){return ne.copy(te)},this.setViewport=function(ne,_e,De,Pe){ne.isVector4?te.set(ne.x,ne.y,ne.z,ne.w):te.set(ne,_e,De,Pe),le.viewport(W.copy(te).multiplyScalar(ee).round())},this.getScissor=function(ne){return ne.copy(ae)},this.setScissor=function(ne,_e,De,Pe){ne.isVector4?ae.set(ne.x,ne.y,ne.z,ne.w):ae.set(ne,_e,De,Pe),le.scissor(P.copy(ae).multiplyScalar(ee).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(ne){le.setScissorTest(xe=ne)},this.setOpaqueSort=function(ne){H=ne},this.setTransparentSort=function(ne){q=ne},this.getClearColor=function(ne){return ne.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor(...arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha(...arguments)},this.clear=function(ne=!0,_e=!0,De=!0){let Pe=0;if(ne){let Me=!1;if(D!==null){const it=D.texture.format;Me=v.has(it)}if(Me){const it=D.texture.type,ht=y.has(it),bt=ce.getClearColor(),xt=ce.getClearAlpha(),Pt=bt.r,wt=bt.g,mt=bt.b;ht?(b[0]=Pt,b[1]=wt,b[2]=mt,b[3]=xt,F.clearBufferuiv(F.COLOR,0,b)):(x[0]=Pt,x[1]=wt,x[2]=mt,x[3]=xt,F.clearBufferiv(F.COLOR,0,x))}else Pe|=F.COLOR_BUFFER_BIT}_e&&(Pe|=F.DEPTH_BUFFER_BIT),De&&(Pe|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),F.clear(Pe)},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",Te,!1),n.removeEventListener("webglcontextrestored",ye,!1),n.removeEventListener("webglcontextcreationerror",Ge,!1),ce.dispose(),Ie.dispose(),ze.dispose(),Ee.dispose(),U.dispose(),L.dispose(),ve.dispose(),de.dispose(),Je.dispose(),ge.dispose(),je.dispose(),je.removeEventListener("sessionstart",qn),je.removeEventListener("sessionend",bi),ti.stop()};function Te(ne){ne.preventDefault(),RF("WebGLRenderer: Context Lost."),C=!0}function ye(){RF("WebGLRenderer: Context Restored."),C=!1;const ne=Ae.autoReset,_e=Fe.enabled,De=Fe.autoUpdate,Pe=Fe.needsUpdate,Me=Fe.type;be(),Ae.autoReset=ne,Fe.enabled=_e,Fe.autoUpdate=De,Fe.needsUpdate=Pe,Fe.type=Me}function Ge(ne){Or("WebGLRenderer: A WebGL context could not be created. Reason: ",ne.statusMessage)}function ft(ne){const _e=ne.target;_e.removeEventListener("dispose",ft),yt(_e)}function yt(ne){Rt(ne),Ee.remove(ne)}function Rt(ne){const _e=Ee.get(ne).programs;_e!==void 0&&(_e.forEach(function(De){ge.releaseProgram(De)}),ne.isShaderMaterial&&ge.releaseShaderCache(ne))}this.renderBufferDirect=function(ne,_e,De,Pe,Me,it){_e===null&&(_e=ue);const ht=Me.isMesh&&Me.matrixWorld.determinant()<0,bt=he(ne,_e,De,Pe,Me);le.setMaterial(Pe,ht);let xt=De.index,Pt=1;if(Pe.wireframe===!0){if(xt=me.getWireframeAttribute(De),xt===void 0)return;Pt=2}const wt=De.drawRange,mt=De.attributes.position;let qt=wt.start*Pt,Ut=(wt.start+wt.count)*Pt;it!==null&&(qt=Math.max(qt,it.start*Pt),Ut=Math.min(Ut,(it.start+it.count)*Pt)),xt!==null?(qt=Math.max(qt,0),Ut=Math.min(Ut,xt.count)):mt!=null&&(qt=Math.max(qt,0),Ut=Math.min(Ut,mt.count));const nn=Ut-qt;if(nn<0||nn===1/0)return;de.setup(Me,Pe,bt,De,xt);let dn,gn=He;if(xt!==null&&(dn=X.get(xt),gn=Ye,gn.setIndex(dn)),Me.isMesh)Pe.wireframe===!0?(le.setLineWidth(Pe.wireframeLinewidth*B()),gn.setMode(F.LINES)):gn.setMode(F.TRIANGLES);else if(Me.isLine){let It=Pe.linewidth;It===void 0&&(It=1),le.setLineWidth(It*B()),Me.isLineSegments?gn.setMode(F.LINES):Me.isLineLoop?gn.setMode(F.LINE_LOOP):gn.setMode(F.LINE_STRIP)}else Me.isPoints?gn.setMode(F.POINTS):Me.isSprite&&gn.setMode(F.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)u0("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(V.get("WEBGL_multi_draw"))gn.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{const It=Me._multiDrawStarts,Yt=Me._multiDrawCounts,Jt=Me._multiDrawCount,Sr=xt?X.get(xt).bytesPerElement:1,kr=Ee.get(Pe).currentProgram.getUniforms();for(let kn=0;kn<Jt;kn++)kr.setValue(F,"_gl_DrawID",kn),gn.render(It[kn]/Sr,Yt[kn])}else if(Me.isInstancedMesh)gn.renderInstances(qt,nn,Me.count);else if(De.isInstancedBufferGeometry){const It=De._maxInstanceCount!==void 0?De._maxInstanceCount:1/0,Yt=Math.min(De.instanceCount,It);gn.renderInstances(qt,nn,Yt)}else gn.render(qt,nn)};function cn(ne,_e,De){ne.transparent===!0&&ne.side===Ko&&ne.forceSinglePass===!1?(ne.side=$s,ne.needsUpdate=!0,Nr(ne,_e,De),ne.side=Qu,ne.needsUpdate=!0,Nr(ne,_e,De),ne.side=Ko):Nr(ne,_e,De)}this.compile=function(ne,_e,De=null){De===null&&(De=ne),w=ze.get(De),w.init(_e),T.push(w),De.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),ne!==De&&ne.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),w.setupLights();const Pe=new Set;return ne.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;const it=Me.material;if(it)if(Array.isArray(it))for(let ht=0;ht<it.length;ht++){const bt=it[ht];cn(bt,De,Me),Pe.add(bt)}else cn(it,De,Me),Pe.add(it)}),w=T.pop(),Pe},this.compileAsync=function(ne,_e,De=null){const Pe=this.compile(ne,_e,De);return new Promise(Me=>{function it(){if(Pe.forEach(function(ht){Ee.get(ht).currentProgram.isReady()&&Pe.delete(ht)}),Pe.size===0){Me(ne);return}setTimeout(it,10)}V.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let jt=null;function Rn(ne){jt&&jt(ne)}function qn(){ti.stop()}function bi(){ti.start()}const ti=new f7;ti.setAnimationLoop(Rn),typeof self<"u"&&ti.setContext(self),this.setAnimationLoop=function(ne){jt=ne,je.setAnimationLoop(ne),ne===null?ti.stop():ti.start()},je.addEventListener("sessionstart",qn),je.addEventListener("sessionend",bi),this.render=function(ne,_e){if(_e!==void 0&&_e.isCamera!==!0){Or("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(ne.matrixWorldAutoUpdate===!0&&ne.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(_e),_e=je.getCamera()),ne.isScene===!0&&ne.onBeforeRender(R,ne,_e,D),w=ze.get(ne,T.length),w.init(_e),T.push(w),fe.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),re.setFromProjectionMatrix(fe,Jo,_e.reversedDepth),Ce=this.localClippingEnabled,pe=at.init(this.clippingPlanes,Ce),M=Ie.get(ne,A.length),M.init(),A.push(M),je.enabled===!0&&je.isPresenting===!0){const it=R.xr.getDepthSensingMesh();it!==null&&vi(it,_e,-1/0,R.sortObjects)}vi(ne,_e,0,R.sortObjects),M.finish(),R.sortObjects===!0&&M.sort(H,q),ct=je.enabled===!1||je.isPresenting===!1||je.hasDepthSensing()===!1,ct&&ce.addToRenderList(M,ne),this.info.render.frame++,pe===!0&&at.beginShadows();const De=w.state.shadowsArray;Fe.render(De,ne,_e),pe===!0&&at.endShadows(),this.info.autoReset===!0&&this.info.reset();const Pe=M.opaque,Me=M.transmissive;if(w.setupLights(),_e.isArrayCamera){const it=_e.cameras;if(Me.length>0)for(let ht=0,bt=it.length;ht<bt;ht++){const xt=it[ht];Qi(Pe,Me,ne,xt)}ct&&ce.render(ne);for(let ht=0,bt=it.length;ht<bt;ht++){const xt=it[ht];Li(M,ne,xt,xt.viewport)}}else Me.length>0&&Qi(Pe,Me,ne,_e),ct&&ce.render(ne),Li(M,ne,_e);D!==null&&N===0&&(se.updateMultisampleRenderTarget(D),se.updateRenderTargetMipmap(D)),ne.isScene===!0&&ne.onAfterRender(R,ne,_e),de.resetDefaultState(),z=-1,j=null,T.pop(),T.length>0?(w=T[T.length-1],pe===!0&&at.setGlobalState(R.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function vi(ne,_e,De,Pe){if(ne.visible===!1)return;if(ne.layers.test(_e.layers)){if(ne.isGroup)De=ne.renderOrder;else if(ne.isLOD)ne.autoUpdate===!0&&ne.update(_e);else if(ne.isLight)w.pushLight(ne),ne.castShadow&&w.pushShadow(ne);else if(ne.isSprite){if(!ne.frustumCulled||re.intersectsSprite(ne)){Pe&&Re.setFromMatrixPosition(ne.matrixWorld).applyMatrix4(fe);const ht=ve.update(ne),bt=ne.material;bt.visible&&M.push(ne,ht,bt,De,Re.z,null)}}else if((ne.isMesh||ne.isLine||ne.isPoints)&&(!ne.frustumCulled||re.intersectsObject(ne))){const ht=ve.update(ne),bt=ne.material;if(Pe&&(ne.boundingSphere!==void 0?(ne.boundingSphere===null&&ne.computeBoundingSphere(),Re.copy(ne.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),Re.copy(ht.boundingSphere.center)),Re.applyMatrix4(ne.matrixWorld).applyMatrix4(fe)),Array.isArray(bt)){const xt=ht.groups;for(let Pt=0,wt=xt.length;Pt<wt;Pt++){const mt=xt[Pt],qt=bt[mt.materialIndex];qt&&qt.visible&&M.push(ne,ht,qt,De,Re.z,mt)}}else bt.visible&&M.push(ne,ht,bt,De,Re.z,null)}}const it=ne.children;for(let ht=0,bt=it.length;ht<bt;ht++)vi(it[ht],_e,De,Pe)}function Li(ne,_e,De,Pe){const{opaque:Me,transmissive:it,transparent:ht}=ne;w.setupLightsView(De),pe===!0&&at.setGlobalState(R.clippingPlanes,De),Pe&&le.viewport(W.copy(Pe)),Me.length>0&&Ir(Me,_e,De),it.length>0&&Ir(it,_e,De),ht.length>0&&Ir(ht,_e,De),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function Qi(ne,_e,De,Pe){if((De.isScene===!0?De.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Pe.id]===void 0&&(w.state.transmissionRenderTarget[Pe.id]=new jf(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")||V.has("EXT_color_buffer_float")?Pm:sl,minFilter:rf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:En.workingColorSpace}));const it=w.state.transmissionRenderTarget[Pe.id],ht=Pe.viewport||W;it.setSize(ht.z*R.transmissionResolutionScale,ht.w*R.transmissionResolutionScale);const bt=R.getRenderTarget(),xt=R.getActiveCubeFace(),Pt=R.getActiveMipmapLevel();R.setRenderTarget(it),R.getClearColor(K),G=R.getClearAlpha(),G<1&&R.setClearColor(16777215,.5),R.clear(),ct&&ce.render(De);const wt=R.toneMapping;R.toneMapping=Hu;const mt=Pe.viewport;if(Pe.viewport!==void 0&&(Pe.viewport=void 0),w.setupLightsView(Pe),pe===!0&&at.setGlobalState(R.clippingPlanes,Pe),Ir(ne,De,Pe),se.updateMultisampleRenderTarget(it),se.updateRenderTargetMipmap(it),V.has("WEBGL_multisampled_render_to_texture")===!1){let qt=!1;for(let Ut=0,nn=_e.length;Ut<nn;Ut++){const dn=_e[Ut],{object:gn,geometry:It,material:Yt,group:Jt}=dn;if(Yt.side===Ko&&gn.layers.test(Pe.layers)){const Sr=Yt.side;Yt.side=$s,Yt.needsUpdate=!0,mr(gn,De,Pe,It,Yt,Jt),Yt.side=Sr,Yt.needsUpdate=!0,qt=!0}}qt===!0&&(se.updateMultisampleRenderTarget(it),se.updateRenderTargetMipmap(it))}R.setRenderTarget(bt,xt,Pt),R.setClearColor(K,G),mt!==void 0&&(Pe.viewport=mt),R.toneMapping=wt}function Ir(ne,_e,De){const Pe=_e.isScene===!0?_e.overrideMaterial:null;for(let Me=0,it=ne.length;Me<it;Me++){const ht=ne[Me],{object:bt,geometry:xt,group:Pt}=ht;let wt=ht.material;wt.allowOverride===!0&&Pe!==null&&(wt=Pe),bt.layers.test(De.layers)&&mr(bt,_e,De,xt,wt,Pt)}}function mr(ne,_e,De,Pe,Me,it){ne.onBeforeRender(R,_e,De,Pe,Me,it),ne.modelViewMatrix.multiplyMatrices(De.matrixWorldInverse,ne.matrixWorld),ne.normalMatrix.getNormalMatrix(ne.modelViewMatrix),Me.onBeforeRender(R,_e,De,Pe,ne,it),Me.transparent===!0&&Me.side===Ko&&Me.forceSinglePass===!1?(Me.side=$s,Me.needsUpdate=!0,R.renderBufferDirect(De,_e,Pe,Me,ne,it),Me.side=Qu,Me.needsUpdate=!0,R.renderBufferDirect(De,_e,Pe,Me,ne,it),Me.side=Ko):R.renderBufferDirect(De,_e,Pe,Me,ne,it),ne.onAfterRender(R,_e,De,Pe,Me,it)}function Nr(ne,_e,De){_e.isScene!==!0&&(_e=ue);const Pe=Ee.get(ne),Me=w.state.lights,it=w.state.shadowsArray,ht=Me.state.version,bt=ge.getParameters(ne,Me.state,it,_e,De),xt=ge.getProgramCacheKey(bt);let Pt=Pe.programs;Pe.environment=ne.isMeshStandardMaterial?_e.environment:null,Pe.fog=_e.fog,Pe.envMap=(ne.isMeshStandardMaterial?L:U).get(ne.envMap||Pe.environment),Pe.envMapRotation=Pe.environment!==null&&ne.envMap===null?_e.environmentRotation:ne.envMapRotation,Pt===void 0&&(ne.addEventListener("dispose",ft),Pt=new Map,Pe.programs=Pt);let wt=Pt.get(xt);if(wt!==void 0){if(Pe.currentProgram===wt&&Pe.lightsStateVersion===ht)return Ic(ne,bt),wt}else bt.uniforms=ge.getUniforms(ne),ne.onBeforeCompile(bt,R),wt=ge.acquireProgram(bt,xt),Pt.set(xt,wt),Pe.uniforms=bt.uniforms;const mt=Pe.uniforms;return(!ne.isShaderMaterial&&!ne.isRawShaderMaterial||ne.clipping===!0)&&(mt.clippingPlanes=at.uniform),Ic(ne,bt),Pe.needsLights=et(ne),Pe.lightsStateVersion=ht,Pe.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),Pe.currentProgram=wt,Pe.uniformsList=null,wt}function so(ne){if(ne.uniformsList===null){const _e=ne.currentProgram.getUniforms();ne.uniformsList=O_.seqWithValue(_e.seq,ne.uniforms)}return ne.uniformsList}function Ic(ne,_e){const De=Ee.get(ne);De.outputColorSpace=_e.outputColorSpace,De.batching=_e.batching,De.batchingColor=_e.batchingColor,De.instancing=_e.instancing,De.instancingColor=_e.instancingColor,De.instancingMorph=_e.instancingMorph,De.skinning=_e.skinning,De.morphTargets=_e.morphTargets,De.morphNormals=_e.morphNormals,De.morphColors=_e.morphColors,De.morphTargetsCount=_e.morphTargetsCount,De.numClippingPlanes=_e.numClippingPlanes,De.numIntersection=_e.numClipIntersection,De.vertexAlphas=_e.vertexAlphas,De.vertexTangents=_e.vertexTangents,De.toneMapping=_e.toneMapping}function he(ne,_e,De,Pe,Me){_e.isScene!==!0&&(_e=ue),se.resetTextureUnits();const it=_e.fog,ht=Pe.isMeshStandardMaterial?_e.environment:null,bt=D===null?R.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:im,xt=(Pe.isMeshStandardMaterial?L:U).get(Pe.envMap||ht),Pt=Pe.vertexColors===!0&&!!De.attributes.color&&De.attributes.color.itemSize===4,wt=!!De.attributes.tangent&&(!!Pe.normalMap||Pe.anisotropy>0),mt=!!De.morphAttributes.position,qt=!!De.morphAttributes.normal,Ut=!!De.morphAttributes.color;let nn=Hu;Pe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=R.toneMapping);const dn=De.morphAttributes.position||De.morphAttributes.normal||De.morphAttributes.color,gn=dn!==void 0?dn.length:0,It=Ee.get(Pe),Yt=w.state.lights;if(pe===!0&&(Ce===!0||ne!==j)){const _i=ne===j&&Pe.id===z;at.setState(Pe,ne,_i)}let Jt=!1;Pe.version===It.__version?(It.needsLights&&It.lightsStateVersion!==Yt.state.version||It.outputColorSpace!==bt||Me.isBatchedMesh&&It.batching===!1||!Me.isBatchedMesh&&It.batching===!0||Me.isBatchedMesh&&It.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&It.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&It.instancing===!1||!Me.isInstancedMesh&&It.instancing===!0||Me.isSkinnedMesh&&It.skinning===!1||!Me.isSkinnedMesh&&It.skinning===!0||Me.isInstancedMesh&&It.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&It.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&It.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&It.instancingMorph===!1&&Me.morphTexture!==null||It.envMap!==xt||Pe.fog===!0&&It.fog!==it||It.numClippingPlanes!==void 0&&(It.numClippingPlanes!==at.numPlanes||It.numIntersection!==at.numIntersection)||It.vertexAlphas!==Pt||It.vertexTangents!==wt||It.morphTargets!==mt||It.morphNormals!==qt||It.morphColors!==Ut||It.toneMapping!==nn||It.morphTargetsCount!==gn)&&(Jt=!0):(Jt=!0,It.__version=Pe.version);let Sr=It.currentProgram;Jt===!0&&(Sr=Nr(Pe,_e,Me));let kr=!1,kn=!1,ao=!1;const Pn=Sr.getUniforms(),yi=It.uniforms;if(le.useProgram(Sr.program)&&(kr=!0,kn=!0,ao=!0),Pe.id!==z&&(z=Pe.id,kn=!0),kr||j!==ne){le.buffers.depth.getReversed()&&ne.reversedDepth!==!0&&(ne._reversedDepth=!0,ne.updateProjectionMatrix()),Pn.setValue(F,"projectionMatrix",ne.projectionMatrix),Pn.setValue(F,"viewMatrix",ne.matrixWorldInverse);const ji=Pn.map.cameraPosition;ji!==void 0&&ji.setValue(F,Se.setFromMatrixPosition(ne.matrixWorld)),J.logarithmicDepthBuffer&&Pn.setValue(F,"logDepthBufFC",2/(Math.log(ne.far+1)/Math.LN2)),(Pe.isMeshPhongMaterial||Pe.isMeshToonMaterial||Pe.isMeshLambertMaterial||Pe.isMeshBasicMaterial||Pe.isMeshStandardMaterial||Pe.isShaderMaterial)&&Pn.setValue(F,"isOrthographic",ne.isOrthographicCamera===!0),j!==ne&&(j=ne,kn=!0,ao=!0)}if(Me.isSkinnedMesh){Pn.setOptional(F,Me,"bindMatrix"),Pn.setOptional(F,Me,"bindMatrixInverse");const _i=Me.skeleton;_i&&(_i.boneTexture===null&&_i.computeBoneTexture(),Pn.setValue(F,"boneTexture",_i.boneTexture,se))}Me.isBatchedMesh&&(Pn.setOptional(F,Me,"batchingTexture"),Pn.setValue(F,"batchingTexture",Me._matricesTexture,se),Pn.setOptional(F,Me,"batchingIdTexture"),Pn.setValue(F,"batchingIdTexture",Me._indirectTexture,se),Pn.setOptional(F,Me,"batchingColorTexture"),Me._colorsTexture!==null&&Pn.setValue(F,"batchingColorTexture",Me._colorsTexture,se));const ni=De.morphAttributes;if((ni.position!==void 0||ni.normal!==void 0||ni.color!==void 0)&&Qe.update(Me,De,Sr),(kn||It.receiveShadow!==Me.receiveShadow)&&(It.receiveShadow=Me.receiveShadow,Pn.setValue(F,"receiveShadow",Me.receiveShadow)),Pe.isMeshGouraudMaterial&&Pe.envMap!==null&&(yi.envMap.value=xt,yi.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Pe.isMeshStandardMaterial&&Pe.envMap===null&&_e.environment!==null&&(yi.envMapIntensity.value=_e.environmentIntensity),yi.dfgLUT!==void 0&&(yi.dfgLUT.value=bge()),kn&&(Pn.setValue(F,"toneMappingExposure",R.toneMappingExposure),It.needsLights&&Be(yi,ao),it&&Pe.fog===!0&&Ke.refreshFogUniforms(yi,it),Ke.refreshMaterialUniforms(yi,Pe,ee,Q,w.state.transmissionRenderTarget[ne.id]),O_.upload(F,so(It),yi,se)),Pe.isShaderMaterial&&Pe.uniformsNeedUpdate===!0&&(O_.upload(F,so(It),yi,se),Pe.uniformsNeedUpdate=!1),Pe.isSpriteMaterial&&Pn.setValue(F,"center",Me.center),Pn.setValue(F,"modelViewMatrix",Me.modelViewMatrix),Pn.setValue(F,"normalMatrix",Me.normalMatrix),Pn.setValue(F,"modelMatrix",Me.matrixWorld),Pe.isShaderMaterial||Pe.isRawShaderMaterial){const _i=Pe.uniformsGroups;for(let ji=0,jo=_i.length;ji<jo;ji++){const ml=_i[ji];Je.update(ml,Sr),Je.bind(ml,Sr)}}return Sr}function Be(ne,_e){ne.ambientLightColor.needsUpdate=_e,ne.lightProbe.needsUpdate=_e,ne.directionalLights.needsUpdate=_e,ne.directionalLightShadows.needsUpdate=_e,ne.pointLights.needsUpdate=_e,ne.pointLightShadows.needsUpdate=_e,ne.spotLights.needsUpdate=_e,ne.spotLightShadows.needsUpdate=_e,ne.rectAreaLights.needsUpdate=_e,ne.hemisphereLights.needsUpdate=_e}function et(ne){return ne.isMeshLambertMaterial||ne.isMeshToonMaterial||ne.isMeshPhongMaterial||ne.isMeshStandardMaterial||ne.isShadowMaterial||ne.isShaderMaterial&&ne.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(ne,_e,De){const Pe=Ee.get(ne);Pe.__autoAllocateDepthBuffer=ne.resolveDepthBuffer===!1,Pe.__autoAllocateDepthBuffer===!1&&(Pe.__useRenderToTexture=!1),Ee.get(ne.texture).__webglTexture=_e,Ee.get(ne.depthTexture).__webglTexture=Pe.__autoAllocateDepthBuffer?void 0:De,Pe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ne,_e){const De=Ee.get(ne);De.__webglFramebuffer=_e,De.__useDefaultFramebuffer=_e===void 0};const tt=F.createFramebuffer();this.setRenderTarget=function(ne,_e=0,De=0){D=ne,I=_e,N=De;let Pe=!0,Me=null,it=!1,ht=!1;if(ne){const xt=Ee.get(ne);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(F.FRAMEBUFFER,null),Pe=!1;else if(xt.__webglFramebuffer===void 0)se.setupRenderTarget(ne);else if(xt.__hasExternalTextures)se.rebindTextures(ne,Ee.get(ne.texture).__webglTexture,Ee.get(ne.depthTexture).__webglTexture);else if(ne.depthBuffer){const mt=ne.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ee.has(mt)&&(ne.width!==mt.image.width||ne.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");se.setupDepthRenderbuffer(ne)}}const Pt=ne.texture;(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)&&(ht=!0);const wt=Ee.get(ne).__webglFramebuffer;ne.isWebGLCubeRenderTarget?(Array.isArray(wt[_e])?Me=wt[_e][De]:Me=wt[_e],it=!0):ne.samples>0&&se.useMultisampledRTT(ne)===!1?Me=Ee.get(ne).__webglMultisampledFramebuffer:Array.isArray(wt)?Me=wt[De]:Me=wt,W.copy(ne.viewport),P.copy(ne.scissor),$=ne.scissorTest}else W.copy(te).multiplyScalar(ee).floor(),P.copy(ae).multiplyScalar(ee).floor(),$=xe;if(De!==0&&(Me=tt),le.bindFramebuffer(F.FRAMEBUFFER,Me)&&Pe&&le.drawBuffers(ne,Me),le.viewport(W),le.scissor(P),le.setScissorTest($),it){const xt=Ee.get(ne.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+_e,xt.__webglTexture,De)}else if(ht){const xt=_e;for(let Pt=0;Pt<ne.textures.length;Pt++){const wt=Ee.get(ne.textures[Pt]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+Pt,wt.__webglTexture,De,xt)}}else if(ne!==null&&De!==0){const xt=Ee.get(ne.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,xt.__webglTexture,De)}z=-1},this.readRenderTargetPixels=function(ne,_e,De,Pe,Me,it,ht,bt=0){if(!(ne&&ne.isWebGLRenderTarget)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ee.get(ne).__webglFramebuffer;if(ne.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt){le.bindFramebuffer(F.FRAMEBUFFER,xt);try{const Pt=ne.textures[bt],wt=Pt.format,mt=Pt.type;if(!J.textureFormatReadable(wt)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=ne.width-Pe&&De>=0&&De<=ne.height-Me&&(ne.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+bt),F.readPixels(_e,De,Pe,Me,ut.convert(wt),ut.convert(mt),it))}finally{const Pt=D!==null?Ee.get(D).__webglFramebuffer:null;le.bindFramebuffer(F.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(ne,_e,De,Pe,Me,it,ht,bt=0){if(!(ne&&ne.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ee.get(ne).__webglFramebuffer;if(ne.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt)if(_e>=0&&_e<=ne.width-Pe&&De>=0&&De<=ne.height-Me){le.bindFramebuffer(F.FRAMEBUFFER,xt);const Pt=ne.textures[bt],wt=Pt.format,mt=Pt.type;if(!J.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qt=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,qt),F.bufferData(F.PIXEL_PACK_BUFFER,it.byteLength,F.STREAM_READ),ne.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+bt),F.readPixels(_e,De,Pe,Me,ut.convert(wt),ut.convert(mt),0);const Ut=D!==null?Ee.get(D).__webglFramebuffer:null;le.bindFramebuffer(F.FRAMEBUFFER,Ut);const nn=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await Vue(F,nn,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,qt),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,it),F.deleteBuffer(qt),F.deleteSync(nn),it}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ne,_e=null,De=0){const Pe=Math.pow(2,-De),Me=Math.floor(ne.image.width*Pe),it=Math.floor(ne.image.height*Pe),ht=_e!==null?_e.x:0,bt=_e!==null?_e.y:0;se.setTexture2D(ne,0),F.copyTexSubImage2D(F.TEXTURE_2D,De,0,0,ht,bt,Me,it),le.unbindTexture()};const Ze=F.createFramebuffer(),_t=F.createFramebuffer();this.copyTextureToTexture=function(ne,_e,De=null,Pe=null,Me=0,it=null){it===null&&(Me!==0?(u0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),it=Me,Me=0):it=0);let ht,bt,xt,Pt,wt,mt,qt,Ut,nn;const dn=ne.isCompressedTexture?ne.mipmaps[it]:ne.image;if(De!==null)ht=De.max.x-De.min.x,bt=De.max.y-De.min.y,xt=De.isBox3?De.max.z-De.min.z:1,Pt=De.min.x,wt=De.min.y,mt=De.isBox3?De.min.z:0;else{const ni=Math.pow(2,-Me);ht=Math.floor(dn.width*ni),bt=Math.floor(dn.height*ni),ne.isDataArrayTexture?xt=dn.depth:ne.isData3DTexture?xt=Math.floor(dn.depth*ni):xt=1,Pt=0,wt=0,mt=0}Pe!==null?(qt=Pe.x,Ut=Pe.y,nn=Pe.z):(qt=0,Ut=0,nn=0);const gn=ut.convert(_e.format),It=ut.convert(_e.type);let Yt;_e.isData3DTexture?(se.setTexture3D(_e,0),Yt=F.TEXTURE_3D):_e.isDataArrayTexture||_e.isCompressedArrayTexture?(se.setTexture2DArray(_e,0),Yt=F.TEXTURE_2D_ARRAY):(se.setTexture2D(_e,0),Yt=F.TEXTURE_2D),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,_e.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,_e.unpackAlignment);const Jt=F.getParameter(F.UNPACK_ROW_LENGTH),Sr=F.getParameter(F.UNPACK_IMAGE_HEIGHT),kr=F.getParameter(F.UNPACK_SKIP_PIXELS),kn=F.getParameter(F.UNPACK_SKIP_ROWS),ao=F.getParameter(F.UNPACK_SKIP_IMAGES);F.pixelStorei(F.UNPACK_ROW_LENGTH,dn.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,dn.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Pt),F.pixelStorei(F.UNPACK_SKIP_ROWS,wt),F.pixelStorei(F.UNPACK_SKIP_IMAGES,mt);const Pn=ne.isDataArrayTexture||ne.isData3DTexture,yi=_e.isDataArrayTexture||_e.isData3DTexture;if(ne.isDepthTexture){const ni=Ee.get(ne),_i=Ee.get(_e),ji=Ee.get(ni.__renderTarget),jo=Ee.get(_i.__renderTarget);le.bindFramebuffer(F.READ_FRAMEBUFFER,ji.__webglFramebuffer),le.bindFramebuffer(F.DRAW_FRAMEBUFFER,jo.__webglFramebuffer);for(let ml=0;ml<xt;ml++)Pn&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,Ee.get(ne).__webglTexture,Me,mt+ml),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,Ee.get(_e).__webglTexture,it,nn+ml)),F.blitFramebuffer(Pt,wt,ht,bt,qt,Ut,ht,bt,F.DEPTH_BUFFER_BIT,F.NEAREST);le.bindFramebuffer(F.READ_FRAMEBUFFER,null),le.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(Me!==0||ne.isRenderTargetTexture||Ee.has(ne)){const ni=Ee.get(ne),_i=Ee.get(_e);le.bindFramebuffer(F.READ_FRAMEBUFFER,Ze),le.bindFramebuffer(F.DRAW_FRAMEBUFFER,_t);for(let ji=0;ji<xt;ji++)Pn?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,ni.__webglTexture,Me,mt+ji):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,ni.__webglTexture,Me),yi?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,_i.__webglTexture,it,nn+ji):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,_i.__webglTexture,it),Me!==0?F.blitFramebuffer(Pt,wt,ht,bt,qt,Ut,ht,bt,F.COLOR_BUFFER_BIT,F.NEAREST):yi?F.copyTexSubImage3D(Yt,it,qt,Ut,nn+ji,Pt,wt,ht,bt):F.copyTexSubImage2D(Yt,it,qt,Ut,Pt,wt,ht,bt);le.bindFramebuffer(F.READ_FRAMEBUFFER,null),le.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else yi?ne.isDataTexture||ne.isData3DTexture?F.texSubImage3D(Yt,it,qt,Ut,nn,ht,bt,xt,gn,It,dn.data):_e.isCompressedArrayTexture?F.compressedTexSubImage3D(Yt,it,qt,Ut,nn,ht,bt,xt,gn,dn.data):F.texSubImage3D(Yt,it,qt,Ut,nn,ht,bt,xt,gn,It,dn):ne.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,it,qt,Ut,ht,bt,gn,It,dn.data):ne.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,it,qt,Ut,dn.width,dn.height,gn,dn.data):F.texSubImage2D(F.TEXTURE_2D,it,qt,Ut,ht,bt,gn,It,dn);F.pixelStorei(F.UNPACK_ROW_LENGTH,Jt),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Sr),F.pixelStorei(F.UNPACK_SKIP_PIXELS,kr),F.pixelStorei(F.UNPACK_SKIP_ROWS,kn),F.pixelStorei(F.UNPACK_SKIP_IMAGES,ao),it===0&&_e.generateMipmaps&&F.generateMipmap(Yt),le.unbindTexture()},this.initRenderTarget=function(ne){Ee.get(ne).__webglFramebuffer===void 0&&se.setupRenderTarget(ne)},this.initTexture=function(ne){ne.isCubeTexture?se.setTextureCube(ne,0):ne.isData3DTexture?se.setTexture3D(ne,0):ne.isDataArrayTexture||ne.isCompressedArrayTexture?se.setTexture2DArray(ne,0):se.setTexture2D(ne,0),le.unbindTexture()},this.resetState=function(){I=0,N=0,D=null,le.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Jo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=En._getDrawingBufferColorSpace(e),n.unpackColorSpace=En._getUnpackColorSpace()}};const A5={type:"change"},CP={type:"start"},x7={type:"end"},hy=new wP,T5=new Su,yge=Math.cos(70*Wue.DEG2RAD),ii=new Xe,Us=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},kA=1e-6;class _ge extends Pde{constructor(e,n=null){super(e,n),this.state=Vn.NONE,this.target=new Xe,this.cursor=new Xe,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:Up.ROTATE,MIDDLE:Up.DOLLY,RIGHT:Up.PAN},this.touches={ONE:kp.ROTATE,TWO:kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Xe,this._lastQuaternion=new Lf,this._lastTargetPosition=new Xe,this._quat=new Lf().setFromUnitVectors(e.up,new Xe(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new t5,this._sphericalDelta=new t5,this._scale=1,this._panOffset=new Xe,this._rotateStart=new on,this._rotateEnd=new on,this._rotateDelta=new on,this._panStart=new on,this._panEnd=new on,this._panDelta=new on,this._dollyStart=new on,this._dollyEnd=new on,this._dollyDelta=new on,this._dollyDirection=new Xe,this._mouse=new on,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wge.bind(this),this._onPointerDown=Sge.bind(this),this._onPointerUp=Mge.bind(this),this._onContextMenu=Rge.bind(this),this._onMouseWheel=Tge.bind(this),this._onKeyDown=Cge.bind(this),this._onTouchStart=Nge.bind(this),this._onTouchMove=kge.bind(this),this._onMouseDown=Ege.bind(this),this._onMouseMove=Age.bind(this),this._interceptControlDown=Pge.bind(this),this._interceptControlUp=Dge.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(A5),this.update(),this.state=Vn.NONE}update(e=null){const n=this.object.position;ii.copy(n).sub(this.target),ii.applyQuaternion(this._quat),this._spherical.setFromVector3(ii),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+=Us:r>Math.PI&&(r-=Us),i<-Math.PI?i+=Us:i>Math.PI&&(i-=Us),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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ii.setFromSpherical(this._spherical),ii.applyQuaternion(this._quatInverse),n.copy(this.target).add(ii),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 a=null;if(this.object.isPerspectiveCamera){const o=ii.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new Xe(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(),s=l!==this.object.zoom;const c=new Xe(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=ii.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(hy.origin.copy(this.object.position),hy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(hy.direction))<yge?this.object.lookAt(this.target):(T5.setFromNormalAndCoplanarPoint(this.object.up,this.target),hy.intersectPlane(T5,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>kA||8*(1-this._lastQuaternion.dot(this.object.quaternion))>kA||this._lastTargetPosition.distanceToSquared(this.target)>kA?(this.dispatchEvent(A5),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Us/60*this.autoRotateSpeed*e:Us/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){ii.setFromMatrixColumn(n,0),ii.multiplyScalar(-e),this._panOffset.add(ii)}_panUp(e,n){this.screenSpacePanning===!0?ii.setFromMatrixColumn(n,1):(ii.setFromMatrixColumn(n,0),ii.crossVectors(this.object.up,ii)),ii.multiplyScalar(e),this._panOffset.add(ii)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ii.copy(i).sub(this.target);let s=ii.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/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,s=n-r.top,a=r.width,o=r.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/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(Us*this._rotateDelta.x/n.clientHeight),this._rotateUp(Us*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(Us*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(-Us*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(Us*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(-Us*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,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_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),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Us*this._rotateDelta.x/n.clientHeight),this._rotateUp(Us*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,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),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 a=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(a,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 on,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 Sge(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 wge(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function Mge(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(x7),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 Ege(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 Up.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Vn.DOLLY;break;case Up.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 Up.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(CP)}function Age(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 Tge(t){this.enabled===!1||this.enableZoom===!1||this.state!==Vn.NONE||(t.preventDefault(),this.dispatchEvent(CP),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(x7))}function Cge(t){this.enabled!==!1&&this._handleKeyDown(t)}function Nge(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Vn.TOUCH_ROTATE;break;case kp.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 kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Vn.TOUCH_DOLLY_PAN;break;case kp.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(CP)}function kge(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 Rge(t){this.enabled!==!1&&t.preventDefault()}function Pge(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Dge(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Oge(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)),s={},a={},o=t[0].morphTargetsRelative,l=new pl;let c=0;for(let d=0;d<t.length;++d){const h=t[d];let g=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in h.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,d),c+=m}}if(n){let d=0;const h=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let v=0;v<m.count;++v)h.push(m.getX(v)+d);d+=t[g].attributes.position.count}l.setIndex(h)}for(const d in s){const h=C5(s[d]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,h)}for(const d in a){const h=a[d][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let g=0;g<h;++g){const m=[];for(let y=0;y<a[d].length;++y)m.push(a[d][y][g]);const v=C5(m);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(v)}}return l}function C5(t){let e,n,r,i=-1,s=0;for(let c=0;c<t.length;++c){const d=t[c];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*n}const a=new e(s),o=new Ya(a,n,r);let l=0;for(let c=0;c<t.length;++c){const d=t[c];if(d.isInterleavedBufferAttribute){const h=l/n;for(let g=0,m=d.count;g<m;g++)for(let v=0;v<n;v++){const y=d.getComponent(g,v);o.setComponent(g+h,v,y)}}else a.set(d.array,l);l+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function py(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 RA={exports:{}};var N5;function Lge(){return N5||(N5=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function a(c,d){if(!i[c]){if(!r[c]){var h=typeof py=="function"&&py;if(!d&&h)return h(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(v){var y=r[c][1][v];return a(y||v)},m,m.exports,n,r,i,s)}return i[c].exports}for(var o=typeof py=="function"&&py,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(n,r,i){var s=n("./utils"),a=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,d,h,g,m,v,y,b=[],x=0,M=l.length,w=M,A=s.getTypeOf(l)!=="string";x<l.length;)w=M-x,h=A?(c=l[x++],d=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),d=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),g=c>>2,m=(3&c)<<4|d>>4,v=1<w?(15&d)<<2|h>>6:64,y=2<w?63&h:64,b.push(o.charAt(g)+o.charAt(m)+o.charAt(v)+o.charAt(y));return b.join("")},i.decode=function(l){var c,d,h,g,m,v,y=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=a.uint8array?new Uint8Array(0|w):new Array(0|w);y<l.length;)c=o.indexOf(l.charAt(y++))<<2|(g=o.indexOf(l.charAt(y++)))>>4,d=(15&g)<<4|(m=o.indexOf(l.charAt(y++)))>>2,h=(3&m)<<6|(v=o.indexOf(l.charAt(y++))),M[b++]=c,m!==64&&(M[b++]=d),v!==64&&(M[b++]=h);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),a=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(d,h,g,m,v){this.compressedSize=d,this.uncompressedSize=h,this.crc32=g,this.compression=m,this.compressedContent=v}c.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(d,h,g){return d.pipe(new o).pipe(new l("uncompressedSize")).pipe(h.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(c,d,h,g){var m=a,v=g+h;c^=-1;for(var y=g;y<v;y++)c=c>>>8^m[255&(c^d[y])];return-1^c})(0|l,o,o.length,0):(function(c,d,h,g){var m=a,v=g+h;c^=-1;for(var y=g;y<v;y++)c=c>>>8^m[255&(c^d.charCodeAt(y))];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 s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function d(h,g){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,l),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,h.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(g){h.push({data:g,meta:h.meta})}},i.compressWorker=function(h){return new d("Deflate",h)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,v){var y,b="";for(y=0;y<v;y++)b+=String.fromCharCode(255&m),m>>>=8;return b}function a(m,v,y,b,x,M){var w,A,T=m.file,R=m.compression,C=M!==c.utf8encode,I=o.transformTo("string",M(T.name)),N=o.transformTo("string",c.utf8encode(T.name)),D=T.comment,z=o.transformTo("string",M(D)),j=o.transformTo("string",c.utf8encode(D)),W=N.length!==T.name.length,P=j.length!==D.length,$="",K="",G="",Z=T.dir,Q=T.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};v&&!y||(ee.crc32=m.crc32,ee.compressedSize=m.compressedSize,ee.uncompressedSize=m.uncompressedSize);var H=0;v&&(H|=8),C||!W&&!P||(H|=2048);var q=0,te=0;Z&&(q|=16),x==="UNIX"?(te=798,q|=(function(xe,re){var pe=xe;return xe||(pe=re?16893:33204),(65535&pe)<<16})(T.unixPermissions,Z)):(te=20,q|=(function(xe){return 63&(xe||0)})(T.dosPermissions)),w=Q.getUTCHours(),w<<=6,w|=Q.getUTCMinutes(),w<<=5,w|=Q.getUTCSeconds()/2,A=Q.getUTCFullYear()-1980,A<<=4,A|=Q.getUTCMonth()+1,A<<=5,A|=Q.getUTCDate(),W&&(K=s(1,1)+s(d(I),4)+N,$+="up"+s(K.length,2)+K),P&&(G=s(1,1)+s(d(z),4)+j,$+="uc"+s(G.length,2)+G);var ae="";return ae+=`
  3839. \0`,ae+=s(H,2),ae+=R.magic,ae+=s(w,2),ae+=s(A,2),ae+=s(ee.crc32,4),ae+=s(ee.compressedSize,4),ae+=s(ee.uncompressedSize,4),ae+=s(I.length,2),ae+=s($.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ae+I+$,dirRecord:h.CENTRAL_FILE_HEADER+s(te,2)+ae+s(z.length,2)+"\0\0\0\0"+s(q,4)+s(b,4)+I+$+z}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),d=n("../crc32"),h=n("../signature");function g(m,v,y,b){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=y,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 v=m.meta.percent||0,y=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:y?(v+100*(y-b-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var v=this.streamFiles&&!m.file.dir;if(v){var y=a(m,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var v=this.streamFiles&&!m.file.dir,y=a(m,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),v)this.push({data:(function(b){return h.DATA_DESCRIPTOR+s(b.crc32,4)+s(b.compressedSize,4)+s(b.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var y=this.bytesWritten-m,b=(function(x,M,w,A,T){var R=o.transformTo("string",T(A));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(x,2)+s(x,2)+s(M,4)+s(w,4)+s(R.length,2)+R})(this.dirRecords.length,y,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 v=this;return m.on("data",function(y){v.processChunk(y)}),m.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),m.on("error",function(y){v.error(y)}),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 v=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var y=0;y<v.length;y++)try{v[y].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,v=0;v<m.length;v++)m[v].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),a=n("./ZipFileWorker");i.generateWorker=function(o,l,c){var d=new a(l.streamFiles,c,l.platform,l.encodeFileName),h=0;try{o.forEach(function(g,m){h++;var v=(function(M,w){var A=M||w,T=s[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,l.compression),y=m.options.compressionOptions||l.compressionOptions||{},b=m.dir,x=m.date;m._compressWorker(v,y).withStreamInfo("file",{name:g,dir:b,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;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 a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),a=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(g){return new a.Promise(function(m,v){var y=g.decompressed.getContentWorker().pipe(new c);y.on("error",function(b){v(b)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var v=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var b=new l(m);return b.load(y),b}).then(function(y){var b=[a.Promise.resolve(y)],x=y.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)b.push(h(x[M]));return a.Promise.all(b)}).then(function(y){for(var b=y.shift(),x=b.files,M=0;M<x.length;M++){var w=x[M],A=w.fileNameStr,T=s.resolve(w.fileNameStr);v.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||(v.file(T).unsafeOriginalName=A)}return b.zipComment.length&&(v.comment=b.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),a=n("../stream/GenericWorker");function o(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(o,a),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(d){c.push({data:d,meta:{percent:0}})}).on("error",function(d){c.isPaused?this.generatedError=d:c.error(d)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.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 s=n("readable-stream").Readable;function a(o,l,c){s.call(this,l),this._helper=o;var d=this;o.on("data",function(h,g){d.push(h)||d._helper.pause(),c&&c(g)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(T,R,C){var I,N=o.getTypeOf(R),D=o.extend(C||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(T=x(T)),D.createFolders&&(I=b(T))&&M.call(this,I,!0);var z=N==="string"&&D.binary===!1&&D.base64===!1;C&&C.binary!==void 0||(D.binary=!z),(R instanceof h&&R.uncompressedSize===0||D.dir||!R||R.length===0)&&(D.base64=!1,D.binary=!0,R="",D.compression="STORE",N="string");var j=null;j=R instanceof h||R instanceof l?R:v.isNode&&v.isStream(R)?new y(T,R):o.prepareContent(T,R,D.binary,D.optimizedBinaryString,D.base64);var W=new g(T,j,D);this.files[T]=W}var a=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),v=n("./nodejsUtils"),y=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:d.createFolders,T=x(T),this.files[T]||s.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,C,I;for(R in this.files)I=this.files[R],(C=R.slice(this.root.length,R.length))&&R.slice(0,this.root.length)===this.root&&T(C,I)},filter:function(T){var R=[];return this.forEach(function(C,I){T(C,I)&&R.push(I)}),R},file:function(T,R,C){if(arguments.length!==1)return T=this.root+T,s.call(this,T,R,C),this;if(w(T)){var I=T;return this.filter(function(D,z){return!z.dir&&I.test(D)})}var N=this.files[this.root+T];return N&&!N.dir?N:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(N,D){return D.dir&&T.test(N)});var R=this.root+T,C=M.call(this,R),I=this.clone();return I.root=C.name,I},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 C=this.filter(function(N,D){return D.name.slice(0,T.length)===T}),I=0;I<C.length;I++)delete this.files[C[I].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,C={};try{if((C=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");o.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var I=C.comment||this.comment||"";R=m.generateWorker(this,C,I)}catch(N){(R=new l("error")).error(N)}return new c(R,C.type||"string",C.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 s=n("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===c&&this.data[g+2]===d&&this.data[g+3]===h)return g-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&c===g[1]&&d===g[2]&&h===g[3]},a.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=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.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 s.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=a},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.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=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.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=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.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=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),a=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var g=s.getTypeOf(h);return s.checkSupport(g),g!=="string"||a.uint8array?g==="nodebuffer"?new c(h):a.uint8array?new d(s.transformTo("uint8array",h)):new o(s.transformTo("array",h)):new l(h)}},{"../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 s=n("./GenericWorker"),a=n("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),a=n("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){c.dataIsReady=!0,c.data=d,c.max=d&&d.length||0,c.type=s.getTypeOf(d),c.isPaused||c._tickAndRepeat()},function(d){c.error(d)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.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 s(a){this.name=a||"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}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.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 a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},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 a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),a=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),d=n("../external"),h=null;if(c.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(v,y){return new d.Promise(function(b,x){var M=[],w=v._internalType,A=v._outputType,T=v._mimeType;v.on("data",function(R,C){M.push(R),y&&y(C)}).on("error",function(R){M=[],x(R)}).on("end",function(){try{var R=(function(C,I,N){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",I),N);case"base64":return l.encode(I);default:return s.transformTo(C,I)}})(A,(function(C,I){var N,D=0,z=null,j=0;for(N=0;N<I.length;N++)j+=I[N].length;switch(C){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(z=new Uint8Array(j),N=0;N<I.length;N++)z.set(I[N],D),D+=I[N].length;return z;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+C+"'")}})(w,M),T);b(R)}catch(C){x(C)}M=[]}).resume()})}function m(v,y,b){var x=y;switch(y){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=y,this._mimeType=b,s.checkSupport(x),this._worker=v.pipe(new a(x)),v.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(v){return g(this,v)},on:function(v,y){var b=this;return v==="data"?this._worker.on(v,function(x){y.call(b,x.data,x.meta)}):this._worker.on(v,function(){s.delay(y,arguments,b)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},v)}},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 s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.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 s=n("./utils"),a=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),d=0;d<256;d++)c[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;c[254]=c[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return a.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(v){var y,b,x,M,w,A=v.length,T=0;for(M=0;M<A;M++)(64512&(b=v.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=v.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(x-56320),M++),T+=b<128?1:b<2048?2:b<65536?3:4;for(y=a.uint8array?new Uint8Array(T):new Array(T),M=w=0;w<T;M++)(64512&(b=v.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=v.charCodeAt(M+1)))==56320&&(b=65536+(b-55296<<10)+(x-56320),M++),b<128?y[w++]=b:(b<2048?y[w++]=192|b>>>6:(b<65536?y[w++]=224|b>>>12:(y[w++]=240|b>>>18,y[w++]=128|b>>>12&63),y[w++]=128|b>>>6&63),y[w++]=128|63&b);return y})(m)},i.utf8decode=function(m){return a.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(v){var y,b,x,M,w=v.length,A=new Array(2*w);for(y=b=0;y<w;)if((x=v[y++])<128)A[b++]=x;else if(4<(M=c[x]))A[b++]=65533,y+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&y<w;)x=x<<6|63&v[y++],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),s.applyFromCharCode(A)})(m=s.transformTo(a.uint8array?"uint8array":"array",m))},s.inherits(h,l),h.prototype.processChunk=function(m){var v=s.transformTo(a.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var y=v;(v=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),v.set(y,this.leftOver.length)}else v=this.leftOver.concat(v);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})(v),x=v;b!==v.length&&(a.uint8array?(x=v.subarray(0,b),this.leftOver=v.subarray(b,v.length)):(x=v.slice(0,b),this.leftOver=v.slice(b,v.length))),this.push({data:i.utf8decode(x),meta:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.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 s=n("./support"),a=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(y){return y}function d(y,b){for(var x=0;x<y.length;++x)b[x]=255&y.charCodeAt(x);return b}n("setimmediate"),i.newBlob=function(y,b){i.checkSupport("blob");try{return new Blob([y],{type:b})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(y),x.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(y,b,x){var M=[],w=0,A=y.length;if(A<=x)return String.fromCharCode.apply(null,y);for(;w<A;)b==="array"||b==="nodebuffer"?M.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+x,A)))):M.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+x,A)))),w+=x;return M.join("")},stringifyByChar:function(y){for(var b="",x=0;x<y.length;x++)b+=String.fromCharCode(y[x]);return b},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var b=65536,x=i.getTypeOf(y),M=!0;if(x==="uint8array"?M=h.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=h.applyCanBeUsed.nodebuffer),M)for(;1<b;)try{return h.stringifyByChunk(y,x,b)}catch{b=Math.floor(b/2)}return h.stringifyByChar(y)}function m(y,b){for(var x=0;x<y.length;x++)b[x]=y[x];return b}i.applyFromCharCode=g;var v={};v.string={string:c,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return v.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,o.allocBuffer(y.length))}},v.array={string:g,array:c,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},v.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:c,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},v.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:c,nodebuffer:function(y){return o.newBufferFrom(y)}},v.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return v.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:c},i.transformTo=function(y,b){if(b=b||"",!y)return b;i.checkSupport(y);var x=i.getTypeOf(b);return v[x][y](b)},i.resolve=function(y){for(var b=y.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(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&o.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var b,x,M="";for(x=0;x<(y||"").length;x++)M+="\\x"+((b=y.charCodeAt(x))<16?"0":"")+b.toString(16).toUpperCase();return M},i.delay=function(y,b,x){setImmediate(function(){y.apply(x||null,b||[])})},i.inherits=function(y,b){function x(){}x.prototype=b.prototype,y.prototype=new x},i.extend=function(){var y,b,x={};for(y=0;y<arguments.length;y++)for(b in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],b)&&x[b]===void 0&&(x[b]=arguments[y][b]);return x},i.prepareContent=function(y,b,x,M,w){return l.Promise.resolve(b).then(function(A){return s.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 C=new FileReader;C.onload=function(I){T(I.target.result)},C.onerror=function(I){R(I.target.error)},C.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(w?A=a.decode(A):x&&M!==!0&&(A=(function(R){return d(R,s.uint8array?new Uint8Array(R.length):new Array(R.length))})(A))),A):l.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(g)+", expected "+a.pretty(h)+")")}},isSignature:function(h,g){var m=this.reader.index;this.reader.setIndex(h);var v=this.reader.readString(4)===g;return this.reader.setIndex(m),v},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 h=this.reader.readData(this.zipCommentLength),g=c.uint8array?"uint8array":"array",m=a.transformTo(g,h);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 h,g,m,v=this.zip64EndOfCentralSize-44;0<v;)h=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[h]={id:h,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 h,g;for(h=0;h<this.files.length;h++)g=this.files[h],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(h<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(h);var g=h;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(h=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(h),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 v=g-m;if(0<v)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),d=n("./compressions"),h=n("./support");function g(m,v){this.options=m,this.loadOptions=v}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var v,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=(function(b){for(var x in d)if(Object.prototype.hasOwnProperty.call(d,x)&&d[x].magic===b)return d[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,v,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 v=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(v),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=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var v,y,b,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)v=m.readInt(2),y=m.readInt(2),b=m.readData(y),this.extraFields[v]={id:v,length:y,value:b};m.setIndex(x)},handleUTF8:function(){var m=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var y=a.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var x=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var v=s(m.value);return v.readInt(1)!==1||l(this.fileName)!==v.readInt(4)?null:c.utf8decode(v.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var v=s(m.value);return v.readInt(1)!==1||l(this.fileComment)!==v.readInt(4)?null:c.utf8decode(v.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 s(v,y,b){this.name=v,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=y,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var a=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(v){var y=null,b="string";try{if(!v)throw new Error("No output type specified.");var x=(b=v.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),y=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(y=y.pipe(new l.Utf8EncodeWorker)),!M&&x&&(y=y.pipe(new l.Utf8DecodeWorker))}catch(w){(y=new d("error")).error(w)}return new a(y,b,"")},async:function(v,y){return this.internalStream(v).accumulate(y)},nodeStream:function(v,y){return this.internalStream(v||"nodebuffer").toNodejsStream(y)},_compressWorker:function(v,y){if(this._data instanceof c&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(b,v,y)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var h=["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<h.length;m++)s.prototype[h[m]]=g;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var a,o,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,d=new l(v),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),a=function(){h.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){v(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(v,0)};else{var g=new s.MessageChannel;g.port1.onmessage=v,a=function(){g.port2.postMessage(0)}}var m=[];function v(){var y,b;o=!0;for(var x=m.length;x;){for(b=m,m=[],y=-1;++y<x;)b[y]();x=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||a()}}).call(this,typeof Bv<"u"?Bv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],d=["PENDING"];function h(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,x!==a&&y(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){s(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 v(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function y(x,M){var w=!1;function A(C){w||(w=!0,o.reject(x,C))}function T(C){w||(w=!0,o.resolve(x,C))}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=h).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})})},h.prototype.catch=function(x){return this.then(null,x)},h.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(a);return this.state!==d?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(v,M);if(w.status==="error")return o.reject(x,w.value);var A=w.value;if(A)y(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},h.resolve=function(x){return x instanceof this?x:o.resolve(new this(a),x)},h.reject=function(x){var M=new this(a);return o.reject(M,x)},h.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,C=-1,I=new this(a);++C<w;)N(x[C],C);return I;function N(D,z){M.resolve(D).then(function(j){T[z]=j,++R!==w||A||(A=!0,o.resolve(I,T))},function(j){A||(A=!0,o.reject(I,j))})}},h.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(a);++T<w;)C=x[T],M.resolve(C).then(function(I){A||(A=!0,o.resolve(R,I))},function(I){A||(A=!0,o.reject(R,I))});var C;return R}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),d=Object.prototype.toString,h=0,g=-1,m=0,v=8;function y(x){if(!(this instanceof y))return new y(x);this.options=a.assign({level:g,method:v,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=s.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(w!==h)throw new Error(l[w]);if(M.header&&s.deflateSetHeader(this.strm,M.header),M.dictionary){var A;if(A=typeof M.dictionary=="string"?o.string2buf(M.dictionary):d.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=s.deflateSetDictionary(this.strm,A))!==h)throw new Error(l[w]);this._dict_set=!0}}function b(x,M){var w=new y(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}y.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):d.call(x)==="[object ArrayBuffer]"?T.input=new Uint8Array(x):T.input=x,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new a.Buf8(R),T.next_out=0,T.avail_out=R),(w=s.deflate(T,A))!==1&&w!==h)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(a.shrinkBuf(T.output,T.next_out))):this.onData(a.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return A===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===h):A!==2||(this.onEnd(h),!(T.avail_out=0))},y.prototype.onData=function(x){this.chunks.push(x)},y.prototype.onEnd=function(x){x===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=y,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 s=n("./zlib/inflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),g=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},y||{});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)||y&&y.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 d,this.strm.avail_out=0;var x=s.inflateInit2(this.strm,b.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function v(y,b){var x=new m(b);if(x.push(y,!0),x.err)throw x.msg||c[x.err];return x.result}m.prototype.push=function(y,b){var x,M,w,A,T,R,C=this.strm,I=this.options.chunkSize,N=this.options.dictionary,D=!1;if(this.ended)return!1;M=b===~~b?b:b===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof y=="string"?C.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(I),C.next_out=0,C.avail_out=I),(x=s.inflate(C,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&N&&(R=typeof N=="string"?o.string2buf(N):g.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,x=s.inflateSetDictionary(this.strm,R)),x===l.Z_BUF_ERROR&&D===!0&&(x=l.Z_OK,D=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&x!==l.Z_STREAM_END&&(C.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(C.output,C.next_out),A=C.next_out-w,T=o.buf2string(C.output,w),C.next_out=A,C.avail_out=I-A,A&&a.arraySet(C.output,C.output,w,A,0),this.onData(T)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(D=!0)}while((0<C.avail_in||C.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(M=l.Z_FINISH),M===l.Z_FINISH?(x=s.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):M!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(C.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=v,i.inflateRaw=function(y,b){return(b=b||{}).raw=!0,v(y,b)},i.ungzip=v},{"./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 s=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 d=c.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(l[h]=d[h])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,d,h,g){if(c.subarray&&l.subarray)l.set(c.subarray(d,d+h),g);else for(var m=0;m<h;m++)l[g+m]=c[d+m]},flattenChunks:function(l){var c,d,h,g,m,v;for(c=h=0,d=l.length;c<d;c++)h+=l[c].length;for(v=new Uint8Array(h),c=g=0,d=l.length;c<d;c++)m=l[c],v.set(m,g),g+=m.length;return v}},o={arraySet:function(l,c,d,h,g){for(var m=0;m<h;m++)l[g+m]=c[d+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,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function d(h,g){if(g<65537&&(h.subarray&&o||!h.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(h,g));for(var m="",v=0;v<g;v++)m+=String.fromCharCode(h[v]);return m}l[254]=l[254]=1,i.string2buf=function(h){var g,m,v,y,b,x=h.length,M=0;for(y=0;y<x;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(v=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),y++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new s.Buf8(M),y=b=0;b<M;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(v=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),y++),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(h){return d(h,h.length)},i.binstring2buf=function(h){for(var g=new s.Buf8(h.length),m=0,v=g.length;m<v;m++)g[m]=h.charCodeAt(m);return g},i.buf2string=function(h,g){var m,v,y,b,x=g||h.length,M=new Array(2*x);for(m=v=0;m<x;)if((y=h[m++])<128)M[v++]=y;else if(4<(b=l[y]))M[v++]=65533,m+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&m<x;)y=y<<6|63&h[m++],b--;1<b?M[v++]=65533:y<65536?M[v++]=y:(y-=65536,M[v++]=55296|y>>10&1023,M[v++]=56320|1023&y)}return d(M,v)},i.utf8border=function(h,g){var m;for((g=g||h.length)>h.length&&(g=h.length),m=g-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?g:m+l[h[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,a,o,l){for(var c=65535&s|0,d=s>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3<o?2e3:o;d=d+(c=c+a[l++]|0)|0,--h;);c%=65521,d%=65521}return c|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();r.exports=function(a,o,l,c){var d=s,h=c+l;a^=-1;for(var g=c;g<h;g++)a=a>>>8^d[255&(a^o[g])];return-1^a}},{}],46:[function(n,r,i){var s,a=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),d=n("./messages"),h=0,g=4,m=0,v=-2,y=-1,b=4,x=2,M=8,w=9,A=286,T=30,R=19,C=2*A+1,I=15,N=3,D=258,z=D+N+1,j=42,W=113,P=1,$=2,K=3,G=4;function Z(B,F){return B.msg=d[F],F}function Q(B){return(B<<1)-(4<B?9:0)}function ee(B){for(var F=B.length;0<=--F;)B[F]=0}function H(B){var F=B.state,ie=F.pending;ie>B.avail_out&&(ie=B.avail_out),ie!==0&&(a.arraySet(B.output,F.pending_buf,F.pending_out,ie,B.next_out),B.next_out+=ie,F.pending_out+=ie,B.total_out+=ie,B.avail_out-=ie,F.pending-=ie,F.pending===0&&(F.pending_out=0))}function q(B,F){o._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,F),B.block_start=B.strstart,H(B.strm)}function te(B,F){B.pending_buf[B.pending++]=F}function ae(B,F){B.pending_buf[B.pending++]=F>>>8&255,B.pending_buf[B.pending++]=255&F}function xe(B,F){var ie,V,J=B.max_chain_length,le=B.strstart,Ae=B.prev_length,Ee=B.nice_match,se=B.strstart>B.w_size-z?B.strstart-(B.w_size-z):0,U=B.window,L=B.w_mask,X=B.prev,me=B.strstart+D,ve=U[le+Ae-1],ge=U[le+Ae];B.prev_length>=B.good_match&&(J>>=2),Ee>B.lookahead&&(Ee=B.lookahead);do if(U[(ie=F)+Ae]===ge&&U[ie+Ae-1]===ve&&U[ie]===U[le]&&U[++ie]===U[le+1]){le+=2,ie++;do;while(U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&le<me);if(V=D-(me-le),le=me-D,Ae<V){if(B.match_start=F,Ee<=(Ae=V))break;ve=U[le+Ae-1],ge=U[le+Ae]}}while((F=X[F&L])>se&&--J!=0);return Ae<=B.lookahead?Ae:B.lookahead}function re(B){var F,ie,V,J,le,Ae,Ee,se,U,L,X=B.w_size;do{if(J=B.window_size-B.lookahead-B.strstart,B.strstart>=X+(X-z)){for(a.arraySet(B.window,B.window,X,X,0),B.match_start-=X,B.strstart-=X,B.block_start-=X,F=ie=B.hash_size;V=B.head[--F],B.head[F]=X<=V?V-X:0,--ie;);for(F=ie=X;V=B.prev[--F],B.prev[F]=X<=V?V-X:0,--ie;);J+=X}if(B.strm.avail_in===0)break;if(Ae=B.strm,Ee=B.window,se=B.strstart+B.lookahead,U=J,L=void 0,L=Ae.avail_in,U<L&&(L=U),ie=L===0?0:(Ae.avail_in-=L,a.arraySet(Ee,Ae.input,Ae.next_in,L,se),Ae.state.wrap===1?Ae.adler=l(Ae.adler,Ee,L,se):Ae.state.wrap===2&&(Ae.adler=c(Ae.adler,Ee,L,se)),Ae.next_in+=L,Ae.total_in+=L,L),B.lookahead+=ie,B.lookahead+B.insert>=N)for(le=B.strstart-B.insert,B.ins_h=B.window[le],B.ins_h=(B.ins_h<<B.hash_shift^B.window[le+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[le+N-1])&B.hash_mask,B.prev[le&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=le,le++,B.insert--,!(B.lookahead+B.insert<N)););}while(B.lookahead<z&&B.strm.avail_in!==0)}function pe(B,F){for(var ie,V;;){if(B.lookahead<z){if(re(B),B.lookahead<z&&F===h)return P;if(B.lookahead===0)break}if(ie=0,B.lookahead>=N&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),ie!==0&&B.strstart-ie<=B.w_size-z&&(B.match_length=xe(B,ie)),B.match_length>=N)if(V=o._tr_tally(B,B.strstart-B.match_start,B.match_length-N),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=N){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else V=o._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(V&&(q(B,!1),B.strm.avail_out===0))return P}return B.insert=B.strstart<N-1?B.strstart:N-1,F===g?(q(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(q(B,!1),B.strm.avail_out===0)?P:$}function Ce(B,F){for(var ie,V,J;;){if(B.lookahead<z){if(re(B),B.lookahead<z&&F===h)return P;if(B.lookahead===0)break}if(ie=0,B.lookahead>=N&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=N-1,ie!==0&&B.prev_length<B.max_lazy_match&&B.strstart-ie<=B.w_size-z&&(B.match_length=xe(B,ie),B.match_length<=5&&(B.strategy===1||B.match_length===N&&4096<B.strstart-B.match_start)&&(B.match_length=N-1)),B.prev_length>=N&&B.match_length<=B.prev_length){for(J=B.strstart+B.lookahead-N,V=o._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-N),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=J&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=N-1,B.strstart++,V&&(q(B,!1),B.strm.avail_out===0))return P}else if(B.match_available){if((V=o._tr_tally(B,0,B.window[B.strstart-1]))&&q(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return P}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(V=o._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<N-1?B.strstart:N-1,F===g?(q(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(q(B,!1),B.strm.avail_out===0)?P:$}function fe(B,F,ie,V,J){this.good_length=B,this.max_lazy=F,this.nice_length=ie,this.max_chain=V,this.func=J}function Se(){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 a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*T+1)),this.bl_tree=new a.Buf16(2*(2*R+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(I+1),this.heap=new a.Buf16(2*A+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*A+1),ee(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(B){var F;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=x,(F=B.state).pending=0,F.pending_out=0,F.wrap<0&&(F.wrap=-F.wrap),F.status=F.wrap?j:W,B.adler=F.wrap===2?0:1,F.last_flush=h,o._tr_init(F),m):Z(B,v)}function ue(B){var F=Re(B);return F===m&&(function(ie){ie.window_size=2*ie.w_size,ee(ie.head),ie.max_lazy_match=s[ie.level].max_lazy,ie.good_match=s[ie.level].good_length,ie.nice_match=s[ie.level].nice_length,ie.max_chain_length=s[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,ie.ins_h=0})(B.state),F}function ct(B,F,ie,V,J,le){if(!B)return v;var Ae=1;if(F===y&&(F=6),V<0?(Ae=0,V=-V):15<V&&(Ae=2,V-=16),J<1||w<J||ie!==M||V<8||15<V||F<0||9<F||le<0||b<le)return Z(B,v);V===8&&(V=9);var Ee=new Se;return(B.state=Ee).strm=B,Ee.wrap=Ae,Ee.gzhead=null,Ee.w_bits=V,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=J+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+N-1)/N),Ee.window=new a.Buf8(2*Ee.w_size),Ee.head=new a.Buf16(Ee.hash_size),Ee.prev=new a.Buf16(Ee.w_size),Ee.lit_bufsize=1<<J+6,Ee.pending_buf_size=4*Ee.lit_bufsize,Ee.pending_buf=new a.Buf8(Ee.pending_buf_size),Ee.d_buf=1*Ee.lit_bufsize,Ee.l_buf=3*Ee.lit_bufsize,Ee.level=F,Ee.strategy=le,Ee.method=ie,ue(B)}s=[new fe(0,0,0,0,function(B,F){var ie=65535;for(ie>B.pending_buf_size-5&&(ie=B.pending_buf_size-5);;){if(B.lookahead<=1){if(re(B),B.lookahead===0&&F===h)return P;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var V=B.block_start+ie;if((B.strstart===0||B.strstart>=V)&&(B.lookahead=B.strstart-V,B.strstart=V,q(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-z&&(q(B,!1),B.strm.avail_out===0))return P}return B.insert=0,F===g?(q(B,!0),B.strm.avail_out===0?K:G):(B.strstart>B.block_start&&(q(B,!1),B.strm.avail_out),P)}),new fe(4,4,8,4,pe),new fe(4,5,16,8,pe),new fe(4,6,32,32,pe),new fe(4,4,16,16,Ce),new fe(8,16,32,32,Ce),new fe(8,16,128,128,Ce),new fe(8,32,128,256,Ce),new fe(32,128,258,1024,Ce),new fe(32,258,258,4096,Ce)],i.deflateInit=function(B,F){return ct(B,F,M,15,8,0)},i.deflateInit2=ct,i.deflateReset=ue,i.deflateResetKeep=Re,i.deflateSetHeader=function(B,F){return B&&B.state?B.state.wrap!==2?v:(B.state.gzhead=F,m):v},i.deflate=function(B,F){var ie,V,J,le;if(!B||!B.state||5<F||F<0)return B?Z(B,v):v;if(V=B.state,!B.output||!B.input&&B.avail_in!==0||V.status===666&&F!==g)return Z(B,B.avail_out===0?-5:v);if(V.strm=B,ie=V.last_flush,V.last_flush=F,V.status===j)if(V.wrap===2)B.adler=0,te(V,31),te(V,139),te(V,8),V.gzhead?(te(V,(V.gzhead.text?1:0)+(V.gzhead.hcrc?2:0)+(V.gzhead.extra?4:0)+(V.gzhead.name?8:0)+(V.gzhead.comment?16:0)),te(V,255&V.gzhead.time),te(V,V.gzhead.time>>8&255),te(V,V.gzhead.time>>16&255),te(V,V.gzhead.time>>24&255),te(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),te(V,255&V.gzhead.os),V.gzhead.extra&&V.gzhead.extra.length&&(te(V,255&V.gzhead.extra.length),te(V,V.gzhead.extra.length>>8&255)),V.gzhead.hcrc&&(B.adler=c(B.adler,V.pending_buf,V.pending,0)),V.gzindex=0,V.status=69):(te(V,0),te(V,0),te(V,0),te(V,0),te(V,0),te(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),te(V,3),V.status=W);else{var Ae=M+(V.w_bits-8<<4)<<8;Ae|=(2<=V.strategy||V.level<2?0:V.level<6?1:V.level===6?2:3)<<6,V.strstart!==0&&(Ae|=32),Ae+=31-Ae%31,V.status=W,ae(V,Ae),V.strstart!==0&&(ae(V,B.adler>>>16),ae(V,65535&B.adler)),B.adler=1}if(V.status===69)if(V.gzhead.extra){for(J=V.pending;V.gzindex<(65535&V.gzhead.extra.length)&&(V.pending!==V.pending_buf_size||(V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),H(B),J=V.pending,V.pending!==V.pending_buf_size));)te(V,255&V.gzhead.extra[V.gzindex]),V.gzindex++;V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),V.gzindex===V.gzhead.extra.length&&(V.gzindex=0,V.status=73)}else V.status=73;if(V.status===73)if(V.gzhead.name){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),H(B),J=V.pending,V.pending===V.pending_buf_size)){le=1;break}le=V.gzindex<V.gzhead.name.length?255&V.gzhead.name.charCodeAt(V.gzindex++):0,te(V,le)}while(le!==0);V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),le===0&&(V.gzindex=0,V.status=91)}else V.status=91;if(V.status===91)if(V.gzhead.comment){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),H(B),J=V.pending,V.pending===V.pending_buf_size)){le=1;break}le=V.gzindex<V.gzhead.comment.length?255&V.gzhead.comment.charCodeAt(V.gzindex++):0,te(V,le)}while(le!==0);V.gzhead.hcrc&&V.pending>J&&(B.adler=c(B.adler,V.pending_buf,V.pending-J,J)),le===0&&(V.status=103)}else V.status=103;if(V.status===103&&(V.gzhead.hcrc?(V.pending+2>V.pending_buf_size&&H(B),V.pending+2<=V.pending_buf_size&&(te(V,255&B.adler),te(V,B.adler>>8&255),B.adler=0,V.status=W)):V.status=W),V.pending!==0){if(H(B),B.avail_out===0)return V.last_flush=-1,m}else if(B.avail_in===0&&Q(F)<=Q(ie)&&F!==g)return Z(B,-5);if(V.status===666&&B.avail_in!==0)return Z(B,-5);if(B.avail_in!==0||V.lookahead!==0||F!==h&&V.status!==666){var Ee=V.strategy===2?(function(se,U){for(var L;;){if(se.lookahead===0&&(re(se),se.lookahead===0)){if(U===h)return P;break}if(se.match_length=0,L=o._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++,L&&(q(se,!1),se.strm.avail_out===0))return P}return se.insert=0,U===g?(q(se,!0),se.strm.avail_out===0?K:G):se.last_lit&&(q(se,!1),se.strm.avail_out===0)?P:$})(V,F):V.strategy===3?(function(se,U){for(var L,X,me,ve,ge=se.window;;){if(se.lookahead<=D){if(re(se),se.lookahead<=D&&U===h)return P;if(se.lookahead===0)break}if(se.match_length=0,se.lookahead>=N&&0<se.strstart&&(X=ge[me=se.strstart-1])===ge[++me]&&X===ge[++me]&&X===ge[++me]){ve=se.strstart+D;do;while(X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&X===ge[++me]&&me<ve);se.match_length=D-(ve-me),se.match_length>se.lookahead&&(se.match_length=se.lookahead)}if(se.match_length>=N?(L=o._tr_tally(se,1,se.match_length-N),se.lookahead-=se.match_length,se.strstart+=se.match_length,se.match_length=0):(L=o._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++),L&&(q(se,!1),se.strm.avail_out===0))return P}return se.insert=0,U===g?(q(se,!0),se.strm.avail_out===0?K:G):se.last_lit&&(q(se,!1),se.strm.avail_out===0)?P:$})(V,F):s[V.level].func(V,F);if(Ee!==K&&Ee!==G||(V.status=666),Ee===P||Ee===K)return B.avail_out===0&&(V.last_flush=-1),m;if(Ee===$&&(F===1?o._tr_align(V):F!==5&&(o._tr_stored_block(V,0,0,!1),F===3&&(ee(V.head),V.lookahead===0&&(V.strstart=0,V.block_start=0,V.insert=0))),H(B),B.avail_out===0))return V.last_flush=-1,m}return F!==g?m:V.wrap<=0?1:(V.wrap===2?(te(V,255&B.adler),te(V,B.adler>>8&255),te(V,B.adler>>16&255),te(V,B.adler>>24&255),te(V,255&B.total_in),te(V,B.total_in>>8&255),te(V,B.total_in>>16&255),te(V,B.total_in>>24&255)):(ae(V,B.adler>>>16),ae(V,65535&B.adler)),H(B),0<V.wrap&&(V.wrap=-V.wrap),V.pending!==0?m:1)},i.deflateEnd=function(B){var F;return B&&B.state?(F=B.state.status)!==j&&F!==69&&F!==73&&F!==91&&F!==103&&F!==W&&F!==666?Z(B,v):(B.state=null,F===W?Z(B,-3):m):v},i.deflateSetDictionary=function(B,F){var ie,V,J,le,Ae,Ee,se,U,L=F.length;if(!B||!B.state||(le=(ie=B.state).wrap)===2||le===1&&ie.status!==j||ie.lookahead)return v;for(le===1&&(B.adler=l(B.adler,F,L,0)),ie.wrap=0,L>=ie.w_size&&(le===0&&(ee(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),U=new a.Buf8(ie.w_size),a.arraySet(U,F,L-ie.w_size,ie.w_size,0),F=U,L=ie.w_size),Ae=B.avail_in,Ee=B.next_in,se=B.input,B.avail_in=L,B.next_in=0,B.input=F,re(ie);ie.lookahead>=N;){for(V=ie.strstart,J=ie.lookahead-(N-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[V+N-1])&ie.hash_mask,ie.prev[V&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=V,V++,--J;);ie.strstart=V,ie.lookahead=N-1,re(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,B.next_in=Ee,B.input=se,B.avail_in=Ae,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(s,a){var o,l,c,d,h,g,m,v,y,b,x,M,w,A,T,R,C,I,N,D,z,j,W,P,$;o=s.state,l=s.next_in,P=s.input,c=l+(s.avail_in-5),d=s.next_out,$=s.output,h=d-(a-s.avail_out),g=d+(s.avail_out-257),m=o.dmax,v=o.wsize,y=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,C=(1<<o.distbits)-1;e:do{w<15&&(M+=P[l++]<<w,w+=8,M+=P[l++]<<w,w+=8),I=A[M&R];t:for(;;){if(M>>>=N=I>>>24,w-=N,(N=I>>>16&255)===0)$[d++]=65535&I;else{if(!(16&N)){if((64&N)==0){I=A[(65535&I)+(M&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}D=65535&I,(N&=15)&&(w<N&&(M+=P[l++]<<w,w+=8),D+=M&(1<<N)-1,M>>>=N,w-=N),w<15&&(M+=P[l++]<<w,w+=8,M+=P[l++]<<w,w+=8),I=T[M&C];n:for(;;){if(M>>>=N=I>>>24,w-=N,!(16&(N=I>>>16&255))){if((64&N)==0){I=T[(65535&I)+(M&(1<<N)-1)];continue n}s.msg="invalid distance code",o.mode=30;break e}if(z=65535&I,w<(N&=15)&&(M+=P[l++]<<w,(w+=8)<N&&(M+=P[l++]<<w,w+=8)),m<(z+=M&(1<<N)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=N,w-=N,(N=d-h)<z){if(y<(N=z-N)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(W=x,(j=0)===b){if(j+=v-N,N<D){for(D-=N;$[d++]=x[j++],--N;);j=d-z,W=$}}else if(b<N){if(j+=v+b-N,(N-=b)<D){for(D-=N;$[d++]=x[j++],--N;);if(j=0,b<D){for(D-=N=b;$[d++]=x[j++],--N;);j=d-z,W=$}}}else if(j+=b-N,N<D){for(D-=N;$[d++]=x[j++],--N;);j=d-z,W=$}for(;2<D;)$[d++]=W[j++],$[d++]=W[j++],$[d++]=W[j++],D-=3;D&&($[d++]=W[j++],1<D&&($[d++]=W[j++]))}else{for(j=d-z;$[d++]=$[j++],$[d++]=$[j++],$[d++]=$[j++],2<(D-=3););D&&($[d++]=$[j++],1<D&&($[d++]=$[j++]))}break}}break}}while(l<c&&d<g);l-=D=w>>3,M&=(1<<(w-=D<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=d<g?g-d+257:257-(d-g),o.hold=M,o.bits=w}},{}],49:[function(n,r,i){var s=n("../utils/common"),a=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),d=1,h=2,g=0,m=-2,v=1,y=852,b=592;function x(j){return(j>>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(j){var W;return j&&j.state?(W=j.state,j.total_in=j.total_out=W.total=0,j.msg="",W.wrap&&(j.adler=1&W.wrap),W.mode=v,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new s.Buf32(y),W.distcode=W.distdyn=new s.Buf32(b),W.sane=1,W.back=-1,g):m}function A(j){var W;return j&&j.state?((W=j.state).wsize=0,W.whave=0,W.wnext=0,w(j)):m}function T(j,W){var P,$;return j&&j.state?($=j.state,W<0?(P=0,W=-W):(P=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?m:($.window!==null&&$.wbits!==W&&($.window=null),$.wrap=P,$.wbits=W,A(j))):m}function R(j,W){var P,$;return j?($=new M,(j.state=$).window=null,(P=T(j,W))!==g&&(j.state=null),P):m}var C,I,N=!0;function D(j){if(N){var W;for(C=new s.Buf32(512),I=new s.Buf32(32),W=0;W<144;)j.lens[W++]=8;for(;W<256;)j.lens[W++]=9;for(;W<280;)j.lens[W++]=7;for(;W<288;)j.lens[W++]=8;for(c(d,j.lens,0,288,C,0,j.work,{bits:9}),W=0;W<32;)j.lens[W++]=5;c(h,j.lens,0,32,I,0,j.work,{bits:5}),N=!1}j.lencode=C,j.lenbits=9,j.distcode=I,j.distbits=5}function z(j,W,P,$){var K,G=j.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new s.Buf8(G.wsize)),$>=G.wsize?(s.arraySet(G.window,W,P-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):($<(K=G.wsize-G.wnext)&&(K=$),s.arraySet(G.window,W,P-$,K,G.wnext),($-=K)?(s.arraySet(G.window,W,P-$,$,0),G.wnext=$,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(j){return R(j,15)},i.inflateInit2=R,i.inflate=function(j,W){var P,$,K,G,Z,Q,ee,H,q,te,ae,xe,re,pe,Ce,fe,Se,Re,ue,ct,B,F,ie,V,J=0,le=new s.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!j||!j.state||!j.output||!j.input&&j.avail_in!==0)return m;(P=j.state).mode===12&&(P.mode=13),Z=j.next_out,K=j.output,ee=j.avail_out,G=j.next_in,$=j.input,Q=j.avail_in,H=P.hold,q=P.bits,te=Q,ae=ee,F=g;e:for(;;)switch(P.mode){case v:if(P.wrap===0){P.mode=13;break}for(;q<16;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(2&P.wrap&&H===35615){le[P.check=0]=255&H,le[1]=H>>>8&255,P.check=o(P.check,le,2,0),q=H=0,P.mode=2;break}if(P.flags=0,P.head&&(P.head.done=!1),!(1&P.wrap)||(((255&H)<<8)+(H>>8))%31){j.msg="incorrect header check",P.mode=30;break}if((15&H)!=8){j.msg="unknown compression method",P.mode=30;break}if(q-=4,B=8+(15&(H>>>=4)),P.wbits===0)P.wbits=B;else if(B>P.wbits){j.msg="invalid window size",P.mode=30;break}P.dmax=1<<B,j.adler=P.check=1,P.mode=512&H?10:12,q=H=0;break;case 2:for(;q<16;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(P.flags=H,(255&P.flags)!=8){j.msg="unknown compression method",P.mode=30;break}if(57344&P.flags){j.msg="unknown header flags set",P.mode=30;break}P.head&&(P.head.text=H>>8&1),512&P.flags&&(le[0]=255&H,le[1]=H>>>8&255,P.check=o(P.check,le,2,0)),q=H=0,P.mode=3;case 3:for(;q<32;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.head&&(P.head.time=H),512&P.flags&&(le[0]=255&H,le[1]=H>>>8&255,le[2]=H>>>16&255,le[3]=H>>>24&255,P.check=o(P.check,le,4,0)),q=H=0,P.mode=4;case 4:for(;q<16;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.head&&(P.head.xflags=255&H,P.head.os=H>>8),512&P.flags&&(le[0]=255&H,le[1]=H>>>8&255,P.check=o(P.check,le,2,0)),q=H=0,P.mode=5;case 5:if(1024&P.flags){for(;q<16;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.length=H,P.head&&(P.head.extra_len=H),512&P.flags&&(le[0]=255&H,le[1]=H>>>8&255,P.check=o(P.check,le,2,0)),q=H=0}else P.head&&(P.head.extra=null);P.mode=6;case 6:if(1024&P.flags&&(Q<(xe=P.length)&&(xe=Q),xe&&(P.head&&(B=P.head.extra_len-P.length,P.head.extra||(P.head.extra=new Array(P.head.extra_len)),s.arraySet(P.head.extra,$,G,xe,B)),512&P.flags&&(P.check=o(P.check,$,xe,G)),Q-=xe,G+=xe,P.length-=xe),P.length))break e;P.length=0,P.mode=7;case 7:if(2048&P.flags){if(Q===0)break e;for(xe=0;B=$[G+xe++],P.head&&B&&P.length<65536&&(P.head.name+=String.fromCharCode(B)),B&&xe<Q;);if(512&P.flags&&(P.check=o(P.check,$,xe,G)),Q-=xe,G+=xe,B)break e}else P.head&&(P.head.name=null);P.length=0,P.mode=8;case 8:if(4096&P.flags){if(Q===0)break e;for(xe=0;B=$[G+xe++],P.head&&B&&P.length<65536&&(P.head.comment+=String.fromCharCode(B)),B&&xe<Q;);if(512&P.flags&&(P.check=o(P.check,$,xe,G)),Q-=xe,G+=xe,B)break e}else P.head&&(P.head.comment=null);P.mode=9;case 9:if(512&P.flags){for(;q<16;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(H!==(65535&P.check)){j.msg="header crc mismatch",P.mode=30;break}q=H=0}P.head&&(P.head.hcrc=P.flags>>9&1,P.head.done=!0),j.adler=P.check=0,P.mode=12;break;case 10:for(;q<32;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}j.adler=P.check=x(H),q=H=0,P.mode=11;case 11:if(P.havedict===0)return j.next_out=Z,j.avail_out=ee,j.next_in=G,j.avail_in=Q,P.hold=H,P.bits=q,2;j.adler=P.check=1,P.mode=12;case 12:if(W===5||W===6)break e;case 13:if(P.last){H>>>=7&q,q-=7&q,P.mode=27;break}for(;q<3;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}switch(P.last=1&H,q-=1,3&(H>>>=1)){case 0:P.mode=14;break;case 1:if(D(P),P.mode=20,W!==6)break;H>>>=2,q-=2;break e;case 2:P.mode=17;break;case 3:j.msg="invalid block type",P.mode=30}H>>>=2,q-=2;break;case 14:for(H>>>=7&q,q-=7&q;q<32;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if((65535&H)!=(H>>>16^65535)){j.msg="invalid stored block lengths",P.mode=30;break}if(P.length=65535&H,q=H=0,P.mode=15,W===6)break e;case 15:P.mode=16;case 16:if(xe=P.length){if(Q<xe&&(xe=Q),ee<xe&&(xe=ee),xe===0)break e;s.arraySet(K,$,G,xe,Z),Q-=xe,G+=xe,ee-=xe,Z+=xe,P.length-=xe;break}P.mode=12;break;case 17:for(;q<14;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(P.nlen=257+(31&H),H>>>=5,q-=5,P.ndist=1+(31&H),H>>>=5,q-=5,P.ncode=4+(15&H),H>>>=4,q-=4,286<P.nlen||30<P.ndist){j.msg="too many length or distance symbols",P.mode=30;break}P.have=0,P.mode=18;case 18:for(;P.have<P.ncode;){for(;q<3;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.lens[Ae[P.have++]]=7&H,H>>>=3,q-=3}for(;P.have<19;)P.lens[Ae[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,ie={bits:P.lenbits},F=c(0,P.lens,0,19,P.lencode,0,P.work,ie),P.lenbits=ie.bits,F){j.msg="invalid code lengths set",P.mode=30;break}P.have=0,P.mode=19;case 19:for(;P.have<P.nlen+P.ndist;){for(;fe=(J=P.lencode[H&(1<<P.lenbits)-1])>>>16&255,Se=65535&J,!((Ce=J>>>24)<=q);){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(Se<16)H>>>=Ce,q-=Ce,P.lens[P.have++]=Se;else{if(Se===16){for(V=Ce+2;q<V;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(H>>>=Ce,q-=Ce,P.have===0){j.msg="invalid bit length repeat",P.mode=30;break}B=P.lens[P.have-1],xe=3+(3&H),H>>>=2,q-=2}else if(Se===17){for(V=Ce+3;q<V;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}q-=Ce,B=0,xe=3+(7&(H>>>=Ce)),H>>>=3,q-=3}else{for(V=Ce+7;q<V;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}q-=Ce,B=0,xe=11+(127&(H>>>=Ce)),H>>>=7,q-=7}if(P.have+xe>P.nlen+P.ndist){j.msg="invalid bit length repeat",P.mode=30;break}for(;xe--;)P.lens[P.have++]=B}}if(P.mode===30)break;if(P.lens[256]===0){j.msg="invalid code -- missing end-of-block",P.mode=30;break}if(P.lenbits=9,ie={bits:P.lenbits},F=c(d,P.lens,0,P.nlen,P.lencode,0,P.work,ie),P.lenbits=ie.bits,F){j.msg="invalid literal/lengths set",P.mode=30;break}if(P.distbits=6,P.distcode=P.distdyn,ie={bits:P.distbits},F=c(h,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,ie),P.distbits=ie.bits,F){j.msg="invalid distances set",P.mode=30;break}if(P.mode=20,W===6)break e;case 20:P.mode=21;case 21:if(6<=Q&&258<=ee){j.next_out=Z,j.avail_out=ee,j.next_in=G,j.avail_in=Q,P.hold=H,P.bits=q,l(j,ae),Z=j.next_out,K=j.output,ee=j.avail_out,G=j.next_in,$=j.input,Q=j.avail_in,H=P.hold,q=P.bits,P.mode===12&&(P.back=-1);break}for(P.back=0;fe=(J=P.lencode[H&(1<<P.lenbits)-1])>>>16&255,Se=65535&J,!((Ce=J>>>24)<=q);){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(fe&&(240&fe)==0){for(Re=Ce,ue=fe,ct=Se;fe=(J=P.lencode[ct+((H&(1<<Re+ue)-1)>>Re)])>>>16&255,Se=65535&J,!(Re+(Ce=J>>>24)<=q);){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}H>>>=Re,q-=Re,P.back+=Re}if(H>>>=Ce,q-=Ce,P.back+=Ce,P.length=Se,fe===0){P.mode=26;break}if(32&fe){P.back=-1,P.mode=12;break}if(64&fe){j.msg="invalid literal/length code",P.mode=30;break}P.extra=15&fe,P.mode=22;case 22:if(P.extra){for(V=P.extra;q<V;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.length+=H&(1<<P.extra)-1,H>>>=P.extra,q-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=23;case 23:for(;fe=(J=P.distcode[H&(1<<P.distbits)-1])>>>16&255,Se=65535&J,!((Ce=J>>>24)<=q);){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if((240&fe)==0){for(Re=Ce,ue=fe,ct=Se;fe=(J=P.distcode[ct+((H&(1<<Re+ue)-1)>>Re)])>>>16&255,Se=65535&J,!(Re+(Ce=J>>>24)<=q);){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}H>>>=Re,q-=Re,P.back+=Re}if(H>>>=Ce,q-=Ce,P.back+=Ce,64&fe){j.msg="invalid distance code",P.mode=30;break}P.offset=Se,P.extra=15&fe,P.mode=24;case 24:if(P.extra){for(V=P.extra;q<V;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}P.offset+=H&(1<<P.extra)-1,H>>>=P.extra,q-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){j.msg="invalid distance too far back",P.mode=30;break}P.mode=25;case 25:if(ee===0)break e;if(xe=ae-ee,P.offset>xe){if((xe=P.offset-xe)>P.whave&&P.sane){j.msg="invalid distance too far back",P.mode=30;break}re=xe>P.wnext?(xe-=P.wnext,P.wsize-xe):P.wnext-xe,xe>P.length&&(xe=P.length),pe=P.window}else pe=K,re=Z-P.offset,xe=P.length;for(ee<xe&&(xe=ee),ee-=xe,P.length-=xe;K[Z++]=pe[re++],--xe;);P.length===0&&(P.mode=21);break;case 26:if(ee===0)break e;K[Z++]=P.length,ee--,P.mode=21;break;case 27:if(P.wrap){for(;q<32;){if(Q===0)break e;Q--,H|=$[G++]<<q,q+=8}if(ae-=ee,j.total_out+=ae,P.total+=ae,ae&&(j.adler=P.check=P.flags?o(P.check,K,ae,Z-ae):a(P.check,K,ae,Z-ae)),ae=ee,(P.flags?H:x(H))!==P.check){j.msg="incorrect data check",P.mode=30;break}q=H=0}P.mode=28;case 28:if(P.wrap&&P.flags){for(;q<32;){if(Q===0)break e;Q--,H+=$[G++]<<q,q+=8}if(H!==(4294967295&P.total)){j.msg="incorrect length check",P.mode=30;break}q=H=0}P.mode=29;case 29:F=1;break e;case 30:F=-3;break e;case 31:return-4;case 32:default:return m}return j.next_out=Z,j.avail_out=ee,j.next_in=G,j.avail_in=Q,P.hold=H,P.bits=q,(P.wsize||ae!==j.avail_out&&P.mode<30&&(P.mode<27||W!==4))&&z(j,j.output,j.next_out,ae-j.avail_out)?(P.mode=31,-4):(te-=j.avail_in,ae-=j.avail_out,j.total_in+=te,j.total_out+=ae,P.total+=ae,P.wrap&&ae&&(j.adler=P.check=P.flags?o(P.check,K,ae,j.next_out-ae):a(P.check,K,ae,j.next_out-ae)),j.data_type=P.bits+(P.last?64:0)+(P.mode===12?128:0)+(P.mode===20||P.mode===15?256:0),(te==0&&ae===0||W===4)&&F===g&&(F=-5),F)},i.inflateEnd=function(j){if(!j||!j.state)return m;var W=j.state;return W.window&&(W.window=null),j.state=null,g},i.inflateGetHeader=function(j,W){var P;return j&&j.state?(2&(P=j.state).wrap)==0?m:((P.head=W).done=!1,g):m},i.inflateSetDictionary=function(j,W){var P,$=W.length;return j&&j.state?(P=j.state).wrap!==0&&P.mode!==11?m:P.mode===11&&a(1,W,$,0)!==P.check?-3:z(j,W,$,$)?(P.mode=31,-4):(P.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 s=n("../utils/common"),a=[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(d,h,g,m,v,y,b,x){var M,w,A,T,R,C,I,N,D,z=x.bits,j=0,W=0,P=0,$=0,K=0,G=0,Z=0,Q=0,ee=0,H=0,q=null,te=0,ae=new s.Buf16(16),xe=new s.Buf16(16),re=null,pe=0;for(j=0;j<=15;j++)ae[j]=0;for(W=0;W<m;W++)ae[h[g+W]]++;for(K=z,$=15;1<=$&&ae[$]===0;$--);if($<K&&(K=$),$===0)return v[y++]=20971520,v[y++]=20971520,x.bits=1,0;for(P=1;P<$&&ae[P]===0;P++);for(K<P&&(K=P),j=Q=1;j<=15;j++)if(Q<<=1,(Q-=ae[j])<0)return-1;if(0<Q&&(d===0||$!==1))return-1;for(xe[1]=0,j=1;j<15;j++)xe[j+1]=xe[j]+ae[j];for(W=0;W<m;W++)h[g+W]!==0&&(b[xe[h[g+W]]++]=W);if(C=d===0?(q=re=b,19):d===1?(q=a,te-=257,re=o,pe-=257,256):(q=l,re=c,-1),j=P,R=y,Z=W=H=0,A=-1,T=(ee=1<<(G=K))-1,d===1&&852<ee||d===2&&592<ee)return 1;for(;;){for(I=j-Z,D=b[W]<C?(N=0,b[W]):b[W]>C?(N=re[pe+b[W]],q[te+b[W]]):(N=96,0),M=1<<j-Z,P=w=1<<G;v[R+(H>>Z)+(w-=M)]=I<<24|N<<16|D|0,w!==0;);for(M=1<<j-1;H&M;)M>>=1;if(M!==0?(H&=M-1,H+=M):H=0,W++,--ae[j]==0){if(j===$)break;j=h[g+b[W]]}if(K<j&&(H&T)!==A){for(Z===0&&(Z=K),R+=P,Q=1<<(G=j-Z);G+Z<$&&!((Q-=ae[G+Z])<=0);)G++,Q<<=1;if(ee+=1<<G,d===1&&852<ee||d===2&&592<ee)return 1;v[A=H&T]=K<<24|G<<16|R-y|0}}return H!==0&&(v[R+H]=j-Z<<24|64<<16|0),x.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),a=0,o=1;function l(J){for(var le=J.length;0<=--le;)J[le]=0}var c=0,d=29,h=256,g=h+1+d,m=30,v=19,y=2*g+1,b=15,x=16,M=7,w=256,A=16,T=17,R=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(g+2));l(z);var j=new Array(2*m);l(j);var W=new Array(512);l(W);var P=new Array(256);l(P);var $=new Array(d);l($);var K,G,Z,Q=new Array(m);function ee(J,le,Ae,Ee,se){this.static_tree=J,this.extra_bits=le,this.extra_base=Ae,this.elems=Ee,this.max_length=se,this.has_stree=J&&J.length}function H(J,le){this.dyn_tree=J,this.max_code=0,this.stat_desc=le}function q(J){return J<256?W[J]:W[256+(J>>>7)]}function te(J,le){J.pending_buf[J.pending++]=255&le,J.pending_buf[J.pending++]=le>>>8&255}function ae(J,le,Ae){J.bi_valid>x-Ae?(J.bi_buf|=le<<J.bi_valid&65535,te(J,J.bi_buf),J.bi_buf=le>>x-J.bi_valid,J.bi_valid+=Ae-x):(J.bi_buf|=le<<J.bi_valid&65535,J.bi_valid+=Ae)}function xe(J,le,Ae){ae(J,Ae[2*le],Ae[2*le+1])}function re(J,le){for(var Ae=0;Ae|=1&J,J>>>=1,Ae<<=1,0<--le;);return Ae>>>1}function pe(J,le,Ae){var Ee,se,U=new Array(b+1),L=0;for(Ee=1;Ee<=b;Ee++)U[Ee]=L=L+Ae[Ee-1]<<1;for(se=0;se<=le;se++){var X=J[2*se+1];X!==0&&(J[2*se]=re(U[X]++,X))}}function Ce(J){var le;for(le=0;le<g;le++)J.dyn_ltree[2*le]=0;for(le=0;le<m;le++)J.dyn_dtree[2*le]=0;for(le=0;le<v;le++)J.bl_tree[2*le]=0;J.dyn_ltree[2*w]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function fe(J){8<J.bi_valid?te(J,J.bi_buf):0<J.bi_valid&&(J.pending_buf[J.pending++]=J.bi_buf),J.bi_buf=0,J.bi_valid=0}function Se(J,le,Ae,Ee){var se=2*le,U=2*Ae;return J[se]<J[U]||J[se]===J[U]&&Ee[le]<=Ee[Ae]}function Re(J,le,Ae){for(var Ee=J.heap[Ae],se=Ae<<1;se<=J.heap_len&&(se<J.heap_len&&Se(le,J.heap[se+1],J.heap[se],J.depth)&&se++,!Se(le,Ee,J.heap[se],J.depth));)J.heap[Ae]=J.heap[se],Ae=se,se<<=1;J.heap[Ae]=Ee}function ue(J,le,Ae){var Ee,se,U,L,X=0;if(J.last_lit!==0)for(;Ee=J.pending_buf[J.d_buf+2*X]<<8|J.pending_buf[J.d_buf+2*X+1],se=J.pending_buf[J.l_buf+X],X++,Ee===0?xe(J,se,le):(xe(J,(U=P[se])+h+1,le),(L=C[U])!==0&&ae(J,se-=$[U],L),xe(J,U=q(--Ee),Ae),(L=I[U])!==0&&ae(J,Ee-=Q[U],L)),X<J.last_lit;);xe(J,w,le)}function ct(J,le){var Ae,Ee,se,U=le.dyn_tree,L=le.stat_desc.static_tree,X=le.stat_desc.has_stree,me=le.stat_desc.elems,ve=-1;for(J.heap_len=0,J.heap_max=y,Ae=0;Ae<me;Ae++)U[2*Ae]!==0?(J.heap[++J.heap_len]=ve=Ae,J.depth[Ae]=0):U[2*Ae+1]=0;for(;J.heap_len<2;)U[2*(se=J.heap[++J.heap_len]=ve<2?++ve:0)]=1,J.depth[se]=0,J.opt_len--,X&&(J.static_len-=L[2*se+1]);for(le.max_code=ve,Ae=J.heap_len>>1;1<=Ae;Ae--)Re(J,U,Ae);for(se=me;Ae=J.heap[1],J.heap[1]=J.heap[J.heap_len--],Re(J,U,1),Ee=J.heap[1],J.heap[--J.heap_max]=Ae,J.heap[--J.heap_max]=Ee,U[2*se]=U[2*Ae]+U[2*Ee],J.depth[se]=(J.depth[Ae]>=J.depth[Ee]?J.depth[Ae]:J.depth[Ee])+1,U[2*Ae+1]=U[2*Ee+1]=se,J.heap[1]=se++,Re(J,U,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ge,Ke){var Ie,ze,at,Fe,ce,Qe,He=Ke.dyn_tree,Ye=Ke.max_code,ut=Ke.stat_desc.static_tree,de=Ke.stat_desc.has_stree,Je=Ke.stat_desc.extra_bits,be=Ke.stat_desc.extra_base,je=Ke.stat_desc.max_length,Te=0;for(Fe=0;Fe<=b;Fe++)ge.bl_count[Fe]=0;for(He[2*ge.heap[ge.heap_max]+1]=0,Ie=ge.heap_max+1;Ie<y;Ie++)je<(Fe=He[2*He[2*(ze=ge.heap[Ie])+1]+1]+1)&&(Fe=je,Te++),He[2*ze+1]=Fe,Ye<ze||(ge.bl_count[Fe]++,ce=0,be<=ze&&(ce=Je[ze-be]),Qe=He[2*ze],ge.opt_len+=Qe*(Fe+ce),de&&(ge.static_len+=Qe*(ut[2*ze+1]+ce)));if(Te!==0){do{for(Fe=je-1;ge.bl_count[Fe]===0;)Fe--;ge.bl_count[Fe]--,ge.bl_count[Fe+1]+=2,ge.bl_count[je]--,Te-=2}while(0<Te);for(Fe=je;Fe!==0;Fe--)for(ze=ge.bl_count[Fe];ze!==0;)Ye<(at=ge.heap[--Ie])||(He[2*at+1]!==Fe&&(ge.opt_len+=(Fe-He[2*at+1])*He[2*at],He[2*at+1]=Fe),ze--)}})(J,le),pe(U,ve,J.bl_count)}function B(J,le,Ae){var Ee,se,U=-1,L=le[1],X=0,me=7,ve=4;for(L===0&&(me=138,ve=3),le[2*(Ae+1)+1]=65535,Ee=0;Ee<=Ae;Ee++)se=L,L=le[2*(Ee+1)+1],++X<me&&se===L||(X<ve?J.bl_tree[2*se]+=X:se!==0?(se!==U&&J.bl_tree[2*se]++,J.bl_tree[2*A]++):X<=10?J.bl_tree[2*T]++:J.bl_tree[2*R]++,U=se,ve=(X=0)===L?(me=138,3):se===L?(me=6,3):(me=7,4))}function F(J,le,Ae){var Ee,se,U=-1,L=le[1],X=0,me=7,ve=4;for(L===0&&(me=138,ve=3),Ee=0;Ee<=Ae;Ee++)if(se=L,L=le[2*(Ee+1)+1],!(++X<me&&se===L)){if(X<ve)for(;xe(J,se,J.bl_tree),--X!=0;);else se!==0?(se!==U&&(xe(J,se,J.bl_tree),X--),xe(J,A,J.bl_tree),ae(J,X-3,2)):X<=10?(xe(J,T,J.bl_tree),ae(J,X-3,3)):(xe(J,R,J.bl_tree),ae(J,X-11,7));U=se,ve=(X=0)===L?(me=138,3):se===L?(me=6,3):(me=7,4)}}l(Q);var ie=!1;function V(J,le,Ae,Ee){ae(J,(c<<1)+(Ee?1:0),3),(function(se,U,L,X){fe(se),te(se,L),te(se,~L),s.arraySet(se.pending_buf,se.window,U,L,se.pending),se.pending+=L})(J,le,Ae)}i._tr_init=function(J){ie||((function(){var le,Ae,Ee,se,U,L=new Array(b+1);for(se=Ee=0;se<d-1;se++)for($[se]=Ee,le=0;le<1<<C[se];le++)P[Ee++]=se;for(P[Ee-1]=se,se=U=0;se<16;se++)for(Q[se]=U,le=0;le<1<<I[se];le++)W[U++]=se;for(U>>=7;se<m;se++)for(Q[se]=U<<7,le=0;le<1<<I[se]-7;le++)W[256+U++]=se;for(Ae=0;Ae<=b;Ae++)L[Ae]=0;for(le=0;le<=143;)z[2*le+1]=8,le++,L[8]++;for(;le<=255;)z[2*le+1]=9,le++,L[9]++;for(;le<=279;)z[2*le+1]=7,le++,L[7]++;for(;le<=287;)z[2*le+1]=8,le++,L[8]++;for(pe(z,g+1,L),le=0;le<m;le++)j[2*le+1]=5,j[2*le]=re(le,5);K=new ee(z,C,h+1,g,b),G=new ee(j,I,0,m,b),Z=new ee(new Array(0),N,0,v,M)})(),ie=!0),J.l_desc=new H(J.dyn_ltree,K),J.d_desc=new H(J.dyn_dtree,G),J.bl_desc=new H(J.bl_tree,Z),J.bi_buf=0,J.bi_valid=0,Ce(J)},i._tr_stored_block=V,i._tr_flush_block=function(J,le,Ae,Ee){var se,U,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(X){var me,ve=4093624447;for(me=0;me<=31;me++,ve>>>=1)if(1&ve&&X.dyn_ltree[2*me]!==0)return a;if(X.dyn_ltree[18]!==0||X.dyn_ltree[20]!==0||X.dyn_ltree[26]!==0)return o;for(me=32;me<h;me++)if(X.dyn_ltree[2*me]!==0)return o;return a})(J)),ct(J,J.l_desc),ct(J,J.d_desc),L=(function(X){var me;for(B(X,X.dyn_ltree,X.l_desc.max_code),B(X,X.dyn_dtree,X.d_desc.max_code),ct(X,X.bl_desc),me=v-1;3<=me&&X.bl_tree[2*D[me]+1]===0;me--);return X.opt_len+=3*(me+1)+5+5+4,me})(J),se=J.opt_len+3+7>>>3,(U=J.static_len+3+7>>>3)<=se&&(se=U)):se=U=Ae+5,Ae+4<=se&&le!==-1?V(J,le,Ae,Ee):J.strategy===4||U===se?(ae(J,2+(Ee?1:0),3),ue(J,z,j)):(ae(J,4+(Ee?1:0),3),(function(X,me,ve,ge){var Ke;for(ae(X,me-257,5),ae(X,ve-1,5),ae(X,ge-4,4),Ke=0;Ke<ge;Ke++)ae(X,X.bl_tree[2*D[Ke]+1],3);F(X,X.dyn_ltree,me-1),F(X,X.dyn_dtree,ve-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),ue(J,J.dyn_ltree,J.dyn_dtree)),Ce(J),Ee&&fe(J)},i._tr_tally=function(J,le,Ae){return J.pending_buf[J.d_buf+2*J.last_lit]=le>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&le,J.pending_buf[J.l_buf+J.last_lit]=255&Ae,J.last_lit++,le===0?J.dyn_ltree[2*Ae]++:(J.matches++,le--,J.dyn_ltree[2*(P[Ae]+h+1)]++,J.dyn_dtree[2*q(le)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ae(J,2,3),xe(J,w,z),(function(le){le.bi_valid===16?(te(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)})(J)}},{"../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(s){(function(a,o){if(!a.setImmediate){var l,c,d,h,g=1,m={},v=!1,y=a.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(a);b=b&&b.setTimeout?b:a,l={}.toString.call(a.process)==="[object process]"?function(A){process.nextTick(function(){M(A)})}:(function(){if(a.postMessage&&!a.importScripts){var A=!0,T=a.onmessage;return a.onmessage=function(){A=!1},a.postMessage("","*"),a.onmessage=T,A}})()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",w,!1):a.attachEvent("onmessage",w),function(A){a.postMessage(h+A,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(c=y.documentElement,function(A){var T=y.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 C={callback:A,args:T};return m[g]=C,l(g),g++},b.clearImmediate=x}function x(A){delete m[A]}function M(A){if(v)setTimeout(M,0,A);else{var T=m[A];if(T){v=!0;try{(function(R){var C=R.callback,I=R.args;switch(I.length){case 0:C();break;case 1:C(I[0]);break;case 2:C(I[0],I[1]);break;case 3:C(I[0],I[1],I[2]);break;default:C.apply(o,I)}})(T)}finally{x(A),v=!1}}}}function w(A){A.source===a&&typeof A.data=="string"&&A.data.indexOf(h)===0&&M(+A.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Bv<"u"?Bv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(RA)),RA.exports}var jge=Lge();const Ige=ro(jge);function Uge(t){const e=new Yr;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 k5=Uge;async function R5(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],s=[],a=[],o=i.getElementsByTagName("vertex");for(let c=0;c<o.length;c++){const d=o[c];s.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const d=l[c];a.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}s.length>0&&a.length>0&&e.push({vertices:s,triangles:a})}return e}async function Fge(t){const e=await Ige.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function s(d){const h=d.startsWith("/")?d.slice(1):d,g=e.files[h];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const a=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!a){const d=Object.keys(e.files).find(h=>h.endsWith(".model"));if(d){const h=await s(d);if(h){const g=await R5(h);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await s(a);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let d=0;d<l.length;d++){const h=l[d],g=h.getAttribute("id");if(!g)continue;const m=[],v=h.getElementsByTagName("mesh");for(let b=0;b<v.length;b++){const x=v[b],M=[],w=[],A=x.getElementsByTagName("vertex");for(let R=0;R<A.length;R++){const C=A[R];M.push(parseFloat(C.getAttribute("x")||"0"),parseFloat(C.getAttribute("y")||"0"),parseFloat(C.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let R=0;R<T.length;R++){const C=T[R];w.push(parseInt(C.getAttribute("v1")||"0"),parseInt(C.getAttribute("v2")||"0"),parseInt(C.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&m.push({vertices:M,triangles:w})}const y=h.getElementsByTagName("component");for(let b=0;b<y.length;b++){const x=y[b],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const w=await s(M);if(w){const A=await R5(w),T=x.getAttribute("transform"),R=k5(T);for(const C of A)if(T){const I=[];for(let N=0;N<C.vertices.length;N+=3){const D=new Xe(C.vertices[N],C.vertices[N+1],C.vertices[N+2]);D.applyMatrix4(R),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:C.triangles})}else m.push(C)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const c=o.getElementsByTagName("build");if(c.length>0){const d=c[0].getElementsByTagName("item");for(let h=0;h<d.length;h++){const g=d[h],m=g.getAttribute("objectid");if(!m)continue;const v=k5(g.getAttribute("transform"));r.push({objectId:m,transform:v})}}return{objects:n,buildItems:r}}function P5(t){const e=new pl,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 Ya(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function zge({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),s=E.useRef(null),a=E.useRef(null),o=E.useRef(null),[l,c]=E.useState(!0),[d,h]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const v=r.current,y=v.clientWidth,b=v.clientHeight,x=new xde;x.background=new vn(1710618),s.current=x;const M=new Ha(45,y/b,.1,1e4);M.position.set(150,150,150),a.current=M;const w=new vge({antialias:!0});w.setSize(y,b),w.setPixelRatio(window.devicePixelRatio),v.appendChild(w.domElement),i.current=w;const A=new _ge(M,w.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new Nde(16777215,.6);x.add(T);const R=new e5(16777215,.8);R.position.set(100,100,100),x.add(R);const C=new e5(16777215,.4);C.position.set(-100,50,-100),x.add(C);const I=Math.max(e.x,e.y),N=Math.ceil(I/16),D=new Rde(I,N,4473924,3355443);x.add(D);const z=new TP(e.x,e.y),j=new MP({color:44610,transparent:!0,opacity:.15,side:Ko}),W=new al(z,j);W.rotation.x=-Math.PI/2,W.position.y=-.5,x.add(W);let P;const $=()=>{P=requestAnimationFrame($),A.update(),w.render(x,M)};$(),fetch(t).then(G=>{if(!G.ok)throw new Error("Failed to load file");return G.arrayBuffer()}).then(Fge).then(({objects:G,buildItems:Z})=>{if(G.size===0)throw new Error("No meshes found in 3MF file");const Q=new Mde({color:44610,shininess:30,flatShading:!1}),ee=new mx,H=[];if(Z.length>0)for(const fe of Z){const Se=G.get(fe.objectId);if(Se)for(const Re of Se.meshes){const ue=[];for(let B=0;B<Re.vertices.length;B+=3){const F=new Xe(Re.vertices[B],Re.vertices[B+1],Re.vertices[B+2]);F.applyMatrix4(fe.transform),ue.push(F.x,F.y,F.z)}const ct=P5({vertices:ue,triangles:Re.triangles});H.push(ct)}}else for(const fe of G.values())for(const Se of fe.meshes){const Re=P5(Se);H.push(Re)}if(H.length>0){const fe=H.length===1?H[0]:Oge(H,!1);if(fe){const Se=new al(fe,Q);ee.add(Se)}if(H.length>1)for(const Se of H)Se.dispose()}const q=new If().setFromObject(ee),te=q.getCenter(new Xe);ee.position.y=-q.min.y,Z.length===0&&(ee.position.x=-te.x,ee.position.z=-te.z),x.add(ee);const ae=new If().setFromObject(ee),xe=ae.getCenter(new Xe),re=ae.getSize(new Xe),Ce=Math.max(re.x,re.y,re.z)*1.8;M.position.set(xe.x+Ce*.7,xe.y+Ce*.5,xe.z+Ce*.7),A.target.copy(xe),A.update(),c(!1)}).catch(G=>{h(G.message),c(!1)});const K=()=>{if(!v)return;const G=v.clientWidth,Z=v.clientHeight;M.aspect=G/Z,M.updateProjectionMatrix(),w.setSize(G,Z)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(P),A.dispose(),w.dispose(),v.removeChild(w.domElement)}},[t,e]);const g=()=>{a.current&&o.current&&(a.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=v=>{a.current&&a.current.position.multiplyScalar(v)};return u.jsxs("div",{className:`relative ${n}`,children:[u.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:u.jsx("p",{className:"text-red-400",children:d})}),!l&&!d&&u.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[u.jsx(Ue,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:u.jsx(uce,{className:"w-4 h-4"})}),u.jsx(Ue,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:u.jsx(hce,{className:"w-4 h-4"})}),u.jsx(Ue,{variant:"secondary",size:"sm",onClick:g,children:u.jsx(X0,{className:"w-4 h-4"})})]})]})}const xw="159",Qh={ROTATE:0,DOLLY:1,PAN:2},Jh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Bge=0,D5=1,Hge=2,b7=1,$ge=2,Xl=3,ed=0,Vs=1,Jl=2,$u=0,Bp=1,O5=2,L5=3,j5=4,Vge=5,Qd=100,Gge=101,Wge=102,I5=103,U5=104,qge=200,Xge=201,Kge=202,Yge=203,B3=204,H3=205,Zge=206,Qge=207,Jge=208,exe=209,txe=210,nxe=211,rxe=212,ixe=213,sxe=214,axe=0,oxe=1,lxe=2,u1=3,cxe=4,uxe=5,dxe=6,fxe=7,NP=0,hxe=1,pxe=2,Vu=0,mxe=1,gxe=2,xxe=3,bxe=4,vxe=5,v7=300,am=301,om=302,$3=303,V3=304,bw=306,G3=1e3,bo=1001,W3=1002,Wi=1003,F5=1004,PA=1005,$a=1006,yxe=1007,d0=1008,Gu=1009,_xe=1010,Sxe=1011,kP=1012,y7=1013,ju=1014,ac=1015,f0=1016,_7=1017,S7=1018,hf=1020,wxe=1021,Va=1023,Mxe=1024,Exe=1025,pf=1026,lm=1027,Axe=1028,w7=1029,Txe=1030,M7=1031,E7=1033,DA=33776,OA=33777,LA=33778,jA=33779,z5=35840,B5=35841,H5=35842,$5=35843,A7=36196,V5=37492,G5=37496,W5=37808,q5=37809,X5=37810,K5=37811,Y5=37812,Z5=37813,Q5=37814,J5=37815,ez=37816,tz=37817,nz=37818,rz=37819,iz=37820,sz=37821,IA=36492,az=36494,oz=36495,Cxe=36283,lz=36284,cz=36285,uz=36286,T7=3e3,mf=3001,Nxe=3200,kxe=3201,C7=0,Rxe=1,Ga="",qi="srgb",_c="srgb-linear",RP="display-p3",vw="display-p3-linear",d1="linear",sr="srgb",f1="rec709",h1="p3",ep=7680,dz=519,Pxe=512,Dxe=513,Oxe=514,N7=515,Lxe=516,jxe=517,Ixe=518,Uxe=519,q3=35044,fz="300 es",X3=1035,el=2e3,h0=2001;class eh{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 s=i.indexOf(n);s!==-1&&i.splice(s,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 s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const ns=["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 hz=1234567;const kx=Math.PI/180,p0=180/Math.PI;function hc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ns[t&255]+ns[t>>8&255]+ns[t>>16&255]+ns[t>>24&255]+"-"+ns[e&255]+ns[e>>8&255]+"-"+ns[e>>16&15|64]+ns[e>>24&255]+"-"+ns[n&63|128]+ns[n>>8&255]+"-"+ns[n>>16&255]+ns[n>>24&255]+ns[r&255]+ns[r>>8&255]+ns[r>>16&255]+ns[r>>24&255]).toLowerCase()}function Xi(t,e,n){return Math.max(e,Math.min(n,t))}function PP(t,e){return(t%e+e)%e}function Fxe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function zxe(t,e,n){return t!==e?(n-t)/(e-t):0}function Rx(t,e,n){return(1-n)*t+n*e}function Bxe(t,e,n,r){return Rx(t,e,1-Math.exp(-n*r))}function Hxe(t,e=1){return e-Math.abs(PP(t,e*2)-e)}function $xe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Vxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Gxe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Wxe(t,e){return t+Math.random()*(e-t)}function qxe(t){return t*(.5-Math.random())}function Xxe(t){t!==void 0&&(hz=t);let e=hz+=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 Kxe(t){return t*kx}function Yxe(t){return t*p0}function K3(t){return(t&t-1)===0&&t!==0}function Zxe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function p1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Qxe(t,e,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+r)/2),d=a((e+r)/2),h=s((e-r)/2),g=a((e-r)/2),m=s((r-e)/2),v=a((r-e)/2);switch(i){case"XYX":t.set(o*d,l*h,l*g,o*c);break;case"YZY":t.set(l*g,o*d,l*h,o*c);break;case"ZXZ":t.set(l*h,l*g,o*d,o*c);break;case"XZX":t.set(o*d,l*v,l*m,o*c);break;case"YXY":t.set(l*m,o*d,l*v,o*c);break;case"ZYZ":t.set(l*v,l*m,o*d,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Yo(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 k7={DEG2RAD:kx,RAD2DEG:p0,generateUUID:hc,clamp:Xi,euclideanModulo:PP,mapLinear:Fxe,inverseLerp:zxe,lerp:Rx,damp:Bxe,pingpong:Hxe,smoothstep:$xe,smootherstep:Vxe,randInt:Gxe,randFloat:Wxe,randFloatSpread:qxe,seededRandom:Xxe,degToRad:Kxe,radToDeg:Yxe,isPowerOfTwo:K3,ceilPowerOfTwo:Zxe,floorPowerOfTwo:p1,setQuaternionFromProperEuler:Qxe,normalize:Hn,denormalize:Yo};class Kt{constructor(e=0,n=0){Kt.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(Xi(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),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,s,a,o,l,c){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c)}set(e,n,r,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[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,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],d=r[4],h=r[7],g=r[2],m=r[5],v=r[8],y=i[0],b=i[3],x=i[6],M=i[1],w=i[4],A=i[7],T=i[2],R=i[5],C=i[8];return s[0]=a*y+o*M+l*T,s[3]=a*b+o*w+l*R,s[6]=a*x+o*A+l*C,s[1]=c*y+d*M+h*T,s[4]=c*b+d*w+h*R,s[7]=c*x+d*A+h*C,s[2]=g*y+m*M+v*T,s[5]=g*b+m*w+v*R,s[8]=g*x+m*A+v*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return n*a*d-n*o*c-r*s*d+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,g=o*l-d*s,m=c*s-a*l,v=n*h+r*g+i*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/v;return e[0]=h*y,e[1]=(i*c-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(UA.makeScale(e,n)),this}rotate(e){return this.premultiply(UA.makeRotation(-e)),this}translate(e,n){return this.premultiply(UA.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 UA=new fn;function R7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function m1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Jxe(){const t=m1("canvas");return t.style.display="block",t}const pz={};function Px(t){t in pz||(pz[t]=!0,console.warn(t))}const mz=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),gz=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),my={[_c]:{transfer:d1,primaries:f1,toReference:t=>t,fromReference:t=>t},[qi]:{transfer:sr,primaries:f1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[vw]:{transfer:d1,primaries:h1,toReference:t=>t.applyMatrix3(gz),fromReference:t=>t.applyMatrix3(mz)},[RP]:{transfer:sr,primaries:h1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(gz),fromReference:t=>t.applyMatrix3(mz).convertLinearToSRGB()}},e0e=new Set([_c,vw]),$n={enabled:!0,_workingColorSpace:_c,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(!e0e.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=my[e].toReference,i=my[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 my[t].primaries},getTransfer:function(t){return t===Ga?d1:my[t].transfer}};function Hp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function FA(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let tp;class P7{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{tp===void 0&&(tp=m1("canvas")),tp.width=e.width,tp.height=e.height;const r=tp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=tp}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=m1("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),s=i.data;for(let a=0;a<s.length;a++)s[a]=Hp(s[a]/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(Hp(n[r]/255)*255):n[r]=Hp(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 t0e=0;class D7{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:t0e++}),this.uuid=hc(),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 s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(zA(i[a].image)):s.push(zA(i[a]))}else s=zA(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function zA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?P7.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let n0e=0;class Gs extends eh{constructor(e=Gs.DEFAULT_IMAGE,n=Gs.DEFAULT_MAPPING,r=bo,i=bo,s=$a,a=d0,o=Va,l=Gu,c=Gs.DEFAULT_ANISOTROPY,d=Ga){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:n0e++}),this.uuid=hc(),this.name="",this.source=new D7(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Kt(0,0),this.repeat=new Kt(1,1),this.center=new Kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Px("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===mf?qi:Ga),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!==v7)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case G3:e.x=e.x-Math.floor(e.x);break;case bo:e.x=e.x<0?0:1;break;case W3: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 G3:e.y=e.y-Math.floor(e.y);break;case bo:e.y=e.y<0?0:1;break;case W3: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 Px("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===qi?mf:T7}set encoding(e){Px("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===mf?qi:Ga}}Gs.DEFAULT_IMAGE=null;Gs.DEFAULT_MAPPING=v7;Gs.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,s=this.w,a=e.elements;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.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,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,s;const l=e.elements,c=l[0],d=l[4],h=l[8],g=l[1],m=l[5],v=l[9],y=l[2],b=l[6],x=l[10];if(Math.abs(d-g)<.01&&Math.abs(h-y)<.01&&Math.abs(v-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(h+y)<.1&&Math.abs(v+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=(d+g)/4,C=(h+y)/4,I=(v+b)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),i=R/r,s=C/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=R/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=C/s,i=I/s),this.set(r,i,s,n),this}let M=Math.sqrt((b-v)*(b-v)+(h-y)*(h-y)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(b-v)/M,this.y=(h-y)/M,this.z=(g-d)/M,this.w=Math.acos((c+m+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const 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 r0e extends eh{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&&(Px("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===mf?qi:Ga),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:$a,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Gs(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 D7(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 Uf extends r0e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class O7 extends Gs{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=Wi,this.minFilter=Wi,this.wrapR=bo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class i0e extends Gs{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=Wi,this.minFilter=Wi,this.wrapR=bo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ff{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,s,a,o){let l=r[i+0],c=r[i+1],d=r[i+2],h=r[i+3];const g=s[a+0],m=s[a+1],v=s[a+2],y=s[a+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=d,e[n+3]=h;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=v,e[n+3]=y;return}if(h!==y||l!==g||c!==m||d!==v){let b=1-o;const x=l*g+c*m+d*v+h*y,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,d=d*b+v*A,h=h*b+y*A,b===1-o){const T=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=T,c*=T,d*=T,h*=T}}e[n]=l,e[n+1]=c,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],d=r[i+3],h=s[a],g=s[a+1],m=s[a+2],v=s[a+3];return e[n]=o*v+d*h+l*m-c*g,e[n+1]=l*v+d*g+c*h-o*m,e[n+2]=c*v+d*m+o*g-l*h,e[n+3]=d*v-o*h-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,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),d=o(i/2),h=o(s/2),g=l(r/2),m=l(i/2),v=l(s/2);switch(a){case"XYZ":this._x=g*d*h+c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h-g*m*v;break;case"YXZ":this._x=g*d*h+c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h+g*m*v;break;case"ZXY":this._x=g*d*h-c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h-g*m*v;break;case"ZYX":this._x=g*d*h-c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h+g*m*v;break;case"YZX":this._x=g*d*h+c*m*v,this._y=c*m*h+g*d*v,this._z=c*d*v-g*m*h,this._w=c*d*h-g*m*v;break;case"XZY":this._x=g*d*h-c*m*v,this._y=c*m*h-g*d*v,this._z=c*d*v+g*m*h,this._w=c*d*h+g*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}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],s=n[8],a=n[1],o=n[5],l=n[9],c=n[2],d=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-c)*m,this._z=(a-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(s-c)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(a-i)/m,this._x=(s+c)/m,this._y=(l+d)/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(Xi(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,s=e._z,a=e._w,o=n._x,l=n._y,c=n._z,d=n._w;return this._x=r*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-r*c,this._z=s*d+a*c+r*l-i*o,this._w=a*d-r*o-i*l-s*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,s=this._z,a=this._w;let o=a*e._w+r*e._x+i*e._y+s*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=a,this._x=r,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*a+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),h=Math.sin((1-n)*d)/c,g=Math.sin(n*d)/c;return this._w=a*h+this._w*g,this._x=r*h+this._x*g,this._y=i*h+this._y*g,this._z=s*h+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(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),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 ke{constructor(e=0,n=0,r=0){ke.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(xz.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(xz.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);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}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),d=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+l*c+a*h-o*d,this.y=r+l*d+o*c-s*h,this.z=i+l*h+s*d-a*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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[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,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,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 BA.copy(this).projectOnVector(e),this.sub(BA)}reflect(e){return this.sub(BA.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(Xi(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 BA=new ke,xz=new Ff;class Za{constructor(e=new ke(1/0,1/0,1/0),n=new ke(-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(po.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(po.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=po.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 s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,po):po.fromBufferAttribute(s,a),po.applyMatrix4(e.matrixWorld),this.expandByPoint(po);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),gy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),gy.copy(r.boundingBox)),gy.applyMatrix4(e.matrixWorld),this.union(gy)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],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,po),po.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(Qg),xy.subVectors(this.max,Qg),np.subVectors(e.a,Qg),rp.subVectors(e.b,Qg),ip.subVectors(e.c,Qg),hu.subVectors(rp,np),pu.subVectors(ip,rp),zd.subVectors(np,ip);let n=[0,-hu.z,hu.y,0,-pu.z,pu.y,0,-zd.z,zd.y,hu.z,0,-hu.x,pu.z,0,-pu.x,zd.z,0,-zd.x,-hu.y,hu.x,0,-pu.y,pu.x,0,-zd.y,zd.x,0];return!HA(n,np,rp,ip,xy)||(n=[1,0,0,0,1,0,0,0,1],!HA(n,np,rp,ip,xy))?!1:(by.crossVectors(hu,pu),n=[by.x,by.y,by.z],HA(n,np,rp,ip,xy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,po).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(po).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:(Fl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fl),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 Fl=[new ke,new ke,new ke,new ke,new ke,new ke,new ke,new ke],po=new ke,gy=new Za,np=new ke,rp=new ke,ip=new ke,hu=new ke,pu=new ke,zd=new ke,Qg=new ke,xy=new ke,by=new ke,Bd=new ke;function HA(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Bd.fromArray(t,s);const o=i.x*Math.abs(Bd.x)+i.y*Math.abs(Bd.y)+i.z*Math.abs(Bd.z),l=e.dot(Bd),c=n.dot(Bd),d=r.dot(Bd);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const s0e=new Za,Jg=new ke,$A=new ke;class nl{constructor(e=new ke,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):s0e.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));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;Jg.subVectors(e,this.center);const n=Jg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Jg,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):($A.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Jg.copy(e.center).add($A)),this.expandByPoint(Jg.copy(e.center).sub($A))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const zl=new ke,VA=new ke,vy=new ke,mu=new ke,GA=new ke,yy=new ke,WA=new ke;class DP{constructor(e=new ke,n=new ke(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,zl)),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=zl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(zl.copy(this.origin).addScaledVector(this.direction,n),zl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){VA.copy(e).add(n).multiplyScalar(.5),vy.copy(n).sub(e).normalize(),mu.copy(this.origin).sub(VA);const s=e.distanceTo(n)*.5,a=-this.direction.dot(vy),o=mu.dot(this.direction),l=-mu.dot(vy),c=mu.lengthSq(),d=Math.abs(1-a*a);let h,g,m,v;if(d>0)if(h=a*l-o,g=a*o-l,v=s*d,h>=0)if(g>=-v)if(g<=v){const y=1/d;h*=y,g*=y,m=h*(h+a*g+2*o)+g*(a*h+g+2*l)+c}else g=s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g=-s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-v?(h=Math.max(0,-(-a*s+o)),g=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c):g<=v?(h=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+c):(h=Math.max(0,-(a*s+o)),g=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c);else g=a>0?-s:s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(VA).addScaledVector(vy,g),m}intersectSphere(e,n){zl.subVectors(e.center,this.origin);const r=zl.dot(this.direction),i=zl.dot(zl)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;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,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=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),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),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,zl)!==null}intersectTriangle(e,n,r,i,s){GA.subVectors(n,e),yy.subVectors(r,e),WA.crossVectors(GA,yy);let a=this.direction.dot(WA),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;mu.subVectors(this.origin,e);const l=o*this.direction.dot(yy.crossVectors(mu,yy));if(l<0)return null;const c=o*this.direction.dot(GA.cross(mu));if(c<0||l+c>a)return null;const d=-o*mu.dot(WA);return d<0?null:this.at(d/a,s)}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 tr{constructor(e,n,r,i,s,a,o,l,c,d,h,g,m,v,y,b){tr.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,s,a,o,l,c,d,h,g,m,v,y,b)}set(e,n,r,i,s,a,o,l,c,d,h,g,m,v,y,b){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=s,x[5]=a,x[9]=o,x[13]=l,x[2]=c,x[6]=d,x[10]=h,x[14]=g,x[3]=m,x[7]=v,x[11]=y,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 tr().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/sp.setFromMatrixColumn(e,0).length(),s=1/sp.setFromMatrixColumn(e,1).length(),a=1/sp.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]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,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,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*h,v=o*d,y=o*h;n[0]=l*d,n[4]=-l*h,n[8]=c,n[1]=m+v*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=v+m*c,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*h,v=c*d,y=c*h;n[0]=g+y*o,n[4]=v*o-m,n[8]=a*c,n[1]=a*h,n[5]=a*d,n[9]=-o,n[2]=m*o-v,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*h,v=c*d,y=c*h;n[0]=g-y*o,n[4]=-a*h,n[8]=v+m*o,n[1]=m+v*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*c,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*h,v=o*d,y=o*h;n[0]=l*d,n[4]=v*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-v,n[2]=-c,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*c,v=o*l,y=o*c;n[0]=l*d,n[4]=y-g*h,n[8]=v*h+m,n[1]=h,n[5]=a*d,n[9]=-o*d,n[2]=-c*d,n[6]=m*h+v,n[10]=g-y*h}else if(e.order==="XZY"){const g=a*l,m=a*c,v=o*l,y=o*c;n[0]=l*d,n[4]=-h,n[8]=c*d,n[1]=g*h+y,n[5]=a*d,n[9]=m*h-v,n[2]=v*h-m,n[6]=o*d,n[10]=y*h+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(a0e,e,o0e)}lookAt(e,n,r){const i=this.elements;return la.subVectors(e,n),la.lengthSq()===0&&(la.z=1),la.normalize(),gu.crossVectors(r,la),gu.lengthSq()===0&&(Math.abs(r.z)===1?la.x+=1e-4:la.z+=1e-4,la.normalize(),gu.crossVectors(r,la)),gu.normalize(),_y.crossVectors(la,gu),i[0]=gu.x,i[4]=_y.x,i[8]=la.x,i[1]=gu.y,i[5]=_y.y,i[9]=la.y,i[2]=gu.z,i[6]=_y.z,i[10]=la.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,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],d=r[1],h=r[5],g=r[9],m=r[13],v=r[2],y=r[6],b=r[10],x=r[14],M=r[3],w=r[7],A=r[11],T=r[15],R=i[0],C=i[4],I=i[8],N=i[12],D=i[1],z=i[5],j=i[9],W=i[13],P=i[2],$=i[6],K=i[10],G=i[14],Z=i[3],Q=i[7],ee=i[11],H=i[15];return s[0]=a*R+o*D+l*P+c*Z,s[4]=a*C+o*z+l*$+c*Q,s[8]=a*I+o*j+l*K+c*ee,s[12]=a*N+o*W+l*G+c*H,s[1]=d*R+h*D+g*P+m*Z,s[5]=d*C+h*z+g*$+m*Q,s[9]=d*I+h*j+g*K+m*ee,s[13]=d*N+h*W+g*G+m*H,s[2]=v*R+y*D+b*P+x*Z,s[6]=v*C+y*z+b*$+x*Q,s[10]=v*I+y*j+b*K+x*ee,s[14]=v*N+y*W+b*G+x*H,s[3]=M*R+w*D+A*P+T*Z,s[7]=M*C+w*z+A*$+T*Q,s[11]=M*I+w*j+A*K+T*ee,s[15]=M*N+w*W+A*G+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],g=e[10],m=e[14],v=e[3],y=e[7],b=e[11],x=e[15];return v*(+s*l*h-i*c*h-s*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+s*a*g-i*a*m+i*c*d-s*l*d)+b*(+n*c*h-n*o*m-s*a*h+r*a*m+s*o*d-r*c*d)+x*(-i*o*d-n*l*h+n*o*g+i*a*h-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,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],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],g=e[10],m=e[11],v=e[12],y=e[13],b=e[14],x=e[15],M=h*b*c-y*g*c+y*l*m-o*b*m-h*l*x+o*g*x,w=v*g*c-d*b*c-v*l*m+a*b*m+d*l*x-a*g*x,A=d*y*c-v*h*c+v*o*m-a*y*m-d*o*x+a*h*x,T=v*h*l-d*y*l-v*o*g+a*y*g+d*o*b-a*h*b,R=n*M+r*w+i*A+s*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/R;return e[0]=M*C,e[1]=(y*g*s-h*b*s-y*i*m+r*b*m+h*i*x-r*g*x)*C,e[2]=(o*b*s-y*l*s+y*i*c-r*b*c-o*i*x+r*l*x)*C,e[3]=(h*l*s-o*g*s-h*i*c+r*g*c+o*i*m-r*l*m)*C,e[4]=w*C,e[5]=(d*b*s-v*g*s+v*i*m-n*b*m-d*i*x+n*g*x)*C,e[6]=(v*l*s-a*b*s-v*i*c+n*b*c+a*i*x-n*l*x)*C,e[7]=(a*g*s-d*l*s+d*i*c-n*g*c-a*i*m+n*l*m)*C,e[8]=A*C,e[9]=(v*h*s-d*y*s-v*r*m+n*y*m+d*r*x-n*h*x)*C,e[10]=(a*y*s-v*o*s+v*r*c-n*y*c-a*r*x+n*o*x)*C,e[11]=(d*o*s-a*h*s-d*r*c+n*h*c+a*r*m-n*o*m)*C,e[12]=T*C,e[13]=(d*y*i-v*h*i+v*r*g-n*y*g-d*r*b+n*h*b)*C,e[14]=(v*o*i-a*y*i-v*r*l+n*y*l+a*r*b-n*o*b)*C,e[15]=(a*h*i-d*o*i+d*r*l-n*h*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,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),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+r,d*l-i*a,0,c*l-i*o,d*l+i*a,s*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,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,c=s+s,d=a+a,h=o+o,g=s*c,m=s*d,v=s*h,y=a*d,b=a*h,x=o*h,M=l*c,w=l*d,A=l*h,T=r.x,R=r.y,C=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+A)*T,i[2]=(v-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]=(v+w)*C,i[9]=(b-M)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=sp.set(i[0],i[1],i[2]).length();const a=sp.set(i[4],i[5],i[6]).length(),o=sp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],mo.copy(this);const c=1/s,d=1/a,h=1/o;return mo.elements[0]*=c,mo.elements[1]*=c,mo.elements[2]*=c,mo.elements[4]*=d,mo.elements[5]*=d,mo.elements[6]*=d,mo.elements[8]*=h,mo.elements[9]*=h,mo.elements[10]*=h,n.setFromRotationMatrix(mo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=el){const l=this.elements,c=2*s/(n-e),d=2*s/(r-i),h=(n+e)/(n-e),g=(r+i)/(r-i);let m,v;if(o===el)m=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===h0)m=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=d,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=el){const l=this.elements,c=1/(n-e),d=1/(r-i),h=1/(a-s),g=(n+e)*c,m=(r+i)*d;let v,y;if(o===el)v=(a+s)*h,y=-2*h;else if(o===h0)v=s*h,y=-1*h;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*d,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-v,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 sp=new ke,mo=new tr,a0e=new ke(0,0,0),o0e=new ke(1,1,1),gu=new ke,_y=new ke,la=new ke,bz=new tr,vz=new Ff;class Y0{constructor(e=0,n=0,r=0,i=Y0.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,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Xi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Xi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Xi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Xi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Xi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return bz.makeRotationFromQuaternion(e),this.setFromRotationMatrix(bz,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return vz.setFromEuler(this),this.setFromQuaternion(vz,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}}Y0.DEFAULT_ORDER="XYZ";class L7{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 l0e=0;const yz=new ke,ap=new Ff,Bl=new tr,Sy=new ke,ex=new ke,c0e=new ke,u0e=new Ff,_z=new ke(1,0,0),Sz=new ke(0,1,0),wz=new ke(0,0,1),d0e={type:"added"},f0e={type:"removed"};class Ms extends eh{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:l0e++}),this.uuid=hc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ms.DEFAULT_UP.clone();const e=new ke,n=new Y0,r=new Ff,i=new ke(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),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 tr},normalMatrix:{value:new fn}}),this.matrix=new tr,this.matrixWorld=new tr,this.matrixAutoUpdate=Ms.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ms.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new L7,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 ap.setFromAxisAngle(e,n),this.quaternion.multiply(ap),this}rotateOnWorldAxis(e,n){return ap.setFromAxisAngle(e,n),this.quaternion.premultiply(ap),this}rotateX(e){return this.rotateOnAxis(_z,e)}rotateY(e){return this.rotateOnAxis(Sz,e)}rotateZ(e){return this.rotateOnAxis(wz,e)}translateOnAxis(e,n){return yz.copy(e).applyQuaternion(this.quaternion),this.position.add(yz.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(_z,e)}translateY(e){return this.translateOnAxis(Sz,e)}translateZ(e){return this.translateOnAxis(wz,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Bl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Sy.copy(e):Sy.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ex.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Bl.lookAt(ex,Sy,this.up):Bl.lookAt(Sy,ex,this.up),this.quaternion.setFromRotationMatrix(Bl),i&&(Bl.extractRotation(i.matrixWorld),ap.setFromRotationMatrix(Bl),this.quaternion.premultiply(ap.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(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(d0e)):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(f0e)),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),Bl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Bl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Bl),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 a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].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(ex,e,c0e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ex,u0e,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 s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.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 s=0,a=i.length;s<a;s++){const o=i[s];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 s(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=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(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(s(e.materials,this.material[l]));i.material=o}else i.material=s(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(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),g=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),v.length>0&&(r.nodes=v)}return r.object=i,r;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Ms.DEFAULT_UP=new ke(0,1,0);Ms.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ms.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const go=new ke,Hl=new ke,qA=new ke,$l=new ke,op=new ke,lp=new ke,Mz=new ke,XA=new ke,KA=new ke,YA=new ke;let wy=!1;class xo{constructor(e=new ke,n=new ke,r=new ke){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),go.subVectors(e,n),i.cross(go);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){go.subVectors(i,n),Hl.subVectors(r,n),qA.subVectors(e,n);const a=go.dot(go),o=go.dot(Hl),l=go.dot(qA),c=Hl.dot(Hl),d=Hl.dot(qA),h=a*c-o*o;if(h===0)return s.set(-2,-1,-1);const g=1/h,m=(c*l-o*d)*g,v=(a*d-o*l)*g;return s.set(1-m-v,v,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,$l),$l.x>=0&&$l.y>=0&&$l.x+$l.y<=1}static getUV(e,n,r,i,s,a,o,l){return wy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),wy=!0),this.getInterpolation(e,n,r,i,s,a,o,l)}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,$l),l.setScalar(0),l.addScaledVector(s,$l.x),l.addScaledVector(a,$l.y),l.addScaledVector(o,$l.z),l}static isFrontFacing(e,n,r,i){return go.subVectors(r,n),Hl.subVectors(e,n),go.cross(Hl).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 go.subVectors(this.c,this.b),Hl.subVectors(this.a,this.b),go.cross(Hl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return wy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),wy=!0),xo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return xo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return xo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;op.subVectors(i,r),lp.subVectors(s,r),XA.subVectors(e,r);const l=op.dot(XA),c=lp.dot(XA);if(l<=0&&c<=0)return n.copy(r);KA.subVectors(e,i);const d=op.dot(KA),h=lp.dot(KA);if(d>=0&&h<=d)return n.copy(i);const g=l*h-d*c;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(op,a);YA.subVectors(e,s);const m=op.dot(YA),v=lp.dot(YA);if(v>=0&&m<=v)return n.copy(s);const y=m*c-l*v;if(y<=0&&c>=0&&v<=0)return o=c/(c-v),n.copy(r).addScaledVector(lp,o);const b=d*v-m*h;if(b<=0&&h-d>=0&&m-v>=0)return Mz.subVectors(s,i),o=(h-d)/(h-d+(m-v)),n.copy(i).addScaledVector(Mz,o);const x=1/(b+y+g);return a=y*x,o=g*x,n.copy(r).addScaledVector(op,a).addScaledVector(lp,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={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},xu={h:0,s:0,l:0},My={h:0,s:0,l:0};function ZA(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 $t=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=qi){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=PP(e,1),n=Xi(n,0,1),r=Xi(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=ZA(a,s,e+1/3),this.g=ZA(a,s,e),this.b=ZA(a,s,e-1/3)}return $n.toWorkingColorSpace(this,i),this}setStyle(e,n=qi){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,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=qi){const r=j7[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=Hp(e.r),this.g=Hp(e.g),this.b=Hp(e.b),this}copyLinearToSRGB(e){return this.r=FA(e.r),this.g=FA(e.g),this.b=FA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qi){return $n.fromWorkingColorSpace(rs.copy(this),e),Math.round(Xi(rs.r*255,0,255))*65536+Math.round(Xi(rs.g*255,0,255))*256+Math.round(Xi(rs.b*255,0,255))}getHexString(e=qi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$n.workingColorSpace){$n.fromWorkingColorSpace(rs.copy(this),n);const r=rs.r,i=rs.g,s=rs.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,n=$n.workingColorSpace){return $n.fromWorkingColorSpace(rs.copy(this),n),e.r=rs.r,e.g=rs.g,e.b=rs.b,e}getStyle(e=qi){$n.fromWorkingColorSpace(rs.copy(this),e);const n=rs.r,r=rs.g,i=rs.b;return e!==qi?`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(xu),this.setHSL(xu.h+e,xu.s+n,xu.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(xu),e.getHSL(My);const r=Rx(xu.h,My.h,n),i=Rx(xu.s,My.s,n),s=Rx(xu.l,My.l,n);return this.setHSL(r,i,s),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,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[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 rs=new $t;$t.NAMES=j7;let h0e=0;class Lm extends eh{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:h0e++}),this.uuid=hc(),this.name="",this.type="Material",this.blending=Bp,this.side=ed,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=B3,this.blendDst=H3,this.blendEquation=Qd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=u1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ep,this.stencilZFail=ep,this.stencilZPass=ep,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!==Bp&&(r.blending=this.blending),this.side!==ed&&(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!==B3&&(r.blendSrc=this.blendSrc),this.blendDst!==H3&&(r.blendDst=this.blendDst),this.blendEquation!==Qd&&(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!==u1&&(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!==dz&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ep&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ep&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ep&&(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(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}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 s=0;s!==i;++s)r[s]=n[s].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 I7 extends Lm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new $t(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=NP,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 $r=new ke,Ey=new Kt;class ga{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=q3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ac,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,s=this.itemSize;i<s;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++)Ey.fromBufferAttribute(this,n),Ey.applyMatrix3(e),this.setXY(n,Ey.x,Ey.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix3(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix4(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyNormalMatrix(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.transformDirection(e),this.setXYZ(n,$r.x,$r.y,$r.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=Yo(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=Yo(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=Yo(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=Yo(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=Yo(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,s){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),s=Hn(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,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!==q3&&(e.usage=this.usage),e}}class U7 extends ga{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class F7 extends ga{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Lr extends ga{constructor(e,n,r){super(new Float32Array(e),n,r)}}let p0e=0;const Ra=new tr,QA=new Ms,cp=new ke,ca=new Za,tx=new Za,Mi=new ke;class ds extends eh{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:p0e++}),this.uuid=hc(),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(R7(e)?F7:U7)(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 s=new fn().getNormalMatrix(e);r.applyNormalMatrix(s),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 Ra.makeRotationFromQuaternion(e),this.applyMatrix4(Ra),this}rotateX(e){return Ra.makeRotationX(e),this.applyMatrix4(Ra),this}rotateY(e){return Ra.makeRotationY(e),this.applyMatrix4(Ra),this}rotateZ(e){return Ra.makeRotationZ(e),this.applyMatrix4(Ra),this}translate(e,n,r){return Ra.makeTranslation(e,n,r),this.applyMatrix4(Ra),this}scale(e,n,r){return Ra.makeScale(e,n,r),this.applyMatrix4(Ra),this}lookAt(e){return QA.lookAt(e),QA.updateMatrix(),this.applyMatrix4(QA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cp).negate(),this.translate(cp.x,cp.y,cp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Lr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Za);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 ke(-1/0,-1/0,-1/0),new ke(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 s=n[r];ca.setFromBufferAttribute(s),this.morphTargetsRelative?(Mi.addVectors(this.boundingBox.min,ca.min),this.boundingBox.expandByPoint(Mi),Mi.addVectors(this.boundingBox.max,ca.max),this.boundingBox.expandByPoint(Mi)):(this.boundingBox.expandByPoint(ca.min),this.boundingBox.expandByPoint(ca.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 nl);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 ke,1/0);return}if(e){const r=this.boundingSphere.center;if(ca.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];tx.setFromBufferAttribute(o),this.morphTargetsRelative?(Mi.addVectors(ca.min,tx.min),ca.expandByPoint(Mi),Mi.addVectors(ca.max,tx.max),ca.expandByPoint(Mi)):(ca.expandByPoint(tx.min),ca.expandByPoint(tx.max))}ca.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Mi.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Mi));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)Mi.fromBufferAttribute(o,c),l&&(cp.fromBufferAttribute(e,c),Mi.add(cp)),i=Math.max(i,r.distanceToSquared(Mi))}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,s=n.normal.array,a=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ga(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],d=[];for(let D=0;D<o;D++)c[D]=new ke,d[D]=new ke;const h=new ke,g=new ke,m=new ke,v=new Kt,y=new Kt,b=new Kt,x=new ke,M=new ke;function w(D,z,j){h.fromArray(i,D*3),g.fromArray(i,z*3),m.fromArray(i,j*3),v.fromArray(a,D*2),y.fromArray(a,z*2),b.fromArray(a,j*2),g.sub(h),m.sub(h),y.sub(v),b.sub(v);const W=1/(y.x*b.y-b.x*y.y);isFinite(W)&&(x.copy(g).multiplyScalar(b.y).addScaledVector(m,-y.y).multiplyScalar(W),M.copy(m).multiplyScalar(y.x).addScaledVector(g,-b.x).multiplyScalar(W),c[D].add(x),c[z].add(x),c[j].add(x),d[D].add(M),d[z].add(M),d[j].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,z=A.length;D<z;++D){const j=A[D],W=j.start,P=j.count;for(let $=W,K=W+P;$<K;$+=3)w(r[$+0],r[$+1],r[$+2])}const T=new ke,R=new ke,C=new ke,I=new ke;function N(D){C.fromArray(s,D*3),I.copy(C);const z=c[D];T.copy(z),T.sub(C.multiplyScalar(C.dot(z))).normalize(),R.crossVectors(I,z);const W=R.dot(d[D])<0?-1:1;l[D*4]=T.x,l[D*4+1]=T.y,l[D*4+2]=T.z,l[D*4+3]=W}for(let D=0,z=A.length;D<z;++D){const j=A[D],W=j.start,P=j.count;for(let $=W,K=W+P;$<K;$+=3)N(r[$+0]),N(r[$+1]),N(r[$+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 ga(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 ke,s=new ke,a=new ke,o=new ke,l=new ke,c=new ke,d=new ke,h=new ke;if(e)for(let g=0,m=e.count;g<m;g+=3){const v=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,b),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(r,v),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,b),o.add(d),l.add(d),c.add(d),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(y,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),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Mi.fromBufferAttribute(e,n),Mi.normalize(),e.setXYZ(n,Mi.x,Mi.y,Mi.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,g=new c.constructor(l.length*d);let m=0,v=0;for(let y=0,b=l.length;y<b;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let x=0;x<d;x++)g[v++]=c[m++]}return new ga(g,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ds,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 s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const g=c[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[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 s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));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 d=i[c];this.setAttribute(c,d.clone(n))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let g=0,m=h.length;g<m;g++)d.push(h[g].clone(n));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.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 Ez=new tr,Hd=new DP,Ay=new nl,Az=new ke,up=new ke,dp=new ke,fp=new ke,JA=new ke,Ty=new ke,Cy=new Kt,Ny=new Kt,ky=new Kt,Tz=new ke,Cz=new ke,Nz=new ke,Ry=new ke,Py=new ke;class Mo extends Ms{constructor(e=new ds,n=new I7){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 s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){Ty.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(JA.fromBufferAttribute(h,e),a?Ty.addScaledVector(JA,d):Ty.addScaledVector(JA.sub(n),d))}n.add(Ty)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Ay.copy(r.boundingSphere),Ay.applyMatrix4(s),Hd.copy(e.ray).recast(e.near),!(Ay.containsPoint(Hd.origin)===!1&&(Hd.intersectSphere(Ay,Az)===null||Hd.origin.distanceToSquared(Az)>(e.far-e.near)**2))&&(Ez.copy(s).invert(),Hd.copy(e.ray).applyMatrix4(Ez),!(r.boundingBox!==null&&Hd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Hd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,y=g.length;v<y;v++){const b=g[v],x=a[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),C=o.getX(A+1),I=o.getX(A+2);i=Dy(this,x,e,r,c,d,h,R,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let b=v,x=y;b<x;b+=3){const M=o.getX(b),w=o.getX(b+1),A=o.getX(b+2);i=Dy(this,a,e,r,c,d,h,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let v=0,y=g.length;v<y;v++){const b=g[v],x=a[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,C=A+1,I=A+2;i=Dy(this,x,e,r,c,d,h,R,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let b=v,x=y;b<x;b+=3){const M=b,w=b+1,A=b+2;i=Dy(this,a,e,r,c,d,h,M,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function m0e(t,e,n,r,i,s,a,o){let l;if(e.side===Vs?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===ed,o),l===null)return null;Py.copy(o),Py.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Py);return c<n.near||c>n.far?null:{distance:c,point:Py.clone(),object:t}}function Dy(t,e,n,r,i,s,a,o,l,c){t.getVertexPosition(o,up),t.getVertexPosition(l,dp),t.getVertexPosition(c,fp);const d=m0e(t,e,n,r,up,dp,fp,Ry);if(d){i&&(Cy.fromBufferAttribute(i,o),Ny.fromBufferAttribute(i,l),ky.fromBufferAttribute(i,c),d.uv=xo.getInterpolation(Ry,up,dp,fp,Cy,Ny,ky,new Kt)),s&&(Cy.fromBufferAttribute(s,o),Ny.fromBufferAttribute(s,l),ky.fromBufferAttribute(s,c),d.uv1=xo.getInterpolation(Ry,up,dp,fp,Cy,Ny,ky,new Kt),d.uv2=d.uv1),a&&(Tz.fromBufferAttribute(a,o),Cz.fromBufferAttribute(a,l),Nz.fromBufferAttribute(a,c),d.normal=xo.getInterpolation(Ry,up,dp,fp,Tz,Cz,Nz,new ke),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new ke,materialIndex:0};xo.getNormal(up,dp,fp,h.normal),d.face=h}return d}class Z0 extends ds{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let g=0,m=0;v("z","y","x",-1,-1,r,n,e,a,s,0),v("z","y","x",1,-1,r,n,-e,a,s,1),v("x","z","y",1,1,e,r,n,i,a,2),v("x","z","y",1,-1,e,r,-n,i,a,3),v("x","y","z",1,-1,e,n,r,i,s,4),v("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Lr(c,3)),this.setAttribute("normal",new Lr(d,3)),this.setAttribute("uv",new Lr(h,2));function v(y,b,x,M,w,A,T,R,C,I,N){const D=A/C,z=T/I,j=A/2,W=T/2,P=R/2,$=C+1,K=I+1;let G=0,Z=0;const Q=new ke;for(let ee=0;ee<K;ee++){const H=ee*z-W;for(let q=0;q<$;q++){const te=q*D-j;Q[y]=te*M,Q[b]=H*w,Q[x]=P,c.push(Q.x,Q.y,Q.z),Q[y]=0,Q[b]=0,Q[x]=R>0?1:-1,d.push(Q.x,Q.y,Q.z),h.push(q/C),h.push(1-ee/I),G+=1}}for(let ee=0;ee<I;ee++)for(let H=0;H<C;H++){const q=g+H+$*ee,te=g+H+$*(ee+1),ae=g+(H+1)+$*(ee+1),xe=g+(H+1)+$*ee;l.push(q,te,xe),l.push(te,ae,xe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Z0(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cm(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 xs(t){const e={};for(let n=0;n<t.length;n++){const r=cm(t[n]);for(const i in r)e[i]=r[i]}return e}function g0e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function z7(t){return t.getRenderTarget()===null?t.outputColorSpace:$n.workingColorSpace}const OP={clone:cm,merge:xs};var x0e=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,b0e=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class td extends Lm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=x0e,this.fragmentShader=b0e,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=cm(e.uniforms),this.uniformsGroups=g0e(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 a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}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 B7 extends Ms{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tr,this.projectionMatrix=new tr,this.projectionMatrixInverse=new tr,this.coordinateSystem=el}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 da extends B7{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=p0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(kx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return p0*2*Math.atan(Math.tan(kx*.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,s,a){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=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(kx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/c,i*=a.width/l,r*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+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 hp=-90,pp=1;class v0e extends Ms{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new da(hp,pp,e,n);i.layers=this.layers,this.add(i);const s=new da(hp,pp,e,n);s.layers=this.layers,this.add(s);const a=new da(hp,pp,e,n);a.layers=this.layers,this.add(a);const o=new da(hp,pp,e,n);o.layers=this.layers,this.add(o);const l=new da(hp,pp,e,n);l.layers=this.layers,this.add(l);const c=new da(hp,pp,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const c of n)this.remove(c);if(e===el)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.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===h0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.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[s,a,o,l,c,d]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,g,m),e.xr.enabled=v,r.texture.needsPMREMUpdate=!0}}class H7 extends Gs{constructor(e,n,r,i,s,a,o,l,c,d){e=e!==void 0?e:[],n=n!==void 0?n:am,super(e,n,r,i,s,a,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class y0e extends Uf{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&&(Px("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===mf?qi:Ga),this.texture=new H7(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:$a}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 Z0(5,5,5),s=new td({name:"CubemapFromEquirect",uniforms:cm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Vs,blending:$u});s.uniforms.tEquirect.value=n;const a=new Mo(i,s),o=n.minFilter;return n.minFilter===d0&&(n.minFilter=$a),new v0e(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}}const eT=new ke,_0e=new ke,S0e=new fn;class wu{constructor(e=new ke(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=eT.subVectors(r,n).cross(_0e.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(eT),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}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||S0e.getNormalMatrix(e),i=this.coplanarPoint(eT).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 $d=new nl,Oy=new ke;class yw{constructor(e=new wu,n=new wu,r=new wu,i=new wu,s=new wu,a=new wu){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),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=el){const r=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],d=i[5],h=i[6],g=i[7],m=i[8],v=i[9],y=i[10],b=i[11],x=i[12],M=i[13],w=i[14],A=i[15];if(r[0].setComponents(l-s,g-c,b-m,A-x).normalize(),r[1].setComponents(l+s,g+c,b+m,A+x).normalize(),r[2].setComponents(l+a,g+d,b+v,A+M).normalize(),r[3].setComponents(l-a,g-d,b-v,A-M).normalize(),r[4].setComponents(l-o,g-h,b-y,A-w).normalize(),n===el)r[5].setComponents(l+o,g+h,b+y,A+w).normalize();else if(n===h0)r[5].setComponents(o,h,y,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(),$d.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),$d.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($d)}intersectsSprite(e){return $d.center.set(0,0,0),$d.radius=.7071067811865476,$d.applyMatrix4(e.matrixWorld),this.intersectsSphere($d)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].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(Oy.x=i.normal.x>0?e.max.x:e.min.x,Oy.y=i.normal.y>0?e.max.y:e.min.y,Oy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Oy)<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 $7(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),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(s){n=s},setContext:function(s){t=s}}}function w0e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(c,d){const h=c.array,g=c.usage,m=h.byteLength,v=t.createBuffer();t.bindBuffer(d,v),t.bufferData(d,h,g),c.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:v,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version,size:m}}function s(c,d,h){const g=d.array,m=d._updateRange,v=d.updateRanges;if(t.bindBuffer(h,c),m.count===-1&&v.length===0&&t.bufferSubData(h,0,g),v.length!==0){for(let y=0,b=v.length;y<b;y++){const x=v[y];n?t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g,x.start,x.count):t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g.subarray(x.start,x.start+x.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function a(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const d=r.get(c);d&&(t.deleteBuffer(d.buffer),r.delete(c))}function l(c,d){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 h=r.get(c);if(h===void 0)r.set(c,i(c,d));else if(h.version<c.version){if(h.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.");s(h.buffer,c,d),h.version=c.version}}return{get:a,remove:o,update:l}}class LP extends ds{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,d=l+1,h=e/o,g=n/l,m=[],v=[],y=[],b=[];for(let x=0;x<d;x++){const M=x*g-a;for(let w=0;w<c;w++){const A=w*h-s;v.push(A,-M,0),y.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 Lr(v,3)),this.setAttribute("normal",new Lr(y,3)),this.setAttribute("uv",new Lr(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new LP(e.width,e.height,e.widthSegments,e.heightSegments)}}var M0e=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,E0e=`#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`,A0e=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,T0e=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,C0e=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,N0e=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,k0e=`#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`,R0e=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,P0e=`#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`,D0e=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,O0e=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,L0e=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,j0e=`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`,I0e=`#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`,U0e=`#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`,F0e=`#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`,z0e=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,B0e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,H0e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,$0e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,V0e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,G0e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,W0e=`#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`,q0e=`#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`,X0e=`#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`,K0e=`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`,Y0e=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,Z0e=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,Q0e=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,J0e=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,ebe="gl_FragColor = linearToOutputTexel( gl_FragColor );",tbe=`
  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. }`,nbe=`#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`,rbe=`#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`,ibe=`#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`,sbe=`#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`,abe=`#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`,obe=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,lbe=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,cbe=`#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`,ube=`#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`,dbe=`#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. }`,fbe=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,hbe=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,pbe=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,mbe=`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`,gbe=`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`,xbe=`#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`,bbe=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,vbe=`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`,ybe=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,_be=`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`,Sbe=`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`,wbe=`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. }`,Mbe=`
  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`,Ebe=`#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`,Abe=`#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`,Tbe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,Cbe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,Nbe=`#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`,kbe=`#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`,Rbe=`#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`,Pbe=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,Dbe=`#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`,Obe=`#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`,Lbe=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,jbe=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,Ibe=`#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`,Ube=`#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`,Fbe=`#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`,zbe=`#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`,Bbe=`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;`,Hbe=`#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`,$be=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,Vbe=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,Gbe=`#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`,Wbe=`#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`,qbe=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,Xbe=`#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`,Kbe=`#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`,Ybe=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,Zbe=`#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 );`,Qbe=`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. }`,Jbe=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,eve=`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;`,tve=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,nve=`#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`,rve=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,ive=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,sve=`#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`,ave=`#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`,ove=`#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`,lve=`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. }`,cve=`#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`,uve=`#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`,dve=`#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`,fve=`#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`,hve=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,pve=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,mve=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,gve=`#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; }`,xve=`#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`,bve=`#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`,vve=`#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`,yve=`#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`,_ve=`#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`,Sve=`#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 wve=`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. }`,Mve=`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. }`,Eve=`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. }`,Ave=`#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. }`,Tve=`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. }`,Cve=`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. }`,Nve=`#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. }`,kve=`#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. }`,Rve=`#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. }`,Pve=`#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. }`,Dve=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,Ove=`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. }`,Lve=`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. }`,jve=`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. }`,Ive=`#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. }`,Uve=`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. }`,Fve=`#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. }`,zve=`#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. }`,Bve=`#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. }`,Hve=`#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. }`,$ve=`#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. }`,Vve=`#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. }`,Gve=`#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. }`,Wve=`#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. }`,qve=`#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. }`,Xve=`#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. }`,Kve=`#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. }`,Yve=`#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. }`,Zve=`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. }`,Qve=`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. }`,Jve=`#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. }`,eye=`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. }`,tye=`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. }`,nye=`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. }`,an={alphahash_fragment:M0e,alphahash_pars_fragment:E0e,alphamap_fragment:A0e,alphamap_pars_fragment:T0e,alphatest_fragment:C0e,alphatest_pars_fragment:N0e,aomap_fragment:k0e,aomap_pars_fragment:R0e,batching_pars_vertex:P0e,batching_vertex:D0e,begin_vertex:O0e,beginnormal_vertex:L0e,bsdfs:j0e,iridescence_fragment:I0e,bumpmap_pars_fragment:U0e,clipping_planes_fragment:F0e,clipping_planes_pars_fragment:z0e,clipping_planes_pars_vertex:B0e,clipping_planes_vertex:H0e,color_fragment:$0e,color_pars_fragment:V0e,color_pars_vertex:G0e,color_vertex:W0e,common:q0e,cube_uv_reflection_fragment:X0e,defaultnormal_vertex:K0e,displacementmap_pars_vertex:Y0e,displacementmap_vertex:Z0e,emissivemap_fragment:Q0e,emissivemap_pars_fragment:J0e,colorspace_fragment:ebe,colorspace_pars_fragment:tbe,envmap_fragment:nbe,envmap_common_pars_fragment:rbe,envmap_pars_fragment:ibe,envmap_pars_vertex:sbe,envmap_physical_pars_fragment:xbe,envmap_vertex:abe,fog_vertex:obe,fog_pars_vertex:lbe,fog_fragment:cbe,fog_pars_fragment:ube,gradientmap_pars_fragment:dbe,lightmap_fragment:fbe,lightmap_pars_fragment:hbe,lights_lambert_fragment:pbe,lights_lambert_pars_fragment:mbe,lights_pars_begin:gbe,lights_toon_fragment:bbe,lights_toon_pars_fragment:vbe,lights_phong_fragment:ybe,lights_phong_pars_fragment:_be,lights_physical_fragment:Sbe,lights_physical_pars_fragment:wbe,lights_fragment_begin:Mbe,lights_fragment_maps:Ebe,lights_fragment_end:Abe,logdepthbuf_fragment:Tbe,logdepthbuf_pars_fragment:Cbe,logdepthbuf_pars_vertex:Nbe,logdepthbuf_vertex:kbe,map_fragment:Rbe,map_pars_fragment:Pbe,map_particle_fragment:Dbe,map_particle_pars_fragment:Obe,metalnessmap_fragment:Lbe,metalnessmap_pars_fragment:jbe,morphcolor_vertex:Ibe,morphnormal_vertex:Ube,morphtarget_pars_vertex:Fbe,morphtarget_vertex:zbe,normal_fragment_begin:Bbe,normal_fragment_maps:Hbe,normal_pars_fragment:$be,normal_pars_vertex:Vbe,normal_vertex:Gbe,normalmap_pars_fragment:Wbe,clearcoat_normal_fragment_begin:qbe,clearcoat_normal_fragment_maps:Xbe,clearcoat_pars_fragment:Kbe,iridescence_pars_fragment:Ybe,opaque_fragment:Zbe,packing:Qbe,premultiplied_alpha_fragment:Jbe,project_vertex:eve,dithering_fragment:tve,dithering_pars_fragment:nve,roughnessmap_fragment:rve,roughnessmap_pars_fragment:ive,shadowmap_pars_fragment:sve,shadowmap_pars_vertex:ave,shadowmap_vertex:ove,shadowmask_pars_fragment:lve,skinbase_vertex:cve,skinning_pars_vertex:uve,skinning_vertex:dve,skinnormal_vertex:fve,specularmap_fragment:hve,specularmap_pars_fragment:pve,tonemapping_fragment:mve,tonemapping_pars_fragment:gve,transmission_fragment:xve,transmission_pars_fragment:bve,uv_pars_fragment:vve,uv_pars_vertex:yve,uv_vertex:_ve,worldpos_vertex:Sve,background_vert:wve,background_frag:Mve,backgroundCube_vert:Eve,backgroundCube_frag:Ave,cube_vert:Tve,cube_frag:Cve,depth_vert:Nve,depth_frag:kve,distanceRGBA_vert:Rve,distanceRGBA_frag:Pve,equirect_vert:Dve,equirect_frag:Ove,linedashed_vert:Lve,linedashed_frag:jve,meshbasic_vert:Ive,meshbasic_frag:Uve,meshlambert_vert:Fve,meshlambert_frag:zve,meshmatcap_vert:Bve,meshmatcap_frag:Hve,meshnormal_vert:$ve,meshnormal_frag:Vve,meshphong_vert:Gve,meshphong_frag:Wve,meshphysical_vert:qve,meshphysical_frag:Xve,meshtoon_vert:Kve,meshtoon_frag:Yve,points_vert:Zve,points_frag:Qve,shadow_vert:Jve,shadow_frag:eye,sprite_vert:tye,sprite_frag:nye},vt={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},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 fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Kt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(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 $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},zs={basic:{uniforms:xs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:xs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:xs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:xs([vt.common,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.roughnessmap,vt.metalnessmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:xs([vt.common,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.gradientmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:xs([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:xs([vt.points,vt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:xs([vt.common,vt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:xs([vt.common,vt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:xs([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:xs([vt.sprite,vt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:xs([vt.common,vt.displacementmap,{referencePosition:{value:new ke},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:xs([vt.lights,vt.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};zs.physical={uniforms:xs([zs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new Kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const Ly={r:0,b:0,g:0};function rye(t,e,n,r,i,s,a){const o=new $t(0);let l=s===!0?0:1,c,d,h=null,g=0,m=null;function v(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?y(o,l):w&&w.isColor&&(y(w,1),M=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,a):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===bw)?(d===void 0&&(d=new Mo(new Z0(1,1,1),new td({name:"BackgroundCubeMaterial",uniforms:cm(zs.backgroundCube.uniforms),vertexShader:zs.backgroundCube.vertexShader,fragmentShader:zs.backgroundCube.fragmentShader,side:Vs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,R,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,d.material.toneMapped=$n.getTransfer(w.colorSpace)!==sr,(h!==w||g!==w.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new Mo(new LP(2,2),new td({name:"BackgroundMaterial",uniforms:cm(zs.background.uniforms),vertexShader:zs.background.vertexShader,fragmentShader:zs.background.fragmentShader,side:ed,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)!==sr,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||g!==w.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function y(b,x){b.getRGB(Ly,z7(t)),r.buffers.color.setClear(Ly.r,Ly.g,Ly.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(b,x=1){o.set(b),l=x,y(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,y(o,l)},render:v}}function iye(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||s!==null,o={},l=b(null);let c=l,d=!1;function h(P,$,K,G,Z){let Q=!1;if(a){const ee=y(G,K,$);c!==ee&&(c=ee,m(c.object)),Q=x(P,G,K,Z),Q&&M(P,G,K,Z)}else{const ee=$.wireframe===!0;(c.geometry!==G.id||c.program!==K.id||c.wireframe!==ee)&&(c.geometry=G.id,c.program=K.id,c.wireframe=ee,Q=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(Q||d)&&(d=!1,I(P,$,K,G),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function g(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(P){return r.isWebGL2?t.bindVertexArray(P):s.bindVertexArrayOES(P)}function v(P){return r.isWebGL2?t.deleteVertexArray(P):s.deleteVertexArrayOES(P)}function y(P,$,K){const G=K.wireframe===!0;let Z=o[P.id];Z===void 0&&(Z={},o[P.id]=Z);let Q=Z[$.id];Q===void 0&&(Q={},Z[$.id]=Q);let ee=Q[G];return ee===void 0&&(ee=b(g()),Q[G]=ee),ee}function b(P){const $=[],K=[],G=[];for(let Z=0;Z<i;Z++)$[Z]=0,K[Z]=0,G[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:K,attributeDivisors:G,object:P,attributes:{},index:null}}function x(P,$,K,G){const Z=c.attributes,Q=$.attributes;let ee=0;const H=K.getAttributes();for(const q in H)if(H[q].location>=0){const ae=Z[q];let xe=Q[q];if(xe===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(xe=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(xe=P.instanceColor)),ae===void 0||ae.attribute!==xe||xe&&ae.data!==xe.data)return!0;ee++}return c.attributesNum!==ee||c.index!==G}function M(P,$,K,G){const Z={},Q=$.attributes;let ee=0;const H=K.getAttributes();for(const q in H)if(H[q].location>=0){let ae=Q[q];ae===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(ae=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(ae=P.instanceColor));const xe={};xe.attribute=ae,ae&&ae.data&&(xe.data=ae.data),Z[q]=xe,ee++}c.attributes=Z,c.attributesNum=ee,c.index=G}function w(){const P=c.newAttributes;for(let $=0,K=P.length;$<K;$++)P[$]=0}function A(P){T(P,0)}function T(P,$){const K=c.newAttributes,G=c.enabledAttributes,Z=c.attributeDivisors;K[P]=1,G[P]===0&&(t.enableVertexAttribArray(P),G[P]=1),Z[P]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,$),Z[P]=$)}function R(){const P=c.newAttributes,$=c.enabledAttributes;for(let K=0,G=$.length;K<G;K++)$[K]!==P[K]&&(t.disableVertexAttribArray(K),$[K]=0)}function C(P,$,K,G,Z,Q,ee){ee===!0?t.vertexAttribIPointer(P,$,K,Z,Q):t.vertexAttribPointer(P,$,K,G,Z,Q)}function I(P,$,K,G){if(r.isWebGL2===!1&&(P.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const Z=G.attributes,Q=K.getAttributes(),ee=$.defaultAttributeValues;for(const H in Q){const q=Q[H];if(q.location>=0){let te=Z[H];if(te===void 0&&(H==="instanceMatrix"&&P.instanceMatrix&&(te=P.instanceMatrix),H==="instanceColor"&&P.instanceColor&&(te=P.instanceColor)),te!==void 0){const ae=te.normalized,xe=te.itemSize,re=n.get(te);if(re===void 0)continue;const pe=re.buffer,Ce=re.type,fe=re.bytesPerElement,Se=r.isWebGL2===!0&&(Ce===t.INT||Ce===t.UNSIGNED_INT||te.gpuType===y7);if(te.isInterleavedBufferAttribute){const Re=te.data,ue=Re.stride,ct=te.offset;if(Re.isInstancedInterleavedBuffer){for(let B=0;B<q.locationSize;B++)T(q.location+B,Re.meshPerAttribute);P.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let B=0;B<q.locationSize;B++)A(q.location+B);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let B=0;B<q.locationSize;B++)C(q.location+B,xe/q.locationSize,Ce,ae,ue*fe,(ct+xe/q.locationSize*B)*fe,Se)}else{if(te.isInstancedBufferAttribute){for(let Re=0;Re<q.locationSize;Re++)T(q.location+Re,te.meshPerAttribute);P.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let Re=0;Re<q.locationSize;Re++)A(q.location+Re);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let Re=0;Re<q.locationSize;Re++)C(q.location+Re,xe/q.locationSize,Ce,ae,xe*fe,xe/q.locationSize*Re*fe,Se)}}else if(ee!==void 0){const ae=ee[H];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(q.location,ae);break;case 3:t.vertexAttrib3fv(q.location,ae);break;case 4:t.vertexAttrib4fv(q.location,ae);break;default:t.vertexAttrib1fv(q.location,ae)}}}}R()}function N(){j();for(const P in o){const $=o[P];for(const K in $){const G=$[K];for(const Z in G)v(G[Z].object),delete G[Z];delete $[K]}delete o[P]}}function D(P){if(o[P.id]===void 0)return;const $=o[P.id];for(const K in $){const G=$[K];for(const Z in G)v(G[Z].object),delete G[Z];delete $[K]}delete o[P.id]}function z(P){for(const $ in o){const K=o[$];if(K[P.id]===void 0)continue;const G=K[P.id];for(const Z in G)v(G[Z].object),delete G[Z];delete K[P.id]}}function j(){W(),d=!0,c!==l&&(c=l,m(c.object))}function W(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:j,resetDefaultState:W,dispose:N,releaseStatesOfGeometry:D,releaseStatesOfProgram:z,initAttributes:w,enableAttribute:A,disableUnusedAttributes:R}}function sye(t,e,n,r){const i=r.isWebGL2;let s;function a(d){s=d}function o(d,h){t.drawArrays(s,d,h),n.update(h,s,1)}function l(d,h,g){if(g===0)return;let m,v;if(i)m=t,v="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),v="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[v](s,d,h,g),n.update(h,s,g)}function c(d,h,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let v=0;v<g;v++)this.render(d[v],h[v]);else{m.multiDrawArraysWEBGL(s,d,0,h,0,g);let v=0;for(let y=0;y<g;y++)v+=h[y];n.update(v,s,1)}}this.setMode=a,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function aye(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=a||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=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=a||e.has("OES_texture_float"),T=w&&A,R=a?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:v,maxAttributes:y,maxVertexUniforms:b,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:R}}function oye(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new wu,o=new fn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,g){n=d(h,g,0)},this.setState=function(h,g,m){const v=h.clippingPlanes,y=h.clipIntersection,b=h.clipShadows,x=t.get(h);if(!i||v===null||v.length===0||s&&!b)s?d(null):c();else{const M=s?0:r,w=M*4;let A=x.clippingState||null;l.value=A,A=d(v,g,w,m);for(let T=0;T!==w;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=y?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 d(h,g,m,v){const y=h!==null?h.length:0;let b=null;if(y!==0){if(b=l.value,v!==!0||b===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(b===null||b.length<x)&&(b=new Float32Array(x));for(let w=0,A=m;w!==y;++w,A+=4)a.copy(h[w]).applyMatrix4(M,o),a.normal.toArray(b,A),b[A+3]=a.constant}l.value=b,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function lye(t){let e=new WeakMap;function n(a,o){return o===$3?a.mapping=am:o===V3&&(a.mapping=om),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===$3||o===V3)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new y0e(l.height/2);return c.fromEquirectangularTexture(t,a),e.set(a,c),a.addEventListener("dispose",i),n(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class cye extends B7{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=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=s,this.far=a,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,s,a){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=s,this.view.height=a,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 s=r-e,a=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,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,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 Rp=4,kz=[.125,.215,.35,.446,.526,.582],Jd=20,tT=new cye,Rz=new $t;let nT=null,rT=0,iT=0;const Wd=(1+Math.sqrt(5))/2,mp=1/Wd,Pz=[new ke(1,1,1),new ke(-1,1,1),new ke(1,1,-1),new ke(-1,1,-1),new ke(0,Wd,mp),new ke(0,Wd,-mp),new ke(mp,0,Wd),new ke(-mp,0,Wd),new ke(Wd,mp,0),new ke(-Wd,mp,0)];class Dz{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){nT=this._renderer.getRenderTarget(),rT=this._renderer.getActiveCubeFace(),iT=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=jz(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Lz(),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(nT,rT,iT),e.scissorTest=!1,jy(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===am||e.mapping===om?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nT=this._renderer.getRenderTarget(),rT=this._renderer.getActiveCubeFace(),iT=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:$a,minFilter:$a,generateMipmaps:!1,type:f0,format:Va,colorSpace:_c,depthBuffer:!1},i=Oz(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Oz(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=uye(s)),this._blurMaterial=dye(s,e,n)}return i}_compileMaterial(e){const n=new Mo(this._lodPlanes[0],e);this._renderer.compile(n,tT)}_sceneToCubeUV(e,n,r,i){const o=new da(90,1,n,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,g=d.toneMapping;d.getClearColor(Rz),d.toneMapping=Vu,d.autoClear=!1;const m=new I7({name:"PMREM.Background",side:Vs,depthWrite:!1,depthTest:!1}),v=new Mo(new Z0,m);let y=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,y=!0):(m.color.copy(Rz),y=!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;jy(i,M*w,x>2?w:0,w,w),d.setRenderTarget(i),y&&d.render(v,o),d.render(e,o)}v.geometry.dispose(),v.material.dispose(),d.toneMapping=g,d.autoClear=h,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===am||e.mapping===om;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=jz()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Lz());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new Mo(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;jy(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,tT)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=Pz[(i-1)%Pz.length];this._blur(e,i-1,i,s,a)}n.autoClear=r}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=new Mo(this._lodPlanes[i],c),g=c.uniforms,m=this._sizeLods[r]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Jd-1),y=s/v,b=isFinite(s)?1+Math.floor(d*y):Jd;b>Jd&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Jd}`);const x=[];let M=0;for(let C=0;C<Jd;++C){const I=C/y,N=Math.exp(-I*I/2);x.push(N),C===0?M+=N:C<b&&(M+=2*N)}for(let C=0;C<x.length;C++)x[C]=x[C]/M;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=x,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=v,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Rp?i-w+Rp:0),R=4*(this._cubeSize-A);jy(n,T,R,3*A,2*A),l.setRenderTarget(n),l.render(h,tT)}}function uye(t){const e=[],n=[],r=[];let i=t;const s=t-Rp+1+kz.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);n.push(o);let l=1/o;a>t-Rp?l=kz[a-t+Rp-1]:a===0&&(l=0),r.push(l);const c=1/(o-2),d=-c,h=1+c,g=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,v=6,y=3,b=2,x=1,M=new Float32Array(y*v*m),w=new Float32Array(b*v*m),A=new Float32Array(x*v*m);for(let R=0;R<m;R++){const C=R%3*2/3-1,I=R>2?0:-1,N=[C,I,0,C+2/3,I,0,C+2/3,I+1,0,C,I,0,C+2/3,I+1,0,C,I+1,0];M.set(N,y*v*R),w.set(g,b*v*R);const D=[R,R,R,R,R,R];A.set(D,x*v*R)}const T=new ds;T.setAttribute("position",new ga(M,y)),T.setAttribute("uv",new ga(w,b)),T.setAttribute("faceIndex",new ga(A,x)),e.push(T),i>Rp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function Oz(t,e,n){const r=new Uf(t,e,n);return r.texture.mapping=bw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function jy(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function dye(t,e,n){const r=new Float32Array(Jd),i=new ke(0,1,0);return new td({name:"SphericalGaussianBlur",defines:{n:Jd,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:jP(),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:$u,depthTest:!1,depthWrite:!1})}function Lz(){return new td({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:jP(),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:$u,depthTest:!1,depthWrite:!1})}function jz(){return new td({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jP(),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:$u,depthTest:!1,depthWrite:!1})}function jP(){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 fye(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===$3||l===V3,d=l===am||l===om;if(c||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let h=e.get(o);return n===null&&(n=new Dz(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),e.set(o,h),h.texture}else{if(e.has(o))return e.get(o).texture;{const h=o.image;if(c&&h&&h.height>0||d&&h&&i(h)){n===null&&(n=new Dz(t));const g=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",s),g.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let d=0;d<c;d++)o[d]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function hye(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 pye(t,e,n,r){const i={},s=new WeakMap;function a(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const v in g.attributes)e.remove(g.attributes[v]);for(const v in g.morphAttributes){const y=g.morphAttributes[v];for(let b=0,x=y.length;b<x;b++)e.remove(y[b])}g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const v in g)e.update(g[v],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const v in m){const y=m[v];for(let b=0,x=y.length;b<x;b++)e.update(y[b],t.ARRAY_BUFFER)}}function c(h){const g=[],m=h.index,v=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,A=M.length;w<A;w+=3){const T=M[w+0],R=M[w+1],C=M[w+2];g.push(T,R,R,C,C,T)}}else if(v!==void 0){const M=v.array;y=v.version;for(let w=0,A=M.length/3-1;w<A;w+=3){const T=w+0,R=w+1,C=w+2;g.push(T,R,R,C,C,T)}}else return;const b=new(R7(g)?F7:U7)(g,1);b.version=y;const x=s.get(h);x&&e.remove(x),s.set(h,b)}function d(h){const g=s.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:d}}function mye(t,e,n,r){const i=r.isWebGL2;let s;function a(m){s=m}let o,l;function c(m){o=m.type,l=m.bytesPerElement}function d(m,v){t.drawElements(s,v,o,m*l),n.update(v,s,1)}function h(m,v,y){if(y===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](s,v,o,m*l,y),n.update(v,s,y)}function g(m,v,y){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let x=0;x<y;x++)this.render(m[x]/l,v[x]);else{b.multiDrawElementsWEBGL(s,v,0,o,m,0,y);let x=0;for(let M=0;M<y;M++)x+=v[M];n.update(x,s,1)}}this.setMode=a,this.setIndex=c,this.render=d,this.renderInstances=h,this.renderMultiDraw=g}function gye(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);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 xye(t,e){return t[0]-e[0]}function bye(t,e){return Math.abs(e[1])-Math.abs(t[1])}function vye(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Gn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,d,h){const g=c.morphTargetInfluences;if(e.isWebGL2===!0){const v=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=v!==void 0?v.length:0;let b=s.get(d);if(b===void 0||b.count!==y){let $=function(){W.dispose(),s.delete(d),d.removeEventListener("dispose",$)};var m=$;b!==void 0&&b.texture.dispose();const w=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,R=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let N=0;w===!0&&(N=1),A===!0&&(N=2),T===!0&&(N=3);let D=d.attributes.position.count*N,z=1;D>e.maxTextureSize&&(z=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const j=new Float32Array(D*z*4*y),W=new O7(j,D,z,y);W.type=ac,W.needsUpdate=!0;const P=N*4;for(let K=0;K<y;K++){const G=R[K],Z=C[K],Q=I[K],ee=D*z*4*K;for(let H=0;H<G.count;H++){const q=H*P;w===!0&&(a.fromBufferAttribute(G,H),j[ee+q+0]=a.x,j[ee+q+1]=a.y,j[ee+q+2]=a.z,j[ee+q+3]=0),A===!0&&(a.fromBufferAttribute(Z,H),j[ee+q+4]=a.x,j[ee+q+5]=a.y,j[ee+q+6]=a.z,j[ee+q+7]=0),T===!0&&(a.fromBufferAttribute(Q,H),j[ee+q+8]=a.x,j[ee+q+9]=a.y,j[ee+q+10]=a.z,j[ee+q+11]=Q.itemSize===4?a.w:1)}}b={count:y,texture:W,size:new Kt(D,z)},s.set(d,b),d.addEventListener("dispose",$)}let x=0;for(let w=0;w<g.length;w++)x+=g[w];const M=d.morphTargetsRelative?1:1-x;h.getUniforms().setValue(t,"morphTargetBaseInfluence",M),h.getUniforms().setValue(t,"morphTargetInfluences",g),h.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const v=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==v){y=[];for(let A=0;A<v;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<v;A++){const T=y[A];T[0]=A,T[1]=g[A]}y.sort(bye);for(let A=0;A<8;A++)A<v&&y[A][1]?(o[A][0]=y[A][0],o[A][1]=y[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(xye);const b=d.morphAttributes.position,x=d.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const T=o[A],R=T[0],C=T[1];R!==Number.MAX_SAFE_INTEGER&&C?(b&&d.getAttribute("morphTarget"+A)!==b[R]&&d.setAttribute("morphTarget"+A,b[R]),x&&d.getAttribute("morphNormal"+A)!==x[R]&&d.setAttribute("morphNormal"+A,x[R]),i[A]=C,M+=C):(b&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),x&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const w=d.morphTargetsRelative?1:1-M;h.getUniforms().setValue(t,"morphTargetBaseInfluence",w),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function yye(t,e,n,r){let i=new WeakMap;function s(l){const c=r.render.frame,d=l.geometry,h=e.get(l,d);if(i.get(h)!==c&&(e.update(h),i.set(h,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 h}function a(){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:s,dispose:a}}class V7 extends Gs{constructor(e,n,r,i,s,a,o,l,c,d){if(d=d!==void 0?d:pf,d!==pf&&d!==lm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===pf&&(r=ju),r===void 0&&d===lm&&(r=hf),super(null,i,s,a,o,l,d,r,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Wi,this.minFilter=l!==void 0?l:Wi,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 G7=new Gs,W7=new V7(1,1);W7.compareFunction=N7;const q7=new O7,X7=new i0e,K7=new H7,Iz=[],Uz=[],Fz=new Float32Array(16),zz=new Float32Array(9),Bz=new Float32Array(4);function jm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=Iz[i];if(s===void 0&&(s=new Float32Array(i),Iz[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function di(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 fi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function _w(t,e){let n=Uz[e];n===void 0&&(n=new Int32Array(e),Uz[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function _ye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Sye(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(di(n,e))return;t.uniform2fv(this.addr,e),fi(n,e)}}function wye(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(di(n,e))return;t.uniform3fv(this.addr,e),fi(n,e)}}function Mye(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(di(n,e))return;t.uniform4fv(this.addr,e),fi(n,e)}}function Eye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(di(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),fi(n,e)}else{if(di(n,r))return;Bz.set(r),t.uniformMatrix2fv(this.addr,!1,Bz),fi(n,r)}}function Aye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(di(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),fi(n,e)}else{if(di(n,r))return;zz.set(r),t.uniformMatrix3fv(this.addr,!1,zz),fi(n,r)}}function Tye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(di(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),fi(n,e)}else{if(di(n,r))return;Fz.set(r),t.uniformMatrix4fv(this.addr,!1,Fz),fi(n,r)}}function Cye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Nye(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(di(n,e))return;t.uniform2iv(this.addr,e),fi(n,e)}}function kye(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(di(n,e))return;t.uniform3iv(this.addr,e),fi(n,e)}}function Rye(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(di(n,e))return;t.uniform4iv(this.addr,e),fi(n,e)}}function Pye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Dye(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(di(n,e))return;t.uniform2uiv(this.addr,e),fi(n,e)}}function Oye(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(di(n,e))return;t.uniform3uiv(this.addr,e),fi(n,e)}}function Lye(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(di(n,e))return;t.uniform4uiv(this.addr,e),fi(n,e)}}function jye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?W7:G7;n.setTexture2D(e||s,i)}function Iye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||X7,i)}function Uye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||K7,i)}function Fye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||q7,i)}function zye(t){switch(t){case 5126:return _ye;case 35664:return Sye;case 35665:return wye;case 35666:return Mye;case 35674:return Eye;case 35675:return Aye;case 35676:return Tye;case 5124:case 35670:return Cye;case 35667:case 35671:return Nye;case 35668:case 35672:return kye;case 35669:case 35673:return Rye;case 5125:return Pye;case 36294:return Dye;case 36295:return Oye;case 36296:return Lye;case 35678:case 36198:case 36298:case 36306:case 35682:return jye;case 35679:case 36299:case 36307:return Iye;case 35680:case 36300:case 36308:case 36293:return Uye;case 36289:case 36303:case 36311:case 36292:return Fye}}function Bye(t,e){t.uniform1fv(this.addr,e)}function Hye(t,e){const n=jm(e,this.size,2);t.uniform2fv(this.addr,n)}function $ye(t,e){const n=jm(e,this.size,3);t.uniform3fv(this.addr,n)}function Vye(t,e){const n=jm(e,this.size,4);t.uniform4fv(this.addr,n)}function Gye(t,e){const n=jm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Wye(t,e){const n=jm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function qye(t,e){const n=jm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Xye(t,e){t.uniform1iv(this.addr,e)}function Kye(t,e){t.uniform2iv(this.addr,e)}function Yye(t,e){t.uniform3iv(this.addr,e)}function Zye(t,e){t.uniform4iv(this.addr,e)}function Qye(t,e){t.uniform1uiv(this.addr,e)}function Jye(t,e){t.uniform2uiv(this.addr,e)}function e_e(t,e){t.uniform3uiv(this.addr,e)}function t_e(t,e){t.uniform4uiv(this.addr,e)}function n_e(t,e,n){const r=this.cache,i=e.length,s=_w(n,i);di(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||G7,s[a])}function r_e(t,e,n){const r=this.cache,i=e.length,s=_w(n,i);di(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||X7,s[a])}function i_e(t,e,n){const r=this.cache,i=e.length,s=_w(n,i);di(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||K7,s[a])}function s_e(t,e,n){const r=this.cache,i=e.length,s=_w(n,i);di(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||q7,s[a])}function a_e(t){switch(t){case 5126:return Bye;case 35664:return Hye;case 35665:return $ye;case 35666:return Vye;case 35674:return Gye;case 35675:return Wye;case 35676:return qye;case 5124:case 35670:return Xye;case 35667:case 35671:return Kye;case 35668:case 35672:return Yye;case 35669:case 35673:return Zye;case 5125:return Qye;case 36294:return Jye;case 36295:return e_e;case 36296:return t_e;case 35678:case 36198:case 36298:case 36306:case 35682:return n_e;case 35679:case 36299:case 36307:return r_e;case 35680:case 36300:case 36308:case 36293:return i_e;case 36289:case 36303:case 36311:case 36292:return s_e}}class o_e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=zye(n.type)}}class l_e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=a_e(n.type)}}class c_e{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}}const sT=/(\w+)(\])?(\[|\.)?/g;function Hz(t,e){t.seq.push(e),t.map[e.id]=e}function u_e(t,e,n){const r=t.name,i=r.length;for(sT.lastIndex=0;;){const s=sT.exec(r),a=sT.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){Hz(n,c===void 0?new o_e(o,t,e):new l_e(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new c_e(o),Hz(n,h)),n=h}}}class L_{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);u_e(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.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 s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}}function $z(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const d_e=37297;let f_e=0;function h_e(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
  7343. `)}function p_e(t){const e=$n.getPrimaries($n.workingColorSpace),n=$n.getPrimaries(t);let r;switch(e===n?r="":e===h1&&n===f1?r="LinearDisplayP3ToLinearSRGB":e===f1&&n===h1&&(r="LinearSRGBToLinearDisplayP3"),t){case _c:case vw:return[r,"LinearTransferOETF"];case qi:case RP:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function Vz(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return n.toUpperCase()+`
  7344. `+i+`
  7345. `+h_e(t.getShaderSource(e),a)}else return i}function m_e(t,e){const n=p_e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function g_e(t,e){let n;switch(e){case mxe:n="Linear";break;case gxe:n="Reinhard";break;case xxe:n="OptimizedCineon";break;case bxe:n="ACESFilmic";break;case vxe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function x_e(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(xx).join(`
  7346. `)}function b_e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function v_e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function xx(t){return t!==""}function Gz(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 Wz(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const y_e=/^[ \t]*#include +<([\w\d./]+)>/gm;function Y3(t){return t.replace(y_e,S_e)}const __e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function S_e(t,e){let n=an[e];if(n===void 0){const r=__e.get(e);if(r!==void 0)n=an[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 Y3(n)}const w_e=/#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 qz(t){return t.replace(w_e,M_e)}function M_e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function Xz(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 E_e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===b7?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===$ge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Xl&&(e="SHADOWMAP_TYPE_VSM"),e}function A_e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case am:case om:e="ENVMAP_TYPE_CUBE";break;case bw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function T_e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case om:e="ENVMAP_MODE_REFRACTION";break}return e}function C_e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case NP:e="ENVMAP_BLENDING_MULTIPLY";break;case hxe:e="ENVMAP_BLENDING_MIX";break;case pxe:e="ENVMAP_BLENDING_ADD";break}return e}function N_e(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 k_e(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=E_e(n),c=A_e(n),d=T_e(n),h=C_e(n),g=N_e(n),m=n.isWebGL2?"":x_e(n),v=b_e(s),y=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,v].filter(xx).join(`
  7353. `),b.length>0&&(b+=`
  7354. `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v].filter(xx).join(`
  7355. `),x.length>0&&(x+=`
  7356. `)):(b=[Xz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7357. `].filter(xx).join(`
  7358. `),x=[m,Xz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+h:"",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!==Vu?"#define TONE_MAPPING":"",n.toneMapping!==Vu?an.tonemapping_pars_fragment:"",n.toneMapping!==Vu?g_e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,m_e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(xx).join(`
  7360. `)),a=Y3(a),a=Gz(a,n),a=Wz(a,n),o=Y3(o),o=Gz(o,n),o=Wz(o,n),a=qz(a),o=qz(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===fz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===fz?"":"#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+a,A=M+x+o,T=$z(i,i.VERTEX_SHADER,w),R=$z(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,R),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(z){if(t.debug.checkShaderErrors){const j=i.getProgramInfoLog(y).trim(),W=i.getShaderInfoLog(T).trim(),P=i.getShaderInfoLog(R).trim();let $=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,R);else{const G=Vz(i,T,"vertex"),Z=Vz(i,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+j+`
  7367. `+G+`
  7368. `+Z)}else j!==""?console.warn("THREE.WebGLProgram: Program Info Log:",j):(W===""||P==="")&&(K=!1);K&&(z.diagnostics={runnable:$,programLog:j,vertexShader:{log:W,prefix:b},fragmentShader:{log:P,prefix:x}})}i.deleteShader(T),i.deleteShader(R),I=new L_(i,y),N=v_e(i,y)}let I;this.getUniforms=function(){return I===void 0&&C(this),I};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,d_e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=f_e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=R,this}let R_e=0;class P_e{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.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 D_e(e),n.set(e,r)),r}}class D_e{constructor(e){this.id=R_e++,this.code=e,this.usedTimes=0}}function O_e(t,e,n,r,i,s,a){const o=new L7,l=new P_e,c=[],d=i.isWebGL2,h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return N===0?"uv":`uv${N}`}function b(N,D,z,j,W){const P=j.fog,$=W.geometry,K=N.isMeshStandardMaterial?j.environment:null,G=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),Z=G&&G.mapping===bw?G.image.height:null,Q=v[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=ee!==void 0?ee.length:0;let q=0;$.morphAttributes.position!==void 0&&(q=1),$.morphAttributes.normal!==void 0&&(q=2),$.morphAttributes.color!==void 0&&(q=3);let te,ae,xe,re;if(Q){const cn=zs[Q];te=cn.vertexShader,ae=cn.fragmentShader}else te=N.vertexShader,ae=N.fragmentShader,l.update(N),xe=l.getVertexShaderID(N),re=l.getFragmentShaderID(N);const pe=t.getRenderTarget(),Ce=W.isInstancedMesh===!0,fe=W.isBatchedMesh===!0,Se=!!N.map,Re=!!N.matcap,ue=!!G,ct=!!N.aoMap,B=!!N.lightMap,F=!!N.bumpMap,ie=!!N.normalMap,V=!!N.displacementMap,J=!!N.emissiveMap,le=!!N.metalnessMap,Ae=!!N.roughnessMap,Ee=N.anisotropy>0,se=N.clearcoat>0,U=N.iridescence>0,L=N.sheen>0,X=N.transmission>0,me=Ee&&!!N.anisotropyMap,ve=se&&!!N.clearcoatMap,ge=se&&!!N.clearcoatNormalMap,Ke=se&&!!N.clearcoatRoughnessMap,Ie=U&&!!N.iridescenceMap,ze=U&&!!N.iridescenceThicknessMap,at=L&&!!N.sheenColorMap,Fe=L&&!!N.sheenRoughnessMap,ce=!!N.specularMap,Qe=!!N.specularColorMap,He=!!N.specularIntensityMap,Ye=X&&!!N.transmissionMap,ut=X&&!!N.thicknessMap,de=!!N.gradientMap,Je=!!N.alphaMap,be=N.alphaTest>0,je=!!N.alphaHash,Te=!!N.extensions,ye=!!$.attributes.uv1,Ge=!!$.attributes.uv2,ft=!!$.attributes.uv3;let yt=Vu;return N.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(yt=t.toneMapping),{isWebGL2:d,shaderID:Q,shaderType:N.type,shaderName:N.name,vertexShader:te,fragmentShader:ae,defines:N.defines,customVertexShaderID:xe,customFragmentShaderID:re,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:fe,instancing:Ce,instancingColor:Ce&&W.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:pe===null?t.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:_c,map:Se,matcap:Re,envMap:ue,envMapMode:ue&&G.mapping,envMapCubeUVHeight:Z,aoMap:ct,lightMap:B,bumpMap:F,normalMap:ie,displacementMap:g&&V,emissiveMap:J,normalMapObjectSpace:ie&&N.normalMapType===Rxe,normalMapTangentSpace:ie&&N.normalMapType===C7,metalnessMap:le,roughnessMap:Ae,anisotropy:Ee,anisotropyMap:me,clearcoat:se,clearcoatMap:ve,clearcoatNormalMap:ge,clearcoatRoughnessMap:Ke,iridescence:U,iridescenceMap:Ie,iridescenceThicknessMap:ze,sheen:L,sheenColorMap:at,sheenRoughnessMap:Fe,specularMap:ce,specularColorMap:Qe,specularIntensityMap:He,transmission:X,transmissionMap:Ye,thicknessMap:ut,gradientMap:de,opaque:N.transparent===!1&&N.blending===Bp,alphaMap:Je,alphaTest:be,alphaHash:je,combine:N.combine,mapUv:Se&&y(N.map.channel),aoMapUv:ct&&y(N.aoMap.channel),lightMapUv:B&&y(N.lightMap.channel),bumpMapUv:F&&y(N.bumpMap.channel),normalMapUv:ie&&y(N.normalMap.channel),displacementMapUv:V&&y(N.displacementMap.channel),emissiveMapUv:J&&y(N.emissiveMap.channel),metalnessMapUv:le&&y(N.metalnessMap.channel),roughnessMapUv:Ae&&y(N.roughnessMap.channel),anisotropyMapUv:me&&y(N.anisotropyMap.channel),clearcoatMapUv:ve&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:ge&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:at&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(N.sheenRoughnessMap.channel),specularMapUv:ce&&y(N.specularMap.channel),specularColorMapUv:Qe&&y(N.specularColorMap.channel),specularIntensityMapUv:He&&y(N.specularIntensityMap.channel),transmissionMapUv:Ye&&y(N.transmissionMap.channel),thicknessMapUv:ut&&y(N.thicknessMap.channel),alphaMapUv:Je&&y(N.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(ie||Ee),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:ye,vertexUv2s:Ge,vertexUv3s:ft,pointsUvs:W.isPoints===!0&&!!$.attributes.uv&&(Se||Je),fog:!!P,useFog:N.fog===!0,fogExp2:P&&P.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:q,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Se&&N.map.isVideoTexture===!0&&$n.getTransfer(N.map.colorSpace)===sr,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Jl,flipSided:N.side===Vs,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:Te&&N.extensions.derivatives===!0,extensionFragDepth:Te&&N.extensions.fragDepth===!0,extensionDrawBuffers:Te&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:Te&&N.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()}}function x(N){const D=[];if(N.shaderID?D.push(N.shaderID):(D.push(N.customVertexShaderID),D.push(N.customFragmentShaderID)),N.defines!==void 0)for(const z in N.defines)D.push(z),D.push(N.defines[z]);return N.isRawShaderMaterial===!1&&(M(D,N),w(D,N),D.push(t.outputColorSpace)),D.push(N.customProgramCacheKey),D.join()}function M(N,D){N.push(D.precision),N.push(D.outputColorSpace),N.push(D.envMapMode),N.push(D.envMapCubeUVHeight),N.push(D.mapUv),N.push(D.alphaMapUv),N.push(D.lightMapUv),N.push(D.aoMapUv),N.push(D.bumpMapUv),N.push(D.normalMapUv),N.push(D.displacementMapUv),N.push(D.emissiveMapUv),N.push(D.metalnessMapUv),N.push(D.roughnessMapUv),N.push(D.anisotropyMapUv),N.push(D.clearcoatMapUv),N.push(D.clearcoatNormalMapUv),N.push(D.clearcoatRoughnessMapUv),N.push(D.iridescenceMapUv),N.push(D.iridescenceThicknessMapUv),N.push(D.sheenColorMapUv),N.push(D.sheenRoughnessMapUv),N.push(D.specularMapUv),N.push(D.specularColorMapUv),N.push(D.specularIntensityMapUv),N.push(D.transmissionMapUv),N.push(D.thicknessMapUv),N.push(D.combine),N.push(D.fogExp2),N.push(D.sizeAttenuation),N.push(D.morphTargetsCount),N.push(D.morphAttributeCount),N.push(D.numDirLights),N.push(D.numPointLights),N.push(D.numSpotLights),N.push(D.numSpotLightMaps),N.push(D.numHemiLights),N.push(D.numRectAreaLights),N.push(D.numDirLightShadows),N.push(D.numPointLightShadows),N.push(D.numSpotLightShadows),N.push(D.numSpotLightShadowsWithMaps),N.push(D.numLightProbes),N.push(D.shadowMapType),N.push(D.toneMapping),N.push(D.numClippingPlanes),N.push(D.numClipIntersection),N.push(D.depthPacking)}function w(N,D){o.disableAll(),D.isWebGL2&&o.enable(0),D.supportsVertexTextures&&o.enable(1),D.instancing&&o.enable(2),D.instancingColor&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),N.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.skinning&&o.enable(4),D.morphTargets&&o.enable(5),D.morphNormals&&o.enable(6),D.morphColors&&o.enable(7),D.premultipliedAlpha&&o.enable(8),D.shadowMapEnabled&&o.enable(9),D.useLegacyLights&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),N.push(o.mask)}function A(N){const D=v[N.type];let z;if(D){const j=zs[D];z=OP.clone(j.uniforms)}else z=N.uniforms;return z}function T(N,D){let z;for(let j=0,W=c.length;j<W;j++){const P=c[j];if(P.cacheKey===D){z=P,++z.usedTimes;break}}return z===void 0&&(z=new k_e(t,D,N,s),c.push(z)),z}function R(N){if(--N.usedTimes===0){const D=c.indexOf(N);c[D]=c[c.length-1],c.pop(),N.destroy()}}function C(N){l.remove(N)}function I(){l.dispose()}return{getParameters:b,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:R,releaseShaderCache:C,programs:c,dispose:I}}function L_e(){let t=new WeakMap;function e(s){let a=t.get(s);return a===void 0&&(a={},t.set(s,a)),a}function n(s){t.delete(s)}function r(s,a,o){t.get(s)[a]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function j_e(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Kz(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 Yz(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(h,g,m,v,y,b){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:v,renderOrder:h.renderOrder,z:y,group:b},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=v,x.renderOrder=h.renderOrder,x.z=y,x.group=b),e++,x}function o(h,g,m,v,y,b){const x=a(h,g,m,v,y,b);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,v,y,b){const x=a(h,g,m,v,y,b);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||j_e),r.length>1&&r.sort(g||Kz),i.length>1&&i.sort(g||Kz)}function d(){for(let h=e,g=t.length;h<g;h++){const m=t[h];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:s,push:o,unshift:l,finish:d,sort:c}}function I_e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new Yz,t.set(r,[a])):i>=s.length?(a=new Yz,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function U_e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new ke,color:new $t};break;case"SpotLight":n={position:new ke,direction:new ke,color:new $t,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ke,color:new $t,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ke,skyColor:new $t,groundColor:new $t};break;case"RectAreaLight":n={color:new $t,position:new ke,halfWidth:new ke,halfHeight:new ke};break}return t[e.id]=n,n}}}function F_e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let z_e=0;function B_e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function H_e(t,e){const n=new U_e,r=F_e(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new ke);const s=new ke,a=new tr,o=new tr;function l(d,h){let g=0,m=0,v=0;for(let j=0;j<9;j++)i.probe[j].set(0,0,0);let y=0,b=0,x=0,M=0,w=0,A=0,T=0,R=0,C=0,I=0,N=0;d.sort(B_e);const D=h===!0?Math.PI:1;for(let j=0,W=d.length;j<W;j++){const P=d[j],$=P.color,K=P.intensity,G=P.distance,Z=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)g+=$.r*K*D,m+=$.g*K*D,v+=$.b*K*D;else if(P.isLightProbe){for(let Q=0;Q<9;Q++)i.probe[Q].addScaledVector(P.sh.coefficients[Q],K);N++}else if(P.isDirectionalLight){const Q=n.get(P);if(Q.color.copy(P.color).multiplyScalar(P.intensity*D),P.castShadow){const ee=P.shadow,H=r.get(P);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.directionalShadow[y]=H,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=P.shadow.matrix,A++}i.directional[y]=Q,y++}else if(P.isSpotLight){const Q=n.get(P);Q.position.setFromMatrixPosition(P.matrixWorld),Q.color.copy($).multiplyScalar(K*D),Q.distance=G,Q.coneCos=Math.cos(P.angle),Q.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),Q.decay=P.decay,i.spot[x]=Q;const ee=P.shadow;if(P.map&&(i.spotLightMap[C]=P.map,C++,ee.updateMatrices(P),P.castShadow&&I++),i.spotLightMatrix[x]=ee.matrix,P.castShadow){const H=r.get(P);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.spotShadow[x]=H,i.spotShadowMap[x]=Z,R++}x++}else if(P.isRectAreaLight){const Q=n.get(P);Q.color.copy($).multiplyScalar(K),Q.halfWidth.set(P.width*.5,0,0),Q.halfHeight.set(0,P.height*.5,0),i.rectArea[M]=Q,M++}else if(P.isPointLight){const Q=n.get(P);if(Q.color.copy(P.color).multiplyScalar(P.intensity*D),Q.distance=P.distance,Q.decay=P.decay,P.castShadow){const ee=P.shadow,H=r.get(P);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,H.shadowCameraNear=ee.camera.near,H.shadowCameraFar=ee.camera.far,i.pointShadow[b]=H,i.pointShadowMap[b]=Z,i.pointShadowMatrix[b]=P.shadow.matrix,T++}i.point[b]=Q,b++}else if(P.isHemisphereLight){const Q=n.get(P);Q.skyColor.copy(P.color).multiplyScalar(K*D),Q.groundColor.copy(P.groundColor).multiplyScalar(K*D),i.hemi[w]=Q,w++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_FLOAT_1,i.rectAreaLTC2=vt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_HALF_1,i.rectAreaLTC2=vt.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]=v;const z=i.hash;(z.directionalLength!==y||z.pointLength!==b||z.spotLength!==x||z.rectAreaLength!==M||z.hemiLength!==w||z.numDirectionalShadows!==A||z.numPointShadows!==T||z.numSpotShadows!==R||z.numSpotMaps!==C||z.numLightProbes!==N)&&(i.directional.length=y,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+C-I,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=N,z.directionalLength=y,z.pointLength=b,z.spotLength=x,z.rectAreaLength=M,z.hemiLength=w,z.numDirectionalShadows=A,z.numPointShadows=T,z.numSpotShadows=R,z.numSpotMaps=C,z.numLightProbes=N,i.version=z_e++)}function c(d,h){let g=0,m=0,v=0,y=0,b=0;const x=h.matrixWorldInverse;for(let M=0,w=d.length;M<w;M++){const A=d[M];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(x),g++}else if(A.isSpotLight){const T=i.spot[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(x),v++}else if(A.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),o.identity(),a.copy(A.matrixWorld),a.premultiply(x),o.extractRotation(a),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),y++}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 Zz(t,e){const n=new H_e(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function a(h){r.push(h)}function o(h){i.push(h)}function l(h){n.setup(r,h)}function c(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function $_e(t,e){let n=new WeakMap;function r(s,a=0){const o=n.get(s);let l;return o===void 0?(l=new Zz(t,e),n.set(s,[l])):a>=o.length?(l=new Zz(t,e),o.push(l)):l=o[a],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class V_e extends Lm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Nxe,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 G_e extends Lm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const W_e=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,q_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 X_e(t,e,n){let r=new yw;const i=new Kt,s=new Kt,a=new Gn,o=new V_e({depthPacking:kxe}),l=new G_e,c={},d=n.maxTextureSize,h={[ed]:Vs,[Vs]:ed,[Jl]:Jl},g=new td({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Kt},radius:{value:4}},vertexShader:W_e,fragmentShader:q_e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const v=new ds;v.setAttribute("position",new ga(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Mo(v,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=b7;let x=this.type;this.render=function(T,R,C){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||T.length===0)return;const I=t.getRenderTarget(),N=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),z=t.state;z.setBlending($u),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const j=x!==Xl&&this.type===Xl,W=x===Xl&&this.type!==Xl;for(let P=0,$=T.length;P<$;P++){const K=T[P],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();if(i.multiply(Z),s.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Z.x),i.x=s.x*Z.x,G.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Z.y),i.y=s.y*Z.y,G.mapSize.y=s.y)),G.map===null||j===!0||W===!0){const ee=this.type!==Xl?{minFilter:Wi,magFilter:Wi}:{};G.map!==null&&G.map.dispose(),G.map=new Uf(i.x,i.y,ee),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const Q=G.getViewportCount();for(let ee=0;ee<Q;ee++){const H=G.getViewport(ee);a.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),z.viewport(a),G.updateMatrices(K,ee),r=G.getFrustum(),A(R,C,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===Xl&&M(G,C),G.needsUpdate=!1}x=this.type,b.needsUpdate=!1,t.setRenderTarget(I,N,D)};function M(T,R){const C=e.update(y);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 Uf(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,C,g,y,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,C,m,y,null)}function w(T,R,C,I){let N=null;const D=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)N=D;else if(N=C.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 z=N.uuid,j=R.uuid;let W=c[z];W===void 0&&(W={},c[z]=W);let P=W[j];P===void 0&&(P=N.clone(),W[j]=P),N=P}if(N.visible=R.visible,N.wireframe=R.wireframe,I===Xl?N.side=R.shadowSide!==null?R.shadowSide:R.side:N.side=R.shadowSide!==null?R.shadowSide:h[R.side],N.alphaMap=R.alphaMap,N.alphaTest=R.alphaTest,N.map=R.map,N.clipShadows=R.clipShadows,N.clippingPlanes=R.clippingPlanes,N.clipIntersection=R.clipIntersection,N.displacementMap=R.displacementMap,N.displacementScale=R.displacementScale,N.displacementBias=R.displacementBias,N.wireframeLinewidth=R.wireframeLinewidth,N.linewidth=R.linewidth,C.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const z=t.properties.get(N);z.light=C}return N}function A(T,R,C,I,N){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&N===Xl)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const j=e.update(T),W=T.material;if(Array.isArray(W)){const P=j.groups;for(let $=0,K=P.length;$<K;$++){const G=P[$],Z=W[G.materialIndex];if(Z&&Z.visible){const Q=w(T,Z,I,N);T.onBeforeShadow(t,T,R,C,j,Q,G),t.renderBufferDirect(C,null,j,Q,T,G),T.onAfterShadow(t,T,R,C,j,Q,G)}}}else if(W.visible){const P=w(T,W,I,N);T.onBeforeShadow(t,T,R,C,j,P,null),t.renderBufferDirect(C,null,j,P,T,null),T.onAfterShadow(t,T,R,C,j,P,null)}}const z=T.children;for(let j=0,W=z.length;j<W;j++)A(z[j],R,C,I,N)}}function K_e(t,e,n){const r=n.isWebGL2;function i(){let be=!1;const je=new Gn;let Te=null;const ye=new Gn(0,0,0,0);return{setMask:function(Ge){Te!==Ge&&!be&&(t.colorMask(Ge,Ge,Ge,Ge),Te=Ge)},setLocked:function(Ge){be=Ge},setClear:function(Ge,ft,yt,Rt,cn){cn===!0&&(Ge*=Rt,ft*=Rt,yt*=Rt),je.set(Ge,ft,yt,Rt),ye.equals(je)===!1&&(t.clearColor(Ge,ft,yt,Rt),ye.copy(je))},reset:function(){be=!1,Te=null,ye.set(-1,0,0,0)}}}function s(){let be=!1,je=null,Te=null,ye=null;return{setTest:function(Ge){Ge?fe(t.DEPTH_TEST):Se(t.DEPTH_TEST)},setMask:function(Ge){je!==Ge&&!be&&(t.depthMask(Ge),je=Ge)},setFunc:function(Ge){if(Te!==Ge){switch(Ge){case axe:t.depthFunc(t.NEVER);break;case oxe:t.depthFunc(t.ALWAYS);break;case lxe:t.depthFunc(t.LESS);break;case u1:t.depthFunc(t.LEQUAL);break;case cxe:t.depthFunc(t.EQUAL);break;case uxe:t.depthFunc(t.GEQUAL);break;case dxe:t.depthFunc(t.GREATER);break;case fxe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Te=Ge}},setLocked:function(Ge){be=Ge},setClear:function(Ge){ye!==Ge&&(t.clearDepth(Ge),ye=Ge)},reset:function(){be=!1,je=null,Te=null,ye=null}}}function a(){let be=!1,je=null,Te=null,ye=null,Ge=null,ft=null,yt=null,Rt=null,cn=null;return{setTest:function(jt){be||(jt?fe(t.STENCIL_TEST):Se(t.STENCIL_TEST))},setMask:function(jt){je!==jt&&!be&&(t.stencilMask(jt),je=jt)},setFunc:function(jt,Rn,qn){(Te!==jt||ye!==Rn||Ge!==qn)&&(t.stencilFunc(jt,Rn,qn),Te=jt,ye=Rn,Ge=qn)},setOp:function(jt,Rn,qn){(ft!==jt||yt!==Rn||Rt!==qn)&&(t.stencilOp(jt,Rn,qn),ft=jt,yt=Rn,Rt=qn)},setLocked:function(jt){be=jt},setClear:function(jt){cn!==jt&&(t.clearStencil(jt),cn=jt)},reset:function(){be=!1,je=null,Te=null,ye=null,Ge=null,ft=null,yt=null,Rt=null,cn=null}}}const o=new i,l=new s,c=new a,d=new WeakMap,h=new WeakMap;let g={},m={},v=new WeakMap,y=[],b=null,x=!1,M=null,w=null,A=null,T=null,R=null,C=null,I=null,N=new $t(0,0,0),D=0,z=!1,j=null,W=null,P=null,$=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,Q=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(ee)[1]),Z=Q>=1):ee.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),Z=Q>=2);let H=null,q={};const te=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),xe=new Gn().fromArray(te),re=new Gn().fromArray(ae);function pe(be,je,Te,ye){const Ge=new Uint8Array(4),ft=t.createTexture();t.bindTexture(be,ft),t.texParameteri(be,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(be,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let yt=0;yt<Te;yt++)r&&(be===t.TEXTURE_3D||be===t.TEXTURE_2D_ARRAY)?t.texImage3D(je,0,t.RGBA,1,1,ye,0,t.RGBA,t.UNSIGNED_BYTE,Ge):t.texImage2D(je+yt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ge);return ft}const Ce={};Ce[t.TEXTURE_2D]=pe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ce[t.TEXTURE_CUBE_MAP]=pe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ce[t.TEXTURE_2D_ARRAY]=pe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ce[t.TEXTURE_3D]=pe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),fe(t.DEPTH_TEST),l.setFunc(u1),J(!1),le(D5),fe(t.CULL_FACE),ie($u);function fe(be){g[be]!==!0&&(t.enable(be),g[be]=!0)}function Se(be){g[be]!==!1&&(t.disable(be),g[be]=!1)}function Re(be,je){return m[be]!==je?(t.bindFramebuffer(be,je),m[be]=je,r&&(be===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=je),be===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=je)),!0):!1}function ue(be,je){let Te=y,ye=!1;if(be)if(Te=v.get(je),Te===void 0&&(Te=[],v.set(je,Te)),be.isWebGLMultipleRenderTargets){const Ge=be.texture;if(Te.length!==Ge.length||Te[0]!==t.COLOR_ATTACHMENT0){for(let ft=0,yt=Ge.length;ft<yt;ft++)Te[ft]=t.COLOR_ATTACHMENT0+ft;Te.length=Ge.length,ye=!0}}else Te[0]!==t.COLOR_ATTACHMENT0&&(Te[0]=t.COLOR_ATTACHMENT0,ye=!0);else Te[0]!==t.BACK&&(Te[0]=t.BACK,ye=!0);ye&&(n.isWebGL2?t.drawBuffers(Te):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Te))}function ct(be){return b!==be?(t.useProgram(be),b=be,!0):!1}const B={[Qd]:t.FUNC_ADD,[Gge]:t.FUNC_SUBTRACT,[Wge]:t.FUNC_REVERSE_SUBTRACT};if(r)B[I5]=t.MIN,B[U5]=t.MAX;else{const be=e.get("EXT_blend_minmax");be!==null&&(B[I5]=be.MIN_EXT,B[U5]=be.MAX_EXT)}const F={[qge]:t.ZERO,[Xge]:t.ONE,[Kge]:t.SRC_COLOR,[B3]:t.SRC_ALPHA,[txe]:t.SRC_ALPHA_SATURATE,[Jge]:t.DST_COLOR,[Zge]:t.DST_ALPHA,[Yge]:t.ONE_MINUS_SRC_COLOR,[H3]:t.ONE_MINUS_SRC_ALPHA,[exe]:t.ONE_MINUS_DST_COLOR,[Qge]:t.ONE_MINUS_DST_ALPHA,[nxe]:t.CONSTANT_COLOR,[rxe]:t.ONE_MINUS_CONSTANT_COLOR,[ixe]:t.CONSTANT_ALPHA,[sxe]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(be,je,Te,ye,Ge,ft,yt,Rt,cn,jt){if(be===$u){x===!0&&(Se(t.BLEND),x=!1);return}if(x===!1&&(fe(t.BLEND),x=!0),be!==Vge){if(be!==M||jt!==z){if((w!==Qd||R!==Qd)&&(t.blendEquation(t.FUNC_ADD),w=Qd,R=Qd),jt)switch(be){case Bp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case O5:t.blendFunc(t.ONE,t.ONE);break;case L5:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case j5:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",be);break}else switch(be){case Bp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case O5:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case L5:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case j5:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",be);break}A=null,T=null,C=null,I=null,N.set(0,0,0),D=0,M=be,z=jt}return}Ge=Ge||je,ft=ft||Te,yt=yt||ye,(je!==w||Ge!==R)&&(t.blendEquationSeparate(B[je],B[Ge]),w=je,R=Ge),(Te!==A||ye!==T||ft!==C||yt!==I)&&(t.blendFuncSeparate(F[Te],F[ye],F[ft],F[yt]),A=Te,T=ye,C=ft,I=yt),(Rt.equals(N)===!1||cn!==D)&&(t.blendColor(Rt.r,Rt.g,Rt.b,cn),N.copy(Rt),D=cn),M=be,z=!1}function V(be,je){be.side===Jl?Se(t.CULL_FACE):fe(t.CULL_FACE);let Te=be.side===Vs;je&&(Te=!Te),J(Te),be.blending===Bp&&be.transparent===!1?ie($u):ie(be.blending,be.blendEquation,be.blendSrc,be.blendDst,be.blendEquationAlpha,be.blendSrcAlpha,be.blendDstAlpha,be.blendColor,be.blendAlpha,be.premultipliedAlpha),l.setFunc(be.depthFunc),l.setTest(be.depthTest),l.setMask(be.depthWrite),o.setMask(be.colorWrite);const ye=be.stencilWrite;c.setTest(ye),ye&&(c.setMask(be.stencilWriteMask),c.setFunc(be.stencilFunc,be.stencilRef,be.stencilFuncMask),c.setOp(be.stencilFail,be.stencilZFail,be.stencilZPass)),Ee(be.polygonOffset,be.polygonOffsetFactor,be.polygonOffsetUnits),be.alphaToCoverage===!0?fe(t.SAMPLE_ALPHA_TO_COVERAGE):Se(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(be){j!==be&&(be?t.frontFace(t.CW):t.frontFace(t.CCW),j=be)}function le(be){be!==Bge?(fe(t.CULL_FACE),be!==W&&(be===D5?t.cullFace(t.BACK):be===Hge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Se(t.CULL_FACE),W=be}function Ae(be){be!==P&&(Z&&t.lineWidth(be),P=be)}function Ee(be,je,Te){be?(fe(t.POLYGON_OFFSET_FILL),($!==je||K!==Te)&&(t.polygonOffset(je,Te),$=je,K=Te)):Se(t.POLYGON_OFFSET_FILL)}function se(be){be?fe(t.SCISSOR_TEST):Se(t.SCISSOR_TEST)}function U(be){be===void 0&&(be=t.TEXTURE0+G-1),H!==be&&(t.activeTexture(be),H=be)}function L(be,je,Te){Te===void 0&&(H===null?Te=t.TEXTURE0+G-1:Te=H);let ye=q[Te];ye===void 0&&(ye={type:void 0,texture:void 0},q[Te]=ye),(ye.type!==be||ye.texture!==je)&&(H!==Te&&(t.activeTexture(Te),H=Te),t.bindTexture(be,je||Ce[be]),ye.type=be,ye.texture=je)}function X(){const be=q[H];be!==void 0&&be.type!==void 0&&(t.bindTexture(be.type,null),be.type=void 0,be.texture=void 0)}function me(){try{t.compressedTexImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ve(){try{t.compressedTexImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ge(){try{t.texSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ke(){try{t.texSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ie(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ze(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function at(){try{t.texStorage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Fe(){try{t.texStorage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ce(){try{t.texImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Qe(){try{t.texImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function He(be){xe.equals(be)===!1&&(t.scissor(be.x,be.y,be.z,be.w),xe.copy(be))}function Ye(be){re.equals(be)===!1&&(t.viewport(be.x,be.y,be.z,be.w),re.copy(be))}function ut(be,je){let Te=h.get(je);Te===void 0&&(Te=new WeakMap,h.set(je,Te));let ye=Te.get(be);ye===void 0&&(ye=t.getUniformBlockIndex(je,be.name),Te.set(be,ye))}function de(be,je){const ye=h.get(je).get(be);d.get(je)!==ye&&(t.uniformBlockBinding(je,ye,be.__bindingPointIndex),d.set(je,ye))}function Je(){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={},H=null,q={},m={},v=new WeakMap,y=[],b=null,x=!1,M=null,w=null,A=null,T=null,R=null,C=null,I=null,N=new $t(0,0,0),D=0,z=!1,j=null,W=null,P=null,$=null,K=null,xe.set(0,0,t.canvas.width,t.canvas.height),re.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:fe,disable:Se,bindFramebuffer:Re,drawBuffers:ue,useProgram:ct,setBlending:ie,setMaterial:V,setFlipSided:J,setCullFace:le,setLineWidth:Ae,setPolygonOffset:Ee,setScissorTest:se,activeTexture:U,bindTexture:L,unbindTexture:X,compressedTexImage2D:me,compressedTexImage3D:ve,texImage2D:ce,texImage3D:Qe,updateUBOMapping:ut,uniformBlockBinding:de,texStorage2D:at,texStorage3D:Fe,texSubImage2D:ge,texSubImage3D:Ke,compressedTexSubImage2D:Ie,compressedTexSubImage3D:ze,scissor:He,viewport:Ye,reset:Je}}function Y_e(t,e,n,r,i,s,a){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,d=i.maxTextureSize,h=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),v=new WeakMap;let y;const b=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(U,L){return x?new OffscreenCanvas(U,L):m1("canvas")}function w(U,L,X,me){let ve=1;if((U.width>me||U.height>me)&&(ve=me/Math.max(U.width,U.height)),ve<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const ge=L?p1:Math.floor,Ke=ge(ve*U.width),Ie=ge(ve*U.height);y===void 0&&(y=M(Ke,Ie));const ze=X?M(Ke,Ie):y;return ze.width=Ke,ze.height=Ie,ze.getContext("2d").drawImage(U,0,0,Ke,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+Ke+"x"+Ie+")."),ze}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function A(U){return K3(U.width)&&K3(U.height)}function T(U){return o?!1:U.wrapS!==bo||U.wrapT!==bo||U.minFilter!==Wi&&U.minFilter!==$a}function R(U,L){return U.generateMipmaps&&L&&U.minFilter!==Wi&&U.minFilter!==$a}function C(U){t.generateMipmap(U)}function I(U,L,X,me,ve=!1){if(o===!1)return L;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let ge=L;if(L===t.RED&&(X===t.FLOAT&&(ge=t.R32F),X===t.HALF_FLOAT&&(ge=t.R16F),X===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(X===t.UNSIGNED_BYTE&&(ge=t.R8UI),X===t.UNSIGNED_SHORT&&(ge=t.R16UI),X===t.UNSIGNED_INT&&(ge=t.R32UI),X===t.BYTE&&(ge=t.R8I),X===t.SHORT&&(ge=t.R16I),X===t.INT&&(ge=t.R32I)),L===t.RG&&(X===t.FLOAT&&(ge=t.RG32F),X===t.HALF_FLOAT&&(ge=t.RG16F),X===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RGBA){const Ke=ve?d1:$n.getTransfer(me);X===t.FLOAT&&(ge=t.RGBA32F),X===t.HALF_FLOAT&&(ge=t.RGBA16F),X===t.UNSIGNED_BYTE&&(ge=Ke===sr?t.SRGB8_ALPHA8:t.RGBA8),X===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),X===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function N(U,L,X){return R(U,X)===!0||U.isFramebufferTexture&&U.minFilter!==Wi&&U.minFilter!==$a?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function D(U){return U===Wi||U===F5||U===PA?t.NEAREST:t.LINEAR}function z(U){const L=U.target;L.removeEventListener("dispose",z),W(L),L.isVideoTexture&&v.delete(L)}function j(U){const L=U.target;L.removeEventListener("dispose",j),$(L)}function W(U){const L=r.get(U);if(L.__webglInit===void 0)return;const X=U.source,me=b.get(X);if(me){const ve=me[L.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&P(U),Object.keys(me).length===0&&b.delete(X)}r.remove(U)}function P(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const X=U.source,me=b.get(X);delete me[L.__cacheKey],a.memory.textures--}function $(U){const L=U.texture,X=r.get(U),me=r.get(L);if(me.__webglTexture!==void 0&&(t.deleteTexture(me.__webglTexture),a.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(X.__webglFramebuffer[ve]))for(let ge=0;ge<X.__webglFramebuffer[ve].length;ge++)t.deleteFramebuffer(X.__webglFramebuffer[ve][ge]);else t.deleteFramebuffer(X.__webglFramebuffer[ve]);X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer[ve])}else{if(Array.isArray(X.__webglFramebuffer))for(let ve=0;ve<X.__webglFramebuffer.length;ve++)t.deleteFramebuffer(X.__webglFramebuffer[ve]);else t.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&t.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&t.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let ve=0;ve<X.__webglColorRenderbuffer.length;ve++)X.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(X.__webglColorRenderbuffer[ve]);X.__webglDepthRenderbuffer&&t.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let ve=0,ge=L.length;ve<ge;ve++){const Ke=r.get(L[ve]);Ke.__webglTexture&&(t.deleteTexture(Ke.__webglTexture),a.memory.textures--),r.remove(L[ve])}r.remove(L),r.remove(U)}let K=0;function G(){K=0}function Z(){const U=K;return U>=l&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+l),K+=1,U}function Q(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function ee(U,L){const X=r.get(U);if(U.isVideoTexture&&Ee(U),U.isRenderTargetTexture===!1&&U.version>0&&X.__version!==U.version){const me=U.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{fe(X,U,L);return}}n.bindTexture(t.TEXTURE_2D,X.__webglTexture,t.TEXTURE0+L)}function H(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){fe(X,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,X.__webglTexture,t.TEXTURE0+L)}function q(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){fe(X,U,L);return}n.bindTexture(t.TEXTURE_3D,X.__webglTexture,t.TEXTURE0+L)}function te(U,L){const X=r.get(U);if(U.version>0&&X.__version!==U.version){Se(X,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,X.__webglTexture,t.TEXTURE0+L)}const ae={[G3]:t.REPEAT,[bo]:t.CLAMP_TO_EDGE,[W3]:t.MIRRORED_REPEAT},xe={[Wi]:t.NEAREST,[F5]:t.NEAREST_MIPMAP_NEAREST,[PA]:t.NEAREST_MIPMAP_LINEAR,[$a]:t.LINEAR,[yxe]:t.LINEAR_MIPMAP_NEAREST,[d0]:t.LINEAR_MIPMAP_LINEAR},re={[Pxe]:t.NEVER,[Uxe]:t.ALWAYS,[Dxe]:t.LESS,[N7]:t.LEQUAL,[Oxe]:t.EQUAL,[Ixe]:t.GEQUAL,[Lxe]:t.GREATER,[jxe]:t.NOTEQUAL};function pe(U,L,X){if(X?(t.texParameteri(U,t.TEXTURE_WRAP_S,ae[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,ae[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,ae[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,xe[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,xe[L.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==bo||L.wrapT!==bo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(U,t.TEXTURE_MAG_FILTER,D(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,D(L.minFilter)),L.minFilter!==Wi&&L.minFilter!==$a&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,re[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const me=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Wi||L.minFilter!==PA&&L.minFilter!==d0||L.type===ac&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===f0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(U,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ce(U,L){let X=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",z));const me=L.source;let ve=b.get(me);ve===void 0&&(ve={},b.set(me,ve));const ge=Q(L);if(ge!==U.__cacheKey){ve[ge]===void 0&&(ve[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,X=!0),ve[ge].usedTimes++;const Ke=ve[U.__cacheKey];Ke!==void 0&&(ve[U.__cacheKey].usedTimes--,Ke.usedTimes===0&&P(L)),U.__cacheKey=ge,U.__webglTexture=ve[ge].texture}return X}function fe(U,L,X){let me=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(me=t.TEXTURE_3D);const ve=Ce(U,L),ge=L.source;n.bindTexture(me,U.__webglTexture,t.TEXTURE0+X);const Ke=r.get(ge);if(ge.version!==Ke.__version||ve===!0){n.activeTexture(t.TEXTURE0+X);const Ie=$n.getPrimaries($n.workingColorSpace),ze=L.colorSpace===Ga?null:$n.getPrimaries(L.colorSpace),at=L.colorSpace===Ga||Ie===ze?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,at);const Fe=T(L)&&A(L.image)===!1;let ce=w(L.image,Fe,!1,d);ce=se(L,ce);const Qe=A(ce)||o,He=s.convert(L.format,L.colorSpace);let Ye=s.convert(L.type),ut=I(L.internalFormat,He,Ye,L.colorSpace,L.isVideoTexture);pe(me,L,Qe);let de;const Je=L.mipmaps,be=o&&L.isVideoTexture!==!0&&ut!==A7,je=Ke.__version===void 0||ve===!0,Te=N(L,ce,Qe);if(L.isDepthTexture)ut=t.DEPTH_COMPONENT,o?L.type===ac?ut=t.DEPTH_COMPONENT32F:L.type===ju?ut=t.DEPTH_COMPONENT24:L.type===hf?ut=t.DEPTH24_STENCIL8:ut=t.DEPTH_COMPONENT16:L.type===ac&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===pf&&ut===t.DEPTH_COMPONENT&&L.type!==kP&&L.type!==ju&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=ju,Ye=s.convert(L.type)),L.format===lm&&ut===t.DEPTH_COMPONENT&&(ut=t.DEPTH_STENCIL,L.type!==hf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=hf,Ye=s.convert(L.type))),je&&(be?n.texStorage2D(t.TEXTURE_2D,1,ut,ce.width,ce.height):n.texImage2D(t.TEXTURE_2D,0,ut,ce.width,ce.height,0,He,Ye,null));else if(L.isDataTexture)if(Je.length>0&&Qe){be&&je&&n.texStorage2D(t.TEXTURE_2D,Te,ut,Je[0].width,Je[0].height);for(let ye=0,Ge=Je.length;ye<Ge;ye++)de=Je[ye],be?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,Ye,de.data):n.texImage2D(t.TEXTURE_2D,ye,ut,de.width,de.height,0,He,Ye,de.data);L.generateMipmaps=!1}else be?(je&&n.texStorage2D(t.TEXTURE_2D,Te,ut,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce.width,ce.height,He,Ye,ce.data)):n.texImage2D(t.TEXTURE_2D,0,ut,ce.width,ce.height,0,He,Ye,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){be&&je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Te,ut,Je[0].width,Je[0].height,ce.depth);for(let ye=0,Ge=Je.length;ye<Ge;ye++)de=Je[ye],L.format!==Va?He!==null?be?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,de.width,de.height,ce.depth,He,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ye,ut,de.width,de.height,ce.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,de.width,de.height,ce.depth,He,Ye,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ye,ut,de.width,de.height,ce.depth,0,He,Ye,de.data)}else{be&&je&&n.texStorage2D(t.TEXTURE_2D,Te,ut,Je[0].width,Je[0].height);for(let ye=0,Ge=Je.length;ye<Ge;ye++)de=Je[ye],L.format!==Va?He!==null?be?n.compressedTexSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,de.data):n.compressedTexImage2D(t.TEXTURE_2D,ye,ut,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,Ye,de.data):n.texImage2D(t.TEXTURE_2D,ye,ut,de.width,de.height,0,He,Ye,de.data)}else if(L.isDataArrayTexture)be?(je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Te,ut,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ce.width,ce.height,ce.depth,He,Ye,ce.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ut,ce.width,ce.height,ce.depth,0,He,Ye,ce.data);else if(L.isData3DTexture)be?(je&&n.texStorage3D(t.TEXTURE_3D,Te,ut,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ce.width,ce.height,ce.depth,He,Ye,ce.data)):n.texImage3D(t.TEXTURE_3D,0,ut,ce.width,ce.height,ce.depth,0,He,Ye,ce.data);else if(L.isFramebufferTexture){if(je)if(be)n.texStorage2D(t.TEXTURE_2D,Te,ut,ce.width,ce.height);else{let ye=ce.width,Ge=ce.height;for(let ft=0;ft<Te;ft++)n.texImage2D(t.TEXTURE_2D,ft,ut,ye,Ge,0,He,Ye,null),ye>>=1,Ge>>=1}}else if(Je.length>0&&Qe){be&&je&&n.texStorage2D(t.TEXTURE_2D,Te,ut,Je[0].width,Je[0].height);for(let ye=0,Ge=Je.length;ye<Ge;ye++)de=Je[ye],be?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,He,Ye,de):n.texImage2D(t.TEXTURE_2D,ye,ut,He,Ye,de);L.generateMipmaps=!1}else be?(je&&n.texStorage2D(t.TEXTURE_2D,Te,ut,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,He,Ye,ce)):n.texImage2D(t.TEXTURE_2D,0,ut,He,Ye,ce);R(L,Qe)&&C(me),Ke.__version=ge.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Se(U,L,X){if(L.image.length!==6)return;const me=Ce(U,L),ve=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+X);const ge=r.get(ve);if(ve.version!==ge.__version||me===!0){n.activeTexture(t.TEXTURE0+X);const Ke=$n.getPrimaries($n.workingColorSpace),Ie=L.colorSpace===Ga?null:$n.getPrimaries(L.colorSpace),ze=L.colorSpace===Ga||Ke===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,ze);const at=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let ye=0;ye<6;ye++)!at&&!Fe?ce[ye]=w(L.image[ye],!1,!0,c):ce[ye]=Fe?L.image[ye].image:L.image[ye],ce[ye]=se(L,ce[ye]);const Qe=ce[0],He=A(Qe)||o,Ye=s.convert(L.format,L.colorSpace),ut=s.convert(L.type),de=I(L.internalFormat,Ye,ut,L.colorSpace),Je=o&&L.isVideoTexture!==!0,be=ge.__version===void 0||me===!0;let je=N(L,Qe,He);pe(t.TEXTURE_CUBE_MAP,L,He);let Te;if(at){Je&&be&&n.texStorage2D(t.TEXTURE_CUBE_MAP,je,de,Qe.width,Qe.height);for(let ye=0;ye<6;ye++){Te=ce[ye].mipmaps;for(let Ge=0;Ge<Te.length;Ge++){const ft=Te[Ge];L.format!==Va?Ye!==null?Je?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,0,0,ft.width,ft.height,Ye,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,de,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,0,0,ft.width,ft.height,Ye,ut,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge,de,ft.width,ft.height,0,Ye,ut,ft.data)}}}else{Te=L.mipmaps,Je&&be&&(Te.length>0&&je++,n.texStorage2D(t.TEXTURE_CUBE_MAP,je,de,ce[0].width,ce[0].height));for(let ye=0;ye<6;ye++)if(Fe){Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ce[ye].width,ce[ye].height,Ye,ut,ce[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,de,ce[ye].width,ce[ye].height,0,Ye,ut,ce[ye].data);for(let Ge=0;Ge<Te.length;Ge++){const yt=Te[Ge].image[ye].image;Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,0,0,yt.width,yt.height,Ye,ut,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,de,yt.width,yt.height,0,Ye,ut,yt.data)}}else{Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Ye,ut,ce[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,de,Ye,ut,ce[ye]);for(let Ge=0;Ge<Te.length;Ge++){const ft=Te[Ge];Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,0,0,Ye,ut,ft.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ge+1,de,Ye,ut,ft.image[ye])}}}R(L,He)&&C(t.TEXTURE_CUBE_MAP),ge.__version=ve.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Re(U,L,X,me,ve,ge){const Ke=s.convert(X.format,X.colorSpace),Ie=s.convert(X.type),ze=I(X.internalFormat,Ke,Ie,X.colorSpace);if(!r.get(L).__hasExternalTextures){const Fe=Math.max(1,L.width>>ge),ce=Math.max(1,L.height>>ge);ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY?n.texImage3D(ve,ge,ze,Fe,ce,L.depth,0,Ke,Ie,null):n.texImage2D(ve,ge,ze,Fe,ce,0,Ke,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ve,r.get(X).__webglTexture,0,le(L)):(ve===t.TEXTURE_2D||ve>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ve<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,ve,r.get(X).__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(U,L,X){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let me=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(X||Ae(L)){const ve=L.depthTexture;ve&&ve.isDepthTexture&&(ve.type===ac?me=t.DEPTH_COMPONENT32F:ve.type===ju&&(me=t.DEPTH_COMPONENT24));const ge=le(L);Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,me,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,me,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,me,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const me=le(L);X&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const me=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ve=0;ve<me.length;ve++){const ge=me[ve],Ke=s.convert(ge.format,ge.colorSpace),Ie=s.convert(ge.type),ze=I(ge.internalFormat,Ke,Ie,ge.colorSpace),at=le(L);X&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,at,ze,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,at,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ct(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!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),ee(L.depthTexture,0);const me=r.get(L.depthTexture).__webglTexture,ve=le(L);if(L.depthTexture.format===pf)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0);else if(L.depthTexture.format===lm)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function B(U){const L=r.get(U),X=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");ct(L.__webglFramebuffer,U)}else if(X){L.__webglDepthbuffer=[];for(let me=0;me<6;me++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[me]),L.__webglDepthbuffer[me]=t.createRenderbuffer(),ue(L.__webglDepthbuffer[me],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ue(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function F(U,L,X){const me=r.get(U);L!==void 0&&Re(me.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),X!==void 0&&B(U)}function ie(U){const L=U.texture,X=r.get(U),me=r.get(L);U.addEventListener("dispose",j),U.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=L.version,a.memory.textures++);const ve=U.isWebGLCubeRenderTarget===!0,ge=U.isWebGLMultipleRenderTargets===!0,Ke=A(U)||o;if(ve){X.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer[Ie]=[];for(let ze=0;ze<L.mipmaps.length;ze++)X.__webglFramebuffer[Ie][ze]=t.createFramebuffer()}else X.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){X.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)X.__webglFramebuffer[Ie]=t.createFramebuffer()}else X.__webglFramebuffer=t.createFramebuffer();if(ge)if(i.drawBuffers){const Ie=U.texture;for(let ze=0,at=Ie.length;ze<at;ze++){const Fe=r.get(Ie[ze]);Fe.__webglTexture===void 0&&(Fe.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&U.samples>0&&Ae(U)===!1){const Ie=ge?L:[L];X.__webglMultisampledFramebuffer=t.createFramebuffer(),X.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let ze=0;ze<Ie.length;ze++){const at=Ie[ze];X.__webglColorRenderbuffer[ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,X.__webglColorRenderbuffer[ze]);const Fe=s.convert(at.format,at.colorSpace),ce=s.convert(at.type),Qe=I(at.internalFormat,Fe,ce,at.colorSpace,U.isXRRenderTarget===!0),He=le(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,Qe,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ze,t.RENDERBUFFER,X.__webglColorRenderbuffer[ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(X.__webglDepthRenderbuffer=t.createRenderbuffer(),ue(X.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),pe(t.TEXTURE_CUBE_MAP,L,Ke);for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)Re(X.__webglFramebuffer[Ie][ze],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,ze);else Re(X.__webglFramebuffer[Ie],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);R(L,Ke)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ge){const Ie=U.texture;for(let ze=0,at=Ie.length;ze<at;ze++){const Fe=Ie[ze],ce=r.get(Fe);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture),pe(t.TEXTURE_2D,Fe,Ke),Re(X.__webglFramebuffer,U,Fe,t.COLOR_ATTACHMENT0+ze,t.TEXTURE_2D,0),R(Fe,Ke)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(o?Ie=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ie,me.__webglTexture),pe(Ie,L,Ke),o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)Re(X.__webglFramebuffer[ze],U,L,t.COLOR_ATTACHMENT0,Ie,ze);else Re(X.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ie,0);R(L,Ke)&&C(Ie),n.unbindTexture()}U.depthBuffer&&B(U)}function V(U){const L=A(U)||o,X=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let me=0,ve=X.length;me<ve;me++){const ge=X[me];if(R(ge,L)){const Ke=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ie=r.get(ge).__webglTexture;n.bindTexture(Ke,Ie),C(Ke),n.unbindTexture()}}}function J(U){if(o&&U.samples>0&&Ae(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],X=U.width,me=U.height;let ve=t.COLOR_BUFFER_BIT;const ge=[],Ke=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=r.get(U),ze=U.isWebGLMultipleRenderTargets===!0;if(ze)for(let at=0;at<L.length;at++)n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let at=0;at<L.length;at++){ge.push(t.COLOR_ATTACHMENT0+at),U.depthBuffer&&ge.push(Ke);const Fe=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(Fe===!1&&(U.depthBuffer&&(ve|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(ve|=t.STENCIL_BUFFER_BIT)),ze&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[at]),Fe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ke]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ke])),ze){const ce=r.get(L[at]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ce,0)}t.blitFramebuffer(0,0,X,me,0,0,X,me,ve,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ge)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ze)for(let at=0;at<L.length;at++){n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[at]);const Fe=r.get(L[at]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+at,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function le(U){return Math.min(h,U.samples)}function Ae(U){const L=r.get(U);return o&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ee(U){const L=a.render.frame;v.get(U)!==L&&(v.set(U,L),U.update())}function se(U,L){const X=U.colorSpace,me=U.format,ve=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===X3||X!==_c&&X!==Ga&&($n.getTransfer(X)===sr?o===!1?e.has("EXT_sRGB")===!0&&me===Va?(U.format=X3,U.minFilter=$a,U.generateMipmaps=!1):L=P7.sRGBToLinear(L):(me!==Va||ve!==Gu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),L}this.allocateTextureUnit=Z,this.resetTextureUnits=G,this.setTexture2D=ee,this.setTexture2DArray=H,this.setTexture3D=q,this.setTextureCube=te,this.rebindTextures=F,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=Ae}function Z_e(t,e,n){const r=n.isWebGL2;function i(s,a=Ga){let o;const l=$n.getTransfer(a);if(s===Gu)return t.UNSIGNED_BYTE;if(s===_7)return t.UNSIGNED_SHORT_4_4_4_4;if(s===S7)return t.UNSIGNED_SHORT_5_5_5_1;if(s===_xe)return t.BYTE;if(s===Sxe)return t.SHORT;if(s===kP)return t.UNSIGNED_SHORT;if(s===y7)return t.INT;if(s===ju)return t.UNSIGNED_INT;if(s===ac)return t.FLOAT;if(s===f0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===wxe)return t.ALPHA;if(s===Va)return t.RGBA;if(s===Mxe)return t.LUMINANCE;if(s===Exe)return t.LUMINANCE_ALPHA;if(s===pf)return t.DEPTH_COMPONENT;if(s===lm)return t.DEPTH_STENCIL;if(s===X3)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Axe)return t.RED;if(s===w7)return t.RED_INTEGER;if(s===Txe)return t.RG;if(s===M7)return t.RG_INTEGER;if(s===E7)return t.RGBA_INTEGER;if(s===DA||s===OA||s===LA||s===jA)if(l===sr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===DA)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===OA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===LA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===jA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===DA)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===OA)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===LA)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===jA)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===z5||s===B5||s===H5||s===$5)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===z5)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===B5)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===H5)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===$5)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===A7)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===V5||s===G5)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===V5)return l===sr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===G5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===W5||s===q5||s===X5||s===K5||s===Y5||s===Z5||s===Q5||s===J5||s===ez||s===tz||s===nz||s===rz||s===iz||s===sz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===W5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===q5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===X5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===K5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Y5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Z5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Q5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===J5)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===ez)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===tz)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===nz)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===rz)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===iz)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===sz)return l===sr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===IA||s===az||s===oz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===IA)return l===sr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===az)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===oz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Cxe||s===lz||s===cz||s===uz)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===IA)return o.COMPRESSED_RED_RGTC1_EXT;if(s===lz)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===cz)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===uz)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===hf?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class Q_e extends da{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class bx extends Ms{constructor(){super(),this.isGroup=!0,this.type="Group"}}const J_e={type:"move"};class aT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new bx,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 bx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ke,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ke),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new bx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ke,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ke),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,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),x=this._getHandJoint(c,y);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 d=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=d.position.distanceTo(h.position),m=.02,v=.005;c.inputState.pinching&&g>m+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),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(J_e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new bx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class e1e extends eh{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,g=null,m=null,v=null;const y=n.getContextAttributes();let b=null,x=null;const M=[],w=[],A=new Kt;let T=null;const R=new da;R.layers.enable(1),R.viewport=new Gn;const C=new da;C.layers.enable(2),C.viewport=new Gn;const I=[R,C],N=new Q_e;N.layers.enable(1),N.layers.enable(2);let D=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let ae=M[te];return ae===void 0&&(ae=new aT,M[te]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(te){let ae=M[te];return ae===void 0&&(ae=new aT,M[te]=ae),ae.getGripSpace()},this.getHand=function(te){let ae=M[te];return ae===void 0&&(ae=new aT,M[te]=ae),ae.getHandSpace()};function j(te){const ae=w.indexOf(te.inputSource);if(ae===-1)return;const xe=M[ae];xe!==void 0&&(xe.update(te.inputSource,te.frame,c||a),xe.dispatchEvent({type:te.type,data:te.inputSource}))}function W(){i.removeEventListener("select",j),i.removeEventListener("selectstart",j),i.removeEventListener("selectend",j),i.removeEventListener("squeeze",j),i.removeEventListener("squeezestart",j),i.removeEventListener("squeezeend",j),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",P);for(let te=0;te<M.length;te++){const ae=w[te];ae!==null&&(w[te]=null,M[te].disconnect(ae))}D=null,z=null,e.setRenderTarget(b),m=null,g=null,h=null,i=null,x=null,q.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){s=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){o=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(te){c=te},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h},this.getFrame=function(){return v},this.getSession=function(){return i},this.setSession=async function(te){if(i=te,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",j),i.addEventListener("selectstart",j),i.addEventListener("selectend",j),i.addEventListener("squeeze",j),i.addEventListener("squeezestart",j),i.addEventListener("squeezeend",j),i.addEventListener("end",W),i.addEventListener("inputsourceschange",P),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new Uf(m.framebufferWidth,m.framebufferHeight,{format:Va,type:Gu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,xe=null,re=null;y.depth&&(re=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?lm:pf,xe=y.stencil?hf:ju);const pe={colorFormat:n.RGBA8,depthFormat:re,scaleFactor:s};h=new XRWebGLBinding(i,n),g=h.createProjectionLayer(pe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),x=new Uf(g.textureWidth,g.textureHeight,{format:Va,type:Gu,depthTexture:new V7(g.textureWidth,g.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ce=e.properties.get(x);Ce.__ignoreDepthValues=g.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),q.setContext(i),q.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function P(te){for(let ae=0;ae<te.removed.length;ae++){const xe=te.removed[ae],re=w.indexOf(xe);re>=0&&(w[re]=null,M[re].disconnect(xe))}for(let ae=0;ae<te.added.length;ae++){const xe=te.added[ae];let re=w.indexOf(xe);if(re===-1){for(let Ce=0;Ce<M.length;Ce++)if(Ce>=w.length){w.push(xe),re=Ce;break}else if(w[Ce]===null){w[Ce]=xe,re=Ce;break}if(re===-1)break}const pe=M[re];pe&&pe.connect(xe)}}const $=new ke,K=new ke;function G(te,ae,xe){$.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(xe.matrixWorld);const re=$.distanceTo(K),pe=ae.projectionMatrix.elements,Ce=xe.projectionMatrix.elements,fe=pe[14]/(pe[10]-1),Se=pe[14]/(pe[10]+1),Re=(pe[9]+1)/pe[5],ue=(pe[9]-1)/pe[5],ct=(pe[8]-1)/pe[0],B=(Ce[8]+1)/Ce[0],F=fe*ct,ie=fe*B,V=re/(-ct+B),J=V*-ct;ae.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(J),te.translateZ(V),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();const le=fe+V,Ae=Se+V,Ee=F-J,se=ie+(re-J),U=Re*Se/Ae*le,L=ue*Se/Ae*le;te.projectionMatrix.makePerspective(Ee,se,U,L,le,Ae),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}function Z(te,ae){ae===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(ae.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(i===null)return;N.near=C.near=R.near=te.near,N.far=C.far=R.far=te.far,(D!==N.near||z!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),D=N.near,z=N.far);const ae=te.parent,xe=N.cameras;Z(N,ae);for(let re=0;re<xe.length;re++)Z(xe[re],ae);xe.length===2?G(N,R,C):N.projectionMatrix.copy(R.projectionMatrix),Q(te,N,ae)};function Q(te,ae,xe){xe===null?te.matrix.copy(ae.matrixWorld):(te.matrix.copy(xe.matrixWorld),te.matrix.invert(),te.matrix.multiply(ae.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(ae.projectionMatrix),te.projectionMatrixInverse.copy(ae.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=p0*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return N},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)};let ee=null;function H(te,ae){if(d=ae.getViewerPose(c||a),v=ae,d!==null){const xe=d.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let re=!1;xe.length!==N.cameras.length&&(N.cameras.length=0,re=!0);for(let pe=0;pe<xe.length;pe++){const Ce=xe[pe];let fe=null;if(m!==null)fe=m.getViewport(Ce);else{const Re=h.getViewSubImage(g,Ce);fe=Re.viewport,pe===0&&(e.setRenderTargetTextures(x,Re.colorTexture,g.ignoreDepthValues?void 0:Re.depthStencilTexture),e.setRenderTarget(x))}let Se=I[pe];Se===void 0&&(Se=new da,Se.layers.enable(pe),Se.viewport=new Gn,I[pe]=Se),Se.matrix.fromArray(Ce.transform.matrix),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.projectionMatrix.fromArray(Ce.projectionMatrix),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert(),Se.viewport.set(fe.x,fe.y,fe.width,fe.height),pe===0&&(N.matrix.copy(Se.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),re===!0&&N.cameras.push(Se)}}for(let xe=0;xe<M.length;xe++){const re=w[xe],pe=M[xe];re!==null&&pe!==void 0&&pe.update(re,ae,c||a)}ee&&ee(te,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),v=null}const q=new $7;q.setAnimationLoop(H),this.setAnimationLoop=function(te){ee=te},this.dispose=function(){}}}function t1e(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,z7(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?s(b,x):x.isMeshToonMaterial?(s(b,x),h(b,x)):x.isMeshPhongMaterial?(s(b,x),d(b,x)):x.isMeshStandardMaterial?(s(b,x),g(b,x),x.isMeshPhysicalMaterial&&m(b,x,A)):x.isMeshMatcapMaterial?(s(b,x),v(b,x)):x.isMeshDepthMaterial?s(b,x):x.isMeshDistanceMaterial?(s(b,x),y(b,x)):x.isMeshNormalMaterial?s(b,x):x.isLineBasicMaterial?(a(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 s(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===Vs&&(b.bumpScale.value*=-1)),x.normalMap&&(b.normalMap.value=x.normalMap,n(x.normalMap,b.normalMapTransform),b.normalScale.value.copy(x.normalScale),x.side===Vs&&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 a(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 d(b,x){b.specular.value.copy(x.specular),b.shininess.value=Math.max(x.shininess,1e-4)}function h(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===Vs&&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 v(b,x){x.matcap&&(b.matcap.value=x.matcap)}function y(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 n1e(t,e,n,r){let i={},s={},a=[];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&&(v(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",b));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;s[M.id]!==R&&(g(M),s[M.id]=R)}function d(M){const w=h();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 h(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.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,C=A.length;R<C;R++){const I=A[R];if(m(I,R,T)===!0){const N=I.__offset,D=Array.isArray(I.value)?I.value:[I.value];let z=0;for(let j=0;j<D.length;j++){const W=D[j],P=y(W);typeof W=="number"?(I.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,N+z,I.__data)):W.isMatrix3?(I.__data[0]=W.elements[0],I.__data[1]=W.elements[1],I.__data[2]=W.elements[2],I.__data[3]=W.elements[0],I.__data[4]=W.elements[3],I.__data[5]=W.elements[4],I.__data[6]=W.elements[5],I.__data[7]=W.elements[0],I.__data[8]=W.elements[6],I.__data[9]=W.elements[7],I.__data[10]=W.elements[8],I.__data[11]=W.elements[0]):(W.toArray(I.__data,z),z+=P.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,I.__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],C=[];for(let I=0;I<R.length;I++)C.push(R[I].clone());A[w]=C}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]],C=Array.isArray(T)?T:[T];for(let I=0;I<R.length;I++){const N=R[I];if(N.equals(C[I])===!1)return N.copy(C[I]),!0}}return!1}function v(M){const w=M.uniforms;let A=0;const T=16;let R=0;for(let C=0,I=w.length;C<I;C++){const N=w[C],D={boundary:0,storage:0},z=Array.isArray(N.value)?N.value:[N.value];for(let j=0,W=z.length;j<W;j++){const P=z[j],$=y(P);D.boundary+=$.boundary,D.storage+=$.storage}if(N.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=A,C>0){R=A%T;const j=T-R;R!==0&&j-D.boundary<0&&(A+=T-R,N.__offset=A)}A+=D.storage}return R=A%T,R>0&&(A+=T-R),M.__size=A,M.__cache={},this}function y(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=a.indexOf(w.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);a=[],i={},s={}}return{bind:l,update:c,dispose:x}}class Z3{constructor(e={}){const{canvas:n=Jxe(),context:r=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=a;const m=new Uint32Array(4),v=new Int32Array(4);let y=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=qi,this._useLegacyLights=!1,this.toneMapping=Vu,this.toneMappingExposure=1;const w=this;let A=!1,T=0,R=0,C=null,I=-1,N=null;const D=new Gn,z=new Gn;let j=null;const W=new $t(0);let P=0,$=n.width,K=n.height,G=1,Z=null,Q=null;const ee=new Gn(0,0,$,K),H=new Gn(0,0,$,K);let q=!1;const te=new yw;let ae=!1,xe=!1,re=null;const pe=new tr,Ce=new Kt,fe=new ke,Se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return C===null?G:1}let ue=r;function ct(he,Be){for(let et=0;et<he.length;et++){const tt=he[et],Ze=n.getContext(tt,Be);if(Ze!==null)return Ze}return null}try{const he={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${xw}`),n.addEventListener("webglcontextlost",Je,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",je,!1),ue===null){const Be=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Be.shift(),ue=ct(Be,he),ue===null)throw ct(Be)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ue instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ue.getShaderPrecisionFormat===void 0&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw console.error("THREE.WebGLRenderer: "+he.message),he}let B,F,ie,V,J,le,Ae,Ee,se,U,L,X,me,ve,ge,Ke,Ie,ze,at,Fe,ce,Qe,He,Ye;function ut(){B=new hye(ue),F=new aye(ue,B,e),B.init(F),Qe=new Z_e(ue,B,F),ie=new K_e(ue,B,F),V=new gye(ue),J=new L_e,le=new Y_e(ue,B,ie,J,F,Qe,V),Ae=new lye(w),Ee=new fye(w),se=new w0e(ue,F),He=new iye(ue,B,se,F),U=new pye(ue,se,V,He),L=new yye(ue,U,se,V),at=new vye(ue,F,le),Ke=new oye(J),X=new O_e(w,Ae,Ee,B,F,He,Ke),me=new t1e(w,J),ve=new I_e,ge=new $_e(B,F),ze=new rye(w,Ae,Ee,ie,L,g,l),Ie=new X_e(w,L,F),Ye=new n1e(ue,V,F,ie),Fe=new sye(ue,B,V,F),ce=new mye(ue,B,V,F),V.programs=X.programs,w.capabilities=F,w.extensions=B,w.properties=J,w.renderLists=ve,w.shadowMap=Ie,w.state=ie,w.info=V}ut();const de=new e1e(w,ue);this.xr=de,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const he=B.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=B.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(he){he!==void 0&&(G=he,this.setSize($,K,!1))},this.getSize=function(he){return he.set($,K)},this.setSize=function(he,Be,et=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=he,K=Be,n.width=Math.floor(he*G),n.height=Math.floor(Be*G),et===!0&&(n.style.width=he+"px",n.style.height=Be+"px"),this.setViewport(0,0,he,Be)},this.getDrawingBufferSize=function(he){return he.set($*G,K*G).floor()},this.setDrawingBufferSize=function(he,Be,et){$=he,K=Be,G=et,n.width=Math.floor(he*et),n.height=Math.floor(Be*et),this.setViewport(0,0,he,Be)},this.getCurrentViewport=function(he){return he.copy(D)},this.getViewport=function(he){return he.copy(ee)},this.setViewport=function(he,Be,et,tt){he.isVector4?ee.set(he.x,he.y,he.z,he.w):ee.set(he,Be,et,tt),ie.viewport(D.copy(ee).multiplyScalar(G).floor())},this.getScissor=function(he){return he.copy(H)},this.setScissor=function(he,Be,et,tt){he.isVector4?H.set(he.x,he.y,he.z,he.w):H.set(he,Be,et,tt),ie.scissor(z.copy(H).multiplyScalar(G).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(he){ie.setScissorTest(q=he)},this.setOpaqueSort=function(he){Z=he},this.setTransparentSort=function(he){Q=he},this.getClearColor=function(he){return he.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor.apply(ze,arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha.apply(ze,arguments)},this.clear=function(he=!0,Be=!0,et=!0){let tt=0;if(he){let Ze=!1;if(C!==null){const _t=C.texture.format;Ze=_t===E7||_t===M7||_t===w7}if(Ze){const _t=C.texture.type,ne=_t===Gu||_t===ju||_t===kP||_t===hf||_t===_7||_t===S7,_e=ze.getClearColor(),De=ze.getClearAlpha(),Pe=_e.r,Me=_e.g,it=_e.b;ne?(m[0]=Pe,m[1]=Me,m[2]=it,m[3]=De,ue.clearBufferuiv(ue.COLOR,0,m)):(v[0]=Pe,v[1]=Me,v[2]=it,v[3]=De,ue.clearBufferiv(ue.COLOR,0,v))}else tt|=ue.COLOR_BUFFER_BIT}Be&&(tt|=ue.DEPTH_BUFFER_BIT),et&&(tt|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ue.clear(tt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Je,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",je,!1),ve.dispose(),ge.dispose(),J.dispose(),Ae.dispose(),Ee.dispose(),L.dispose(),He.dispose(),Ye.dispose(),X.dispose(),de.dispose(),de.removeEventListener("sessionstart",cn),de.removeEventListener("sessionend",jt),re&&(re.dispose(),re=null),Rn.stop()};function Je(he){he.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function be(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const he=V.autoReset,Be=Ie.enabled,et=Ie.autoUpdate,tt=Ie.needsUpdate,Ze=Ie.type;ut(),V.autoReset=he,Ie.enabled=Be,Ie.autoUpdate=et,Ie.needsUpdate=tt,Ie.type=Ze}function je(he){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Te(he){const Be=he.target;Be.removeEventListener("dispose",Te),ye(Be)}function ye(he){Ge(he),J.remove(he)}function Ge(he){const Be=J.get(he).programs;Be!==void 0&&(Be.forEach(function(et){X.releaseProgram(et)}),he.isShaderMaterial&&X.releaseShaderCache(he))}this.renderBufferDirect=function(he,Be,et,tt,Ze,_t){Be===null&&(Be=Se);const ne=Ze.isMesh&&Ze.matrixWorld.determinant()<0,_e=Nr(he,Be,et,tt,Ze);ie.setMaterial(tt,ne);let De=et.index,Pe=1;if(tt.wireframe===!0){if(De=U.getWireframeAttribute(et),De===void 0)return;Pe=2}const Me=et.drawRange,it=et.attributes.position;let ht=Me.start*Pe,bt=(Me.start+Me.count)*Pe;_t!==null&&(ht=Math.max(ht,_t.start*Pe),bt=Math.min(bt,(_t.start+_t.count)*Pe)),De!==null?(ht=Math.max(ht,0),bt=Math.min(bt,De.count)):it!=null&&(ht=Math.max(ht,0),bt=Math.min(bt,it.count));const xt=bt-ht;if(xt<0||xt===1/0)return;He.setup(Ze,tt,_e,et,De);let Pt,wt=Fe;if(De!==null&&(Pt=se.get(De),wt=ce,wt.setIndex(Pt)),Ze.isMesh)tt.wireframe===!0?(ie.setLineWidth(tt.wireframeLinewidth*Re()),wt.setMode(ue.LINES)):wt.setMode(ue.TRIANGLES);else if(Ze.isLine){let mt=tt.linewidth;mt===void 0&&(mt=1),ie.setLineWidth(mt*Re()),Ze.isLineSegments?wt.setMode(ue.LINES):Ze.isLineLoop?wt.setMode(ue.LINE_LOOP):wt.setMode(ue.LINE_STRIP)}else Ze.isPoints?wt.setMode(ue.POINTS):Ze.isSprite&&wt.setMode(ue.TRIANGLES);if(Ze.isBatchedMesh)wt.renderMultiDraw(Ze._multiDrawStarts,Ze._multiDrawCounts,Ze._multiDrawCount);else if(Ze.isInstancedMesh)wt.renderInstances(ht,xt,Ze.count);else if(et.isInstancedBufferGeometry){const mt=et._maxInstanceCount!==void 0?et._maxInstanceCount:1/0,qt=Math.min(et.instanceCount,mt);wt.renderInstances(ht,xt,qt)}else wt.render(ht,xt)};function ft(he,Be,et){he.transparent===!0&&he.side===Jl&&he.forceSinglePass===!1?(he.side=Vs,he.needsUpdate=!0,Qi(he,Be,et),he.side=ed,he.needsUpdate=!0,Qi(he,Be,et),he.side=Jl):Qi(he,Be,et)}this.compile=function(he,Be,et=null){et===null&&(et=he),b=ge.get(et),b.init(),M.push(b),et.traverseVisible(function(Ze){Ze.isLight&&Ze.layers.test(Be.layers)&&(b.pushLight(Ze),Ze.castShadow&&b.pushShadow(Ze))}),he!==et&&he.traverseVisible(function(Ze){Ze.isLight&&Ze.layers.test(Be.layers)&&(b.pushLight(Ze),Ze.castShadow&&b.pushShadow(Ze))}),b.setupLights(w._useLegacyLights);const tt=new Set;return he.traverse(function(Ze){const _t=Ze.material;if(_t)if(Array.isArray(_t))for(let ne=0;ne<_t.length;ne++){const _e=_t[ne];ft(_e,et,Ze),tt.add(_e)}else ft(_t,et,Ze),tt.add(_t)}),M.pop(),b=null,tt},this.compileAsync=function(he,Be,et=null){const tt=this.compile(he,Be,et);return new Promise(Ze=>{function _t(){if(tt.forEach(function(ne){J.get(ne).currentProgram.isReady()&&tt.delete(ne)}),tt.size===0){Ze(he);return}setTimeout(_t,10)}B.get("KHR_parallel_shader_compile")!==null?_t():setTimeout(_t,10)})};let yt=null;function Rt(he){yt&&yt(he)}function cn(){Rn.stop()}function jt(){Rn.start()}const Rn=new $7;Rn.setAnimationLoop(Rt),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(he){yt=he,de.setAnimationLoop(he),he===null?Rn.stop():Rn.start()},de.addEventListener("sessionstart",cn),de.addEventListener("sessionend",jt),this.render=function(he,Be){if(Be!==void 0&&Be.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Be.parent===null&&Be.matrixWorldAutoUpdate===!0&&Be.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera(Be),Be=de.getCamera()),he.isScene===!0&&he.onBeforeRender(w,he,Be,C),b=ge.get(he,M.length),b.init(),M.push(b),pe.multiplyMatrices(Be.projectionMatrix,Be.matrixWorldInverse),te.setFromProjectionMatrix(pe),xe=this.localClippingEnabled,ae=Ke.init(this.clippingPlanes,xe),y=ve.get(he,x.length),y.init(),x.push(y),qn(he,Be,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(Z,Q),this.info.render.frame++,ae===!0&&Ke.beginShadows();const et=b.state.shadowsArray;if(Ie.render(et,he,Be),ae===!0&&Ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),ze.render(y,he),b.setupLights(w._useLegacyLights),Be.isArrayCamera){const tt=Be.cameras;for(let Ze=0,_t=tt.length;Ze<_t;Ze++){const ne=tt[Ze];bi(y,he,ne,ne.viewport)}}else bi(y,he,Be);C!==null&&(le.updateMultisampleRenderTarget(C),le.updateRenderTargetMipmap(C)),he.isScene===!0&&he.onAfterRender(w,he,Be),He.resetDefaultState(),I=-1,N=null,M.pop(),M.length>0?b=M[M.length-1]:b=null,x.pop(),x.length>0?y=x[x.length-1]:y=null};function qn(he,Be,et,tt){if(he.visible===!1)return;if(he.layers.test(Be.layers)){if(he.isGroup)et=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(Be);else if(he.isLight)b.pushLight(he),he.castShadow&&b.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||te.intersectsSprite(he)){tt&&fe.setFromMatrixPosition(he.matrixWorld).applyMatrix4(pe);const ne=L.update(he),_e=he.material;_e.visible&&y.push(he,ne,_e,et,fe.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||te.intersectsObject(he))){const ne=L.update(he),_e=he.material;if(tt&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),fe.copy(he.boundingSphere.center)):(ne.boundingSphere===null&&ne.computeBoundingSphere(),fe.copy(ne.boundingSphere.center)),fe.applyMatrix4(he.matrixWorld).applyMatrix4(pe)),Array.isArray(_e)){const De=ne.groups;for(let Pe=0,Me=De.length;Pe<Me;Pe++){const it=De[Pe],ht=_e[it.materialIndex];ht&&ht.visible&&y.push(he,ne,ht,et,fe.z,it)}}else _e.visible&&y.push(he,ne,_e,et,fe.z,null)}}const _t=he.children;for(let ne=0,_e=_t.length;ne<_e;ne++)qn(_t[ne],Be,et,tt)}function bi(he,Be,et,tt){const Ze=he.opaque,_t=he.transmissive,ne=he.transparent;b.setupLightsView(et),ae===!0&&Ke.setGlobalState(w.clippingPlanes,et),_t.length>0&&ti(Ze,_t,Be,et),tt&&ie.viewport(D.copy(tt)),Ze.length>0&&vi(Ze,Be,et),_t.length>0&&vi(_t,Be,et),ne.length>0&&vi(ne,Be,et),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function ti(he,Be,et,tt){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;const _t=F.isWebGL2;re===null&&(re=new Uf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?f0:Gu,minFilter:d0,samples:_t?4:0})),w.getDrawingBufferSize(Ce),_t?re.setSize(Ce.x,Ce.y):re.setSize(p1(Ce.x),p1(Ce.y));const ne=w.getRenderTarget();w.setRenderTarget(re),w.getClearColor(W),P=w.getClearAlpha(),P<1&&w.setClearColor(16777215,.5),w.clear();const _e=w.toneMapping;w.toneMapping=Vu,vi(he,et,tt),le.updateMultisampleRenderTarget(re),le.updateRenderTargetMipmap(re);let De=!1;for(let Pe=0,Me=Be.length;Pe<Me;Pe++){const it=Be[Pe],ht=it.object,bt=it.geometry,xt=it.material,Pt=it.group;if(xt.side===Jl&&ht.layers.test(tt.layers)){const wt=xt.side;xt.side=Vs,xt.needsUpdate=!0,Li(ht,et,tt,bt,xt,Pt),xt.side=wt,xt.needsUpdate=!0,De=!0}}De===!0&&(le.updateMultisampleRenderTarget(re),le.updateRenderTargetMipmap(re)),w.setRenderTarget(ne),w.setClearColor(W,P),w.toneMapping=_e}function vi(he,Be,et){const tt=Be.isScene===!0?Be.overrideMaterial:null;for(let Ze=0,_t=he.length;Ze<_t;Ze++){const ne=he[Ze],_e=ne.object,De=ne.geometry,Pe=tt===null?ne.material:tt,Me=ne.group;_e.layers.test(et.layers)&&Li(_e,Be,et,De,Pe,Me)}}function Li(he,Be,et,tt,Ze,_t){he.onBeforeRender(w,Be,et,tt,Ze,_t),he.modelViewMatrix.multiplyMatrices(et.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),Ze.onBeforeRender(w,Be,et,tt,he,_t),Ze.transparent===!0&&Ze.side===Jl&&Ze.forceSinglePass===!1?(Ze.side=Vs,Ze.needsUpdate=!0,w.renderBufferDirect(et,Be,tt,Ze,he,_t),Ze.side=ed,Ze.needsUpdate=!0,w.renderBufferDirect(et,Be,tt,Ze,he,_t),Ze.side=Jl):w.renderBufferDirect(et,Be,tt,Ze,he,_t),he.onAfterRender(w,Be,et,tt,Ze,_t)}function Qi(he,Be,et){Be.isScene!==!0&&(Be=Se);const tt=J.get(he),Ze=b.state.lights,_t=b.state.shadowsArray,ne=Ze.state.version,_e=X.getParameters(he,Ze.state,_t,Be,et),De=X.getProgramCacheKey(_e);let Pe=tt.programs;tt.environment=he.isMeshStandardMaterial?Be.environment:null,tt.fog=Be.fog,tt.envMap=(he.isMeshStandardMaterial?Ee:Ae).get(he.envMap||tt.environment),Pe===void 0&&(he.addEventListener("dispose",Te),Pe=new Map,tt.programs=Pe);let Me=Pe.get(De);if(Me!==void 0){if(tt.currentProgram===Me&&tt.lightsStateVersion===ne)return mr(he,_e),Me}else _e.uniforms=X.getUniforms(he),he.onBuild(et,_e,w),he.onBeforeCompile(_e,w),Me=X.acquireProgram(_e,De),Pe.set(De,Me),tt.uniforms=_e.uniforms;const it=tt.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(it.clippingPlanes=Ke.uniform),mr(he,_e),tt.needsLights=Ic(he),tt.lightsStateVersion=ne,tt.needsLights&&(it.ambientLightColor.value=Ze.state.ambient,it.lightProbe.value=Ze.state.probe,it.directionalLights.value=Ze.state.directional,it.directionalLightShadows.value=Ze.state.directionalShadow,it.spotLights.value=Ze.state.spot,it.spotLightShadows.value=Ze.state.spotShadow,it.rectAreaLights.value=Ze.state.rectArea,it.ltc_1.value=Ze.state.rectAreaLTC1,it.ltc_2.value=Ze.state.rectAreaLTC2,it.pointLights.value=Ze.state.point,it.pointLightShadows.value=Ze.state.pointShadow,it.hemisphereLights.value=Ze.state.hemi,it.directionalShadowMap.value=Ze.state.directionalShadowMap,it.directionalShadowMatrix.value=Ze.state.directionalShadowMatrix,it.spotShadowMap.value=Ze.state.spotShadowMap,it.spotLightMatrix.value=Ze.state.spotLightMatrix,it.spotLightMap.value=Ze.state.spotLightMap,it.pointShadowMap.value=Ze.state.pointShadowMap,it.pointShadowMatrix.value=Ze.state.pointShadowMatrix),tt.currentProgram=Me,tt.uniformsList=null,Me}function Ir(he){if(he.uniformsList===null){const Be=he.currentProgram.getUniforms();he.uniformsList=L_.seqWithValue(Be.seq,he.uniforms)}return he.uniformsList}function mr(he,Be){const et=J.get(he);et.outputColorSpace=Be.outputColorSpace,et.batching=Be.batching,et.instancing=Be.instancing,et.instancingColor=Be.instancingColor,et.skinning=Be.skinning,et.morphTargets=Be.morphTargets,et.morphNormals=Be.morphNormals,et.morphColors=Be.morphColors,et.morphTargetsCount=Be.morphTargetsCount,et.numClippingPlanes=Be.numClippingPlanes,et.numIntersection=Be.numClipIntersection,et.vertexAlphas=Be.vertexAlphas,et.vertexTangents=Be.vertexTangents,et.toneMapping=Be.toneMapping}function Nr(he,Be,et,tt,Ze){Be.isScene!==!0&&(Be=Se),le.resetTextureUnits();const _t=Be.fog,ne=tt.isMeshStandardMaterial?Be.environment:null,_e=C===null?w.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:_c,De=(tt.isMeshStandardMaterial?Ee:Ae).get(tt.envMap||ne),Pe=tt.vertexColors===!0&&!!et.attributes.color&&et.attributes.color.itemSize===4,Me=!!et.attributes.tangent&&(!!tt.normalMap||tt.anisotropy>0),it=!!et.morphAttributes.position,ht=!!et.morphAttributes.normal,bt=!!et.morphAttributes.color;let xt=Vu;tt.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(xt=w.toneMapping);const Pt=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,wt=Pt!==void 0?Pt.length:0,mt=J.get(tt),qt=b.state.lights;if(ae===!0&&(xe===!0||he!==N)){const kr=he===N&&tt.id===I;Ke.setState(tt,he,kr)}let Ut=!1;tt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==qt.state.version||mt.outputColorSpace!==_e||Ze.isBatchedMesh&&mt.batching===!1||!Ze.isBatchedMesh&&mt.batching===!0||Ze.isInstancedMesh&&mt.instancing===!1||!Ze.isInstancedMesh&&mt.instancing===!0||Ze.isSkinnedMesh&&mt.skinning===!1||!Ze.isSkinnedMesh&&mt.skinning===!0||Ze.isInstancedMesh&&mt.instancingColor===!0&&Ze.instanceColor===null||Ze.isInstancedMesh&&mt.instancingColor===!1&&Ze.instanceColor!==null||mt.envMap!==De||tt.fog===!0&&mt.fog!==_t||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Ke.numPlanes||mt.numIntersection!==Ke.numIntersection)||mt.vertexAlphas!==Pe||mt.vertexTangents!==Me||mt.morphTargets!==it||mt.morphNormals!==ht||mt.morphColors!==bt||mt.toneMapping!==xt||F.isWebGL2===!0&&mt.morphTargetsCount!==wt)&&(Ut=!0):(Ut=!0,mt.__version=tt.version);let nn=mt.currentProgram;Ut===!0&&(nn=Qi(tt,Be,Ze));let dn=!1,gn=!1,It=!1;const Yt=nn.getUniforms(),Jt=mt.uniforms;if(ie.useProgram(nn.program)&&(dn=!0,gn=!0,It=!0),tt.id!==I&&(I=tt.id,gn=!0),dn||N!==he){Yt.setValue(ue,"projectionMatrix",he.projectionMatrix),Yt.setValue(ue,"viewMatrix",he.matrixWorldInverse);const kr=Yt.map.cameraPosition;kr!==void 0&&kr.setValue(ue,fe.setFromMatrixPosition(he.matrixWorld)),F.logarithmicDepthBuffer&&Yt.setValue(ue,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(tt.isMeshPhongMaterial||tt.isMeshToonMaterial||tt.isMeshLambertMaterial||tt.isMeshBasicMaterial||tt.isMeshStandardMaterial||tt.isShaderMaterial)&&Yt.setValue(ue,"isOrthographic",he.isOrthographicCamera===!0),N!==he&&(N=he,gn=!0,It=!0)}if(Ze.isSkinnedMesh){Yt.setOptional(ue,Ze,"bindMatrix"),Yt.setOptional(ue,Ze,"bindMatrixInverse");const kr=Ze.skeleton;kr&&(F.floatVertexTextures?(kr.boneTexture===null&&kr.computeBoneTexture(),Yt.setValue(ue,"boneTexture",kr.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."))}Ze.isBatchedMesh&&(Yt.setOptional(ue,Ze,"batchingTexture"),Yt.setValue(ue,"batchingTexture",Ze._matricesTexture,le));const Sr=et.morphAttributes;if((Sr.position!==void 0||Sr.normal!==void 0||Sr.color!==void 0&&F.isWebGL2===!0)&&at.update(Ze,et,nn),(gn||mt.receiveShadow!==Ze.receiveShadow)&&(mt.receiveShadow=Ze.receiveShadow,Yt.setValue(ue,"receiveShadow",Ze.receiveShadow)),tt.isMeshGouraudMaterial&&tt.envMap!==null&&(Jt.envMap.value=De,Jt.flipEnvMap.value=De.isCubeTexture&&De.isRenderTargetTexture===!1?-1:1),gn&&(Yt.setValue(ue,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&so(Jt,It),_t&&tt.fog===!0&&me.refreshFogUniforms(Jt,_t),me.refreshMaterialUniforms(Jt,tt,G,K,re),L_.upload(ue,Ir(mt),Jt,le)),tt.isShaderMaterial&&tt.uniformsNeedUpdate===!0&&(L_.upload(ue,Ir(mt),Jt,le),tt.uniformsNeedUpdate=!1),tt.isSpriteMaterial&&Yt.setValue(ue,"center",Ze.center),Yt.setValue(ue,"modelViewMatrix",Ze.modelViewMatrix),Yt.setValue(ue,"normalMatrix",Ze.normalMatrix),Yt.setValue(ue,"modelMatrix",Ze.matrixWorld),tt.isShaderMaterial||tt.isRawShaderMaterial){const kr=tt.uniformsGroups;for(let kn=0,ao=kr.length;kn<ao;kn++)if(F.isWebGL2){const Pn=kr[kn];Ye.update(Pn,nn),Ye.bind(Pn,nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return nn}function so(he,Be){he.ambientLightColor.needsUpdate=Be,he.lightProbe.needsUpdate=Be,he.directionalLights.needsUpdate=Be,he.directionalLightShadows.needsUpdate=Be,he.pointLights.needsUpdate=Be,he.pointLightShadows.needsUpdate=Be,he.spotLights.needsUpdate=Be,he.spotLightShadows.needsUpdate=Be,he.rectAreaLights.needsUpdate=Be,he.hemisphereLights.needsUpdate=Be}function Ic(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(he,Be,et){J.get(he.texture).__webglTexture=Be,J.get(he.depthTexture).__webglTexture=et;const tt=J.get(he);tt.__hasExternalTextures=!0,tt.__hasExternalTextures&&(tt.__autoAllocateDepthBuffer=et===void 0,tt.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),tt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,Be){const et=J.get(he);et.__webglFramebuffer=Be,et.__useDefaultFramebuffer=Be===void 0},this.setRenderTarget=function(he,Be=0,et=0){C=he,T=Be,R=et;let tt=!0,Ze=null,_t=!1,ne=!1;if(he){const De=J.get(he);De.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(ue.FRAMEBUFFER,null),tt=!1):De.__webglFramebuffer===void 0?le.setupRenderTarget(he):De.__hasExternalTextures&&le.rebindTextures(he,J.get(he.texture).__webglTexture,J.get(he.depthTexture).__webglTexture);const Pe=he.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(ne=!0);const Me=J.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Me[Be])?Ze=Me[Be][et]:Ze=Me[Be],_t=!0):F.isWebGL2&&he.samples>0&&le.useMultisampledRTT(he)===!1?Ze=J.get(he).__webglMultisampledFramebuffer:Array.isArray(Me)?Ze=Me[et]:Ze=Me,D.copy(he.viewport),z.copy(he.scissor),j=he.scissorTest}else D.copy(ee).multiplyScalar(G).floor(),z.copy(H).multiplyScalar(G).floor(),j=q;if(ie.bindFramebuffer(ue.FRAMEBUFFER,Ze)&&F.drawBuffers&&tt&&ie.drawBuffers(he,Ze),ie.viewport(D),ie.scissor(z),ie.setScissorTest(j),_t){const De=J.get(he.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+Be,De.__webglTexture,et)}else if(ne){const De=J.get(he.texture),Pe=Be||0;ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,De.__webglTexture,et||0,Pe)}I=-1},this.readRenderTargetPixels=function(he,Be,et,tt,Ze,_t,ne){if(!(he&&he.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=J.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&ne!==void 0&&(_e=_e[ne]),_e){ie.bindFramebuffer(ue.FRAMEBUFFER,_e);try{const De=he.texture,Pe=De.format,Me=De.type;if(Pe!==Va&&Qe.convert(Pe)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const it=Me===f0&&(B.has("EXT_color_buffer_half_float")||F.isWebGL2&&B.has("EXT_color_buffer_float"));if(Me!==Gu&&Qe.convert(Me)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Me===ac&&(F.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!it){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Be>=0&&Be<=he.width-tt&&et>=0&&et<=he.height-Ze&&ue.readPixels(Be,et,tt,Ze,Qe.convert(Pe),Qe.convert(Me),_t)}finally{const De=C!==null?J.get(C).__webglFramebuffer:null;ie.bindFramebuffer(ue.FRAMEBUFFER,De)}}},this.copyFramebufferToTexture=function(he,Be,et=0){const tt=Math.pow(2,-et),Ze=Math.floor(Be.image.width*tt),_t=Math.floor(Be.image.height*tt);le.setTexture2D(Be,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,et,0,0,he.x,he.y,Ze,_t),ie.unbindTexture()},this.copyTextureToTexture=function(he,Be,et,tt=0){const Ze=Be.image.width,_t=Be.image.height,ne=Qe.convert(et.format),_e=Qe.convert(et.type);le.setTexture2D(et,0),ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,et.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,et.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,et.unpackAlignment),Be.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,tt,he.x,he.y,Ze,_t,ne,_e,Be.image.data):Be.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,tt,he.x,he.y,Be.mipmaps[0].width,Be.mipmaps[0].height,ne,Be.mipmaps[0].data):ue.texSubImage2D(ue.TEXTURE_2D,tt,he.x,he.y,ne,_e,Be.image),tt===0&&et.generateMipmaps&&ue.generateMipmap(ue.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(he,Be,et,tt,Ze=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const _t=he.max.x-he.min.x+1,ne=he.max.y-he.min.y+1,_e=he.max.z-he.min.z+1,De=Qe.convert(tt.format),Pe=Qe.convert(tt.type);let Me;if(tt.isData3DTexture)le.setTexture3D(tt,0),Me=ue.TEXTURE_3D;else if(tt.isDataArrayTexture)le.setTexture2DArray(tt,0),Me=ue.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,tt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,tt.unpackAlignment);const it=ue.getParameter(ue.UNPACK_ROW_LENGTH),ht=ue.getParameter(ue.UNPACK_IMAGE_HEIGHT),bt=ue.getParameter(ue.UNPACK_SKIP_PIXELS),xt=ue.getParameter(ue.UNPACK_SKIP_ROWS),Pt=ue.getParameter(ue.UNPACK_SKIP_IMAGES),wt=et.isCompressedTexture?et.mipmaps[0]:et.image;ue.pixelStorei(ue.UNPACK_ROW_LENGTH,wt.width),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,wt.height),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,he.min.x),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,he.min.y),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,he.min.z),et.isDataTexture||et.isData3DTexture?ue.texSubImage3D(Me,Ze,Be.x,Be.y,Be.z,_t,ne,_e,De,Pe,wt.data):et.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(Me,Ze,Be.x,Be.y,Be.z,_t,ne,_e,De,wt.data)):ue.texSubImage3D(Me,Ze,Be.x,Be.y,Be.z,_t,ne,_e,De,Pe,wt),ue.pixelStorei(ue.UNPACK_ROW_LENGTH,it),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,ht),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,bt),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,xt),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,Pt),Ze===0&&tt.generateMipmaps&&ue.generateMipmap(Me),ie.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?le.setTextureCube(he,0):he.isData3DTexture?le.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?le.setTexture2DArray(he,0):le.setTexture2D(he,0),ie.unbindTexture()},this.resetState=function(){T=0,R=0,C=null,ie.reset(),He.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return el}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===RP?"display-p3":"srgb",n.unpackColorSpace=$n.workingColorSpace===vw?"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===qi?mf:T7}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===mf?qi:_c}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 r1e extends Z3{}r1e.prototype.isWebGL1Renderer=!0;class IP{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new $t(e),this.near=n,this.far=r}clone(){return new IP(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class i1e extends Ms{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 s1e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=q3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=hc()}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,s=this.stride;i<s;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=hc()),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=hc()),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 ms=new ke;class Iu{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++)ms.fromBufferAttribute(this,n),ms.applyMatrix4(e),this.setXYZ(n,ms.x,ms.y,ms.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ms.fromBufferAttribute(this,n),ms.applyNormalMatrix(e),this.setXYZ(n,ms.x,ms.y,ms.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ms.fromBufferAttribute(this,n),ms.transformDirection(e),this.setXYZ(n,ms.x,ms.y,ms.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=Yo(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Yo(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Yo(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Yo(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,s){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),s=Hn(s,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]=s,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 s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new ga(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 Iu(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 s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}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 a1e extends Gs{constructor(e=null,n=1,r=1,i,s,a,o,l,c=Wi,d=Wi,h,g){super(null,a,o,l,c,d,i,s,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function o1e(t,e){return t.z-e.z}function l1e(t,e){return e.z-t.z}class c1e{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 s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const gp="batchId",bu=new tr,Qz=new tr,u1e=new tr,Jz=new tr,oT=new yw,Iy=new Za,Vd=new nl,nx=new ke,lT=new c1e,is=new Mo,Uy=[];function d1e(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let a=0;a<r;a++)e.setComponent(s+n,a,t.getComponent(s,a))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class f1e extends Mo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ds,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 a1e(n,e,e,Va,ac);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:d,normalized:h}=l,g=new c.constructor(r*d),m=new l.constructor(g,d,h);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new ga(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(gp,new ga(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(gp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${gp}"`);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===gp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.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 Za);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,bu),this.getBoundingBoxAt(i,Iy).applyMatrix4(bu),n.union(Iy))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nl);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,bu),this.getBoundingSphereAt(i,Vd).applyMatrix4(bu),n.union(Vd))}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 s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),d=c!==null;if(d&&(r===-1?i.indexCount=c.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.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 h=this._visibility,g=this._active,m=this._matricesTexture,v=this._matricesTexture.image.data;h.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,u1e.toArray(v,y*16),m.needsUpdate=!0,a.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Za,sphereInitialized:!1,sphere:new nl});const b=this.geometry.getAttribute(gp);for(let x=0;x<i.vertexCount;x++)b.setX(i.vertexStart+x,y);return b.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),a=n.getIndex(),o=this._reservedRanges[e];if(i&&a.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===gp)continue;const v=n.getAttribute(m),y=r.getAttribute(m);d1e(v,y,l);const b=v.itemSize;for(let x=v.count,M=c;x<M;x++){const w=l+x;for(let A=0;A<b;A++)y.setComponent(w,A,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let v=0;v<a.count;v++)s.setX(m+v,l+a.getX(v));for(let v=a.count,y=o.indexCount;v<y;v++)s.setX(m+v,l);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const h=this._drawRanges[e],g=n.getAttribute("position");return h.count=i?a.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],s=i.box,a=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,c=this._drawRanges[e];for(let d=c.start,h=c.start+c.count;d<h;d++){let g=d;o&&(g=o.getX(g)),s.expandByPoint(nx.fromBufferAttribute(l,g))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,a=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Iy),Iy.getCenter(s.center);const o=a.index,l=a.attributes.position,c=this._drawRanges[e];let d=0;for(let h=c.start,g=c.start+c.count;h<g;h++){let m=h;o&&(m=o.getX(m)),nx.fromBufferAttribute(l,m),d=Math.max(d,s.center.distanceToSquared(nx))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||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,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;is.material=this.material,is.geometry.index=l.index,is.geometry.attributes=l.attributes,is.geometry.boundingBox===null&&(is.geometry.boundingBox=new Za),is.geometry.boundingSphere===null&&(is.geometry.boundingSphere=new nl);for(let c=0;c<a;c++){if(!r[c]||!i[c])continue;const d=s[c];is.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(c,is.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,is.geometry.boundingBox),this.getBoundingSphereAt(c,is.geometry.boundingSphere),is.raycast(e,Uy);for(let h=0,g=Uy.length;h<g;h++){const m=Uy[h];m.object=this,m.batchId=c,n.push(m)}Uy.length=0}is.material=null,is.geometry.index=null,is.geometry.attributes={},is.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,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._visibility,c=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,g=this.perObjectFrustumCulled;g&&(Jz.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),oT.setFromProjectionMatrix(Jz,e.isWebGPURenderer?h0:el));let m=0;if(this.sortObjects){Qz.copy(this.matrixWorld).invert(),nx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(Qz);for(let b=0,x=l.length;b<x;b++)if(l[b]){this.getMatrixAt(b,bu),this.getBoundingSphereAt(b,Vd).applyMatrix4(bu);let M=!1;if(g&&(M=!oT.intersectsSphere(Vd)),!M){const w=nx.distanceTo(Vd.center);lT.push(h[b],w)}}const v=lT.list,y=this.customSort;y===null?v.sort(s.transparent?l1e:o1e):y.call(this,v,r);for(let b=0,x=v.length;b<x;b++){const M=v[b];c[m]=M.start*o,d[m]=M.count,m++}lT.reset()}else for(let v=0,y=l.length;v<y;v++)if(l[v]){let b=!1;if(g&&(this.getMatrixAt(v,bu),this.getBoundingSphereAt(v,Vd).applyMatrix4(bu),b=!oT.intersectsSphere(Vd)),!b){const x=h[v];c[m]=x.start*o,d[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,a){this.onBeforeRender(e,null,i,s,a)}}class Q0 extends Lm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new $t(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 eB=new ke,tB=new ke,nB=new tr,cT=new DP,Fy=new nl;class h1e extends Ms{constructor(e=new ds,n=new Q0){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,s=n.count;i<s;i++)eB.fromBufferAttribute(n,i-1),tB.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=eB.distanceTo(tB);e.setAttribute("lineDistance",new Lr(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,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Fy.copy(r.boundingSphere),Fy.applyMatrix4(i),Fy.radius+=s,e.ray.intersectsSphere(Fy)===!1)return;nB.copy(i).invert(),cT.copy(e.ray).applyMatrix4(nB);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new ke,d=new ke,h=new ke,g=new ke,m=this.isLineSegments?2:1,v=r.index,b=r.attributes.position;if(v!==null){const x=Math.max(0,a.start),M=Math.min(v.count,a.start+a.count);for(let w=x,A=M-1;w<A;w+=m){const T=v.getX(w),R=v.getX(w+1);if(c.fromBufferAttribute(b,T),d.fromBufferAttribute(b,R),cT.distanceSqToSegment(c,d,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(g);I<e.near||I>e.far||n.push({distance:I,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,a.start),M=Math.min(b.count,a.start+a.count);for(let w=x,A=M-1;w<A;w+=m){if(c.fromBufferAttribute(b,w),d.fromBufferAttribute(b,w+1),cT.distanceSqToSegment(c,d,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(g);R<e.near||R>e.far||n.push({distance:R,point:h.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 s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const rB=new ke,iB=new ke;class Sw extends h1e{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,s=n.count;i<s;i+=2)rB.fromBufferAttribute(n,i),iB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+rB.distanceTo(iB);e.setAttribute("lineDistance",new Lr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class p1e extends ds{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new ke,s=new ke;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,d=l.length;c<d;++c){const h=l[c],g=h.start,m=h.count;for(let v=g,y=g+m;v<y;v+=3)for(let b=0;b<3;b++){const x=o.getX(v+b),M=o.getX(v+(b+1)%3);i.fromBufferAttribute(a,x),s.fromBufferAttribute(a,M),sB(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const d=3*o+c,h=3*o+(c+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,h),sB(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Lr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function sB(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 m1e extends Lm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=C7,this.normalScale=new Kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=NP,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 g1e extends Q0{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 Y7 extends Ms{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new $t(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 uT=new tr,aB=new ke,oB=new ke;class x1e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Kt(512,512),this.map=null,this.mapPass=null,this.matrix=new tr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yw,this._frameExtents=new Kt(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;aB.setFromMatrixPosition(e.matrixWorld),n.position.copy(aB),oB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(oB),n.updateMatrixWorld(),uT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(uT),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(uT)}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 lB=new tr,rx=new ke,dT=new ke;class b1e extends x1e{constructor(){super(new da(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Kt(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 ke(1,0,0),new ke(-1,0,0),new ke(0,0,1),new ke(0,0,-1),new ke(0,1,0),new ke(0,-1,0)],this._cubeUps=[new ke(0,1,0),new ke(0,1,0),new ke(0,1,0),new ke(0,1,0),new ke(0,0,1),new ke(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),rx.setFromMatrixPosition(e.matrixWorld),r.position.copy(rx),dT.copy(r.position),dT.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(dT),r.updateMatrixWorld(),i.makeTranslation(-rx.x,-rx.y,-rx.z),lB.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lB)}}class v1e extends Y7{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 b1e}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 y1e extends Y7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class _1e extends ds{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 Q3 extends s1e{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 cB{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(Xi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const uB=new ke,zy=new ke;class S1e{constructor(e=new ke,n=new ke){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){uB.subVectors(e,this.start),zy.subVectors(this.end,this.start);const r=zy.dot(zy);let s=zy.dot(uB)/r;return n&&(s=Xi(s,0,1)),s}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 w1e extends Sw{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 ds;i.setAttribute("position",new Lr(n,3)),i.setAttribute("color",new Lr(r,3));const s=new Q0({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,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:xw}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xw);class rl{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),rl.nextNameID=rl.nextNameID||0,this.$name.id=`lil-gui-name-${++rl.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",a=>a.stopPropagation()),this.domElement.addEventListener("keyup",a=>a.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 M1e extends rl{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 J3(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 E1e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:J3,toHexString:J3},m0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},A1e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=m0.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 m0.toHexString(i)}},T1e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=m0.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 m0.toHexString(i)}},C1e=[E1e,m0,A1e,T1e];function N1e(t){return C1e.find(e=>e.match(t))}class k1e extends rl{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=N1e(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 s=J3(this.$text.value);s&&this._setValueFromHexString(s)}),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 fT extends rl{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 R1e extends rl{constructor(e,n,r,i,s,a){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const o=a!==void 0;this.step(o?a: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))},s=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let a=!1,o,l,c,d,h;const g=5,m=M=>{o=M.clientX,l=c=M.clientY,a=!0,d=this.getValue(),h=0,window.addEventListener("mousemove",v),window.addEventListener("mouseup",y)},v=M=>{if(a){const w=M.clientX-o,A=M.clientY-l;Math.abs(A)>g?(M.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!a){const w=M.clientY-c;h-=w*this._step*this._arrowKeyMultiplier(M),d+h>this._max?h=this._max-d:d+h<this._min&&(h=this._min-d),this._snapClampSetValue(d+h)}c=M.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",y)},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",s,{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",s)},i=x=>{n(x.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let a=!1,o,l;const c=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),a=!1},d=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,l=x.touches[0].clientY,a=!0):c(x),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",g))},h=x=>{if(a){const M=x.touches[0].clientX-o,w=x.touches[0].clientY-l;Math.abs(M)>Math.abs(w)?c(x):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g))}else x.preventDefault(),n(x.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),v=400;let y;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(y),y=setTimeout(m,v)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{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 P1e extends rl{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 D1e extends rl{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 O1e=`.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 L1e(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 dB=!1;class g1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:a=!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(s),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"),!dB&&o&&(L1e(O1e),dB=!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=a}add(e,n,r,i,s){if(Object(r)===r)return new P1e(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new R1e(this,e,n,r,i,s);case"boolean":return new M1e(this,e,n);case"string":return new D1e(this,e,n);case"function":return new fT(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,a)}addColor(e,n,r=1){return new k1e(this,e,n,r)}addFolder(e){const n=new g1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof fT||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 fT)){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=s=>{s.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 hT(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(c){try{l(r.next(c))}catch(d){s(d)}}function o(c){try{l(r.throw(c))}catch(d){s(d)}}function l(c){var d;c.done?i(c.value):(d=c.value,d instanceof n?d:new n((function(h){h(d)}))).then(a,o)}l((r=r.apply(t,[])).next())}))}class UP{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 UP(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 FP{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class fB extends FP{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class vu extends FP{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class hB{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class x1{constructor(e){this.lines=[],this.preamble=new hB(-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((s=>s.comment))).thumbnails;for(const[s,a]of Object.entries(i))this.metadata.thumbnails[s]=a;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(";"),s=i[0],a=n&&i[1]||void 0,o=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.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 fB(e,l,c,a);case"t0":return new vu(e,l,a,0);case"t1":return new vu(e,l,a,1);case"t2":return new vu(e,l,a,2);case"t3":return new vu(e,l,a,3);case"t4":return new vu(e,l,a,4);case"t5":return new vu(e,l,a,5);case"t6":return new vu(e,l,a,6);case"t7":return new vu(e,l,a,7);default:return new FP(e,l,c,a)}}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,s)=>{if(i%2==0)return n;let a=s[i-1];return a=a.toLowerCase(),this.isAlpha(a)&&(n[a]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof fB){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const a=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new hB(this.layers.length,[],r,a))}}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 s=i.comment;if(!s)continue;const a=s.indexOf("thumbnail begin"),o=s.indexOf("thumbnail end");a>-1?r=UP.parse(s.slice(a+15).trim()):r&&(o==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}x1.prototype.parseGcode=x1.prototype.parseGCode;const pB={type:"change"},pT={type:"start"},mB={type:"end"},By=new DP,gB=new wu,j1e=Math.cos(70*k7.DEG2RAD);class I1e extends eh{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new ke,this.cursor=new ke,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:Qh.ROTATE,MIDDLE:Qh.DOLLY,RIGHT:Qh.PAN},this.touches={ONE:Jh.ROTATE,TWO:Jh.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(F){F.addEventListener("keydown",Re),this._domElementKeyEvents=F},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Re),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(pB),r.update(),s=i.NONE},this.update=(function(){const F=new ke,ie=new Ff().setFromUnitVectors(e.up,new ke(0,1,0)),V=ie.clone().invert(),J=new ke,le=new Ff,Ae=new ke,Ee=2*Math.PI;return function(se=null){const U=r.object.position;F.copy(U).sub(r.target),F.applyQuaternion(ie),o.setFromVector3(F),r.autoRotate&&s===i.NONE&&D((function(ve){return ve!==null?2*Math.PI/60*r.autoRotateSpeed*ve:2*Math.PI/60/60*r.autoRotateSpeed})(se)),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,X=r.maxAzimuthAngle;isFinite(L)&&isFinite(X)&&(L<-Math.PI?L+=Ee:L>Math.PI&&(L-=Ee),X<-Math.PI?X+=Ee:X>Math.PI&&(X-=Ee),o.theta=L<=X?Math.max(L,Math.min(X,o.theta)):o.theta>(L+X)/2?Math.max(L,o.theta):Math.min(X,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&R||r.object.isOrthographicCamera?o.radius=Z(o.radius):o.radius=Z(o.radius*c),F.setFromSpherical(o),F.applyQuaternion(V),U.copy(r.target).add(F),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),d.set(0,0,0));let me=!1;if(r.zoomToCursor&&R){let ve=null;if(r.object.isPerspectiveCamera){const ge=F.length();ve=Z(ge*c);const Ke=ge-ve;r.object.position.addScaledVector(A,Ke),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ge=new ke(T.x,T.y,0);ge.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),me=!0;const Ke=new ke(T.x,T.y,0);Ke.unproject(r.object),r.object.position.sub(Ke).add(ge),r.object.updateMatrixWorld(),ve=F.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;ve!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(ve).add(r.object.position):(By.origin.copy(r.object.position),By.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(By.direction))<j1e?e.lookAt(r.target):(gB.setFromNormalAndCoplanarPoint(r.object.up,r.target),By.intersectPlane(gB,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),me=!0);return c=1,R=!1,!!(me||J.distanceToSquared(r.object.position)>a||8*(1-le.dot(r.object.quaternion))>a||Ae.distanceToSquared(r.target)>0)&&(r.dispatchEvent(pB),J.copy(r.object.position),le.copy(r.object.quaternion),Ae.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ue),r.domElement.removeEventListener("pointerdown",pe),r.domElement.removeEventListener("pointercancel",fe),r.domElement.removeEventListener("wheel",Se),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",fe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Re),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 s=i.NONE;const a=1e-6,o=new cB,l=new cB;let c=1;const d=new ke,h=new Kt,g=new Kt,m=new Kt,v=new Kt,y=new Kt,b=new Kt,x=new Kt,M=new Kt,w=new Kt,A=new ke,T=new Kt;let R=!1;const C=[],I={};function N(){return Math.pow(.95,r.zoomSpeed)}function D(F){l.theta-=F}function z(F){l.phi-=F}const j=(function(){const F=new ke;return function(ie,V){F.setFromMatrixColumn(V,0),F.multiplyScalar(-ie),d.add(F)}})(),W=(function(){const F=new ke;return function(ie,V){r.screenSpacePanning===!0?F.setFromMatrixColumn(V,1):(F.setFromMatrixColumn(V,0),F.crossVectors(r.object.up,F)),F.multiplyScalar(ie),d.add(F)}})(),P=(function(){const F=new ke;return function(ie,V){const J=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;F.copy(le).sub(r.target);let Ae=F.length();Ae*=Math.tan(r.object.fov/2*Math.PI/180),j(2*ie*Ae/J.clientHeight,r.object.matrix),W(2*V*Ae/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(j(ie*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),W(V*(r.object.top-r.object.bottom)/r.object.zoom/J.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function $(F){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c/=F:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(F){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c*=F:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(F){if(!r.zoomToCursor)return;R=!0;const ie=r.domElement.getBoundingClientRect(),V=F.clientX-ie.left,J=F.clientY-ie.top,le=ie.width,Ae=ie.height;T.x=V/le*2-1,T.y=-J/Ae*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(F){return Math.max(r.minDistance,Math.min(r.maxDistance,F))}function Q(F){h.set(F.clientX,F.clientY)}function ee(F){v.set(F.clientX,F.clientY)}function H(){if(C.length===1)h.set(C[0].pageX,C[0].pageY);else{const F=.5*(C[0].pageX+C[1].pageX),ie=.5*(C[0].pageY+C[1].pageY);h.set(F,ie)}}function q(){if(C.length===1)v.set(C[0].pageX,C[0].pageY);else{const F=.5*(C[0].pageX+C[1].pageX),ie=.5*(C[0].pageY+C[1].pageY);v.set(F,ie)}}function te(){const F=C[0].pageX-C[1].pageX,ie=C[0].pageY-C[1].pageY,V=Math.sqrt(F*F+ie*ie);x.set(0,V)}function ae(F){if(C.length==1)g.set(F.pageX,F.pageY);else{const V=B(F),J=.5*(F.pageX+V.x),le=.5*(F.pageY+V.y);g.set(J,le)}m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const ie=r.domElement;D(2*Math.PI*m.x/ie.clientHeight),z(2*Math.PI*m.y/ie.clientHeight),h.copy(g)}function xe(F){if(C.length===1)y.set(F.pageX,F.pageY);else{const ie=B(F),V=.5*(F.pageX+ie.x),J=.5*(F.pageY+ie.y);y.set(V,J)}b.subVectors(y,v).multiplyScalar(r.panSpeed),P(b.x,b.y),v.copy(y)}function re(F){const ie=B(F),V=F.pageX-ie.x,J=F.pageY-ie.y,le=Math.sqrt(V*V+J*J);M.set(0,le),w.set(0,Math.pow(M.y/x.y,r.zoomSpeed)),$(w.y),x.copy(M)}function pe(F){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(F.pointerId),r.domElement.addEventListener("pointermove",Ce),r.domElement.addEventListener("pointerup",fe)),(function(ie){C.push(ie)})(F),F.pointerType==="touch"?(function(ie){switch(ct(ie),C.length){case 1:switch(r.touches.ONE){case Jh.ROTATE:if(r.enableRotate===!1)return;H(),s=i.TOUCH_ROTATE;break;case Jh.PAN:if(r.enablePan===!1)return;q(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Jh.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&te(),r.enablePan&&q(),s=i.TOUCH_DOLLY_PAN;break;case Jh.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&te(),r.enableRotate&&H(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(pT)})(F):(function(ie){let V;switch(ie.button){case 0:V=r.mouseButtons.LEFT;break;case 1:V=r.mouseButtons.MIDDLE;break;case 2:V=r.mouseButtons.RIGHT;break;default:V=-1}switch(V){case Qh.DOLLY:if(r.enableZoom===!1)return;(function(J){G(J),x.set(J.clientX,J.clientY)})(ie),s=i.DOLLY;break;case Qh.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;ee(ie),s=i.PAN}else{if(r.enableRotate===!1)return;Q(ie),s=i.ROTATE}break;case Qh.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;Q(ie),s=i.ROTATE}else{if(r.enablePan===!1)return;ee(ie),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(pT)})(F))}function Ce(F){r.enabled!==!1&&(F.pointerType==="touch"?(function(ie){switch(ct(ie),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(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(V){r.enableZoom&&re(V),r.enablePan&&xe(V)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(V){r.enableZoom&&re(V),r.enableRotate&&ae(V)})(ie),r.update();break;default:s=i.NONE}})(F):(function(ie){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(V){g.set(V.clientX,V.clientY),m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const J=r.domElement;D(2*Math.PI*m.x/J.clientHeight),z(2*Math.PI*m.y/J.clientHeight),h.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(V){M.set(V.clientX,V.clientY),w.subVectors(M,x),w.y>0?$(N()):w.y<0&&K(N()),x.copy(M),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(V){y.set(V.clientX,V.clientY),b.subVectors(y,v).multiplyScalar(r.panSpeed),P(b.x,b.y),v.copy(y),r.update()})(ie)}})(F))}function fe(F){(function(ie){delete I[ie.pointerId];for(let V=0;V<C.length;V++)if(C[V].pointerId==ie.pointerId)return void C.splice(V,1)})(F),C.length===0&&(r.domElement.releasePointerCapture(F.pointerId),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",fe)),r.dispatchEvent(mB),s=i.NONE}function Se(F){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(F.preventDefault(),r.dispatchEvent(pT),(function(ie){G(ie),ie.deltaY<0?K(N()):ie.deltaY>0&&$(N()),r.update()})(F),r.dispatchEvent(mB))}function Re(F){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let V=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?z(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,r.keyPanSpeed),V=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?z(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,-r.keyPanSpeed),V=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(r.keyPanSpeed,0),V=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(-r.keyPanSpeed,0),V=!0}V&&(ie.preventDefault(),r.update())})(F)}function ue(F){r.enabled!==!1&&F.preventDefault()}function ct(F){let ie=I[F.pointerId];ie===void 0&&(ie=new Kt,I[F.pointerId]=ie),ie.set(F.pageX,F.pageY)}function B(F){const ie=F.pointerId===C[0].pointerId?C[1]:C[0];return I[ie.pointerId]}r.domElement.addEventListener("contextmenu",ue),r.domElement.addEventListener("pointerdown",pe),r.domElement.addEventListener("pointercancel",fe),r.domElement.addEventListener("wheel",Se,{passive:!1}),this.update()}}vt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Kt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},zs.line={uniforms:OP.merge([vt.common,vt.fog,vt.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 Z7 extends td{constructor(e){super({type:"LineMaterial",uniforms:OP.clone(zs.line.uniforms),vertexShader:zs.line.vertexShader,fragmentShader:zs.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 xB=new Za,Hy=new ke;class Q7 extends _1e{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 Lr([-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 Lr([-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 Q3(n,6,1);return this.setAttribute("instanceStart",new Iu(r,3,0)),this.setAttribute("instanceEnd",new Iu(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 Q3(n,6,1);return this.setAttribute("instanceColorStart",new Iu(r,3,0)),this.setAttribute("instanceColorEnd",new Iu(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 p1e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Za);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),xB.setFromBufferAttribute(n),this.boundingBox.union(xB))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nl),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 s=0,a=e.count;s<a;s++)Hy.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Hy)),Hy.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(Hy));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 bB=new ke,vB=new ke,Bi=new Gn,Hi=new Gn,Bo=new Gn,mT=new ke,gT=new tr,$i=new S1e,yB=new ke,$y=new Za,Vy=new nl,Ho=new Gn;let $o,ef;function _B(t,e,n){return Ho.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ho.multiplyScalar(1/Ho.w),Ho.x=ef/n.width,Ho.y=ef/n.height,Ho.applyMatrix4(t.projectionMatrixInverse),Ho.multiplyScalar(1/Ho.w),Math.abs(Math.max(Ho.x,Ho.y))}class U1e extends Mo{constructor(e=new Q7,n=new Z7({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 a=0,o=0,l=n.count;a<l;a++,o+=2)bB.fromBufferAttribute(n,a),vB.fromBufferAttribute(r,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+bB.distanceTo(vB);const s=new Q3(i,2,1);return e.setAttribute("instanceDistanceStart",new Iu(s,1,0)),e.setAttribute("instanceDistanceEnd",new Iu(s,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 s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;$o=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let c,d;ef=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),Vy.copy(o.boundingSphere).applyMatrix4(a),r?c=.5*ef:c=_B(i,Math.max(i.near,Vy.distanceToPoint($o.origin)),l.resolution),Vy.radius+=c,$o.intersectsSphere(Vy)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),$y.copy(o.boundingBox).applyMatrix4(a),r?d=.5*ef:d=_B(i,Math.max(i.near,$y.distanceToPoint($o.origin)),l.resolution),$y.expandByScalar(d),$o.intersectsBox($y)!==!1&&(r?(function(h,g){const m=h.matrixWorld,v=h.geometry,y=v.attributes.instanceStart,b=v.attributes.instanceEnd;for(let x=0,M=Math.min(v.instanceCount,y.count);x<M;x++){$i.start.fromBufferAttribute(y,x),$i.end.fromBufferAttribute(b,x),$i.applyMatrix4(m);const w=new ke,A=new ke;$o.distanceSqToSegment($i.start,$i.end,A,w),A.distanceTo(w)<.5*ef&&g.push({point:A,pointOnLine:w,distance:$o.origin.distanceTo(A),object:h,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(h,g,m){const v=g.projectionMatrix,y=h.material.resolution,b=h.matrixWorld,x=h.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,A=Math.min(x.instanceCount,M.count),T=-g.near;$o.at(1,Bo),Bo.w=1,Bo.applyMatrix4(g.matrixWorldInverse),Bo.applyMatrix4(v),Bo.multiplyScalar(1/Bo.w),Bo.x*=y.x/2,Bo.y*=y.y/2,Bo.z=0,mT.copy(Bo),gT.multiplyMatrices(g.matrixWorldInverse,b);for(let R=0,C=A;R<C;R++){if(Bi.fromBufferAttribute(M,R),Hi.fromBufferAttribute(w,R),Bi.w=1,Hi.w=1,Bi.applyMatrix4(gT),Hi.applyMatrix4(gT),Bi.z>T&&Hi.z>T)continue;if(Bi.z>T){const j=Bi.z-Hi.z,W=(Bi.z-T)/j;Bi.lerp(Hi,W)}else if(Hi.z>T){const j=Hi.z-Bi.z,W=(Hi.z-T)/j;Hi.lerp(Bi,W)}Bi.applyMatrix4(v),Hi.applyMatrix4(v),Bi.multiplyScalar(1/Bi.w),Hi.multiplyScalar(1/Hi.w),Bi.x*=y.x/2,Bi.y*=y.y/2,Hi.x*=y.x/2,Hi.y*=y.y/2,$i.start.copy(Bi),$i.start.z=0,$i.end.copy(Hi),$i.end.z=0;const I=$i.closestPointToPointParameter(mT,!0);$i.at(I,yB);const N=k7.lerp(Bi.z,Hi.z,I),D=N>=-1&&N<=1,z=mT.distanceTo(yB)<.5*ef;if(D&&z){$i.start.fromBufferAttribute(M,R),$i.end.fromBufferAttribute(w,R),$i.start.applyMatrix4(b),$i.end.applyMatrix4(b);const j=new ke,W=new ke;$o.distanceSqToSegment($i.start,$i.end,W,j),m.push({point:W,pointOnLine:j,distance:$o.origin.distanceTo(W),object:h,face:null,faceIndex:R,uv:null,uv1:null})}}})(this,i,n)))}}class F1e extends Sw{constructor(e,n,r,i,s=4473924,a=8947848){s=new $t(s),a=new $t(a);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],c=[];let d=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?s:a;m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?s:a;m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3}const h=new ds;h.setAttribute("position",new Lr(l,3)),h.setAttribute("color",new Lr(c,3)),super(h,new Q0({vertexColors:!0,toneMapped:!1}))}}function z1e(t,e,n,r){const i=(function(a,o,l){a*=.5,o*=.5,l*=.5;const c=new ds,d=[];return d.push(-a,-o,-l,-a,o,-l,-a,o,-l,a,o,-l,a,o,-l,a,-o,-l,a,-o,-l,-a,-o,-l,-a,-o,l,-a,o,l,-a,o,l,a,o,l,a,o,l,a,-o,l,a,-o,l,-a,-o,l,-a,-o,-l,-a,-o,l,-a,o,-l,-a,o,l,a,o,-l,a,o,l,a,-o,-l,a,-o,l),c.setAttribute("position",new Lr(d,3)),c})(t,e,n),s=new Sw(i,new g1e({color:new $t(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Dx=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,a=0,o=n(new Dx.Panel("FPS","#0ff","#002")),l=n(new Dx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Dx.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){a++;var d=(performance||Date).now();if(l.update(d-i,200),d>=s+1e3&&(o.update(1e3*a/(d-s),100),s=d,a=0,c)){var h=performance.memory;c.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Dx.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,l=48*a,c=3*a,d=2*a,h=3*a,g=15*a,m=74*a,v=30*a,y=document.createElement("canvas");y.width=o,y.height=l,y.style.cssText="width:80px;height:48px";var b=y.getContext("2d");return b.font="bold "+9*a+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,o,l),b.fillStyle=e,b.fillText(t,c,d),b.fillRect(h,g,m,v),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(h,g,m,v),{dom:y,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(s(x)+" "+t+" ("+s(r)+"-"+s(i)+")",c,d),b.drawImage(y,h+a,g,m-a,v,h,g,m-a,v),b.fillRect(h+m-a,g,a,v),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(h+m-a,g,a,s((1-x/M)*v))}}};var B1e=Dx;class SB{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new g1,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 g1,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 H1e extends ds{constructor(e=[new ke],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new ke,a=new ke,o=new Kt,l=[],c=[],d=[],h=[];function g(m){const[v,y,b]=(function(x){const M=e[x],w=new ke,A=new ke,T=new ke,R=new ke;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let C=Number.MAX_VALUE;const I=Math.abs(w.x),N=Math.abs(w.y),D=Math.abs(w.z);return I<=C&&(C=I,A.set(1,0,0)),N<=C&&(C=N,A.set(0,1,0)),D<=C&&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);a.x=A*y.x+w*b.x,a.y=A*y.y+w*b.y,a.z=A*y.z+w*b.z,a.normalize(),c.push(a.x,a.y,a.z),s.x=v.x+n*a.x*.5,s.y=v.y+n*a.y*.5,s.z=v.z+r*a.z*.5,l.push(s.x,s.y,s.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 v=0;v<=i;v++)o.x=m/e.length,o.y=v/i,d.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let v=1;v<=i;v++){const y=(i+1)*(m-1)+(v-1),b=(i+1)*m+(v-1),x=(i+1)*m+v,M=(i+1)*(m-1)+v;h.push(y,b,M),h.push(b,x,M)}})()})(),this.setIndex(h),this.setAttribute("position",new Lr(l,3)),this.setAttribute("normal",new Lr(c,3)),this.setAttribute("uv",new Lr(d,2))}}class Ox{static get initial(){const e=new Ox;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const xT={h:0,s:0,l:0};class $p{constructor(e){var n,r,i,s,a,o,l,c,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Ox.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=$p.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new $t(14737632),this._travelColor=new $t(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 x1(this.minLayerThreshold),this.scene=new i1e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new $t(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=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(a=e.renderTravel)!==null&&a!==void 0?a:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(c=e.extrusionWidth)!==null&&c!==void 0?c:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new B1e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new $t(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new $t(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new $t(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,v]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new $t(v)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+xw),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 Z3({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 Z3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new da(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,g=.8*h;this.scene.fog=new IP(this._backgroundColor,g,h),this.resize(),this.controls=new I1e(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 $t(r)}else this._extrusionColor=new $t(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?$p.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:$p.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new $t(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new $t(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new $t(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new $t(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 w1e(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 y1e(13421772,.3*Math.PI),n=new v1e(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 bx;return n.name=e,n.quaternion.setFromEuler(new Y0(-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=Ox.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 hT(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,s,a,o,l,c;if(e>this.maxLayerIndex)return;const d=this.layers[e],h={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.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,v={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:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(a=m.params.e)!==null&&a!==void 0?a: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 y=((c=m.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(v.x!=this.state.x||v.y!=this.state.y||v.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(h,this.state,v,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(h,this.state,v,y))}this.state.x=v.x,this.state.y=v.y,this.state.z=v.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(h,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const a=.1+.7*n/this.layers.length;s.getHSL(xT),s=new $t().setHSL(xT.h,xT.s,a)}if(n==this.layers.length-1){const a=(r=this._topLayerColor)!==null&&r!==void 0?r:s,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:a,l=e.extrusion.splice(-3),c=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,a.getHex(),e.height),this.addTubeLine([...c,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,a.getHex()),this.addLine([...c,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,s.getHex(),e.height):this.addLine(e.extrusion,s.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 F1e(this.buildVolume.x,10,this.buildVolume.y,10));const e=z1e(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 x1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Ox.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,s){const a=i?e.extrusion:e.travel,o=n.x,l=n.y,c=n.z,d=r.x,h=r.y,g=r.z;let m=r.r,v=r.i,y=r.j;if(m){const $=d-o,K=h-l,G=Math.sqrt(Math.pow($/2,2)+Math.pow(K/2,2));m=Math.max(m,G);const Z=Math.pow($,2)+Math.pow(K,2),Q=Math.pow(m,2)-Z/4;let ee=Math.sqrt(Q/Z);(s&&m<0||!s&&m>0)&&(ee=-ee),v=$/2+K*ee,y=K/2-$*ee}const b=o==d&&l==h,x=o+v,M=l+y,w=Math.sqrt(v*v+y*y),A=Math.atan2(-y,-v),T=Math.atan2(h-M,d-x);let R;b?R=2*Math.PI:(R=s?A-T:T-A,R<0&&(R+=2*Math.PI));let C=w*R/1.8;this.inches&&(C*=25),C<1&&(C=1);let I=R/C;I*=s?-1:1;const N=[];N.push({x:o,y:l,z:c});const D=(c-g)/C;let z=o,j=l,W=c,P=A;for(let $=0;$<C-1;$++)P+=I,z=x+w*Math.cos(P),j=M+w*Math.sin(P),W+=D,N.push({x:z,y:j,z:W});N.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<N.length-1;$++)a.push(N[$].x,N[$].y,N[$].z,N[$+1].x,N[$+1].y,N[$+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ds;i.setAttribute("position",new Lr(e,3)),this.disposables.push(i);const s=new Q0({color:n});this.disposables.push(s);const a=new Sw(i,s);(r=this.group)===null||r===void 0||r.add(a)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let a=0;a<e.length;a+=6){const o=e.slice(a,a+9),l=new ke(o[0],o[1],o[2]),c=new ke(o[3],o[4],o[5]),d=new ke(o[6],o[7],o[8]);i.push(l),c.equals(d)||(i.push(c),s.push(i),i=[])}s.forEach((a=>{var o;const l=new H1e(a,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 Q7;this.disposables.push(i);const s=new Z7({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const a=new U1e(i,s);(r=this.group)===null||r===void 0||r.add(a)}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=>hT(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 m1e({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),a=new f1e(r.length,s,void 0,i);return this.disposables.push(a),(n=this.group)===null||n===void 0||n.add(a),a}_readFromStream(e){var n,r;return hT(this,void 0,void 0,(function*(){const i=e.getReader();let s,a="",o=0;do{console.debug("reading from stream"),s=yield i.read(),o+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const c=(l=s.value,new TextDecoder("utf-8").decode(l)),d=c.lastIndexOf(`
  8059. `),h=c.slice(0,d);this.parser.parseGCode(a+h),a=c.slice(d)}while(!s.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new SB(this):typeof this.devMode=="object"&&(this.devGui=new SB(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())}}$p.defaultExtrusionColor=new $t("hotpink");const $1e=function(t){return new $p(t)};function V1e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),[s,a]=E.useState(!0),[o,l]=E.useState(null),[c,d]=E.useState(!1),[h,g]=E.useState(0),[m,v]=E.useState(0);E.useEffect(()=>{if(!r.current)return;const x=r.current,M=$1e({canvas:x,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=M,a(!0),l(null),d(!1),fetch(t).then(async A=>{if(!A.ok)throw A.status===404&&(await A.json().catch(()=>({}))).detail?.includes("sliced")?(d(!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;v(T),g(T),M.render(),a(!1)}).catch(A=>{l(A.message),a(!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 y=x=>{if(!i.current)return;const M=Math.max(1,Math.min(x,m));g(M),i.current.render()},b=x=>{y(parseInt(x.target.value,10))};return u.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[u.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[u.jsx("canvas",{ref:r,className:"w-full h-full"}),s&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Ot,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),u.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:u.jsxs("div",{className:"text-center max-w-sm px-4",children:[u.jsx(eoe,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),u.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),u.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&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:u.jsx("div",{className:"text-center text-red-400",children:u.jsx("p",{className:"text-sm",children:o})})})]}),!s&&!o&&!c&&m>0&&u.jsx("div",{className:"mt-4 px-2",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(kf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),u.jsx("button",{onClick:()=>y(h-1),disabled:h<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:u.jsx(Nf,{className:"w-4 h-4"})}),u.jsx("input",{type:"range",min:1,max:m,value:h,onChange:b,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),u.jsx("button",{onClick:()=>y(h+1),disabled:h>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:u.jsx(Rm,{className:"w-4 h-4"})}),u.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[h," / ",m]})]})})]})}function G1e({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[s,a]=E.useState(null),[o,l]=E.useState(!0);E.useEffect(()=>{const d=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),E.useEffect(()=>{Le.getArchiveCapabilities(t).then(d=>{a(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),l(!1)}).catch(()=>{a({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const c=()=>{const d=e||"model",h=`${window.location.origin}${Le.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(h)}`};return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:c,children:[u.jsx(vc,{className:"w-4 h-4"}),"Open in Slicer"]}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:n,children:u.jsx(Qt,{className:"w-5 h-5"})})]})]}),s&&u.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[u.jsxs("button",{onClick:()=>s.has_model&&i("3d"),disabled:!s.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":s.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[u.jsx(Zp,{className:"w-4 h-4"}),"3D Model",!s.has_model&&u.jsx("span",{className:"text-xs",children:"(not available)"})]}),u.jsxs("button",{onClick:()=>s.has_gcode&&i("gcode"),disabled:!s.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":s.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[u.jsx(kae,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&u.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),u.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?u.jsx("div",{className:"w-full h-full flex items-center justify-center",children:u.jsx(Ot,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?u.jsx(zge,{url:Le.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?u.jsx(V1e,{gcodeUrl:Le.getArchiveGcode(t),buildVolume:s.build_volume,className:"w-full h-full"}):u.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function W1e({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,s]=E.useState(null);E.useEffect(()=>{const d=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:a,isLoading:o}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),l=At({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Le.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),c=a?.filter(d=>d.is_active)||[];return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:u.jsx(Lt,{className:"w-full max-w-md",children:u.jsxs(Ft,{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:n,children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",u.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?u.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):u.jsx("div",{className:"space-y-2 mb-6",children:c.map(d=>u.jsxs("button",{onClick:()=>s(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[u.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:u.jsx(ko,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),u.jsxs("div",{className:"text-left",children:[u.jsx("p",{className:"text-white font-medium",children:d.name}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),l.isError&&u.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"}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):u.jsxs(u.Fragment,{children:[u.jsx(ko,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function q1e({onClose:t,initialFiles:e}){const n=Nn(),{showToast:r}=Di(),i=E.useRef(null),[s,a]=E.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[o,l]=E.useState(!1),[c,d]=E.useState(),[h,g]=E.useState(null);E.useEffect(()=>{const C=I=>{I.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:m}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),v=At({mutationFn:C=>Le.uploadArchivesBulk(C,c),onSuccess:C=>{g(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),a(I=>I.map(N=>{const D=C.results.find(j=>j.filename===N.file.name),z=C.errors.find(j=>j.filename===N.file.name);return D?{...N,status:"success",archiveId:D.id}:z?{...N,status:"error",error:z.error}:N})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{a(C=>C.map(I=>({...I,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=E.useCallback(C=>{C.preventDefault(),l(!0)},[]),b=E.useCallback(C=>{C.preventDefault(),l(!1)},[]),x=E.useCallback(C=>{C.preventDefault(),l(!1);const I=Array.from(C.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));I.length>0&&a(N=>[...N,...I.map(D=>({file:D,status:"pending"}))])},[]),M=E.useCallback(C=>{const I=Array.from(C.target.files||[]).filter(N=>N.name.endsWith(".3mf"));I.length>0&&a(N=>[...N,...I.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=E.useCallback(C=>{a(I=>I.filter((N,D)=>D!==C))},[]),A=()=>{if(s.length===0)return;const C=s.filter(I=>I.status==="pending");C.length!==0&&(a(I=>I.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),v.mutate(C.map(I=>I.file)))},T=s.filter(C=>C.status==="pending").length,R=v.isPending;return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:u.jsxs(Ft,{className:"p-0 flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsx("div",{className:"p-4",children:u.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:y,onDragLeave:b,onDrop:x,children:[u.jsx(Ka,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),u.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),u.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),u.jsx(Ue,{variant:"secondary",onClick:()=>i.current?.click(),disabled:R,children:"Browse Files"}),u.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),u.jsxs("div",{className:"px-4 pb-4",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),u.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:C=>d(C.target.value?Number(C.target.value):void 0),disabled:R,children:[u.jsx("option",{value:"",children:"No printer"}),m?.map(C=>u.jsx("option",{value:C.id,children:C.name},C.id))]})]}),s.length>0&&u.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:u.jsx("div",{className:"space-y-2",children:s.map((C,I)=>u.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[u.jsx(x9,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),u.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),u.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&u.jsx("button",{onClick:()=>w(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:R,children:u.jsx(Qt,{className:"w-4 h-4"})}),C.status==="uploading"&&u.jsx(Ot,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-xs text-red-400",children:C.error}),u.jsx(No,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${I}`))})}),h&&u.jsx("div",{className:"px-4 pb-4",children:u.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:u.jsxs("p",{className:"text-sm text-white",children:[u.jsx("span",{className:"text-bambu-green",children:h.uploaded})," uploaded",h.failed>0&&u.jsxs(u.Fragment,{children:[", ",u.jsx("span",{className:"text-red-400",children:h.failed})," failed"]})]})})}),u.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[u.jsx(Ue,{variant:"secondary",onClick:t,className:"flex-1",children:h?"Close":"Cancel"}),!h&&u.jsx(Ue,{onClick:A,disabled:T===0||R,className:"flex-1",children:R?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):u.jsxs(u.Fragment,{children:[u.jsx(Ka,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const X1e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function K1e({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const Z=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[e]);const r=Nn(),[i,s]=E.useState(t.print_name||""),[a,o]=E.useState(t.printer_id),[l,c]=E.useState(t.notes||""),[d,h]=E.useState(t.tags||""),[g,m]=E.useState(t.failure_reason||""),[v,y]=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:C}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:I}=Mt({queryKey:["archives"],queryFn:()=>Le.getArchives(void 0,1e3,0),enabled:n.length===0}),N=n.length>0?n:[...new Set(I?.flatMap(Z=>Z.tags?.split(",").map(Q=>Q.trim())||[]).filter(Boolean)||[])].sort(),D=d.split(",").map(Z=>Z.trim()).filter(Boolean),z=N.filter(Z=>!D.includes(Z)),j=Z=>{if(!D.includes(Z)){const Q=[...D,Z].join(", ");h(Q)}R.current!==null&&clearTimeout(R.current),A.current?.focus()},W=Z=>{const Q=D.filter(ee=>ee!==Z).join(", ");h(Q)},P=At({mutationFn:Z=>Le.updateArchive(t.id,Z),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),e()}}),$=async Z=>{const Q=Z.target.files?.[0];if(Q){x(!0);try{const ee=await Le.uploadArchivePhoto(t.id,Q);y(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{x(!1),T.current&&(T.current.value="")}}},K=async Z=>{try{const Q=await Le.deleteArchivePhoto(t.id,Z);y(Q.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Q){console.error("Failed to delete photo:",Q)}},G=Z=>{Z.preventDefault(),P.mutate({print_name:i||void 0,printer_id:a,notes:l||void 0,tags:d||void 0,failure_reason:t.status==="failed"&&g||void 0})};return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:u.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:Z=>Z.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:G,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),u.jsx("input",{type:"text",value:i,onChange:Z=>s(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),u.jsxs("select",{value:a??"",onChange:Z=>o(Z.target.value?Number(Z.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:[u.jsx("option",{value:"",children:"No printer"}),C?.map(Z=>u.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),u.jsx("textarea",{value:l,onChange:Z=>c(Z.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..."})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),D.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:D.map(Z=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[u.jsx(i0,{className:"w-3 h-3"}),Z,u.jsx("button",{type:"button",onClick:()=>W(Z),className:"ml-0.5 text-bambu-gray hover:text-white",children:u.jsx(Qt,{className:"w-3 h-3"})})]},Z))}),u.jsxs("div",{className:"relative",children:[u.jsx("input",{ref:A,type:"text",value:d,onChange:Z=>h(Z.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:D.length>0?"Add more tags...":"Add tags..."}),M&&z.length>0&&u.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:[u.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),u.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:z.map(Z=>u.jsx("button",{type:"button",onClick:()=>j(Z),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:Z},Z))})]})]})]}),t.status==="failed"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),u.jsxs("select",{value:g,onChange:Z=>m(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"Select reason..."}),X1e.map(Z=>u.jsx("option",{value:Z,children:Z},Z))]})]}),u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[u.jsx(J_,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),u.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[v.map(Z=>u.jsxs("div",{className:"relative group",children:[u.jsx("img",{src:Le.getArchivePhotoUrl(t.id,Z),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),u.jsx("button",{type:"button",onClick:()=>K(Z),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:u.jsx(Qn,{className:"w-3 h-3 text-white"})})]},Z)),u.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:[u.jsx("input",{ref:T,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:$,className:"hidden",disabled:b}),b?u.jsx(Ot,{className:"w-6 h-6 text-bambu-gray animate-spin"}):u.jsx(li,{className:"w-6 h-6 text-bambu-gray"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:P.isPending,className:"flex-1",children:[u.jsx(Qo,{className:"w-4 h-4"}),P.isPending?"Saving...":"Save"]})]})]})]})})}function Y1e({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null);return E.useEffect(()=>{const s=l=>{i.current&&!i.current.contains(l.target)&&r()},a=l=>{l.key==="Escape"&&r()},o=()=>{r()};return document.addEventListener("mousedown",s),document.addEventListener("keydown",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",a),document.removeEventListener("scroll",o,!0)}},[r]),E.useEffect(()=>{if(i.current){const s=i.current.getBoundingClientRect(),a=window.innerWidth,o=window.innerHeight;let l=t,c=e;t+s.width>a&&(l=a-s.width-8),e+s.height>o&&(c=o-s.height-8),i.current.style.left=`${l}px`,i.current.style.top=`${c}px`}},[t,e]),u.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((s,a)=>s.divider?u.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},a):u.jsxs("button",{onClick:()=>{s.disabled||(s.onClick(),r())},disabled:s.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${s.disabled?"text-bambu-gray cursor-not-allowed":s.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[s.icon&&u.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:s.icon}),s.label]},a))})}function Z1e({selectedIds:t,existingTags:e,onClose:n}){const r=Nn(),{showToast:i}=Di(),[s,a]=E.useState(""),[o,l]=E.useState(new Set),[c,d]=E.useState("add");E.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=At({mutationFn:async()=>{const y=Array.from(o);let b=0;for(const x of t)try{const M=await Le.getArchive(x),w=M.tags?M.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;c==="add"?A=[...new Set([...w,...y])]:A=w.filter(T=>!o.has(T)),await Le.updateArchive(x,{tags:A.join(", ")}),b++}catch(M){throw console.error(`Failed to update archive ${x}:`,M),new Error(`Failed on archive ${x}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:b,mode:c,tags:y}},onSuccess:({count:y,mode:b,tags:x})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${b==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{l(b=>{const x=new Set(b);return x.has(y)?x.delete(y):x.add(y),x})},m=()=>{s.trim()&&!o.has(s.trim())&&(l(y=>new Set([...y,s.trim()])),a(""))},v=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-md",children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(i0,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),u.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"p-4 space-y-4",children:[u.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),u.jsx(Ue,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),c==="add"&&u.jsxs("div",{className:"flex gap-2",children:[u.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:s,onChange:y=>a(y.target.value),onKeyDown:v}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:u.jsx(li,{className:"w-4 h-4"})})]}),e.length>0&&u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>u.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),o.size>0&&u.jsxs("div",{children:[u.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>u.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:[y,u.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:u.jsx(Qt,{className:"w-3 h-3"})})]},y))})]})]}),u.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[u.jsx(Ue,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{onClick:()=>h.mutate(),disabled:o.size===0||h.isPending,className:"flex-1",children:h.isPending?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):u.jsxs(u.Fragment,{children:[u.jsx(i0,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function Q1e(t,e){return new Date(t,e+1,0).getDate()}function J1e(t,e){return new Date(t,e,1).getDay()}const eSe=["January","February","March","April","May","June","July","August","September","October","November","December"],tSe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function nSe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[s,a]=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]),d=Q1e(s,r),h=J1e(s,r),g=()=>{r===0?(i(11),a(s-1)):i(r-1)},m=()=>{r===11?(i(0),a(s+1)):i(r+1)},v=()=>{i(n.getMonth()),a(n.getFullYear())},y=[];for(let x=0;x<h;x++)y.push(null);for(let x=1;x<=d;x++)y.push(x);const b=o?c.get(o)||[]:[];return u.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[u.jsxs("div",{className:"flex-1",children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Nf,{className:"w-5 h-5 text-bambu-gray"})}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white",children:[eSe[r]," ",s]}),u.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),u.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Rm,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:tSe.map(x=>u.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),u.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((x,M)=>{if(x===null)return u.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${s}-${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()&&s===n.getFullYear(),C=w===o,I=A.filter(D=>D.status==="completed").length,N=A.filter(D=>D.status==="failed").length;return u.jsxs("button",{onClick:()=>l(C?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${C?"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:[u.jsx("span",{className:`text-sm font-medium ${R&&!C?"text-bambu-green":""}`,children:x}),T&&u.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[u.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&I===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),u.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},x)})}),u.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[u.jsxs("div",{children:[u.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()===s}).length}),u.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),u.jsxs("div",{children:[u.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()===s&&x.status==="completed"}).length}),u.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),u.jsxs("div",{children:[u.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()===s&&x.status==="failed"}).length}),u.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),u.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?u.jsxs(u.Fragment,{children:[u.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?u.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:b.map(x=>u.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?u.jsx("img",{src:Le.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):u.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:u.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&u.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>u.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):u.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):u.jsx("div",{className:"text-center py-8",children:u.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function rSe({archiveId:t,archiveName:e,onClose:n}){const r=Le.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),u.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"p-6 flex flex-col items-center",children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),u.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:u.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),u.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),u.jsxs(Ue,{onClick:i,className:"w-full",children:[u.jsx(va,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function iSe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,a]=E.useState(0),[o,l]=E.useState(!1);if(E.useEffect(()=>{const m=v=>{v.key==="Escape"&&r(),v.key==="ArrowLeft"&&a(y=>Math.max(0,y-1)),v.key==="ArrowRight"&&a(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{s>=n.length&&a(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const c=n[s],d=Le.getArchivePhotoUrl(t,c),h=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return u.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[u.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:h,children:[u.jsx(va,{className:"w-4 h-4"}),"Download"]}),i&&u.jsx(Ue,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})}),u.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-6 h-6"})})]})]}),u.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&u.jsx("button",{onClick:()=>a(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:u.jsx(Nf,{className:"w-8 h-8 text-white"})}),u.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&u.jsx("button",{onClick:()=>a(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:u.jsx(Rm,{className:"w-8 h-8 text-white"})})]}),n.length>1&&u.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,v)=>u.jsx("button",{onClick:()=>a(v),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${v===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:u.jsx("img",{src:Le.getArchivePhotoUrl(t,m),alt:`Thumbnail ${v+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&u.jsx(Zi,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(c),l(!1)},onCancel:()=>l(!1)})]})}function Gi(t){this.content=t}Gi.prototype={constructor:Gi,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),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Gi(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Gi(n)},addToStart:function(t,e){return new Gi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Gi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Gi(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=Gi.from(t),t.size?new Gi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Gi.from(t),t.size?new Gi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Gi.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}};Gi.from=function(t){if(t instanceof Gi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Gi(e)};function J7(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),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let a=0;i.text[a]==s.text[a];a++)n++;return n}if(i.content.size||s.content.size){let a=J7(i.content,s.content,n+1);if(a!=null)return a}n+=i.nodeSize}}function eW(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let a=t.child(--i),o=e.child(--s),l=a.nodeSize;if(a==o){n-=l,r-=l;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let c=0,d=Math.min(a.text.length,o.text.length);for(;c<d&&a.text[a.text.length-c-1]==o.text[o.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let c=eW(a.content,o.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class pt{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,s){for(let a=0,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;if(c>e&&r(l,i+o,s||null,a)!==!1&&l.content.size){let d=o+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",a=!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&&(a?a=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new pt(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 s=0,a=0;a<n;s++){let o=this.content[s],l=a+o.nodeSize;l>e&&((a<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=l}return new pt(r,i)}cutByIndex(e,n){return e==n?pt.empty:e==0&&n==this.content.length?this:new pt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new pt(i,s)}addToStart(e){return new pt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new pt(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 J7(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return eW(this,e,n,r)}findIndex(e){if(e==0)return Gy(0,e);if(e==this.size)return Gy(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),s=r+i.nodeSize;if(s>=e)return s==e?Gy(n+1,s):Gy(n,r);r=s}}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 pt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new pt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return pt.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new pt(n||e,r)}static from(e){if(!e)return pt.empty;if(e instanceof pt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new pt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}pt.empty=new pt([],0);const bT={index:0,offset:0};function Gy(t,e){return bT.index=t,bT.offset=e,bT}function b1(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(!b1(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!b1(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Kn=class ek{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}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&&b1(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 ek.none;if(e instanceof ek)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Kn.none=[];class v1 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=nW(this.content,e+this.openStart,n);return r&&new Et(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Et(tW(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(pt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Et(e,r,i)}}Et.empty=new Et(pt.empty,0,0);function tW(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:a,offset:o}=t.findIndex(n);if(i==e||s.isText){if(o!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(tW(s.content,e-i-1,n-i-1)))}function nW(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=nW(a.content,e-s-1,n,a);return o&&t.replaceChild(i,a.copy(o))}function sSe(t,e,n){if(n.openStart>t.depth)throw new v1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new v1("Inconsistent open depths");return rW(t,e,n,0)}function rW(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let a=rW(t,e,n,r+1);return s.copy(s.content.replaceChild(i,a))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let a=t.parent,o=a.content;return xf(a,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=aSe(n,t);return xf(s,sW(t,a,o,e,r))}else return xf(s,y1(t,e,r))}function iW(t,e){if(!e.type.compatibleContent(t.type))throw new v1("Cannot join "+e.type.name+" onto "+t.type.name)}function tk(t,e,n){let r=t.node(n);return iW(r,e.node(n)),r}function gf(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 Lx(t,e,n,r){let i=(e||t).node(n),s=0,a=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(gf(t.nodeAfter,r),s++));for(let o=s;o<a;o++)gf(i.child(o),r);e&&e.depth==n&&e.textOffset&&gf(e.nodeBefore,r)}function xf(t,e){return t.type.checkContent(e),t.copy(e)}function sW(t,e,n,r,i){let s=t.depth>i&&tk(t,e,i+1),a=r.depth>i&&tk(n,r,i+1),o=[];return Lx(null,t,i,o),s&&a&&e.index(i)==n.index(i)?(iW(s,a),gf(xf(s,sW(t,e,n,r,i+1)),o)):(s&&gf(xf(s,y1(t,e,i+1)),o),Lx(e,n,i,o),a&&gf(xf(a,y1(n,r,i+1)),o)),Lx(r,null,i,o),new pt(o)}function y1(t,e,n){let r=[];if(Lx(null,t,n,r),t.depth>n){let i=tk(t,e,n+1);gf(xf(i,y1(t,e,n+1)),r)}return Lx(e,null,n,r),new pt(r)}function aSe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class g0{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 s=0;s<e;s++)i+=r.child(s).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 s=r.marks;for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!i||!s[a].isInSet(i.marks))&&(s=s[a--].removeFromSet(s));return s}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 s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 _1(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,s=n;for(let a=e;;){let{index:o,offset:l}=a.content.findIndex(s),c=s-l;if(r.push(a,o,i+l),!c||(a=a.child(o),a.isText))break;s=c-1,i+=l+1}return new g0(n,r,s)}static resolveCached(e,n){let r=wB.get(e);if(r)for(let s=0;s<r.elts.length;s++){let a=r.elts[s];if(a.pos==n)return a}else wB.set(e,r=new oSe);let i=r.elts[r.i]=g0.resolve(e,n);return r.i=(r.i+1)%lSe,i}}class oSe{constructor(){this.elts=[],this.i=0}}const lSe=12,wB=new WeakMap;class _1{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 cSe=Object.create(null);let Wu=class nk{constructor(e,n,r,i=Kn.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||pt.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&&b1(this.attrs,n||e.defaultAttrs||cSe)&&Kn.sameSet(this.marks,r||Kn.none)}copy(e=null){return e==this.content?this:new nk(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new nk(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),s=this.resolve(n),a=r?0:i.sharedDepth(n),o=i.start(a),c=i.node(a).content.cut(i.pos-o,s.pos-o);return new Et(c,i.depth-a,s.depth-a)}replace(e,n,r){return sSe(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 g0.resolveCached(this,e)}resolveNoCache(e){return g0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.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()+")"),aW(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=pt.empty,i=0,s=r.childCount){let a=this.contentMatchAt(e).matchFragment(r,i,s),o=a&&a.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<s;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 s=this.contentMatchAt(e).matchType(r),a=s&&s.matchFragment(this.content,n);return a?a.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=pt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Wu.prototype.text=void 0;class S1 extends Wu{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):aW(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 S1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new S1(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 aW(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class zf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new uSe(e,n);if(r.next==null)return zf.empty;let i=oW(r);r.next&&r.err("Unexpected trailing text");let s=xSe(gSe(i));return bSe(s,r),s}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 s=n;i&&s<r;s++)i=i.matchType(e.child(s).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 s(a,o){let l=a.matchFragment(e,r);if(l&&(!n||l.validEnd))return pt.from(o.map(c=>c.createAndFill()));for(let c=0;c<a.next.length;c++){let{type:d,next:h}=a.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let g=s(h,o.concat(d));if(g)return g}}return null}return s(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(),s=i.match;if(s.matchType(e)){let a=[];for(let o=i;o.type;o=o.via)a.push(o.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:o,next:l}=s.next[a];!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 s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
  8060. `)}}zf.empty=new zf(!0);class uSe{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 oW(t){let e=[];do e.push(dSe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function dSe(t){let e=[];do e.push(fSe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function fSe(t){let e=mSe(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=hSe(t,e);else break;return e}function MB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function hSe(t,e){let n=MB(t),r=n;return t.eat(",")&&(t.next!="}"?r=MB(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function pSe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let a=n[s];a.isInGroup(e)&&i.push(a)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function mSe(t){if(t.eat("(")){let e=oW(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=pSe(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 gSe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(a,o,l){let c={term:l,to:o};return e[a].push(c),c}function i(a,o){a.forEach(l=>l.to=o)}function s(a,o){if(a.type=="choice")return a.exprs.reduce((l,c)=>l.concat(s(c,o)),[]);if(a.type=="seq")for(let l=0;;l++){let c=s(a.exprs[l],o);if(l==a.exprs.length-1)return c;i(c,o=n())}else if(a.type=="star"){let l=n();return r(o,l),i(s(a.expr,l),l),[r(l)]}else if(a.type=="plus"){let l=n();return i(s(a.expr,o),l),i(s(a.expr,l),l),[r(l)]}else{if(a.type=="opt")return[r(o)].concat(s(a.expr,o));if(a.type=="range"){let l=o;for(let c=0;c<a.min;c++){let d=n();i(s(a.expr,l),d),l=d}if(a.max==-1)i(s(a.expr,l),l);else for(let c=a.min;c<a.max;c++){let d=n();r(l,d),i(s(a.expr,l),d),l=d}return[r(l)]}else{if(a.type=="name")return[r(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function lW(t,e){return e-t}function EB(t,e){let n=[];return r(e),n.sort(lW);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let a=0;a<s.length;a++){let{term:o,to:l}=s[a];!o&&n.indexOf(l)==-1&&r(l)}}}function xSe(t){let e=Object.create(null);return n(EB(t,0));function n(r){let i=[];r.forEach(a=>{t[a].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let d=0;d<i.length;d++)i[d][0]==o&&(c=i[d][1]);EB(t,l).forEach(d=>{c||i.push([o,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new zf(r.indexOf(t.length-1)>-1);for(let a=0;a<i.length;a++){let o=i[a][1].sort(lW);s.next.push({type:i[a][0],next:e[o.join(",")]||n(o)})}return s}}function bSe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,a=[];for(let o=0;o<i.next.length;o++){let{type:l,next:c}=i.next[o];a.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function cW(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 uW(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function dW(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 s=t[i];s.validate&&s.validate(e[i])}}function fW(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ySe(t,r,e[r]);return n}let AB=class hW{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=fW(e,r.attrs),this.defaultAttrs=cW(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==zf.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:uW(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Wu(this,this.computeAttrs(e),pt.from(n),Kn.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new Wu(this,this.computeAttrs(e),n,Kn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=pt.from(n),n.size){let a=this.contentMatch.fillBefore(n);if(!a)return null;n=a.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(pt.empty,!0);return s?new Wu(this,e,n.append(s),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){dW(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((s,a)=>r[s]=new hW(s,n,a));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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function vSe(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class ySe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?vSe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ww{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=fW(e,i.attrs),this.excluded=null;let s=cW(this.attrs);this.instance=s?new Kn(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Kn(this,uW(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new ww(s,i++,n,a)),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){dW(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class pW{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=Gi.from(e.nodes),n.marks=Gi.from(e.marks||{}),this.nodes=AB.compile(this.spec.nodes,this),this.marks=ww.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 s=this.nodes[i],a=s.spec.content||"",o=s.spec.marks;if(s.contentMatch=r[a]||(r[a]=zf.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=o=="_"?null:o?TB(this,o.split(" ")):o==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],a=s.spec.excludes;s.excluded=a==null?[s]:a==""?[]:TB(this,a.split(" "))}this.nodeFromJSON=i=>Wu.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 AB){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 S1(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 TB(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],a=s;if(s)n.push(s);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(a=l)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function _Se(t){return t.tag!=null}function SSe(t){return t.style!=null}let jx=class rk{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(_Se(i))this.tags.push(i);else if(SSe(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new NB(this,n,!1);return r.addAll(e,Kn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new NB(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 s=this.tags[i];if(ESe(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let a=s.getAttrs(e);if(a===!1)continue;s.attrs=a||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let a=this.styles[s],o=a.style;if(!(o.indexOf(e)!=0||a.context&&!r.matchesContext(a.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(a.getAttrs){let l=a.getAttrs(n);if(l===!1)continue;a.attrs=l||void 0}return a}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<s)break}n.splice(a,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(a=>{r(a=kB(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(a=>{r(a=kB(a)),a.node||a.ignore||a.mark||(a.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rk(e,rk.schemaRules(e)))}};const mW={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},wSe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gW={ol:!0,ul:!0},x0=1,ik=2,Ix=4;function CB(t,e,n){return e!=null?(e?x0:0)|(e==="full"?ik:0):t&&t.whitespace=="pre"?x0|ik:n&~Ix}class Wy{constructor(e,n,r,i,s,a){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=Kn.none,this.match=s||(a&Ix?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(pt.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&x0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=pt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(pt.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&&!mW.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class NB{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,a=CB(null,n.preserveWhitespace,0)|(r?Ix:0);i?s=new Wy(i.type,i.attrs,Kn.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new Wy(null,null,Kn.none,!0,null,a):s=new Wy(e.schema.topNodeType,null,Kn.none,!0,null,a),this.nodes=[s],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,s=i.options&ik?"full":this.localPreserveWS||(i.options&x0)>0,{schema:a}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
  8061. `);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(a.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(a.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;gW.hasOwnProperty(a)&&this.parser.normalizeLists&&MSe(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:wSe.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(mW.hasOwnProperty(a))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=l&&l.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),c&&this.sync(s),this.needsBlock=d}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 s=this.parser.matchedStyles[i],a=r.getPropertyValue(s);if(a)for(let o=void 0;;){let l=this.parser.matchStyle(s,a,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 s,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(a,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(a&&a.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)}s&&this.sync(o)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let a=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];a!=o;a=a.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(a,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let a=this.open,o=0;a>=0;a--){let l=this.nodes[a],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+o)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(s);for(let a=0;a<i.length;a++)n=this.enterInner(i[a],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let a=Kn.none;for(let o of i.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):RB(o.type,e.type))&&(a=o.addToSet(a));return s.content.push(e.mark(a)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=CB(e,s,a.options);a.options&Ix&&a.content.length==0&&(o|=Ix);let l=Kn.none;return r=r.filter(c=>(a.type?a.type.allowsMarkType(c.type):RB(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Wy(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|=x0)}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),s=-(r?r.depth+1:0)+(i?0:1),a=(o,l)=>{for(;o>=0;o--){let c=n[o];if(c==""){if(o==n.length-1||o==0)continue;for(;l>=s;l--)if(a(o-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return a(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 MSe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&gW.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ESe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function kB(t){let e={};for(let n in t)e[n]=t[n];return e}function RB(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],a=o=>{s.push(o);for(let l=0;l<o.edgeCount;l++){let{type:c,next:d}=o.edge(l);if(c==e||s.indexOf(d)<0&&a(d))return!0}};if(a(i.contentMatch))return!0}}class th{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=vT(n).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let o=0,l=0;for(;o<s.length&&l<a.marks.length;){let c=a.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[o][0])||c.type.spec.spanning===!1)break;o++,l++}for(;o<s.length;)i=s.pop()[1];for(;l<a.marks.length;){let c=a.marks[l++],d=this.serializeMark(c,a.isInline,n);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=j_(vT(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 s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&j_(vT(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return j_(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new th(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=PB(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return PB(e.marks)}}function PB(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function vT(t){return t.document||window.document}const DB=new WeakMap;function ASe(t){let e=DB.get(t);return e===void 0&&DB.set(t,e=TSe(t)),e}function TSe(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 j_(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],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ASe(r))&&s.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 a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let h in c)if(c[h]!=null){let g=h.indexOf(" ");g>0?l.setAttributeNS(h.slice(0,g),h.slice(g+1),c[h]):h=="style"&&l.style?l.style.cssText=c[h]:l.setAttribute(h,c[h])}}for(let h=d;h<e.length;h++){let g=e[h];if(g===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:v}=j_(t,g,n,r);if(l.appendChild(m),v){if(o)throw new RangeError("Multiple content holes");o=v}}}return{dom:l,contentDOM:o}}const xW=65535,bW=Math.pow(2,16);function CSe(t,e){return t+e*bW}function OB(t){return t&xW}function NSe(t){return(t-(t&xW))/bW}const vW=1,yW=2,I_=4,_W=8;class sk{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&_W)>0}get deletedBefore(){return(this.delInfo&(vW|I_))>0}get deletedAfter(){return(this.delInfo&(yW|I_))>0}get deletedAcross(){return(this.delInfo&I_)>0}}class fa{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&fa.empty)return fa.empty}recover(e){let n=0,r=OB(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+NSe(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,s=this.inverted?2:1,a=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+s],d=this.ranges[o+a],h=l+c;if(e<=h){let g=c?e==l?-1:e==h?1:n:n,m=l+i+(g<0?0:d);if(r)return m;let v=e==(n<0?l:h)?null:CSe(o/3,e-l),y=e==l?yW:e==h?vW:I_;return(n<0?e!=l:e!=h)&&(y|=_W),new sk(m,y,v)}i+=d-c}return r?e+i:new sk(e+i,0,null)}touches(e,n){let r=0,i=OB(n),s=this.inverted?2:1,a=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+s],d=l+c;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+a]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let a=this.ranges[i],o=a-(this.inverted?s:0),l=a+(this.inverted?0:s),c=this.ranges[i+n],d=this.ranges[i+r];e(o,o+c,l,l+d),s+=d-c}}invert(){return new fa(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fa.empty:new fa(e<0?[0,-e,0]:[0,0,e])}}fa.empty=new fa([]);class b0{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 b0(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 b0;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 s=this.from;s<this.to;s++){let a=this._maps[s],o=a.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new sk(e,i,null)}}const yT=Object.create(null);let fs=class{getMap(){return fa.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yT[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 yT)throw new RangeError("Duplicate use of step JSON ID "+e);return yT[e]=n,n.prototype.jsonID=e,n}};class qr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new qr(e,null)}static fail(e){return new qr(null,e)}static fromReplace(e,n,r,i){try{return qr.ok(e.replace(n,r,i))}catch(s){if(s instanceof v1)return qr.fail(s.message);throw s}}}function zP(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(zP(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pt.fromArray(r)}class Uu extends fs{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)),s=new Et(zP(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),n.openStart,n.openEnd);return qr.fromReplace(e,this.from,this.to,s)}invert(){return new Eo(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 Uu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Uu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Uu(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 Uu(n.from,n.to,e.markFromJSON(n.mark))}}fs.jsonID("addMark",Uu);class Eo extends fs{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(zP(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return qr.fromReplace(e,this.from,this.to,r)}invert(){return new Uu(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 Eo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Eo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Eo(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 Eo(n.from,n.to,e.markFromJSON(n.mark))}}fs.jsonID("removeMark",Eo);class Fu extends fs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return qr.fromReplace(e,this.pos,this.pos+1,new Et(pt.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 Fu(this.pos,n.marks[i]);return new Fu(this.pos,this.mark)}}return new Bf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Fu(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 Fu(n.pos,e.markFromJSON(n.mark))}}fs.jsonID("addNodeMark",Fu);class Bf extends fs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return qr.fromReplace(e,this.pos,this.pos+1,new Et(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Fu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bf(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 Bf(n.pos,e.markFromJSON(n.mark))}}fs.jsonID("removeNodeMark",Bf);class Ni extends fs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&ak(e,this.from,this.to)?qr.fail("Structure replace would overwrite content"):qr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fa([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ni(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 Ni(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ni)||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 Ni(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 Ni(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 Ni(n.from,n.to,Et.fromJSON(e,n.slice),!!n.structure)}}fs.jsonID("replace",Ni);class Ri extends fs{constructor(e,n,r,i,s,a,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=a,this.structure=o}apply(e){if(this.structure&&(ak(e,this.from,this.gapFrom)||ak(e,this.gapTo,this.to)))return qr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return qr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?qr.fromReplace(e,this.from,this.to,r):qr.fail("Content does not fit in gap")}getMap(){return new fa([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 Ri(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),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Ri(n.pos,r.pos,i,s,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 Ri(n.from,n.to,n.gapFrom,n.gapTo,Et.fromJSON(e,n.slice),n.insert,!!n.structure)}}fs.jsonID("replaceAround",Ri);function ak(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let a=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function kSe(t,e,n,r){let i=[],s=[],a,o;t.doc.nodesBetween(e,n,(l,c,d)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&d.type.allowsMarkType(r.type)){let g=Math.max(c,e),m=Math.min(c+l.nodeSize,n),v=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(v)||(a&&a.to==g&&a.mark.eq(h[y])?a.to=m:i.push(a=new Eo(g,m,h[y])));o&&o.to==g?o.to=m:s.push(o=new Uu(g,m,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function RSe(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(a,o)=>{if(!a.isInline)return;s++;let l=null;if(r instanceof ww){let c=a.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(a.marks)&&(l=[r]):l=a.marks;if(l&&l.length){let c=Math.min(o+a.nodeSize,n);for(let d=0;d<l.length;d++){let h=l[d],g;for(let m=0;m<i.length;m++){let v=i[m];v.step==s-1&&h.eq(i[m].style)&&(g=v)}g?(g.to=c,g.step=s):i.push({style:h,from:Math.max(o,e),to:c,step:s})}}}),i.forEach(a=>t.step(new Eo(a.from,a.to,a.style)))}function BP(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),a=[],o=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),d=o+c.nodeSize,h=r.matchType(c.type);if(!h)a.push(new Ni(o,d,Et.empty));else{r=h;for(let g=0;g<c.marks.length;g++)n.allowsMarkType(c.marks[g].type)||t.step(new Eo(o,d,c.marks[g]));if(i&&c.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,v;for(;g=m.exec(c.text);)v||(v=new Et(pt.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),a.push(new Ni(o+g.index,o+g.index+g[0].length,v))}}o=d}if(!r.validEnd){let l=r.fillBefore(pt.empty,!0);t.replace(o,o,new Et(l,0,0))}for(let l=a.length-1;l>=0;l--)t.step(a[l])}function PSe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Im(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let a=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&a.canReplace(o,l,n))return r;if(r==0||a.type.spec.isolating||!PSe(a,o,l))break;o&&(i=1),l<a.childCount&&(s=1)}return null}function DSe(t,e,n){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),o=i.after(s+1),l=a,c=o,d=pt.empty,h=0;for(let v=s,y=!1;v>n;v--)y||r.index(v)>0?(y=!0,d=pt.from(r.node(v).copy(d)),h++):l--;let g=pt.empty,m=0;for(let v=s,y=!1;v>n;v--)y||i.after(v+1)<i.end(v)?(y=!0,g=pt.from(i.node(v).copy(g)),m++):c++;t.step(new Ri(l,c,a,o,new Et(d.append(g),h,m),d.size-h,!0))}function HP(t,e,n=null,r=t){let i=OSe(t,e),s=i&&LSe(r,e);return s?i.map(LB).concat({type:e,attrs:n}).concat(s.map(LB)):null}function LB(t){return{type:t,attrs:null}}function OSe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let a=s.length?s[0]:e;return n.canReplaceWith(r,i,a)?s:null}function LSe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),a=e.contentMatch.findWrapping(s.type);if(!a)return null;let l=(a.length?a[a.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:a}function jSe(t,e,n){let r=pt.empty;for(let a=n.length-1;a>=0;a--){if(r.size){let o=n[a].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=pt.from(n[a].type.create(n[a].attrs,r))}let i=e.start,s=e.end;t.step(new Ri(i,s,i,s,new Et(r,0,0),n.length,!0))}function ISe(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(a,o)=>{let l=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,l)&&USe(t.doc,t.mapping.slice(s).map(o),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!v?c=!1:!m&&v&&(c=!0)}c===!1&&wW(t,a,o,s),BP(t,t.mapping.slice(s).map(o,1),r,void 0,c===null);let d=t.mapping.slice(s),h=d.map(o,1),g=d.map(o+a.nodeSize,1);return t.step(new Ri(h,g,h+1,g-1,new Et(pt.from(r.create(l,null,a.marks)),0,0),1,!0)),c===!0&&SW(t,a,o,s),!1}})}function SW(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let a,o=/\r?\n|\r/g;for(;a=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+a.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function wW(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let a=t.mapping.slice(r).map(n+1+s);t.replaceWith(a,a+1,e.type.schema.text(`
  8063. `))}})}function USe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function FSe(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let a=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,a);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ri(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Et(pt.from(a),0,0),1,!0))}function pc(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,a=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=n-2;c>s;c--,d--){let h=i.node(c),g=i.index(c);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(g,h.childCount),v=r&&r[d+1];v&&(m=m.replaceChild(0,v.type.create(v.attrs)));let y=r&&r[d]||h;if(!h.canReplace(g+1,h.childCount)||!y.type.validContent(m))return!1}let o=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(o,o,l?l.type:i.node(s+1).type)}function zSe(t,e,n=1,r){let i=t.doc.resolve(e),s=pt.empty,a=pt.empty;for(let o=i.depth,l=i.depth-n,c=n-1;o>l;o--,c--){s=pt.from(i.node(o).copy(s));let d=r&&r[c];a=pt.from(d?d.type.create(d.attrs,a):i.node(o).copy(a))}t.step(new Ni(e,e,new Et(s.append(a),n,n),!0))}function fd(t,e){let n=t.resolve(e),r=n.index();return MW(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function BSe(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 s=e.child(i),a=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(a),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function MW(t,e){return!!(t&&e&&!t.isLeaf&&BSe(t,e))}function Mw(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,a,o=r.index(i);if(i==r.depth?(s=r.nodeBefore,a=r.nodeAfter):n>0?(s=r.node(i+1),o++,a=r.node(i).maybeChild(o)):(s=r.node(i).maybeChild(o-1),a=r.node(i+1)),s&&!s.isTextblock&&MW(s,a)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function HSe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),a=s.node().type;if(i&&a.inlineContent){let d=a.whitespace=="pre",h=!!a.contentMatch.matchType(i);d&&!h?r=!1:!d&&h&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);wW(t,d.node(),d.before(),o)}a.inlineContent&&BP(t,e+n-1,a,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(o),c=l.map(e-n);if(t.step(new Ni(c,l.map(e+n,-1),Et.empty,!0)),r===!0){let d=t.doc.resolve(c);SW(t,d.node(),d.before(),t.steps.length)}return t}function $Se(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 s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function EW(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(o>0?1:0),c=r.node(a),d=!1;if(s==1)d=c.canReplace(l,l,i);else{let h=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=h&&c.canReplaceWith(l,l,h[0])}if(d)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}function Ew(t,e,n=e,r=Et.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return AW(i,s,r)?new Ni(e,n,r):new VSe(i,s,r).fit()}function AW(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class VSe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=pt.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=pt.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 s=this.placed,a=r.depth,o=i.depth;for(;a&&o&&s.childCount==1;)s=s.firstChild.content,a--,o--;let l=new Et(s,a,o);return e>-1?new Ri(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ni(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 s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=_T(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let a=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:c}=this.frontier[o],d,h=null;if(n==1&&(a?c.matchType(a.type)||(h=c.fillBefore(pt.from(a),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:o,parent:s,inject:h};if(n==2&&a&&(d=c.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:o,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=_T(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=_T(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Et(vx(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Et(vx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let a=this.unplaced,o=r?r.content:a.content,l=a.openStart-e,c=0,d=[],{match:h,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));h=h.matchFragment(i)}let m=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let y=o.child(c),b=h.matchType(y.type);if(!b)break;c++,(c>1||l==0||y.content.size)&&(h=b,d.push(TW(y.mark(g.allowedMarks(y.marks)),c==1?l:0,c==o.childCount?m:-1)))}let v=c==o.childCount;v||(m=-1),this.placed=yx(this.placed,n,pt.from(d)),this.frontier[n].match=h,v&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=o;y<m;y++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=v?e==0?Et.empty:new Et(vx(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new Et(vx(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ST(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],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),a=ST(e,n,i,r,s);if(a){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],d=ST(e,o,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:a,move:s?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=yx(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=yx(this.placed,this.depth,pt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(pt.empty,!0);n.childCount&&(this.placed=yx(this.placed,this.frontier.length,n))}}function vx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(vx(t.firstChild.content,e-1,n)))}function yx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(yx(t.lastChild.content,e-1,n)))}function _T(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function TW(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,TW(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(pt.empty,!0)))),t.copy(r)}function ST(t,e,n,r,i){let s=t.node(e),a=i?t.indexAfter(e):t.index(e);if(a==s.childCount&&!n.compatibleContent(s.type))return null;let o=r.fillBefore(s.content,!0,a);return o&&!GSe(n,s.content,a)?o:null}function GSe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function WSe(t){return t.spec.defining||t.spec.definingForContent}function qSe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(AW(i,s,r))return t.step(new Ni(e,n,r));let a=NW(i,s);a[a.length-1]==0&&a.pop();let o=-(i.depth+1);a.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let v=i.node(g).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;a.indexOf(g)>-1?o=g:i.before(g)==m&&a.splice(1,0,-g)}let l=a.indexOf(o),c=[],d=r.openStart;for(let g=r.content,m=0;;m++){let v=g.firstChild;if(c.push(v),m==r.openStart)break;g=v.content}for(let g=d-1;g>=0;g--){let m=c[g],v=WSe(m.type);if(v&&!m.sameMarkup(i.node(Math.abs(o)-1)))d=g;else if(v||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+d+1)%(r.openStart+1),v=c[m];if(v)for(let y=0;y<a.length;y++){let b=a[(y+l)%a.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,v.type,v.marks))return t.replace(i.before(b),x?s.after(b):n,new Et(CW(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let g=a.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>h));g--){let m=a[g];m<0||(e=i.before(m),n=s.after(m))}}function CW(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(CW(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),a=s.fillBefore(t).append(t);t=a.append(s.matchFragment(a).fillBefore(pt.empty,!0))}return t}function XSe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=$Se(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Et(pt.from(r),0,0))}function KSe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=NW(r,i);for(let a=0;a<s.length;a++){let o=s[a],l=a==s.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 a=1;a<=r.depth&&a<=i.depth;a++)if(e-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return t.delete(r.before(a),n);t.delete(e,n)}function NW(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<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;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Vp extends fs{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 qr.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return qr.fromReplace(e,this.pos,this.pos+1,new Et(pt.from(i),0,n.isLeaf?0:1))}getMap(){return fa.empty}invert(e){return new Vp(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 Vp(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 Vp(n.pos,n.attr,n.value)}}fs.jsonID("attr",Vp);class v0 extends fs{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 qr.ok(r)}getMap(){return fa.empty}invert(e){return new v0(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 v0(n.attr,n.value)}}fs.jsonID("docAttr",v0);let um=class extends Error{};um=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};um.prototype=Object.create(Error.prototype);um.prototype.constructor=um;um.prototype.name="TransformError";class kW{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new b0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new um(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=Ew(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Et(pt.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 qSe(this,e,n,r),this}replaceRangeWith(e,n,r){return XSe(this,e,n,r),this}deleteRange(e,n){return KSe(this,e,n),this}lift(e,n){return DSe(this,e,n),this}join(e,n=1){return HSe(this,e,n),this}wrap(e,n){return jSe(this,e,n),this}setBlockType(e,n=e,r,i=null){return ISe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return FSe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Vp(e,n,r)),this}setDocAttribute(e,n){return this.step(new v0(e,n)),this}addNodeMark(e,n){return this.step(new Fu(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 Bf(e,n));else{let i=r.marks,s,a=[];for(;s=n.isInSet(i);)a.push(new Bf(e,s)),i=s.removeFromSet(i);for(let o=a.length-1;o>=0;o--)this.step(a[o])}return this}split(e,n=1,r){return zSe(this,e,n,r),this}addMark(e,n,r){return kSe(this,e,n,r),this}removeMark(e,n,r){return RSe(this,e,n,r),this}clearIncompatible(e,n,r){return BP(this,e,n,r),this}}const wT=Object.create(null);class ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new YSe(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 s=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:l,$to:c}=a[o],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(c.pos),o?Et.empty:n),o==0&&UB(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:o}=i[s],l=e.mapping.slice(r),c=l.map(a.pos),d=l.map(o.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),UB(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Wt(e):Ep(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let a=n<0?Ep(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Ep(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new xa(e.node(0))}static atStart(e){return Ep(e,e,0,0,1)||new xa(e)}static atEnd(e){return Ep(e,e,e.content.size,e.childCount,-1)||new xa(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=wT[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 wT)throw new RangeError("Duplicate use of selection JSON ID "+e);return wT[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Wt.between(this.$anchor,this.$head).getBookmark()}}ln.prototype.visible=!0;class YSe{constructor(e,n){this.$from=e,this.$to=n}}let jB=!1;function IB(t){!jB&&!t.parent.inlineContent&&(jB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Wt extends ln{constructor(e,n=e){IB(e),IB(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 ln.near(r);let i=e.resolve(n.map(this.anchor));return new Wt(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 Wt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Aw(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 Wt(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 s=ln.findFrom(n,r,!0)||ln.findFrom(n,-r,!0);if(s)n=s.$head;else return ln.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ln.findFrom(e,-r,!0)||ln.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Wt(e,n)}}ln.jsonID("text",Wt);class Aw{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Aw(e.map(this.anchor),e.map(this.head))}resolve(e){return Wt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends ln{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),s=e.resolve(i);return r?ln.near(s):new Ht(s)}content(){return new Et(pt.from(this.node),0,0)}eq(e){return e instanceof Ht&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $P(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;ln.jsonID("node",Ht);class $P{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Aw(r,r):new $P(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):ln.near(n)}}class xa extends ln{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=ln.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new xa(e)}map(e){return new xa(e)}eq(e){return e instanceof xa}getBookmark(){return ZSe}}ln.jsonID("all",xa);const ZSe={map(){return this},resolve(t){return new xa(t)}};function Ep(t,e,n,r,i,s=!1){if(e.inlineContent)return Wt.create(t,n);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let o=e.child(a);if(o.isAtom){if(!s&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let l=Ep(t,o,n+i,i<0?o.childCount:0,i,s);if(l)return l}n+=o.nodeSize*i}return null}function UB(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ni||i instanceof Ri))return;let s=t.mapping.maps[r],a;s.forEach((o,l,c,d)=>{a==null&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}const FB=1,qy=2,zB=4;class QSe extends kW{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|FB)&~qy,this.storedMarks=null,this}get selectionSet(){return(this.updated&FB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=qy,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&qy)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~qy,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 s=this.storedMarks;if(!s){let a=this.doc.resolve(n);s=r==n?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ln.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|=zB,this}get scrolledIntoView(){return(this.updated&zB)>0}}function BB(t,e){return!e||!t?t:t.bind(e)}class _x{constructor(e,n,r){this.name=e,this.init=BB(n.init,r),this.apply=BB(n.apply,r)}}const JSe=[new _x("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new _x("selection",{init(t,e){return t.selection||ln.atStart(e.doc)},apply(t){return t.selection}}),new _x("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new _x("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class MT{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=JSe.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 _x(r.key,r.spec.state,r))})}}class Pp{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 s=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let l=i?i[a].n:0,c=i?i[a].state:this,d=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,r);if(d&&r.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<a?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[a]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Pp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new QSe(this)}static create(e){let n=new MT(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Pp(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 MT(this.schema,e.plugins),r=n.fields,i=new Pp(n);for(let s=0;s<r.length;s++){let a=r[s].name;i[a]=this.hasOwnProperty(a)?this[a]:r[s].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],s=i.spec.state;s&&s.toJSON&&(n[r]=s.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 MT(e.schema,e.plugins),s=new Pp(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Wu.fromJSON(e.schema,n.doc);else if(a.name=="selection")s.selection=ln.fromJSON(s.doc,n.selection);else if(a.name=="storedMarks")n.storedMarks&&(s.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==a.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){s[a.name]=c.fromJSON.call(l,e,n[o],s);return}}s[a.name]=a.init(e,s)}}),s}}function RW(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=RW(i,e,{})),n[r]=i}return n}class yr{constructor(e){this.spec=e,this.props={},e.props&&RW(e.props,this,this.props),this.key=e.key?e.key.key:PW("plugin")}getState(e){return e[this.key]}}const ET=Object.create(null);function PW(t){return t in ET?t+"$"+ ++ET[t]:(ET[t]=0,t+"$")}class hi{constructor(e="key"){this.key=PW(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const VP=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function DW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const OW=(t,e,n)=>{let r=DW(t,n);if(!r)return!1;let i=GP(r);if(!i){let a=r.blockRange(),o=a&&Im(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let s=i.nodeBefore;if($W(t,i,e,-1))return!0;if(r.parent.content.size==0&&(dm(s,"end")||Ht.isSelectable(s)))for(let a=r.depth;;a--){let o=Ew(t.doc,r.before(a),r.after(a),Et.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(dm(s,"end")?ln.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ht.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},ewe=(t,e,n)=>{let r=DW(t,n);if(!r)return!1;let i=GP(r);return i?LW(t,i,e):!1},twe=(t,e,n)=>{let r=IW(t,n);if(!r)return!1;let i=WP(r);return i?LW(t,i,e):!1};function LW(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let a=e.nodeAfter,o=a,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let c=Ew(t.doc,s,l,Et.empty);if(!c||c.from!=s||c instanceof Ni&&c.slice.size>=l-s)return!1;if(n){let d=t.tr.step(c);d.setSelection(Wt.create(d.doc,s)),n(d.scrollIntoView())}return!0}function dm(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 jW=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=GP(r)}let a=s&&s.nodeBefore;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function GP(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 IW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const UW=(t,e,n)=>{let r=IW(t,n);if(!r)return!1;let i=WP(r);if(!i)return!1;let s=i.nodeAfter;if($W(t,i,e,1))return!0;if(r.parent.content.size==0&&(dm(s,"start")||Ht.isSelectable(s))){let a=Ew(t.doc,r.before(),r.after(),Et.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(dm(s,"start")?ln.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},FW=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=WP(r)}let a=s&&s.nodeAfter;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos)).scrollIntoView()),!0)};function WP(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 nwe=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!fd(t.doc,n.from))return!1;i=n.from}else if(i=Mw(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Ht.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},rwe=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!fd(t.doc,n.to))return!1;r=n.to}else if(r=Mw(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},iwe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Im(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},zW=(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 qP(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 swe=(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),s=n.indexAfter(-1),a=qP(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,a.createAndFill());l.setSelection(ln.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},BW=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof xa||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=qP(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(a,s.createAndFill());o.setSelection(Wt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},HW=(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 s=n.before();if(pc(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Im(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function awe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!pc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,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=qP(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(l&&o?{type:o}:null),a=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof Wt||e.selection instanceof xa)&&d.deleteSelection();let h=d.mapping.map(r.pos),g=pc(d.doc,h,s.length,s);if(g||(s[0]=o?{type:o}:null,g=pc(d.doc,h,s.length,s)),!g)return!1;if(d.split(h,s.length,s),!l&&c&&r.node(a).type!=o){let m=d.mapping.map(r.before(a)),v=d.doc.resolve(m);o&&r.node(a-1).canReplaceWith(v.index(),v.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(a)),o)}return n&&n(d.scrollIntoView()),!0}}const owe=awe(),lwe=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(Ht.create(t.doc,i))),!0)};function cwe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||fd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function $W(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,a,o,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&cwe(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(a=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(a[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,v=pt.empty;for(let x=a.length-1;x>=0;x--)v=pt.from(a[x].create(null,v));v=pt.from(i.copy(v));let y=t.tr.step(new Ri(e.pos-1,m,e.pos,m,new Et(v,1,0),a.length,!0)),b=y.doc.resolve(m+2*a.length);b.nodeAfter&&b.nodeAfter.type==i.type&&fd(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:ln.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),g=h&&Im(h);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(h,g).scrollIntoView()),!0;if(c&&dm(s,"start",!0)&&dm(i,"end")){let m=i,v=[];for(;v.push(m),!m.isTextblock;)m=m.lastChild;let y=s,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let x=pt.empty;for(let w=v.length-1;w>=0;w--)x=pt.from(v[w].copy(x));let M=t.tr.step(new Ri(e.pos-v.length,e.pos+s.nodeSize,e.pos+b,e.pos+s.nodeSize-b,new Et(x,v.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function VW(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(Wt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const uwe=VW(-1),dwe=VW(1);function fwe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s),o=a&&HP(a,t,e);return o?(r&&r(n.tr.wrap(a,o).scrollIntoView()),!0):!1}}function HB(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[s];n.doc.nodesBetween(a,o,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(c),h=d.index();i=d.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let a=0;a<n.selection.ranges.length;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];s.setBlockType(o,l,t,e)}r(s.scrollIntoView())}return!0}}function XP(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}XP(VP,OW,jW);XP(VP,UW,FW);XP(zW,BW,HW,owe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function hwe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s);if(!a)return!1;let o=r?n.tr:null;return pwe(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function pwe(t,e,n,r=null){let i=!1,s=e,a=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=a.resolve(e.start-2);s=new _1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new _1(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=HP(s,n,r,e);return o?(t&&mwe(t,e,o,i,n),!0):!1}function mwe(t,e,n,r,i){let s=pt.empty;for(let d=n.length-1;d>=0;d--)s=pt.from(n[d].type.create(n[d].attrs,s));t.step(new Ri(e.start-(r?2:0),e.end,e.start,e.end,new Et(s,0,0),n.length,!0));let a=0;for(let d=0;d<n.length;d++)n[d].type==i&&(a=d+1);let o=n.length-a,l=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,h=e.endIndex,g=!0;d<h;d++,g=!1)!g&&pc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(d).nodeSize;return t}function gwe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,a=>a.childCount>0&&a.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?xwe(e,n,t,s):bwe(e,n,s):!0:!1}}function xwe(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Ri(s-1,a,s,a,new Et(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new _1(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const o=Im(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return fd(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function bwe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,v=n.endIndex-1,y=n.startIndex;v>y;v--)m-=i.child(v).nodeSize,r.delete(m-1,m+1);let s=r.doc.resolve(n.start),a=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(o?0:1),d+1,a.content.append(l?pt.empty:pt.from(i))))return!1;let h=s.pos,g=h+a.nodeSize;return r.step(new Ri(h-(o?1:0),g+(l?1:0),h+1,g-1,new Et((o?pt.empty:pt.from(i.copy(pt.empty))).append(l?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,l?0:1),o?0:1)),e(r.scrollIntoView()),!0}function vwe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let a=s.startIndex;if(a==0)return!1;let o=s.parent,l=o.child(a-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==o.type,d=pt.from(c?t.create():null),h=new Et(pt.from(t.create(null,pt.from(o.type.create(null,d)))),c?3:1,0),g=s.start,m=s.end;n(e.tr.step(new Ri(g-(c?3:1),m,g,m,h,1,!0)).scrollIntoView())}return!0}}const Ki=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},fm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ok=null;const Zl=function(t,e,n){let r=ok||(ok=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},ywe=function(){ok=null},Hf=function(t,e,n,r){return n&&($B(t,e,n,r,-1)||$B(t,e,n,r,1))},_we=/^(img|br|input|textarea|hr)$/i;function $B(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Wa(t))){let a=t.parentNode;if(!a||a.nodeType!=1||J0(t)||_we.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ki(t)+(i<0?0:1),t=a}else if(t.nodeType==1){let a=t.childNodes[e+(i<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((s=a.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=a,e=i<0?Wa(t):0}else return!1}}function Wa(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Swe(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=Wa(t)}else if(t.parentNode&&!J0(t))e=Ki(t),t=t.parentNode;else return null}}function wwe(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&&!J0(t))e=Ki(t)+1,t=t.parentNode;else return null}}function Mwe(t,e,n){for(let r=e==0,i=e==Wa(t);r||i;){if(t==n)return!0;let s=Ki(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Wa(t)}}function J0(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 Tw=function(t){return t.focusNode&&Hf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function tf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Ewe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Awe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Wa(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Wa(r.startContainer),r.startOffset)}}}const ol=typeof navigator<"u"?navigator:null,VB=typeof document<"u"?document:null,hd=ol&&ol.userAgent||"",lk=/Edge\/(\d+)/.exec(hd),GW=/MSIE \d/.exec(hd),ck=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hd),Ws=!!(GW||ck||lk),qu=GW?document.documentMode:ck?+ck[1]:lk?+lk[1]:0,Qa=!Ws&&/gecko\/(\d+)/i.test(hd);Qa&&+(/Firefox\/(\d+)/.exec(hd)||[0,0])[1];const uk=!Ws&&/Chrome\/(\d+)/.exec(hd),cs=!!uk,WW=uk?+uk[1]:0,Es=!Ws&&!!ol&&/Apple Computer/.test(ol.vendor),hm=Es&&(/Mobile\/\w+/.test(hd)||!!ol&&ol.maxTouchPoints>2),za=hm||(ol?/Mac/.test(ol.platform):!1),Twe=ol?/Win/.test(ol.platform):!1,oc=/Android \d/.test(hd),eb=!!VB&&"webkitFontSmoothing"in VB.documentElement.style,Cwe=eb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nwe(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 Vl(t,e){return typeof t=="number"?t:t[e]}function kwe(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 GB(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let a=n||t.dom;a;){if(a.nodeType!=1){a=fm(a);continue}let o=a,l=o==s.body,c=l?Nwe(s):kwe(o),d=0,h=0;if(e.top<c.top+Vl(r,"top")?h=-(c.top-e.top+Vl(i,"top")):e.bottom>c.bottom-Vl(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Vl(i,"top")-c.top:e.bottom-c.bottom+Vl(i,"bottom")),e.left<c.left+Vl(r,"left")?d=-(c.left-e.left+Vl(i,"left")):e.right>c.right-Vl(r,"right")&&(d=e.right-c.right+Vl(i,"right")),d||h)if(l)s.defaultView.scrollBy(d,h);else{let m=o.scrollLeft,v=o.scrollTop;h&&(o.scrollTop+=h),d&&(o.scrollLeft+=d);let y=o.scrollLeft-m,b=o.scrollTop-v;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let g=l?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:fm(a)}}function Rwe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,a=n+1;a<Math.min(innerHeight,e.bottom);a+=5){let o=t.root.elementFromPoint(s,a);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:qW(t.dom)}}function qW(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=fm(r));return e}function Pwe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;XW(n,r==0?0:r-e)}function XW(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let xp=null;function Dwe(t){if(t.setActive)return t.setActive();if(xp)return t.focus(xp);let e=qW(t);t.focus(xp==null?{get preventScroll(){return xp={preventScroll:!0},!0}}:void 0),xp||(xp=!1,XW(e,0))}function KW(t,e){let n,r=2e8,i,s=0,a=e.top,o=e.top,l,c;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=Zl(d).getClientRects();else continue;for(let m=0;m<g.length;m++){let v=g[m];if(v.top<=a&&v.bottom>=o){a=Math.max(v.bottom,a),o=Math.min(v.top,o);let y=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,d.nodeType==1&&y&&(s=h+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!l&&v.left<=e.left&&v.right>=e.left&&(l=d,c={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(s=h+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?Owe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:KW(n,i)}function Owe(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 s=_u(r,1);if(s.top!=s.bottom&&KP(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function KP(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Lwe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function jwe(t,e,n){let{node:r,offset:i}=KW(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let a=r.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Iwe(t,e,n,r){let i=-1;for(let s=e,a=!1;s!=t.dom;){let o=t.docView.nearestDesc(s,!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)&&(!a&&l.left>r.left||l.top>r.top?i=o.posBefore:(!a&&l.right<r.left||l.bottom<r.top)&&(i=o.posAfter),a=!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;s=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function YW(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)),s=i;;){let a=t.childNodes[s];if(a.nodeType==1){let o=a.getClientRects();for(let l=0;l<o.length;l++){let c=o[l];if(KP(e,c))return YW(a,e,c)}}if((s=(s+1)%r)==i)break}return t}function Uwe(t,e){let n=t.dom.ownerDocument,r,i=0,s=Awe(n,e.left,e.top);s&&({node:r,offset:i}=s);let a=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!a||!t.dom.contains(a.nodeType!=1?a.parentNode:a)){let c=t.dom.getBoundingClientRect();if(!KP(e,c)||(a=YW(t.dom,e,c),!a))return null}if(Es)for(let c=a;r&&c;c=fm(c))c.draggable&&(r=void 0);if(a=Lwe(a,e),r){if(Qa&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;eb&&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=Iwe(t,r,i,e))}o==null&&(o=jwe(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function WB(t){return t.top<t.bottom||t.left<t.right}function _u(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(WB(r))return r}return Array.prototype.find.call(n,WB)||t.getBoundingClientRect()}const Fwe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ZW(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),a=eb||Qa;if(r.nodeType==3)if(a&&(Fwe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=_u(Zl(r,i,i),n);if(Qa&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=_u(Zl(r,i-1,i-1),-1);if(c.top==l.top){let d=_u(Zl(r,i,i+1),-1);if(d.top!=l.top)return ix(d,d.left<c.left)}}return l}else{let l=i,c=i,d=n<0?1:-1;return n<0&&!i?(c++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:c++,ix(_u(Zl(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Wa(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return AT(l.getBoundingClientRect(),!1)}if(s==null&&i<Wa(r)){let l=r.childNodes[i];if(l.nodeType==1)return AT(l.getBoundingClientRect(),!0)}return AT(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Wa(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Zl(l,Wa(l)-(a?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return ix(_u(c,1),!1)}if(s==null&&i<Wa(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Zl(l,0,a?0:1):l.nodeType==1?l:null:null;if(c)return ix(_u(c,-1),!0)}return ix(_u(r.nodeType==3?Zl(r):r,-n),n>=0)}function ix(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 AT(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 QW(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 zwe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return QW(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(s,!0);if(!o)break;if(o.node.isBlock){s=o.contentDOM||o.dom;break}s=o.dom.parentNode}let a=ZW(t,i.pos,1);for(let o=s.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Zl(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const Bwe=/[\u0590-\u08ac]/;function Hwe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,a=i==r.parent.content.size,o=t.domSelection();return o?!Bwe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?s:a:QW(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:y}=t.domSelectionRange(),b=v&&!m.contains(v.nodeType==1?v:v.parentNode)||l==v&&c==y;try{o.collapse(d,h),l&&(l!=d||c!=h)&&o.extend&&o.extend(l,c)}catch{}return g!=null&&(o.caretBidiLevel=g),b}):r.pos==r.start()||r.pos==r.end()}let qB=null,XB=null,KB=!1;function $we(t,e,n){return qB==e&&XB==n?KB:(qB=e,XB=n,KB=n=="up"||n=="down"?zwe(t,e,n):Hwe(t,e,n))}const Ja=0,YB=1,sf=2,ll=3;class tb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ja,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 s,a;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(a)+a.size:this.posAtStart}else{let s,a;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ki(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 s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.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 s=this.getDesc(i),a;if(s&&(!n||s.node))if(r&&(a=s.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))r=!1;else return s}}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 s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let a=0;a<i.children.length;a++){let o=i.children[a];if(o.size){i=o;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let a=this.children[r],o=s+a.size;if(o>e||a instanceof eq){i=e-s;break}s=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof JW&&s.side>=0;r--);if(n<=0){let s,a=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,a=!1);return s&&n&&a&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ki(s.dom)+1:0}}else{let s,a=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,a=!1);return s&&a&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ki(s.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,s=-1;for(let a=r,o=0;;o++){let l=this.children[o],c=a+l.size;if(i==-1&&e<=c){let d=a+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=a;for(let h=o;h>0;h--){let g=this.children[h-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Ki(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 d=o+1;d<this.children.length;d++){let h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=Ki(h.dom);break}n+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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 s=Math.min(e,n),a=Math.max(e,n);for(let m=0,v=0;m<this.children.length;m++){let y=this.children[m],b=v+y.size;if(s>v&&a<b)return y.setSelection(e-v-y.border,n-v-y.border,r,i);v=b}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),h=!1;if((Qa||Es)&&e==n){let{node:m,offset:v}=o;if(m.nodeType==3){if(h=!!(v&&m.nodeValue[v-1]==`
  8065. `),h&&v==m.nodeValue.length)for(let y=m,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(o=l={node:b.parentNode,offset:Ki(b)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[v-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Qa&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||h&&Es)&&Hf(o.node,o.offset,d.anchorNode,d.anchorOffset)&&Hf(l.node,l.offset,d.focusNode,d.focusOffset))return;let g=!1;if((c.extend||e==n)&&!(h&&Qa)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let v=o;o=l,l=v}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 s=this.children[i],a=r+s.size;if(r==a?e<=a&&n>=r:e<a&&n>r){let o=r+s.border,l=a-s.border;if(e>=o&&n<=l){this.dirty=e==r||n==a?sf:YB,e==o&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ll:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?sf:ll}r=a}this.dirty=sf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?sf:YB;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class JW extends tb{constructor(e,n,r,i){let s,a=n.type.toDOM;if(typeof a=="function"&&(a=a(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(a.nodeType!=1){let o=document.createElement("span");o.appendChild(a),a=o}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Ja&&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 Vwe extends tb{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 $f extends tb{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],a=s&&s(n,i,r);return(!a||!a.dom)&&(a=th.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new $f(e,n,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&ll||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ll&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ja){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ja}}slice(e,n,r){let i=$f.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;n<a&&(s=fk(s,n,a,r)),e>0&&(s=fk(s,0,e,r));for(let o=0;o<s.length;o++)s[o].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Xu extends tb{constructor(e,n,r,i,s,a,o,l,c){super(e,[],s,a),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,s,a){let o=s.nodeViews[n.type.name],l,c=o&&o(n,s,()=>{if(!l)return a;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,h=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=th.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=rq(d,r,n),c?l=new Gwe(e,n,r,i,d,h||null,g,c,s,a+1):n.isText?new Cw(e,n,r,i,d,g,s):new Xu(e,n,r,i,d,h||null,g,s,a+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=()=>pt.empty)}return e}matchesNode(e,n,r){return this.dirty==Ja&&e.eq(this.node)&&w1(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,s=e.composing?this.localCompositionInfo(e,n):null,a=s&&s.pos>-1?s:null,o=s&&s.pos<0,l=new qwe(this,a&&a.node,e);Ywe(this.node,this.innerDeco,(c,d,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&l.syncToMarks(d==this.node.childCount?Kn.none:this.node.child(d).marks,r,e),l.placeWidget(c,e,i)},(c,d,h,g)=>{l.syncToMarks(c.marks,r,e);let m;l.findNodeMatch(c,d,h,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(m=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,d,h,m,e)||l.updateNextNode(c,d,h,e,g,i)||l.addNode(c,d,h,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==sf)&&(a&&this.protectLocalComposition(e,a),tq(this.contentDOM,this.children,e),hm&&Zwe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Wt)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,o=Qwe(this.node.content,a,r-n,i-n);return o<0?null:{node:s,pos:o,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let a=new Vwe(this,s,n,i);e.input.compositionNodes.push(a),this.children=fk(this.children,r,r+i.length,e,a)}update(e,n,r,i){return this.dirty==ll||!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=Ja}updateOuterDeco(e){if(w1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=nq(this.dom,this.nodeDOM,dk(this.outerDeco,this.node,n),dk(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 ZB(t,e,n,r,i){rq(r,e,t);let s=new Xu(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Cw extends Xu{constructor(e,n,r,i,s,a,o){super(e,n,r,i,s,null,a,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==ll||this.dirty!=Ja&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ja||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=Ja,!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),s=document.createTextNode(i.text);return new Cw(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ll)}get domAtom(){return!1}isText(e){return this.node.text==e}}class eq extends tb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ja&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Gwe extends Xu{constructor(e,n,r,i,s,a,o,l,c,d){super(e,n,r,i,s,a,o,c,d),this.spec=l}update(e,n,r,i){if(this.dirty==ll)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}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 tq(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let a=e[s],o=a.dom;if(o.parentNode==t){for(;o!=r;)r=QB(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(a instanceof $f){let l=r?r.previousSibling:t.lastChild;tq(a.contentDOM,a.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=QB(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ux=function(t){t&&(this.nodeName=t)};Ux.prototype=Object.create(null);const af=[new Ux];function dk(t,e,n){if(t.length==0)return af;let r=n?af[0]:new Ux,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new Ux(a.nodeName));for(let o in a){let l=a[o];l!=null&&(n&&i.length==1&&i.push(r=new Ux(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 nq(t,e,n,r){if(n==af&&r==af)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],o=n[s];if(s){let l;o&&o.nodeName==a.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==a.nodeName||(l=document.createElement(a.nodeName),l.pmIsDeco=!0,l.appendChild(i),o=af[0]),i=l}Wwe(i,o||af[0],a)}return i}function Wwe(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 s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);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 rq(t,e,n){return nq(t,t,af,dk(e,n,t.nodeType!=1))}function w1(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 QB(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class qwe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Xwe(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,s=this.stack.length>>1,a=Math.min(s,e.length);for(;i<a&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Ja,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<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[s])&&!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=$f.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,n,r))s=this.top.children.indexOf(a,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)){s=o;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let a=this.top.children[i];return a.dirty==ll&&a.dom==a.contentDOM&&(a.dirty=sf),a.update(e,n,r,s)?(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,s,a){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Xu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let d=l.dom,h,g=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ll&&w1(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(h=this.recreateWrapper(l,e,n,r,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=sf,h.updateChildren(i,a+1),h.dirty=Ja),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,a){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!w1(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Xu.create(this.top,n,r,i,s,a);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,s){let a=Xu.create(this.top,e,n,r,i,s);a.contentDOM&&a.updateChildren(i,s+1),this.top.children.splice(this.index++,0,a),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 s=new JW(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof $f;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Cw)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Es||cs)&&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 eq(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 Xwe(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,a=[];e:for(;i>0;){let o;for(;;)if(r){let c=n.children[r-1];if(c instanceof $f)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,s.set(o,i),a.push(o)}}return{index:i,matched:s,matches:a.reverse()}}function Kwe(t,e){return t.type.side-e.type.side}function Ywe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,i,e.forChild(s,d),c),s+=d.nodeSize}return}let a=0,o=[],l=null;for(let c=0;;){let d,h;for(;a<i.length&&i[a].to==s;){let b=i[a++];b.widget&&(d?(h||(h=[d])).push(b):d=b)}if(d)if(h){h.sort(Kwe);for(let b=0;b<h.length;b++)n(h[b],c,!!l)}else n(d,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<=s&&o.splice(b--,1);for(;a<i.length&&i[a].from<=s&&i[a].to>s;)o.push(i[a++]);let v=s+g.nodeSize;if(g.isText){let b=v;a<i.length&&i[a].from<b&&(b=i[a].from);for(let x=0;x<o.length;x++)o[x].to<b&&(b=o[x].to);b<v&&(l=g.cut(b-s),g=g.cut(0,b-s),v=b,m=-1)}else for(;a<i.length&&i[a].to<v;)a++;let y=g.isInline&&!g.isLeaf?o.filter(b=>!b.inline):o.slice();r(g,y,e.forChild(s,g),m),s=v}}function Zwe(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 Qwe(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let a=t.child(i++),o=s;if(s+=a.nodeSize,!a.isText)continue;let l=a.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=n){if(s>=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 fk(t,e,n,r,i){let s=[];for(let a=0,o=0;a<t.length;a++){let l=t[a],c=o,d=o+=l.size;c>=n||d<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),d>n&&s.push(l.slice(n-c,l.size,r)))}return s}function YP(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,a=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),l,c;if(Tw(n)){for(l=a;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&Ht.isSelectable(h)&&i.parent&&!(h.isInline&&Mwe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;c=new Ht(a==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=a,g=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;[l,a]=g==t.state.selection.anchor?[g,h]:[h,g],o=r.resolve(a)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let h=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;c=ZP(t,d,o,h)}return c}function iq(t){return t.editable?t.hasFocus():aq(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function mc(t,e=!1){let n=t.state.selection;if(sq(t,n),!!iq(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&cs){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Hf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)eMe(t);else{let{anchor:r,head:i}=n,s,a;JB&&!(n instanceof Wt)&&(n.$from.parent.inlineContent||(s=e6(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=e6(t,n.to))),t.docView.setSelection(r,i,t,e),JB&&(s&&t6(s),a&&t6(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Jwe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const JB=Es||cs&&WW<63;function e6(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Es&&i&&i.contentEditable=="false")return TT(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return TT(i);if(s)return TT(s)}}function TT(t){return t.contentEditable="true",Es&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function t6(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Jwe(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(()=>{(!iq(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function eMe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ki(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ws&&qu<=11&&(n.disabled=!0,n.disabled=!1)}function sq(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(n6(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else n6(t)}function n6(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ZP(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Wt.between(e,n,r)}function r6(t){return t.editable&&!t.hasFocus()?!1:aq(t)}function aq(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 tMe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Hf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function hk(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ln.findFrom(s,e)}function Mu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function i6(t,e,n){let r=t.state.selection;if(r instanceof Wt)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Mu(t,new Wt(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=hk(t.state,e);return i&&i instanceof Ht?Mu(t,i):!1}else if(!(za&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?Ht.isSelectable(s)?Mu(t,new Ht(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):eb?Mu(t,new Wt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Mu(t,new Wt(e>0?r.$to:r.$from));{let i=hk(t.state,e);return i?Mu(t,i):!1}}}function M1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Fx(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function bp(t,e){return e<0?nMe(t):rMe(t)}function nMe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(Qa&&n.nodeType==1&&r<M1(n)&&Fx(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Fx(o,-1))i=n,s=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(oq(n))break;{let o=n.previousSibling;for(;o&&Fx(o,-1);)i=n.parentNode,s=Ki(o),o=o.previousSibling;if(o)n=o,r=M1(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?pk(t,n,r):i&&pk(t,i,s)}function rMe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=M1(n),s,a;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Fx(o,1))s=n,a=++r;else break}else{if(oq(n))break;{let o=n.nextSibling;for(;o&&Fx(o,1);)s=o.parentNode,a=Ki(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=M1(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&pk(t,s,a)}function oq(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function iMe(t,e){for(;t&&e==t.childNodes.length&&!J0(t);)e=Ki(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 sMe(t,e){for(;t&&!e&&!J0(t);)e=Ki(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 pk(t,e,n){if(e.nodeType!=3){let s,a;(a=iMe(e,n))?(e=a,n=0):(s=sMe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Tw(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&mc(t)},50)}function s6(t,e){let n=t.state.doc.resolve(e);if(!(cs||Twe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function a6(t,e,n){let r=t.state.selection;if(r instanceof Wt&&!r.empty||n.indexOf("s")>-1||za&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=hk(t.state,e);if(a&&a instanceof Ht)return Mu(t,a)}if(!i.parent.inlineContent){let a=e<0?i:s,o=r instanceof xa?ln.near(a,e):ln.findFrom(a,e);return o?Mu(t,o):!1}return!1}function o6(t,e){if(!(t.state.selection instanceof Wt))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 s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let a=t.state.tr;return e<0?a.delete(n.pos-s.nodeSize,n.pos):a.delete(n.pos,n.pos+s.nodeSize),t.dispatch(a),!0}return!1}function l6(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function aMe(t){if(!Es||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;l6(t,r,"true"),setTimeout(()=>l6(t,r,"false"),20)}return!1}function oMe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function lMe(t,e){let n=e.keyCode,r=oMe(e);if(n==8||za&&n==72&&r=="c")return o6(t,-1)||bp(t,-1);if(n==46&&!e.shiftKey||za&&n==68&&r=="c")return o6(t,1)||bp(t,1);if(n==13||n==27)return!0;if(n==37||za&&n==66&&r=="c"){let i=n==37?s6(t,t.state.selection.from)=="ltr"?-1:1:-1;return i6(t,i,r)||bp(t,i)}else if(n==39||za&&n==70&&r=="c"){let i=n==39?s6(t,t.state.selection.from)=="ltr"?1:-1:1;return i6(t,i,r)||bp(t,i)}else{if(n==38||za&&n==80&&r=="c")return a6(t,-1,r)||bp(t,-1);if(n==40||za&&n==78&&r=="c")return aMe(t)||a6(t,1,r)||bp(t,1);if(r==(za?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function QP(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=t.someProp("clipboardSerializer")||th.fromSchema(t.state.schema),o=hq(),l=o.createElement("div");l.appendChild(a.serializeFragment(r,{document:o}));let c=l.firstChild,d,h=0;for(;c&&c.nodeType==1&&(d=fq[c.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let v=o.createElement(d[m]);for(;l.firstChild;)v.appendChild(l.firstChild);l.appendChild(v),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${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 lq(t,e,n,r,i){let s=i.parent.type.spec.code,a,o;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",g=>{e=g(e,s||r,t)}),s)return o=new Et(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8067. `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let h=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(h)o=h;else{let g=i.marks(),{schema:m}=t.state,v=th.fromSchema(m);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=a.appendChild(document.createElement("p"));y&&b.appendChild(v.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),a=fMe(n),eb&&hMe(a);let c=a&&a.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let g=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||jx.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!cMe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=pMe(c6(o,+d[1],+d[2]),d[4]);else if(o=Et.maxOpen(uMe(o.content,i),!0),o.openStart||o.openEnd){let h=0,g=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=c6(o,h,g)}return t.someProp("transformPasted",h=>{o=h(o,t,l)}),o}const cMe=/^(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 uMe(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)),s,a=[];if(t.forEach(o=>{if(!a)return;let l=i.findWrapping(o.type),c;if(!l)return a=null;if(c=a.length&&s.length&&uq(l,s,o,a[a.length-1],0))a[a.length-1]=c;else{a.length&&(a[a.length-1]=dq(a[a.length-1],s.length));let d=cq(o,l);a.push(d),i=i.matchType(d.type),s=l}}),a)return pt.from(a)}return t}function cq(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function uq(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=uq(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(pt.from(cq(n,t,i+1))))}}function dq(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,dq(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function mk(t,e,n,r,i,s){let a=e<0?t.firstChild:t.lastChild,o=a.content;return t.childCount>1&&(s=0),i<r-1&&(o=mk(o,e,n,r,i+1,s)),i>=n&&(o=e<0?a.contentMatchAt(0).fillBefore(o,s<=i).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(o))}function c6(t,e,n){return e<t.openStart&&(t=new Et(mk(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Et(mk(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const fq={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 u6=null;function hq(){return u6||(u6=document.implementation.createHTMLDocument("title"))}let CT=null;function dMe(t){let e=window.trustedTypes;return e?(CT||(CT=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),CT.createHTML(t)):t}function fMe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=hq().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&fq[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=dMe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function hMe(t){let e=t.querySelectorAll(cs?"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 pMe(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:s,openEnd:a}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=pt.from(l.create(r[o+1],i)),s++,a++}return new Et(i,s,a)}const As={},Ts={},mMe={touchstart:!0,touchmove:!0};class gMe{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 xMe(t){for(let e in As){let n=As[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{vMe(t,r)&&!JP(t,r)&&(t.editable||!(r.type in Ts))&&n(t,r)},mMe[e]?{passive:!0}:void 0)}Es&&t.dom.addEventListener("input",()=>null),gk(t)}function zu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function bMe(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 gk(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>JP(t,r))})}function JP(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function vMe(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 yMe(t,e){!JP(t,e)&&As[e.type]&&(t.editable||!(e.type in Ts))&&As[e.type](t,e)}Ts.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!mq(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(oc&&cs&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),hm&&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,tf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||lMe(t,n)?n.preventDefault():zu(t,"key")};Ts.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ts.keypress=(t,e)=>{let n=e;if(mq(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||za&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Wt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",a=>a(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function Nw(t){return{left:t.clientX,top:t.clientY}}function _Me(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function eD(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let a=s.depth+1;a>0;a--)if(t.someProp(e,o=>a>s.depth?o(t,n,s.nodeAfter,s.before(a),i,!0):o(t,n,s.node(a),s.before(a),i,!1)))return!0;return!1}function Gp(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 SMe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(Gp(t,new Ht(n)),!0):!1}function wMe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let s=t.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let o=a>s.depth?s.nodeAfter:s.node(a);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(a);break}}return i!=null?(Gp(t,Ht.create(t.state.doc,i)),!0):!1}function MMe(t,e,n,r,i){return eD(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?wMe(t,n):SMe(t,n))}function EMe(t,e,n,r){return eD(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function AMe(t,e,n,r){return eD(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||TMe(t,n,r)}function TMe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Gp(t,Wt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),o=i.before(s);if(a.inlineContent)Gp(t,Wt.create(r,o+1,o+1+a.content.size));else if(Ht.isSelectable(a))Gp(t,Ht.create(r,o));else continue;return!0}}function tD(t){return E1(t)}const pq=za?"metaKey":"ctrlKey";As.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=tD(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&_Me(n,t.input.lastClick)&&!n[pq]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let a=t.posAtCoords(Nw(n));a&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new CMe(t,a,n,!!r)):(s=="doubleClick"?EMe:AMe)(t,a.pos,a.inside,n)?n.preventDefault():zu(t,"pointer"))};class CMe{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[pq],this.allowDefault=r.shiftKey;let s,a;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),a=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,a=d.depth?d.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&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof Ht&&c.from<=a&&c.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Qa&&!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)),zu(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(()=>mc(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(Nw(e))),this.updateAllowDefault(e),this.allowDefault||!n?zu(this.view,"pointer"):MMe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Es&&this.mightDrag&&!this.mightDrag.node.isAtom||cs&&!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)?(Gp(this.view,ln.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):zu(this.view,"pointer")}move(e){this.updateAllowDefault(e),zu(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)}}As.touchstart=t=>{t.input.lastTouch=Date.now(),tD(t),zu(t,"pointer")};As.touchmove=t=>{t.input.lastTouch=Date.now(),zu(t,"pointer")};As.contextmenu=t=>tD(t);function mq(t,e){return t.composing?!0:Es&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const NMe=oc?5e3:-1;Ts.compositionstart=Ts.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Wt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),E1(t,!0),t.markCursor=null;else if(E1(t,!e.selection.empty),Qa&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let a=s<0?i.lastChild:i.childNodes[s-1];if(!a)break;if(a.nodeType==3){let o=t.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else i=a,s=-1}}t.input.composing=!0}gq(t,NMe)};Ts.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,gq(t,20))};function gq(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>E1(t),e))}function xq(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=RMe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function kMe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Swe(e.focusNode,e.focusOffset),r=wwe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let a=n.pmViewDesc;if(!(!a||!a.isText(n.nodeValue)))return r}}return n||r}function RMe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function E1(t,e=!1){if(!(oc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),xq(t),e||t.docView&&t.docView.dirty){let n=YP(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 PMe(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 y0=Ws&&qu<15||hm&&Cwe<604;As.copy=Ts.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=y0?null:n.clipboardData,a=r.content(),{dom:o,text:l}=QP(t,a);s?(n.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",l)):PMe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function DMe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function OMe(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?_0(t,r.value,null,i,e):_0(t,r.textContent,r.innerHTML,i,e)},50)}function _0(t,e,n,r,i){let s=lq(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||Et.empty)))return!0;if(!s)return!1;let a=DMe(s),o=a?t.state.tr.replaceSelectionWith(a,r):t.state.tr.replaceSelection(s);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bq(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ts.paste=(t,e)=>{let n=e;if(t.composing&&!oc)return;let r=y0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&_0(t,bq(r),r.getData("text/html"),i,n)?n.preventDefault():OMe(t,n)};class vq{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const LMe=za?"altKey":"ctrlKey";function yq(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[LMe]}As.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(Nw(n)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)a=Ht.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(a=Ht.create(t.state.doc,h.posBefore))}}let o=(a||t.state.selection).content(),{dom:l,text:c,slice:d}=QP(t,o);(!n.dataTransfer.files.length||!cs||WW>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(y0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",y0||n.dataTransfer.setData("text/plain",c),t.dragging=new vq(d,yq(t,n),a)};As.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ts.dragover=Ts.dragenter=(t,e)=>e.preventDefault();Ts.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(Nw(n));if(!i)return;let s=t.state.doc.resolve(i.pos),a=r&&r.slice;a?t.someProp("transformPasted",v=>{a=v(a,t,!1)}):a=lq(t,bq(n.dataTransfer),y0?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&yq(t,n));if(t.someProp("handleDrop",v=>v(t,n,a||Et.empty,o))){n.preventDefault();return}if(!a)return;n.preventDefault();let l=a?EW(t.state.doc,s.pos,a):s.pos;l==null&&(l=s.pos);let c=t.state.tr;if(o){let{node:v}=r;v?v.replace(c):c.deleteSelection()}let d=c.mapping.map(l),h=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,g=c.doc;if(h?c.replaceRangeWith(d,d,a.content.firstChild):c.replaceRange(d,d,a),c.doc.eq(g))return;let m=c.doc.resolve(d);if(h&&Ht.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Ht(m));else{let v=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((y,b,x,M)=>v=M),c.setSelection(ZP(t,m,c.doc.resolve(v)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};As.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())&&mc(t)},20))};As.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)};As.beforeinput=(t,e)=>{if(cs&&oc&&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",s=>s(t,tf(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Ts)As[t]=Ts[t];function S0(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 A1{constructor(e,n){this.toDOM=e,this.spec=n||bf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:a}=e.mapResult(n.from+i,this.side<0?-1:1);return a?null:new ys(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof A1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&S0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ku{constructor(e,n){this.attrs=e,this.spec=n||bf}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,a=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=a?null:new ys(s,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ku&&S0(this.attrs,e.attrs)&&S0(this.spec,e.spec)}static is(e){return e.type instanceof Ku}destroy(){}}class nD{constructor(e,n){this.attrs=e,this.spec=n||bf}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let a=e.mapResult(n.to+i,-1);return a.deleted||a.pos<=s.pos?null:new ys(s.pos-r,a.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof nD&&S0(this.attrs,e.attrs)&&S0(this.spec,e.spec)}destroy(){}}class ys{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ys(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 ys(e,e,new A1(n,r))}static inline(e,n,r,i){return new ys(e,n,new Ku(r,i))}static node(e,n,r,i){return new ys(e,n,new nD(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ku}get widget(){return this.type instanceof A1}}const Ap=[],bf={};class xr{constructor(e,n){this.local=e.length?e:Ap,this.children=n.length?n:Ap}static create(e,n){return n.length?T1(n,e,0,bf):ss}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=e&&(!s||s(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,n-o,r,i+o,s)}}map(e,n,r){return this==ss||e.maps.length==0?this:this.mapInner(e,n,0,0,r||bf)}mapInner(e,n,r,i,s){let a;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(a||(a=[])).push(l):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?jMe(this.children,a||[],e,n,r,i,s):a?new xr(a.sort(vf),Ap):ss}add(e,n){return n.length?this==ss?xr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((o,l)=>{let c=l+r,d;if(d=Sq(n,o,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(o,d,c+1):i.splice(s,0,l,l+o.nodeSize,T1(d,o,c+1,bf)),s+=3}});let a=_q(s?wq(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new xr(a.length?this.local.concat(a).sort(vf):this.local,i||this.children)}remove(e){return e.length==0||this==ss?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,o=r[s]+n,l=r[s+1]+n;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>o&&h.to<l&&(e[d]=null,(a||(a=[])).push(h));if(!a)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(a,o+1);c!=ss?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,a;s<e.length;s++)if(a=e[s])for(let o=0;o<i.length;o++)i[o].eq(a,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 xr(i,r):ss}forChild(e,n){if(this==ss)return this;if(n.isLeaf)return xr.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 s=e+1,a=s+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<a&&l.to>s&&l.type instanceof Ku){let c=Math.max(s,l.from)-s,d=Math.min(a,l.to)-s;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let o=new xr(i.sort(vf),Ap);return r?new Ru([o,r]):o}return r||ss}eq(e){if(this==e)return!0;if(!(e instanceof xr)||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 rD(this.localsInner(e))}localsInner(e){if(this==ss)return Ap;if(e.inlineContent||!this.local.some(Ku.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ku||n.push(this.local[r]);return n}forEachSet(e){e(this)}}xr.empty=new xr([],[]);xr.removeOverlap=rD;const ss=xr.empty;class Ru{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,bf));return Ru.from(r)}forChild(e,n){if(n.isLeaf)return xr.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=ss&&(s instanceof Ru?r=r.concat(s.members):r.push(s))}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 s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let a=0;a<s.length;a++)n.push(s[a])}}return n?rD(r?n:n.sort(vf)):Ap}static from(e){switch(e.length){case 0:return ss;case 1:return e[0];default:return new Ru(e.every(n=>n instanceof xr)?e:e.reduce((n,r)=>n.concat(r instanceof xr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function jMe(t,e,n,r,i,s,a){let o=t.slice();for(let c=0,d=s;c<n.maps.length;c++){let h=0;n.maps[c].forEach((g,m,v,y)=>{let b=y-v-(m-g);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||g>M+d-h)continue;let w=o[x]+d-h;m>=w?o[x+1]=g<=w?-2:-1:g>=d&&b&&(o[x]+=b,o[x+1]+=b)}h+=b}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){l=!0,o[c+1]=-1;continue}let d=n.map(t[c]+s),h=d-i;if(h<0||h>=r.content.size){l=!0;continue}let g=n.map(t[c+1]+s,-1),m=g-i,{index:v,offset:y}=r.content.findIndex(h),b=r.maybeChild(v);if(b&&y==h&&y+b.nodeSize==m){let x=o[c+2].mapInner(n,b,d+1,t[c]+s+1,a);x!=ss?(o[c]=h,o[c+1]=m,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=IMe(o,t,e,n,i,s,a),d=T1(c,r,0,a);e=d.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,g=0;h<d.children.length;h+=3){let m=d.children[h];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,d.children[h],d.children[h+1],d.children[h+2])}}return new xr(e.sort(vf),o)}function _q(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 ys(i.from+e,i.to+e,i.type))}return n}function IMe(t,e,n,r,i,s,a){function o(l,c){for(let d=0;d<l.local.length;d++){let h=l.local[d].map(r,i,c);h?n.push(h):a.onRemove&&a.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)o(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+s+1);return n}function Sq(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,a;s<t.length;s++)(a=t[s])&&a.from>n&&a.to<r&&((i||(i=[])).push(a),t[s]=null);return i}function wq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function T1(t,e,n,r){let i=[],s=!1;e.forEach((o,l)=>{let c=Sq(t,o,l+n);if(c){s=!0;let d=T1(c,o,n+l+1,r);d!=ss&&i.push(l,l+o.nodeSize,d)}});let a=_q(s?wq(t):t,-n).sort(vf);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||i.length?new xr(a,i):ss}function vf(t,e){return t.from-e.from||t.to-e.to}function rD(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 s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),d6(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),d6(e,i,r.copy(s.from,r.to)));break}}}return e}function d6(t,e,n){for(;e<t.length&&vf(n,t[e])>0;)e++;t.splice(e,0,n)}function NT(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ss&&e.push(r)}),t.cursorWrapper&&e.push(xr.create(t.state.doc,[t.cursorWrapper.deco])),Ru.from(e)}const UMe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},FMe=Ws&&qu<=11;class zMe{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 BMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new zMe,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]);Ws&&qu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),FMe&&(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,UMe)),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(r6(this.view)){if(this.suppressingSelectionUpdates)return mc(this.view);if(Ws&&qu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Hf(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 s=e.focusNode;s;s=fm(s))n.add(s);for(let s=e.anchorNode;s;s=fm(s))if(n.has(s)){r=s;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)&&r6(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,o=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let h=this.registerMutation(n[d],l);h&&(s=s<0?h.from:Math.min(h.from,s),a=a<0?h.to:Math.max(h.to,a),h.typeOver&&(o=!0))}if(Qa&&l.length){let d=l.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,g]=d;h.parentNode&&h.parentNode.parentNode==g.parentNode?g.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let g of d){let m=g.parentNode;m&&m.nodeName=="LI"&&(!h||VMe(e,h)!=m)&&g.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Tw(r)&&(c=YP(e))&&c.eq(ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,mc(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),HMe(e)),this.handleDOMChange(s,a,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||mc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ws&&qu<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:g}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(s=g)}let a=i&&i.parentNode==e.target?Ki(i)+1:0,o=r.localPosFromDOM(e.target,a,-1),l=s&&s.parentNode==e.target?Ki(s):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 f6=new WeakMap,h6=!1;function HMe(t){if(!f6.has(t)&&(f6.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Qa,h6)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."),h6=!0}}function p6(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return Hf(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function $Me(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return p6(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?p6(t,n):null}function VMe(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 GMe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:a,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],Tw(l)||c.push({node:l.focusNode,offset:l.focusOffset})),cs&&t.input.lastKeyCode===8)for(let b=s;b>i;b--){let x=r.childNodes[b-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){s=b;break}if(!M||M.size)break}let h=t.state.doc,g=t.someProp("domParser")||jx.fromSchema(t.state.schema),m=h.resolve(a),v=null,y=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:WMe,context:m});if(c&&c[0].pos!=null){let b=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=b),v={anchor:b+a,head:x+a}}return{doc:y,sel:v,from:a,to:o}}function WMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Es&&/^(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||Es&&/^(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 qMe=/^(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 XMe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=YP(t,C);if(I&&!t.state.selection.eq(I)){if(cs&&oc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,tf(13,"Enter"))))return;let N=t.state.tr.setSelection(I);C=="pointer"?N.setMeta("pointer",!0):C=="key"&&N.scrollIntoView(),s&&N.setMeta("composition",s),t.dispatch(N)}return}let a=t.state.doc.resolve(e),o=a.sharedDepth(n);e=a.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,c=GMe(t,e,n),d=t.state.doc,h=d.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 v=ZMe(h.content,c.doc.content,c.from,g,m);if(v&&t.input.domChangeCount++,(hm&&t.input.lastIOSEnter>Date.now()-225||oc)&&i.some(C=>C.nodeType==1&&!qMe.test(C.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",C=>C(t,tf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&l instanceof Wt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))v={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let C=m6(t,t.state.doc,c.sel);if(C&&!C.eq(t.state.selection)){let I=t.state.tr.setSelection(C);s&&I.setMeta("composition",s),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof Wt&&(v.start>t.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?v.start=t.state.selection.from:v.endA<t.state.selection.to&&v.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),Ws&&qu<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>c.from&&c.doc.textBetween(v.start-c.from-1,v.start-c.from+1)=="  "&&(v.start--,v.endA--,v.endB--);let y=c.doc.resolveNoCache(v.start-c.from),b=c.doc.resolveNoCache(v.endB-c.from),x=d.resolve(v.start),M=y.sameParent(b)&&y.parent.inlineContent&&x.end()>=v.endA;if((hm&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!M&&y.pos<c.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(c.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,tf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&YMe(d,v.start,v.endA,y,b)&&t.someProp("handleKeyDown",C=>C(t,tf(8,"Backspace")))){oc&&cs&&t.domObserver.suppressSelectionUpdates();return}cs&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),oc&&!M&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==v.endA&&(v.endB-=2,b=c.doc.resolveNoCache(v.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,tf(13,"Enter"))})},20));let w=v.start,A=v.endA,T=C=>{let I=C||t.state.tr.replace(w,A,c.doc.slice(v.start-c.from,v.endB-c.from));if(c.sel){let N=m6(t,I.doc,c.sel);N&&!(cs&&t.composing&&N.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==w||N.head==I.mapping.map(A)-1)||Ws&&N.empty&&N.head==w)&&I.setSelection(N)}return s&&I.setMeta("composition",s),I.scrollIntoView()},R;if(M)if(y.pos==b.pos){Ws&&qu<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>mc(t),20));let C=T(t.state.tr.delete(w,A)),I=d.resolve(v.start).marksAcross(d.resolve(v.endA));I&&C.ensureMarks(I),t.dispatch(C)}else if(v.endA==v.endB&&(R=KMe(y.parent.content.cut(y.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,v.endA-x.start())))){let C=T(t.state.tr);R.type=="add"?C.addMark(w,A,R.mark):C.removeMark(w,A,R.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,b.parentOffset),I=()=>T(t.state.tr.insertText(C,w,A));t.someProp("handleTextInput",N=>N(t,w,A,C,I))||t.dispatch(I())}else t.dispatch(T());else t.dispatch(T())}function m6(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:ZP(t,e.resolve(n.anchor),e.resolve(n.head))}function KMe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,a,o,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)o=i[0],a="add",l=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&s.length==1)o=s[0],a="remove",l=d=>d.mark(o.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(pt.from(c).eq(t))return{mark:o,type:a}}function YMe(t,e,n,r,i){if(n-e<=i.pos-r.pos||kT(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let o=s.nodeAfter;return o!=null&&n==e+o.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let a=t.resolve(kT(s,!0,!0));return!a.parent.isTextblock||a.pos>n||kT(a,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function kT(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 s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function ZMe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(a,o));r-=a+l-s}if(a<s&&t.size<e.size){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<e.size&&g6(e.textBetween(s-1,s+1))&&(s+=l?1:-1),o=s+(o-a),a=s}else if(o<s){let l=r<=s&&r>=o?s-r:0;s-=l,s&&s<t.size&&g6(t.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}return{start:s,endA:a,endB:o}}function g6(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 Mq{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 gMe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(_6),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=v6(this),b6(this),this.nodeViews=y6(this),this.docView=ZB(this.state.doc,x6(this),NT(this),this.dom,this),this.domObserver=new BMe(this,(r,i,s,a)=>XMe(this,r,i,s,a)),this.domObserver.start(),xMe(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&&gk(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_6),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,s=!1,a=!1;e.storedMarks&&this.composing&&(xq(this),a=!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=y6(this);JMe(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&gk(this),this.editable=v6(this),b6(this);let l=NT(this),c=x6(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(i.selection))&&(a=!0);let g=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&Rwe(this);if(a){this.domObserver.stop();let m=h&&(Ws||cs)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&QMe(i.selection,e.selection);if(h){let v=cs?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=kMe(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ZB(e.doc,c,l,this.dom,this)),v&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&tMe(this))?mc(this,m):(sq(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&Pwe(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 Ht){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&GB(this,n.getBoundingClientRect(),e)}else GB(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 s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new vq(e.slice,e.move,i<0?void 0:Ht.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 a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[e];if(o!=null&&(i=n?n(o):o))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let o=s[a].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ws){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&&Dwe(this.dom),mc(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 Uwe(this,e)}coordsAtPos(e,n=1){return ZW(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 $we(this,n||this.state,e)}pasteHTML(e,n){return _0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return _0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return QP(this,e)}destroy(){this.docView&&(bMe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],NT(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ywe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return yMe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Es&&this.root.nodeType===11&&Ewe(this.dom.ownerDocument)==this.dom&&$Me(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Mq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function x6(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"),[ys.node(0,t.state.doc.content.size,e)]}function b6(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:ys.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function v6(t){return!t.someProp("editable",e=>e(t.state)===!1)}function QMe(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 y6(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 JMe(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 _6(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 nd={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:"'"},C1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eEe=typeof navigator<"u"&&/Mac/.test(navigator.platform),tEe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Yi=0;Yi<10;Yi++)nd[48+Yi]=nd[96+Yi]=String(Yi);for(var Yi=1;Yi<=24;Yi++)nd[Yi+111]="F"+Yi;for(var Yi=65;Yi<=90;Yi++)nd[Yi]=String.fromCharCode(Yi+32),C1[Yi]=String.fromCharCode(Yi);for(var RT in nd)C1.hasOwnProperty(RT)||(C1[RT]=nd[RT]);function nEe(t){var e=eEe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||tEe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?C1:nd)[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 rEe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),iEe=typeof navigator<"u"&&/Win/.test(navigator.platform);function sEe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!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))s=!0;else if(/^mod$/i.test(l))rEe?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),a&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function aEe(t){let e=Object.create(null);for(let n in t)e[sEe(n)]=t[n];return e}function PT(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 oEe(t){return new yr({props:{handleKeyDown:Eq(t)}})}function Eq(t){let e=aEe(t);return function(n,r){let i=nEe(r),s,a=e[PT(i,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[PT(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(iEe&&r.ctrlKey&&r.altKey)&&(s=nd[r.keyCode])&&s!=i){let o=e[PT(s,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var lEe=Object.defineProperty,iD=(t,e)=>{for(var n in e)lEe(t,n,{get:e[n],enumerable:!0})};function kw(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var Rw=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,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([a,o])=>[a,(...c)=>{const d=o(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a=[],o=!!t,l=t||i.tr,c=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),a.every(h=>h===!0)),d={...Object.fromEntries(Object.entries(n).map(([h,g])=>[h,(...v)=>{const y=this.buildProps(l,e),b=g(...v)(y);return a.push(b),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a={tr:t,editor:r,view:s,state:kw({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)(a)]))}};return a}},Aq={};iD(Aq,{blur:()=>cEe,clearContent:()=>uEe,clearNodes:()=>dEe,command:()=>fEe,createParagraphNear:()=>hEe,cut:()=>pEe,deleteCurrentNode:()=>mEe,deleteNode:()=>gEe,deleteRange:()=>xEe,deleteSelection:()=>bEe,enter:()=>vEe,exitCode:()=>yEe,extendMarkRange:()=>_Ee,first:()=>SEe,focus:()=>MEe,forEach:()=>EEe,insertContent:()=>AEe,insertContentAt:()=>NEe,joinBackward:()=>PEe,joinDown:()=>REe,joinForward:()=>DEe,joinItemBackward:()=>OEe,joinItemForward:()=>LEe,joinTextblockBackward:()=>jEe,joinTextblockForward:()=>IEe,joinUp:()=>kEe,keyboardShortcut:()=>FEe,lift:()=>zEe,liftEmptyBlock:()=>BEe,liftListItem:()=>HEe,newlineInCode:()=>$Ee,resetAttributes:()=>VEe,scrollIntoView:()=>GEe,selectAll:()=>WEe,selectNodeBackward:()=>qEe,selectNodeForward:()=>XEe,selectParentNode:()=>KEe,selectTextblockEnd:()=>YEe,selectTextblockStart:()=>ZEe,setContent:()=>QEe,setMark:()=>g2e,setMeta:()=>x2e,setNode:()=>b2e,setNodeSelection:()=>v2e,setTextDirection:()=>y2e,setTextSelection:()=>_2e,sinkListItem:()=>S2e,splitBlock:()=>w2e,splitListItem:()=>M2e,toggleList:()=>E2e,toggleMark:()=>A2e,toggleNode:()=>T2e,toggleWrap:()=>C2e,undoInputRule:()=>N2e,unsetAllMarks:()=>k2e,unsetMark:()=>R2e,unsetTextDirection:()=>P2e,updateAttributes:()=>D2e,wrapIn:()=>O2e,wrapInList:()=>L2e});var cEe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),uEe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),dEe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:a})=>{t.doc.nodesBetween(s.pos,a.pos,(o,l)=>{if(o.type.isText)return;const{doc:c,mapping:d}=e,h=c.resolve(d.map(l)),g=c.resolve(d.map(l+o.nodeSize)),m=h.blockRange(g);if(!m)return;const v=Im(m);if(o.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(v||v===0)&&e.lift(m,v)})}),!0},fEe=t=>e=>t(e),hEe=()=>({state:t,dispatch:e})=>BW(t,e),pEe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const a=r.mapping.map(e);return r.insert(a,s.content),r.setSelection(new Wt(r.doc.resolve(Math.max(a-1,0)))),!0},mEe=()=>({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 s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const o=i.before(s),l=i.after(s);t.delete(o,l).scrollIntoView()}return!0}return!1};function Jr(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 gEe=t=>({tr:e,state:n,dispatch:r})=>{const i=Jr(t,n.schema),s=e.selection.$anchor;for(let a=s.depth;a>0;a-=1)if(s.node(a).type===i){if(r){const l=s.before(a),c=s.after(a);e.delete(l,c).scrollIntoView()}return!0}return!1},xEe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},bEe=()=>({state:t,dispatch:e})=>VP(t,e),vEe=()=>({commands:t})=>t.keyboardShortcut("Enter"),yEe=()=>({state:t,dispatch:e})=>swe(t,e);function sD(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function N1(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:sD(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Tq(t,e,n={}){return t.find(r=>r.type===e&&N1(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function S6(t,e,n={}){return!!Tq(t,e,n)}function aD(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Tq([...i.node.marks],e,n)))return;let a=i.index,o=t.start()+i.offset,l=a+1,c=o+i.node.nodeSize;for(;a>0&&S6([...t.parent.child(a-1).marks],e,n);)a-=1,o-=t.parent.child(a).nodeSize;for(;l<t.parent.childCount&&S6([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function Nc(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 _Ee=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Nc(t,r.schema),{doc:a,selection:o}=n,{$from:l,from:c,to:d}=o;if(i){const h=aD(l,s,e);if(h&&h.from<=c&&h.to>=d){const g=Wt.create(a,h.from,h.to);n.setSelection(g)}}return!0},SEe=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 Cq(t){return t instanceof Wt}function of(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Nq(t,e=null){if(!e)return null;const n=ln.atStart(t),r=ln.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?Wt.create(t,of(0,i,s),of(t.content.size,i,s)):Wt.create(t,of(e,i,s),of(e,i,s))}function wEe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function oD(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var MEe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(oD()||wEe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!Cq(n.state.selection))return a(),!0;const o=Nq(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return s&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0},EEe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),AEe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),kq=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&&kq(r)}return t};function Xy(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 kq(n)}function w0(t,e,n){if(t instanceof Wu||t instanceof pt)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 pt.fromArray(t.map(o=>e.nodeFromJSON(o)));const a=e.nodeFromJSON(t);return n.errorOnInvalidContent&&a.check(),a}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),w0("",e,n)}if(i){if(n.errorOnInvalidContent){let a=!1,o="";const l=new pW({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=>(a=!0,o=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?jx.fromSchema(l).parseSlice(Xy(t),n.parseOptions):jx.fromSchema(l).parse(Xy(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=jx.fromSchema(e);return n.slice?s.parseSlice(Xy(t),n.parseOptions).content:s.parse(Xy(t),n.parseOptions)}return w0("",e,n)}function TEe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ni||i instanceof Ri))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,l,c,d)=>{a===0&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}var CEe=t=>!("type"in t),NEe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var a;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=b=>{s.emit("contentError",{editor:s,error:b,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{w0(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(b){l(b)}try{o=w0(e,s.schema,{parseOptions:c,errorOnInvalidContent:(a=n.errorOnInvalidContent)!=null?a:s.options.enableContentCheck})}catch(b){return l(b),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((CEe(o)?o:[o]).forEach(b=>{b.check(),g=g?b.isText&&b.marks.length===0:!1,m=m?b.isBlock:!1}),d===h&&m){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,h+=1)}let y;if(g){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof pt){let b="";e.forEach(x=>{x.text&&(b+=x.text)}),y=b}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,h)}else{y=o;const b=r.doc.resolve(d),x=b.node(),M=b.parentOffset===0,w=x.isText||x.isTextblock,A=x.content.size>0;M&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,h,y)}n.updateSelection&&TEe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},kEe=()=>({state:t,dispatch:e})=>nwe(t,e),REe=()=>({state:t,dispatch:e})=>rwe(t,e),PEe=()=>({state:t,dispatch:e})=>OW(t,e),DEe=()=>({state:t,dispatch:e})=>UW(t,e),OEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Mw(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},LEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Mw(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},jEe=()=>({state:t,dispatch:e})=>ewe(t,e),IEe=()=>({state:t,dispatch:e})=>twe(t,e);function Rq(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function UEe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!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))s=!0;else if(/^mod$/i.test(l))oD()||Rq()?a=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var FEe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=UEe(t).split(/-(?!$)/),a=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),o=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,o))});return l?.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function rd(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,a=e?Jr(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(h,g)=>{if(h.isText)return;const m=Math.max(r,g),v=Math.min(i,g+h.nodeSize);o.push({node:h,from:m,to:v})});const l=i-r,c=o.filter(h=>a?a.name===h.node.type.name:!0).filter(h=>N1(h.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((h,g)=>h+g.to-g.from,0)>=l}var zEe=(t,e={})=>({state:n,dispatch:r})=>{const i=Jr(t,n.schema);return rd(n,i,e)?iwe(n,r):!1},BEe=()=>({state:t,dispatch:e})=>HW(t,e),HEe=t=>({state:e,dispatch:n})=>{const r=Jr(t,e.schema);return gwe(r)(e,n)},$Ee=()=>({state:t,dispatch:e})=>zW(t,e);function Pw(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function w6(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 VEe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=Pw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=Jr(t,r.schema)),o==="mark"&&(a=Nc(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,h)=>{s&&s===d.type&&(l=!0,i&&n.setNodeMarkup(h,void 0,w6(d.attrs,e))),a&&d.marks.length&&d.marks.forEach(g=>{a===g.type&&(l=!0,i&&n.addMark(h,h+d.nodeSize,a.create(w6(g.attrs,e))))})})}),l},GEe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),WEe=()=>({tr:t,dispatch:e})=>{if(e){const n=new xa(t.doc);t.setSelection(n)}return!0},qEe=()=>({state:t,dispatch:e})=>jW(t,e),XEe=()=>({state:t,dispatch:e})=>FW(t,e),KEe=()=>({state:t,dispatch:e})=>lwe(t,e),YEe=()=>({state:t,dispatch:e})=>dwe(t,e),ZEe=()=>({state:t,dispatch:e})=>uwe(t,e);function xk(t,e,n={},r={}){return w0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var QEe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:a,commands:o})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=xk(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return a&&s.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Pq(t,e){const n=Nc(e,t.schema),{from:r,to:i,empty:s}=t.selection,a=[];s?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{a.push(...l.marks)});const o=a.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Dq(t,e){const n=new kW(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function JEe(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 e2e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function t2e(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 Dw(t){return e=>t2e(e.$from,t)}function Bt(t,e,n){return t.config[e]===void 0&&t.parent?Bt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Bt(t.parent,e,n):null}):t.config[e]}function lD(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...lD(r())]:e}).flat(10)}function cD(t,e){const n=th.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Oq(t){return typeof t=="function"}function Ln(t,e=void 0,...n){return Oq(t)?e?t.bind(e)(...n):t(...n):t}function n2e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function pm(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 Lq(t){const e=[],{nodeExtensions:n,markExtensions:r}=pm(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage,extensions:i},l=Bt(a,"addGlobalAttributes",o);if(!l)return;l().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([g,m])=>{e.push({type:h,name:g,attribute:{...s,...m}})})})})}),i.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage},l=Bt(a,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([d,h])=>{const g={...s,...h};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:a.name,name:d,attribute:g})})}),e}function Cr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const o=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=o.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const o=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[h,g]=d.split(":").map(m=>m.trim());c.set(h,g)}),o.forEach(d=>{const[h,g]=d.split(":").map(m=>m.trim());c.set(h,g)}),r[i]=Array.from(c.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[i]=s}),r},{})}function k1(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)=>Cr(n,r),{})}function r2e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function M6(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((s,a)=>{const o=a.attribute.parseHTML?a.attribute.parseHTML(n):r2e(n.getAttribute(a.name));return o==null?s:{...s,[a.name]:o}},{});return{...r,...i}}}}function E6(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&n2e(n)?!1:n!=null))}function A6(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 i2e(t,e){var n;const r=Lq(t),{nodeExtensions:i,markExtensions:s}=pm(t),a=(n=i.find(c=>Bt(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(c=>{const d=r.filter(x=>x.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((x,M)=>{const w=Bt(M,"extendNodeSchema",h);return{...x,...w?w(c):{}}},{}),m=E6({...g,content:Ln(Bt(c,"content",h)),marks:Ln(Bt(c,"marks",h)),group:Ln(Bt(c,"group",h)),inline:Ln(Bt(c,"inline",h)),atom:Ln(Bt(c,"atom",h)),selectable:Ln(Bt(c,"selectable",h)),draggable:Ln(Bt(c,"draggable",h)),code:Ln(Bt(c,"code",h)),whitespace:Ln(Bt(c,"whitespace",h)),linebreakReplacement:Ln(Bt(c,"linebreakReplacement",h)),defining:Ln(Bt(c,"defining",h)),isolating:Ln(Bt(c,"isolating",h)),attrs:Object.fromEntries(d.map(A6))}),v=Ln(Bt(c,"parseHTML",h));v&&(m.parseDOM=v.map(x=>M6(x,d)));const y=Bt(c,"renderHTML",h);y&&(m.toDOM=x=>y({node:x,HTMLAttributes:k1(x,d)}));const b=Bt(c,"renderText",h);return b&&(m.toText=b),[c.name,m]})),l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((b,x)=>{const M=Bt(x,"extendMarkSchema",h);return{...b,...M?M(c):{}}},{}),m=E6({...g,inclusive:Ln(Bt(c,"inclusive",h)),excludes:Ln(Bt(c,"excludes",h)),group:Ln(Bt(c,"group",h)),spanning:Ln(Bt(c,"spanning",h)),code:Ln(Bt(c,"code",h)),attrs:Object.fromEntries(d.map(A6))}),v=Ln(Bt(c,"parseHTML",h));v&&(m.parseDOM=v.map(b=>M6(b,d)));const y=Bt(c,"renderHTML",h);return y&&(m.toDOM=b=>y({mark:b,HTMLAttributes:k1(b,d)})),[c.name,m]}));return new pW({topNode:a,nodes:o,marks:l})}function s2e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function uD(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,s=Bt(r,"priority")||100;return i>s?-1:i<s?1:0})}function jq(t){const e=uD(lD(t)),n=s2e(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 Iq(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
  8068. `,textSerializers:a={}}=n||{};let o="";return t.nodesBetween(r,i,(l,c,d,h)=>{var g;l.isBlock&&c>r&&(o+=s);const m=a?.[l.type.name];if(m)return d&&(o+=m({node:l,pos:c,parent:d,index:h,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,c)-c,i-c))}),o}function a2e(t,e){const n={from:0,to:t.content.size};return Iq(t,n,e)}function Uq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function o2e(t,e){const n=Jr(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,o=>{s.push(o)});const a=s.reverse().find(o=>o.type.name===n.name);return a?{...a.attrs}:{}}function Fq(t,e){const n=Pw(typeof e=="string"?e:e.name,t.schema);return n==="node"?o2e(t,e):n==="mark"?Pq(t,e):{}}function l2e(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 c2e(t){const e=l2e(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,a)=>a!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function zq(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const a=[];if(i.ranges.length)i.forEach((o,l)=>{a.push({from:o,to:l})});else{const{from:o,to:l}=n[s];if(o===void 0||l===void 0)return;a.push({from:o,to:l})}a.forEach(({from:o,to:l})=>{const c=e.slice(s).map(o,-1),d=e.slice(s).map(l),h=e.invert().map(c,-1),g=e.invert().map(d);r.push({oldRange:{from:h,to:g},newRange:{from:c,to:d}})})}),c2e(r)}function dD(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),a=aD(s,i.type);a&&r.push({mark:i,...a})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(a=>({from:s,to:s+i.nodeSize,mark:a})))}),r}var u2e=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,a=null;for(;s>0&&a===null;){const o=i.node(s);o?.type.name===e?a=o:s-=1}return[a,s]};function DT(t,e){return e.nodes[t]||e.marks[t]||null}function U_(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var d2e=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,o)=>{var l,c;const d=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:a,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function bk(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Nc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>N1(h.attrs,n,{strict:!1}));let a=0;const o=[];if(i.forEach(({$from:h,$to:g})=>{const m=h.pos,v=g.pos;t.doc.nodesBetween(m,v,(y,b)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(m,b),M=Math.min(v,b+y.nodeSize),w=M-x;a+=w,o.push(...y.marks.map(A=>({mark:A,from:x,to:M})))})}),a===0)return!1;const l=o.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>N1(h.mark.attrs,n,{strict:!1})).reduce((h,g)=>h+g.to-g.from,0),c=o.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,g)=>h+g.to-g.from,0);return(l>0?l+c:l)>=a}function f2e(t,e,n={}){if(!e)return rd(t,null,n)||bk(t,null,n);const r=Pw(e,t.schema);return r==="node"?rd(t,e,n):r==="mark"?bk(t,e,n):!1}var h2e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=Dw(o=>o.type.name===e)(t.selection);if(!s)return!1;const a=t.doc.resolve(s.pos+1);return i.pos+1===a.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},p2e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function T6(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function C6(t,e){const{nodeExtensions:n}=pm(e),r=n.find(a=>a.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Ln(Bt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Ow(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(s=>{i!==!1&&(Ow(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Bq(t){return t instanceof Ht}function m2e(t,e,n){var r;const{selection:i}=e;let s=null;if(Cq(i)&&(s=i.$cursor),s){const o=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(c=>c.type.excludes(n)))}const{ranges:a}=i;return a.some(({$from:o,$to:l})=>{let c=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(d,h,g)=>{if(c)return!1;if(d.isInline){const m=!g||g.type.allowsMarkType(n),v=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));c=m&&v}return!c}),c})}var g2e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:a,ranges:o}=s,l=Nc(t,r.schema);if(i)if(a){const c=Pq(r,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const d=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(d,h,(g,m)=>{const v=Math.max(m,d),y=Math.min(m+g.nodeSize,h);g.marks.find(x=>x.type===l)?g.marks.forEach(x=>{l===x.type&&n.addMark(v,y,l.create({...x.attrs,...e}))}):n.addMark(v,y,l.create(e))})});return m2e(r,n,l)},x2e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),b2e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Jr(t,n.schema);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:o})=>HB(s,{...a,...e})(n)?!0:o.clearNodes()).command(({state:o})=>HB(s,{...a,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},v2e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=of(t,0,r.content.size),s=Ht.create(r,i);e.setSelection(s)}return!0},y2e=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let a,o;return typeof e=="number"?(a=e,o=e):e&&"from"in e&&"to"in e?(a=e.from,o=e.to):(a=s.from,o=s.to),i&&n.doc.nodesBetween(a,o,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},_2e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=Wt.atStart(r).from,o=Wt.atEnd(r).to,l=of(i,a,o),c=of(s,a,o),d=Wt.create(r,l,c);e.setSelection(d)}return!0},S2e=t=>({state:e,dispatch:n})=>{const r=Jr(t,e.schema);return vwe(r)(e,n)};function N6(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 w2e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:o,$to:l}=s,c=i.extensionManager.attributes,d=U_(c,o.node().type.name,o.node().attrs);if(s instanceof Ht&&s.node.isBlock)return!o.parentOffset||!pc(a,o.pos)?!1:(r&&(t&&N6(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:JEe(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=h&&g?[{type:g,attrs:d}]:void 0,v=pc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!v&&pc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(v=!0,m=g?[{type:g,attrs:d}]:void 0),r){if(v&&(s instanceof Wt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!h&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),b=e.doc.resolve(y);o.node(-1).canReplaceWith(b.index(),b.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&N6(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return v},M2e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var a;const o=Jr(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==o)return!1;const g=s.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=pt.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let I=l.depth-M;I>=l.depth-3;I-=1)x=pt.from(l.node(I).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...U_(g,l.node().type.name,l.node().attrs),...e},T=((a=o.contentMatch.defaultType)==null?void 0:a.createAndFill(A))||void 0;x=x.append(pt.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 C=-1;n.doc.nodesBetween(R,n.doc.content.size,(I,N)=>{if(C>-1)return!1;I.isTextblock&&I.content.size===0&&(C=N+1)}),C>-1&&n.setSelection(Wt.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,v={...U_(g,h.type.name,h.attrs),...e},y={...U_(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const b=m?[{type:o,attrs:v},{type:m,attrs:y}]:[{type:o,attrs:v}];if(!pc(n.doc,l.pos,2))return!1;if(i){const{selection:x,storedMarks:M}=r,{splittableMarks:w}=s.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},OT=(t,e)=>{const n=Dw(a=>a.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&&fd(t.doc,n.pos)&&t.join(n.pos),!0},LT=(t,e)=>{const n=Dw(a=>a.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&&fd(t.doc,r)&&t.join(r),!0},E2e=(t,e,n,r={})=>({editor:i,tr:s,state:a,dispatch:o,chain:l,commands:c,can:d})=>{const{extensions:h,splittableMarks:g}=i.extensionManager,m=Jr(t,a.schema),v=Jr(e,a.schema),{selection:y,storedMarks:b}=a,{$from:x,$to:M}=y,w=x.blockRange(M),A=b||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const T=Dw(R=>C6(R.type.name,h))(y);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===m)return c.liftListItem(v);if(C6(T.node.type.name,h)&&m.validContent(T.node.content)&&o)return l().command(()=>(s.setNodeMarkup(T.pos,m),!0)).command(()=>OT(s,m)).command(()=>LT(s,m)).run()}return!n||!A||!o?l().command(()=>d().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>OT(s,m)).command(()=>LT(s,m)).run():l().command(()=>{const R=d().wrapInList(m,r),C=A.filter(I=>g.includes(I.type.name));return s.ensureMarks(C),R?!0:c.clearNodes()}).wrapInList(m,r).command(()=>OT(s,m)).command(()=>LT(s,m)).run()},A2e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,a=Nc(t,r.schema);return bk(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},T2e=(t,e,n={})=>({state:r,commands:i})=>{const s=Jr(t,r.schema),a=Jr(e,r.schema),o=rd(r,s,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(a,l):i.setNode(s,{...l,...n})},C2e=(t,e={})=>({state:n,commands:r})=>{const i=Jr(t,n.schema);return rd(n,i,e)?r.lift(i):r.wrapIn(i,e)},N2e=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const a=t.tr,o=s.transform;for(let l=o.steps.length-1;l>=0;l-=1)a.step(o.steps[l].invert(o.docs[l]));if(s.text){const l=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else a.delete(s.from,s.to)}return!0}}return!1},k2e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},R2e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:a=!1}=e,{selection:o}=n,l=Nc(t,r.schema),{$from:c,empty:d,ranges:h}=o;if(!i)return!0;if(d&&a){let{from:g,to:m}=o;const v=(s=c.marks().find(b=>b.type===l))==null?void 0:s.attrs,y=aD(c,l,v);y&&(g=y.from,m=y.to),n.removeMark(g,m,l)}else h.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},P2e=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,a;return typeof t=="number"?(s=t,a=t):t&&"from"in t&&"to"in t?(s=t.from,a=t.to):(s=i.from,a=i.to),r&&e.doc.nodesBetween(s,a,(o,l)=>{if(o.isText)return;const c={...o.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},D2e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=Pw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=Jr(t,r.schema)),o==="mark"&&(a=Nc(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const d=c.$from.pos,h=c.$to.pos;let g,m,v,y;n.selection.empty?r.doc.nodesBetween(d,h,(b,x)=>{s&&s===b.type&&(l=!0,v=Math.max(x,d),y=Math.min(x+b.nodeSize,h),g=x,m=b)}):r.doc.nodesBetween(d,h,(b,x)=>{x<d&&s&&s===b.type&&(l=!0,v=Math.max(x,d),y=Math.min(x+b.nodeSize,h),g=x,m=b),x>=d&&x<=h&&(s&&s===b.type&&(l=!0,i&&n.setNodeMarkup(x,void 0,{...b.attrs,...e})),a&&b.marks.length&&b.marks.forEach(M=>{if(a===M.type&&(l=!0,i)){const w=Math.max(x,d),A=Math.min(x+b.nodeSize,h);n.addMark(w,A,a.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),a&&m.marks.length&&m.marks.forEach(b=>{a===b.type&&i&&n.addMark(v,y,a.create({...b.attrs,...e}))}))}),l},O2e=(t,e={})=>({state:n,dispatch:r})=>{const i=Jr(t,n.schema);return fwe(i,e)(n,r)},L2e=(t,e={})=>({state:n,dispatch:r})=>{const i=Jr(t,n.schema);return hwe(i,e)(n,r)},j2e=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={}}},Lw=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},I2e=(t,e)=>{if(sD(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 Ky(t){var e;const{editor:n,from:r,to:i,text:s,rules:a,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 d=!1;const h=d2e(c)+s;return a.forEach(g=>{if(d)return;const m=I2e(h,g.find);if(!m)return;const v=l.state.tr,y=kw({state:l.state,transaction:v}),b={from:r-(m[0].length-s.length),to:i},{commands:x,chain:M,can:w}=new Rw({editor:n,state:y});g.handler({state:y,range:b,match:m,commands:x,chain:M,can:w})===null||!v.steps.length||(g.undoable&&v.setMeta(o,{transform:v,from:r,to:i,text:s}),l.dispatch(v),d=!0)}),d}function U2e(t){const{editor:e,rules:n}=t,r=new yr({state:{init(){return null},apply(i,s,a){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=cD(pt.from(d),a.schema);const{from:h}=l,g=h+d.length;Ky({editor:e,from:h,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,o){return Ky({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ky({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:a}=i.state.selection;return a?Ky({editor:e,from:a.pos,to:a.pos,text:`
  8069. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function F2e(t){return Object.prototype.toString.call(t).slice(8,-1)}function Yy(t){return F2e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Hq(t,e){const n={...t};return Yy(t)&&Yy(e)&&Object.keys(e).forEach(r=>{Yy(e[r])&&Yy(t[r])?n[r]=Hq(t[r],e[r]):n[r]=e[r]}),n}var fD=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{...Ln(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ln(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Hq(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}},pd=class $q extends fD{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new $q(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const a=i.marks();if(!!!a.find(c=>c?.type.name===n.name))return!1;const l=a.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 z2e(t){return typeof t=="number"}var B2e=class{constructor(t){this.find=t.find,this.handler=t.handler}},H2e=(t,e,n)=>{if(sD(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function $2e(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:a,dropEvent:o}=t,{commands:l,chain:c,can:d}=new Rw({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,v)=>{var y,b,x,M,w;if((b=(y=m.type)==null?void 0:y.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,v),R=Math.min(i,v+A);if(T>=R)return;const C=m.isText?m.text||"":m.textBetween(T-v,R-v,void 0,"");H2e(C,s.find,a).forEach(N=>{if(N.index===void 0)return;const D=T+N.index+1,z=D+N[0].length,j={from:n.tr.mapping.map(D),to:n.tr.mapping.map(z)},W=s.handler({state:n,range:j,match:N,commands:l,chain:c,can:d,pasteEvent:a,dropEvent:o});h.push(W)})}),h.every(m=>m!==null)}var Zy=null,V2e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function G2e(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:d,from:h,to:g,rule:m,pasteEvt:v})=>{const y=d.tr,b=kw({state:d,transaction:y});if(!(!$2e({editor:e,state:b,from:Math.max(h-1,0),to:g.b-1,rule:m,pasteEvent:v,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new yr({view(h){const g=v=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(v.target)?h.dom.parentElement:null,r&&(Zy=e)},m=()=>{Zy&&(Zy=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,g)=>{if(s=r===h.dom.parentElement,o=g,!s){const m=Zy;m?.isEditable&&setTimeout(()=>{const v=m.state.selection;v&&m.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(h,g)=>{var m;const v=(m=g.clipboardData)==null?void 0:m.getData("text/html");return a=g,i=!!v?.includes("data-pm-slice"),!1}}},appendTransaction:(h,g,m)=>{const v=h[0],y=v.getMeta("uiEvent")==="paste"&&!i,b=v.getMeta("uiEvent")==="drop"&&!s,x=v.getMeta("applyPasteRules"),M=!!x;if(!y&&!b&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=cD(pt.from(T),m.schema);const{from:R}=x,C=R+T.length,I=V2e(T);return l({rule:d,state:m,from:R,to:{b:C},pasteEvt:I})}const w=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!z2e(w)||!A||w===A.b))return l({rule:d,state:m,from:w,to:A,pasteEvt:a})}}))}var jw=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jq(t),this.schema=i2e(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:DT(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return uD([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:DT(r.name,this.schema)},s=[],a=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>pd.handleExit({editor:t,mark:r})),a){const g=Object.fromEntries(Object.entries(a()).map(([m,v])=>[m,()=>v({editor:t})]));o={...o,...g}}const l=oEe(o);s.push(l);const c=Bt(r,"addInputRules",i);if(T6(r,t.options.enableInputRules)&&c){const g=c();if(g&&g.length){const m=U2e({editor:t,rules:g}),v=Array.isArray(m)?m:[m];s.push(...v)}}const d=Bt(r,"addPasteRules",i);if(T6(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=G2e({editor:t,rules:g});s.push(...m)}}const h=Bt(r,"addProseMirrorPlugins",i);if(h){const g=h();s.push(...g)}return s})}get attributes(){return Lq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=pm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(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:Jr(n.name,this.schema)},s=Bt(n,"addNodeView",i);if(!s)return[];const a=s();if(!a)return[];const o=(l,c,d,h,g)=>{const m=k1(l,r);return a({node:l,view:c,getPos:d,decorations:h,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=pm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(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:Nc(n.name,this.schema)},s=Bt(n,"addMarkView",i);if(!s)return[];const a=(o,l,c)=>{const d=k1(o,r);return s()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:h=>{aAe(o,t,h)}})};return[n.name,a]}))}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:DT(e.name,this.schema)};e.type==="mark"&&((n=Ln(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),s=Bt(e,"onCreate",r),a=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),l=Bt(e,"onTransaction",r),c=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),h=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),h&&this.editor.on("destroy",h)})}};jw.resolve=jq;jw.sort=uD;jw.flatten=lD;var W2e={};iD(W2e,{ClipboardTextSerializer:()=>Gq,Commands:()=>Wq,Delete:()=>qq,Drop:()=>Xq,Editable:()=>Kq,FocusEvents:()=>Zq,Keymap:()=>Qq,Paste:()=>Jq,Tabindex:()=>eX,TextDirection:()=>tX,focusEventsPluginKey:()=>Yq});var Wn=class Vq extends fD{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Vq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Gq=Wn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new yr({key:new hi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,a=Math.min(...s.map(d=>d.$from.pos)),o=Math.max(...s.map(d=>d.$to.pos)),l=Uq(n);return Iq(r,{from:a,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Wq=Wn.create({name:"commands",addCommands(){return{...Aq}}}),qq=Wn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var a,o,l,c;if((c=(l=(o=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?c:t.getMeta("y-sync$"))return;const d=Dq(t.before,[t,...e]);zq(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(v,y)=>{const b=y+v.nodeSize-2,x=m.oldRange.from<=y&&b<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:y,to:b,newFrom:d.mapping.map(y),newTo:d.mapping.map(b),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((m,v)=>{var y,b;if(m instanceof Eo){const x=g.slice(v).map(m.from,-1),M=g.slice(v).map(m.to),w=g.invert().map(x,-1),A=g.invert().map(M),T=(y=d.doc.nodeAt(x-1))==null?void 0:y.marks.some(C=>C.eq(m.mark)),R=(b=d.doc.nodeAt(M))==null?void 0:b.marks.some(C=>C.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:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Xq=Wn.create({name:"drop",addProseMirrorPlugins(){return[new yr({key:new hi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Kq=Wn.create({name:"editable",addProseMirrorPlugins(){return[new yr({key:new hi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Yq=new hi("focusEvents"),Zq=Wn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new yr({key:Yq,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}}}})]}}),Qq=Wn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:l,doc:c}=o,{empty:d,$anchor:h}=l,{pos:g,parent:m}=h,v=h.parent.isTextblock&&g>0?o.doc.resolve(g-1):h,y=v.parent.type.spec.isolating,b=h.pos-h.parentOffset,x=y&&v.parent.childCount===1?b===h.pos:ln.atStart(c).from===g;return!d||!m.type.isTextblock||m.textContent.length||!x||x&&h.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.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},s={...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 oD()||Rq()?s:i},addProseMirrorPlugins(){return[new yr({key:new hi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:a,to:o}=e.selection,l=ln.atStart(e.doc).from,c=ln.atEnd(e.doc).to;if(s||!(a===l&&o===c)||!Ow(n.doc))return;const g=n.tr,m=kw({state:n,transaction:g}),{commands:v}=new Rw({editor:this.editor,state:m});if(v.clearNodes(),!!g.steps.length)return g}})]}}),Jq=Wn.create({name:"paste",addProseMirrorPlugins(){return[new yr({key:new hi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),eX=Wn.create({name:"tabindex",addProseMirrorPlugins(){return[new yr({key:new hi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),tX=Wn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=pm(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 yr({key:new hi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),q2e=class Tp{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 Tp(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 Tp(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 Tp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(a);if(!i&&o.depth<=this.depth)return;const l=new Tp(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Tp(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 s=i.node.attrs,a=Object.keys(n);for(let o=0;o<a.length;o+=1){const l=a[o];if(s[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 s=Object.keys(n);return this.children.forEach(a=>{r&&i.length>0||(a.node.type.name===e&&s.every(l=>n[l]===a.node.attrs[l])&&i.push(a),!(r&&i.length>0)&&(i=i.concat(a.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)}},X2e=`.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 K2e(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 Y2e=class extends j2e{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:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Nq(e,this.options.autofocus);this.editorState=Pp.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=K2e(X2e,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=Oq(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 s=typeof i=="string"?`${i}$`:i.key;n=n.filter(a=>!a.key.startsWith(s))}),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?[Kq,Gq.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Wq,Zq,Qq,eX,Xq,Jq,qq,tX.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 jw(r,this)}createCommandManager(){this.commandManager=new Rw({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=xk(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=xk(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Mq(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 d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=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 a=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),o=a?.getMeta("focus"),l=a?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:a}),l&&this.emit("blur",{editor:this,event:l.event,transaction:a}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Fq(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return f2e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return cD(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8128. `,textSerializers:n={}}=t||{};return a2e(this.state.doc,{blockSeparator:e,textSerializers:{...Uq(this.schema),...n}})}get isEmpty(){return Ow(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 q2e(e,this)}get $doc(){return this.$pos(0)}};function mm(t){return new Lw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],o=r[0];if(a){const l=o.search(/\S/),c=n.from+o.indexOf(a),d=c+a.length;if(dD(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>c).length)return null;d<n.to&&s.delete(d,n.to),c>n.from&&s.delete(n.from+l,c);const g=n.from+l+a.length;s.addMark(n.from+l,g,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function nX(t){return new Lw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r)||{},{tr:s}=e,a=n.from;let o=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=a+c;d>o?d=o:o=d+r[1].length;const h=r[0][r[0].length-1];s.insertText(h,a+r[0].length-1),s.replaceWith(d,o,l)}else if(r[0]){const c=t.type.isInline?a:a-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(a),s.mapping.map(o))}s.scrollIntoView()},undoable:t.undoable})}function vk(t){return new Lw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Ln(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,s)},undoable:t.undoable})}function gm(t){return new Lw({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Ln(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),l=a.doc.resolve(n.from).blockRange(),c=l&&HP(l,t.type,s);if(!c)return null;if(a.wrap(l,c),t.keepMarks&&t.editor){const{selection:h,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,v=g||h.$to.parentOffset&&h.$from.marks();if(v){const y=v.filter(b=>m.includes(b.type.name));a.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const d=a.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&fd(a.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&a.join(n.from-1)},undoable:t.undoable})}var Z2e=t=>"touches"in t,Q2e=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=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.clientX-this.startX,l=a.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.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 a=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(a,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=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s;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),(s=t.options)!=null&&s.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"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(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,Z2e(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),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),a=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return s?r=this.startWidth+e:a&&(r=this.startWidth-e),o?i=this.startHeight+n:l&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?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,s,a;if(!n){let c=Math.max(this.minSize.width,t),d=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&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(a=this.maxSize)!=null&&a.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 J2e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var eAe={};iD(eAe,{createAtomBlockMarkdownSpec:()=>tAe,createBlockMarkdownSpec:()=>nAe,createInlineMarkdownSpec:()=>sAe,parseAttributes:()=>hD,parseIndentedBlocks:()=>yk,renderNestedMarkdownContent:()=>mD,serializeAttributes:()=>pD});function hD(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(d=>d.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const a=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(a)).forEach(([,c,d])=>{var h;const g=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[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(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function pD(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 tAe(t){const{nodeName:e,name:n,parseAttributes:r=hD,serializeAttributes:i=pD,defaultAttributes:s={},requiredAttributes:a=[],allowedAttributes:o}=t,l=n||e,c=d=>{if(!o)return d;const h={};return o.forEach(g=>{g in d&&(h[g]=d[g])}),h};return{parseMarkdown:(d,h)=>{const g={...s,...d.attributes};return h.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(h=d.match(g))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(d,h,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=d.match(m);if(!v)return;const y=v[1]||"",b=r(y);if(!a.find(M=>!(M in b)))return{type:e,raw:v[0],attributes:b}}},renderMarkdown:d=>{const h=c(d.attrs||{}),g=i(h),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function nAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=hD,serializeAttributes:s=pD,defaultAttributes:a={},content:o="block",allowedAttributes:l}=t,c=n||e,d=h=>{if(!l)return h;const g={};return l.forEach(m=>{m in h&&(g[m]=h[m])}),g};return{parseMarkdown:(h,g)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(h.tokens||[]):m=g.parseInline(h.tokens||[]);const v={...a,...h.attributes};return g.createNode(e,v,m)},markdownTokenizer:{name:e,level:"block",start(h){var g;const m=new RegExp(`^:::${c}`,"m"),v=(g=h.match(m))==null?void 0:g.index;return v!==void 0?v:-1},tokenize(h,g,m){var v;const y=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=h.match(y);if(!b)return;const[x,M=""]=b,w=i(M);let A=1;const T=x.length;let R="";const C=/^:::([\w-]*)(\s.*)?/gm,I=h.slice(T);for(C.lastIndex=0;;){const N=C.exec(I);if(N===null)break;const D=N.index,z=N[1];if(!((v=N[2])!=null&&v.endsWith(":::"))){if(z)A+=1;else if(A-=1,A===0){const j=I.slice(0,D);R=j.trim();const W=h.slice(0,T+D+N[0].length);let P=[];if(R)if(o==="block")for(P=m.blockTokens(j),P.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=m.inlineTokens($.text))});P.length>0;){const $=P[P.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))P.pop();else break}else P=m.inlineTokens(R);return{type:e,raw:W,attributes:w,content:R,tokens:P}}}}}},renderMarkdown:(h,g)=>{const m=d(h.attrs||{}),v=s(m),y=v?` {${v}}`:"",b=g.renderChildren(h.content||[],`
  8129. `);return`:::${c}${y}
  8130. ${b}
  8131. :::`}}}function rAe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,a]=r;e[i]=s||a,r=n.exec(t)}return e}function iAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function sAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=rAe,serializeAttributes:s=iAe,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,d=g=>{if(!l)return g;const m={};return l.forEach(v=>{v in g&&(m[v]=g[v])}),m},h=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const v={...a,...g.attributes};if(o)return m.createNode(e,v);const y=r?r(g):g.content||"";return y?m.createNode(e,v,[m.createTextNode(y)]):m.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),v=g.match(m),y=v?.index;return y!==void 0?y:-1},tokenize(g,m,v){const y=o?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),b=g.match(y);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 v=d(g.attrs||{}),y=s(v),b=y?` ${y}`:"";return o?`[${c}${b}]`:`[${c}${b}]${m}[/${c}]`}}}function yk(t,e,n){var r,i,s,a;const o=t.split(`
  8132. `),l=[];let c="",d=0;const h=e.baseIndentSize||2;for(;d<o.length;){const g=o[d],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){d+=1,c=`${c}${g}
  8133. `;continue}else return}const v=e.extractItemData(m),{indentLevel:y,mainContent:b}=v;c=`${c}${g}
  8134. `;const x=[b];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const C=o.slice(d+1).findIndex(D=>D.trim()!=="");if(C===-1)break;if((((i=(r=o[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){x.push(T),c=`${c}${T}
  8135. `,d+=1;continue}else break}if((((a=(s=T.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>y)x.push(T),c=`${c}${T}
  8136. `,d+=1;else break}let M;const w=x.slice(1);if(w.length>0){const T=w.map(R=>R.slice(y+h)).join(`
  8137. `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const A=e.createToken(v,M);l.push(A)}if(l.length!==0)return{items:l,raw:c}}function mD(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...a]=t.content,o=e.renderChildren([s]),l=[`${i}${o}`];return a&&a.length>0&&a.forEach(c=>{const d=e.renderChildren([c]);if(d){const h=d.split(`
  8138. `).map(g=>g?e.indent(g):"").join(`
  8139. `);l.push(h)}}),l.join(`
  8140. `)}function aAe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,a=t;i.descendants((o,l)=>{const c=s.mapping.map(l),d=s.mapping.map(l)+o.nodeSize;let h=null;if(o.marks.forEach(m=>{if(m!==a)return!1;h=m}),!h)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});s.removeMark(c,d,t.type),s.addMark(c,d,m)}}),s.docChanged&&e.view.dispatch(s)}var Ks=class rX extends fD{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new rX(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Vf(t){return new B2e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Ln(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];let c=n.to;if(o){const d=l.search(/\S/),h=n.from+l.indexOf(o),g=h+o.length;if(dD(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(b=>b===t.type&&b!==v.mark.type)).filter(v=>v.to>h).length)return null;g<n.to&&a.delete(g,n.to),h>n.from&&a.delete(n.from+d,h),c=n.from+d+o.length,a.addMark(n.from+d,c,t.type.create(s||{})),a.removeStoredMark(t.type)}}})}var jT,k6;function oAe(){return k6||(k6=1,jT=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,s;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(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var a=s[i];if(!(a==="_owner"&&e.$$typeof)&&!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),jT}var lAe=oAe();const cAe=ro(lAe);var IT={exports:{}},UT={};var R6;function uAe(){if(R6)return UT;R6=1;var t=Tm(),e=UG();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return UT.useSyncExternalStoreWithSelector=function(c,d,h,g,m){var v=s(null);if(v.current===null){var y={hasValue:!1,value:null};v.current=y}else y=v.current;v=o(function(){function x(R){if(!M){if(M=!0,w=R,R=g(R),m!==void 0&&y.hasValue){var C=y.value;if(m(C,R))return A=C}return A=R}if(C=A,r(w,R))return C;var I=g(R);return m!==void 0&&m(C,I)?(w=R,C):(w=R,A=I)}var M=!1,w,A,T=h===void 0?null:h;return[function(){return x(d())},T===null?void 0:function(){return x(T())}]},[d,h,g,m]);var b=i(c,v[0],v[1]);return a(function(){y.hasValue=!0,y.value=b},[b]),l(b),b},UT}var P6;function dAe(){return P6||(P6=1,IT.exports=uAe()),IT.exports}var iX=dAe(),fAe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},hAe=({contentComponent:t})=>{const e=$R.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return u.jsx(u.Fragment,{children:Object.values(e)})};function pAe(){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]:cse.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 mAe=class extends fr.Component{constructor(t){var e;super(t),this.editorContentRef=fr.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=pAe(),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 u.jsxs(u.Fragment,{children:[u.jsx("div",{ref:fAe(e,this.editorContentRef),...n}),t?.contentComponent&&u.jsx(hAe,{contentComponent:t.contentComponent})]})}},gAe=E.forwardRef((t,e)=>{const n=fr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return fr.createElement(mAe,{key:n,innerRef:e,...t})}),xAe=fr.memo(gAe),bAe=typeof window<"u"?E.useLayoutEffect:E.useEffect,vAe=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 yAe(t){var e;const[n]=E.useState(()=>new vAe(t.editor)),r=iX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:cAe);return bAe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var _Ae=!1,_k=typeof window>"u",SAe=_k||!!(typeof window<"u"&&window.next),wAe=class sX{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?_k||SAe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new Y2e(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,s)=>{var a;return i===((a=n.extensions)==null?void 0:a[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?sX.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 MAe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new wAe(n)),i=$R.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),yAe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var EAe=E.createContext({editor:null});EAe.Consumer;var AAe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),TAe=()=>E.useContext(AAe);fr.forwardRef((t,e)=>{const{onDragStart:n}=TAe(),r=t.as||"div";return u.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});fr.createContext({markViewContentRef:()=>{}});var R1=(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]},CAe=/^\s*>\s$/,NAe=Ks.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return R1("blockquote",{...Cr(this.options.HTMLAttributes,t),children:R1("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[gm({find:CAe,type:this.type})]}}),kAe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,RAe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,PAe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,DAe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,OAe=pd.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 R1("strong",{...Cr(this.options.HTMLAttributes,t),children:R1("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[mm({find:kAe,type:this.type}),mm({find:PAe,type:this.type})]},addPasteRules(){return[Vf({find:RAe,type:this.type}),Vf({find:DAe,type:this.type})]}}),LAe=/(^|[^`])`([^`]+)`(?!`)$/,jAe=/(^|[^`])`([^`]+)`(?!`)/g,IAe=pd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Cr(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[mm({find:LAe,type:this.type})]},addPasteRules(){return[Vf({find:jAe,type:this.type})]}}),FT=4,UAe=/^```([a-z]+)?[\s\n]$/,FAe=/^~~~([a-z]+)?[\s\n]$/,zAe=Ks.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:FT,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 s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Cr(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:FT,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;if(s.parent.type!==this.type)return!1;const o=" ".repeat(n);return a?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:c,to:d}=i,m=r.doc.textBetween(c,d,`
  8147. `,`
  8148. `).split(`
  8149. `).map(v=>o+v).join(`
  8150. `);return l.replaceWith(c,d,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:FT,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;return s.parent.type!==this.type?!1:a?t.commands.command(({tr:o})=>{var l;const{pos:c}=s,d=s.start(),h=s.end(),m=r.doc.textBetween(d,h,`
  8151. `,`
  8152. `).split(`
  8153. `);let v=0,y=0;const b=c-d;for(let R=0;R<m.length;R+=1){if(y+m[R].length>=b){v=R;break}y+=m[R].length+1}const M=((l=m[v].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let A=d;for(let R=0;R<v;R+=1)A+=m[R].length+1;return o.delete(A,A+w),c-A<=w&&o.setSelection(Wt.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 v;const y=((v=m.match(/^ */))==null?void 0:v[0])||"",b=Math.min(y.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 s=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
  8158. `);return!s||!a?!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:s}=n;if(!s||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(ln.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[vk({find:UAe,type:this.type,getAttributes:t=>({language:t[1]})}),vk({find:FAe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new yr({key:new hi("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,s=i?.mode;if(!n||!s)return!1;const{tr:a,schema:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
  8159. `));return a.replaceSelectionWith(this.type.create({language:s},l)),a.selection.$from.parent.type!==this.type&&a.setSelection(Wt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),BAe=Ks.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8160. `):""}),HAe=Ks.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",Cr(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:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&a){const h=l.filter(g=>o.includes(g.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),$Ae=Ks.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]}`,Cr(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=>vk({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),VAe=Ks.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Cr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!J2e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Bq(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:a,dispatch:o})=>{if(o){const{$to:l}=a.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?a.setSelection(Wt.create(a.doc,l.pos+1)):l.nodeAfter.isBlock?a.setSelection(Ht.create(a.doc,l.pos)):a.setSelection(Wt.create(a.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=d?.create();h&&(a.insert(c,h),a.setSelection(Wt.create(a.doc,c+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[nX({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GAe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,WAe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qAe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,XAe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KAe=pd.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",Cr(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[mm({find:GAe,type:this.type}),mm({find:qAe,type:this.type})]},addPasteRules(){return[Vf({find:WAe,type:this.type}),Vf({find:XAe,type:this.type})]}});const YAe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ZAe="ελ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",Sk="numeric",wk="ascii",Mk="alpha",zx="asciinumeric",Sx="alphanumeric",Ek="domain",aX="emoji",QAe="scheme",JAe="slashscheme",zT="whitespace";function eTe(t,e){return t in e||(e[t]=[]),e[t]}function lf(t,e,n){e[Sk]&&(e[zx]=!0,e[Sx]=!0),e[wk]&&(e[zx]=!0,e[Mk]=!0),e[zx]&&(e[Sx]=!0),e[Mk]&&(e[Sx]=!0),e[Sx]&&(e[Ek]=!0),e[aX]&&(e[Ek]=!0);for(const r in e){const i=eTe(r,n);i.indexOf(t)<0&&i.push(t)}}function tTe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Bs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Bs.groups={};Bs.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],s=e.jr[r][1];if(s&&i.test(t))return s}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||Bs.groups;let i;return e&&e.j?i=e:(i=new Bs(e),n&&r&&lf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let a=0;a<s-1;a++)i=i.tt(t[a]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Bs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let a,o=i.go(t);if(o?(a=new Bs,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Bs,s){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(tTe(a.t,r),n);lf(s,l,r)}else n&&lf(s,n,r);a.t=s}return i.j[t]=a,a}};const rn=(t,e,n,r,i)=>t.ta(e,n,r,i),Er=(t,e,n,r,i)=>t.tr(e,n,r,i),D6=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),Kl="WORD",Ak="UWORD",oX="ASCIINUMERICAL",lX="ALPHANUMERICAL",M0="LOCALHOST",Tk="TLD",Ck="UTLD",F_="SCHEME",Cp="SLASH_SCHEME",gD="NUM",Nk="WS",xD="NL",Bx="OPENBRACE",Hx="CLOSEBRACE",P1="OPENBRACKET",D1="CLOSEBRACKET",O1="OPENPAREN",L1="CLOSEPAREN",j1="OPENANGLEBRACKET",I1="CLOSEANGLEBRACKET",U1="FULLWIDTHLEFTPAREN",F1="FULLWIDTHRIGHTPAREN",z1="LEFTCORNERBRACKET",B1="RIGHTCORNERBRACKET",H1="LEFTWHITECORNERBRACKET",$1="RIGHTWHITECORNERBRACKET",V1="FULLWIDTHLESSTHAN",G1="FULLWIDTHGREATERTHAN",W1="AMPERSAND",q1="APOSTROPHE",X1="ASTERISK",Eu="AT",K1="BACKSLASH",Y1="BACKTICK",Z1="CARET",Pu="COLON",bD="COMMA",Q1="DOLLAR",Go="DOT",J1="EQUALS",vD="EXCLAMATION",ja="HYPHEN",$x="PERCENT",eS="PIPE",tS="PLUS",nS="POUND",Vx="QUERY",yD="QUOTE",cX="FULLWIDTHMIDDLEDOT",_D="SEMI",Wo="SLASH",Gx="TILDE",rS="UNDERSCORE",uX="EMOJI",iS="SYM";var dX=Object.freeze({__proto__:null,ALPHANUMERICAL:lX,AMPERSAND:W1,APOSTROPHE:q1,ASCIINUMERICAL:oX,ASTERISK:X1,AT:Eu,BACKSLASH:K1,BACKTICK:Y1,CARET:Z1,CLOSEANGLEBRACKET:I1,CLOSEBRACE:Hx,CLOSEBRACKET:D1,CLOSEPAREN:L1,COLON:Pu,COMMA:bD,DOLLAR:Q1,DOT:Go,EMOJI:uX,EQUALS:J1,EXCLAMATION:vD,FULLWIDTHGREATERTHAN:G1,FULLWIDTHLEFTPAREN:U1,FULLWIDTHLESSTHAN:V1,FULLWIDTHMIDDLEDOT:cX,FULLWIDTHRIGHTPAREN:F1,HYPHEN:ja,LEFTCORNERBRACKET:z1,LEFTWHITECORNERBRACKET:H1,LOCALHOST:M0,NL:xD,NUM:gD,OPENANGLEBRACKET:j1,OPENBRACE:Bx,OPENBRACKET:P1,OPENPAREN:O1,PERCENT:$x,PIPE:eS,PLUS:tS,POUND:nS,QUERY:Vx,QUOTE:yD,RIGHTCORNERBRACKET:B1,RIGHTWHITECORNERBRACKET:$1,SCHEME:F_,SEMI:_D,SLASH:Wo,SLASH_SCHEME:Cp,SYM:iS,TILDE:Gx,TLD:Tk,UNDERSCORE:rS,UTLD:Ck,UWORD:Ak,WORD:Kl,WS:Nk});const Gl=/[a-z]/,sx=new RegExp("\\p{L}","u"),BT=new RegExp("\\p{Emoji}","u"),Wl=/\d/,HT=/\s/,O6="\r",$T=`
  8163. `,nTe="️",rTe="‍",VT="";let Qy=null,Jy=null;function iTe(t=[]){const e={};Bs.groups=e;const n=new Bs;Qy==null&&(Qy=L6(YAe)),Jy==null&&(Jy=L6(ZAe)),gt(n,"'",q1),gt(n,"{",Bx),gt(n,"}",Hx),gt(n,"[",P1),gt(n,"]",D1),gt(n,"(",O1),gt(n,")",L1),gt(n,"<",j1),gt(n,">",I1),gt(n,"(",U1),gt(n,")",F1),gt(n,"「",z1),gt(n,"」",B1),gt(n,"『",H1),gt(n,"』",$1),gt(n,"<",V1),gt(n,">",G1),gt(n,"&",W1),gt(n,"*",X1),gt(n,"@",Eu),gt(n,"`",Y1),gt(n,"^",Z1),gt(n,":",Pu),gt(n,",",bD),gt(n,"$",Q1),gt(n,".",Go),gt(n,"=",J1),gt(n,"!",vD),gt(n,"-",ja),gt(n,"%",$x),gt(n,"|",eS),gt(n,"+",tS),gt(n,"#",nS),gt(n,"?",Vx),gt(n,'"',yD),gt(n,"/",Wo),gt(n,";",_D),gt(n,"~",Gx),gt(n,"_",rS),gt(n,"\\",K1),gt(n,"・",cX);const r=Er(n,Wl,gD,{[Sk]:!0});Er(r,Wl,r);const i=Er(r,Gl,oX,{[zx]:!0}),s=Er(r,sx,lX,{[Sx]:!0}),a=Er(n,Gl,Kl,{[wk]:!0});Er(a,Wl,i),Er(a,Gl,a),Er(i,Wl,i),Er(i,Gl,i);const o=Er(n,sx,Ak,{[Mk]:!0});Er(o,Gl),Er(o,Wl,s),Er(o,sx,o),Er(s,Wl,s),Er(s,Gl),Er(s,sx,s);const l=gt(n,$T,xD,{[zT]:!0}),c=gt(n,O6,Nk,{[zT]:!0}),d=Er(n,HT,Nk,{[zT]:!0});gt(n,VT,d),gt(c,$T,l),gt(c,VT,d),Er(c,HT,d),gt(d,O6),gt(d,$T),Er(d,HT,d),gt(d,VT,d);const h=Er(n,BT,uX,{[aX]:!0});gt(h,"#"),Er(h,BT,h),gt(h,nTe,h);const g=gt(h,rTe);gt(g,"#"),Er(g,BT,h);const m=[[Gl,a],[Wl,i]],v=[[Gl,null],[sx,o],[Wl,s]];for(let y=0;y<Qy.length;y++)yu(n,Qy[y],Tk,Kl,m);for(let y=0;y<Jy.length;y++)yu(n,Jy[y],Ck,Ak,v);lf(Tk,{tld:!0,ascii:!0},e),lf(Ck,{utld:!0,alpha:!0},e),yu(n,"file",F_,Kl,m),yu(n,"mailto",F_,Kl,m),yu(n,"http",Cp,Kl,m),yu(n,"https",Cp,Kl,m),yu(n,"ftp",Cp,Kl,m),yu(n,"ftps",Cp,Kl,m),lf(F_,{scheme:!0,ascii:!0},e),lf(Cp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,b)=>y[0]>b[0]?1:-1);for(let y=0;y<t.length;y++){const b=t[y][0],M=t[y][1]?{[QAe]:!0}:{[JAe]:!0};b.indexOf("-")>=0?M[Ek]=!0:Gl.test(b)?Wl.test(b)?M[zx]=!0:M[wk]=!0:M[Sk]=!0,D6(n,b,b,M)}return D6(n,"localhost",M0,{ascii:!0}),n.jd=new Bs(iS),{start:n,tokens:Object.assign({groups:e},dX)}}function fX(t,e){const n=sTe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let s=0,a=0;for(;a<r;){let o=t,l=null,c=0,d=null,h=-1,g=-1;for(;a<r&&(l=o.go(n[a]));)o=l,o.accepts()?(h=0,g=0,d=o):h>=0&&(h+=n[a].length,g++),c+=n[a].length,s+=n[a].length,a++;s-=h,a-=g,c-=h,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function sTe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,a=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(a),r+=a.length}return e}function yu(t,e,n,r,i){let s;const a=e.length;for(let o=0;o<a-1;o++){const l=e[o];t.j[l]?s=t.j[l]:(s=new Bs(r),s.jr=i.slice(),t.j[l]=s),t=s}return s=new Bs(n),s.jr=i.slice(),t.j[e[a-1]]=s,s}function L6(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let a=parseInt(t.substring(r,r+s),10);a>0;a--)n.pop();r+=s}else n.push(t[r]),r++}return e}const E0={defaultProtocol:"http",events:null,format:j6,formatHref:j6,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function SD(t,e=null){let n=Object.assign({},E0);t&&(n=Object.assign(n,t instanceof SD?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}SD.prototype={o:E0,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]:E0[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 j6(t){return t}function hX(t,e){this.t="token",this.v=t,this.tk=e}hX.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=E0.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),s=this.toFormattedString(t),a={},o=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return a.href=r,o&&(a.class=o),l&&(a.target=l),c&&(a.rel=c),d&&Object.assign(a,d),{tagName:i,attributes:a,content:s,eventListeners:h}}};function Iw(t,e){class n extends hX{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const I6=Iw("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),U6=Iw("text"),aTe=Iw("nl"),e_=Iw("url",{isLink:!0,toHref(t=E0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==M0&&t[1].t===Pu}}),Pa=t=>new Bs(t);function oTe({groups:t}){const e=t.domain.concat([W1,X1,Eu,K1,Y1,Z1,Q1,J1,ja,gD,$x,eS,tS,nS,Wo,iS,Gx,rS]),n=[q1,Pu,bD,Go,vD,$x,Vx,yD,_D,j1,I1,Bx,Hx,D1,P1,O1,L1,U1,F1,z1,B1,H1,$1,V1,G1],r=[W1,q1,X1,K1,Y1,Z1,Q1,J1,ja,Bx,Hx,$x,eS,tS,nS,Vx,Wo,iS,Gx,rS],i=Pa(),s=gt(i,Gx);rn(s,r,s),rn(s,t.domain,s);const a=Pa(),o=Pa(),l=Pa();rn(i,t.domain,a),rn(i,t.scheme,o),rn(i,t.slashscheme,l),rn(a,r,s),rn(a,t.domain,a);const c=gt(a,Eu);gt(s,Eu,c),gt(o,Eu,c),gt(l,Eu,c);const d=gt(s,Go);rn(d,r,s),rn(d,t.domain,s);const h=Pa();rn(c,t.domain,h),rn(h,t.domain,h);const g=gt(h,Go);rn(g,t.domain,h);const m=Pa(I6);rn(g,t.tld,m),rn(g,t.utld,m),gt(c,M0,m);const v=gt(h,ja);gt(v,ja,v),rn(v,t.domain,h),rn(m,t.domain,h),gt(m,Go,g),gt(m,ja,v);const y=gt(m,Pu);rn(y,t.numeric,I6);const b=gt(a,ja),x=gt(a,Go);gt(b,ja,b),rn(b,t.domain,a),rn(x,r,s),rn(x,t.domain,a);const M=Pa(e_);rn(x,t.tld,M),rn(x,t.utld,M),rn(M,t.domain,a),rn(M,r,s),gt(M,Go,x),gt(M,ja,b),gt(M,Eu,c);const w=gt(M,Pu),A=Pa(e_);rn(w,t.numeric,A);const T=Pa(e_),R=Pa();rn(T,e,T),rn(T,n,R),rn(R,e,T),rn(R,n,R),gt(M,Wo,T),gt(A,Wo,T);const C=gt(o,Pu),I=gt(l,Pu),N=gt(I,Wo),D=gt(N,Wo);rn(o,t.domain,a),gt(o,Go,x),gt(o,ja,b),rn(l,t.domain,a),gt(l,Go,x),gt(l,ja,b),rn(C,t.domain,T),gt(C,Wo,T),gt(C,Vx,T),rn(D,t.domain,T),rn(D,e,T),gt(D,Wo,T);const z=[[Bx,Hx],[P1,D1],[O1,L1],[j1,I1],[U1,F1],[z1,B1],[H1,$1],[V1,G1]];for(let j=0;j<z.length;j++){const[W,P]=z[j],$=gt(T,W);gt(R,W,$),gt($,P,T);const K=Pa(e_);rn($,e,K);const G=Pa();rn($,n),rn(K,e,K),rn(K,n,G),rn(G,e,K),rn(G,n,G),gt(K,P,T),gt(G,P,T)}return gt(i,M0,M),gt(i,xD,aTe),{start:i,tokens:dX}}function lTe(t,e,n){let r=n.length,i=0,s=[],a=[];for(;i<r;){let o=t,l=null,c=null,d=0,h=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)a.push(n[i++]);for(;i<r&&(c=l||o.go(n[i].t));)l=null,o=c,o.accepts()?(g=0,h=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(a.push(n[i]),i++);else{a.length>0&&(s.push(GT(U6,e,a)),a=[]),i-=g,d-=g;const m=h.t,v=n.slice(i-d,i);s.push(GT(m,e,v))}}return a.length>0&&s.push(GT(U6,e,a)),s}function GT(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const cTe=typeof console<"u"&&console&&console.warn||(()=>{}),uTe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ar={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function dTe(){return Bs.groups={},ar.scanner=null,ar.parser=null,ar.tokenQueue=[],ar.pluginQueue=[],ar.customSchemes=[],ar.initialized=!1,ar}function F6(t,e=!1){if(ar.initialized&&cTe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${uTe}`),!/^[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`);ar.customSchemes.push([t,e])}function fTe(){ar.scanner=iTe(ar.customSchemes);for(let t=0;t<ar.tokenQueue.length;t++)ar.tokenQueue[t][1]({scanner:ar.scanner});ar.parser=oTe(ar.scanner.tokens);for(let t=0;t<ar.pluginQueue.length;t++)ar.pluginQueue[t][1]({scanner:ar.scanner,parser:ar.parser});return ar.initialized=!0,ar}function wD(t){return ar.initialized||fTe(),lTe(ar.parser.start,t,fX(ar.scanner.start,t))}wD.scan=fX;function pX(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 SD(n),i=wD(t),s=[];for(let a=0;a<i.length;a++){const o=i[a];o.isLink&&(!e||o.t===e)&&r.check(o)&&s.push(o.toFormattedObject(r))}return s}var MD="[\0-   ᠎ -\u2029  ]",hTe=new RegExp(MD),pTe=new RegExp(`${MD}$`),mTe=new RegExp(MD,"g");function gTe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function xTe(t){return new yr({key:new hi("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,o=Dq(n.doc,[...e]);if(zq(o).forEach(({newRange:c})=>{const d=e2e(r.doc,c,m=>m.isTextblock);let h,g;if(d.length>1)h=d[0],g=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(c.from,c.to," "," ");if(!pTe.test(m))return;h=d[0],g=r.doc.textBetween(h.pos,c.to,void 0," ")}if(h&&g){const m=g.split(hTe).filter(Boolean);if(m.length<=0)return!1;const v=m[m.length-1],y=h.pos+g.lastIndexOf(v);if(!v)return!1;const b=wD(v).map(x=>x.toObject(t.defaultProtocol));if(!gTe(b))return!1;b.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+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=>{dD(x.from,x.to,r.doc).some(M=>M.mark.type===t.type)||a.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!a.steps.length)return a}})}function bTe(t){return new yr({key:new hi("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=null;if(r.target instanceof HTMLAnchorElement)a=r.target;else{let d=r.target;const h=[];for(;d.nodeName!=="DIV";)h.push(d),d=d.parentNode;a=h.find(g=>g.nodeName==="A")}if(!a)return!1;const o=Fq(e.state,t.type.name),l=(i=a?.href)!=null?i:o.href,c=(s=a?.target)!=null?s:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),a&&l?(window.open(l,c),!0):!1}}})}function vTe(t){return new yr({key:new hi("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:a}=s,{empty:o}=a;if(o)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=pX(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||i!==void 0&&!i(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Gd(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(mTe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var mX=pd.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"){F6(t);return}F6(t.scheme,t.optionalSlashes)})},onDestroy(){dTe()},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)=>!!Gd(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=>!!Gd(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=>!!Gd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Cr(this.options.HTMLAttributes,t),0]:["a",Cr(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=>!!Gd(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=>!!Gd(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[Vf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=pX(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Gd(a,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.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(xTe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Gd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(bTe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(vTe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),yTe=mX,_Te=Object.defineProperty,STe=(t,e)=>{for(var n in e)_Te(t,n,{get:e[n],enumerable:!0})},wTe="listItem",z6="textStyle",B6=/^\s*([-+*])\s$/,gX=Ks.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",Cr(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(wTe,this.editor.getAttributes(z6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=gm({find:B6,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=gm({find:B6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(z6),editor:this.editor})),[t]}}),xX=Ks.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Cr(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 a=t.tokens.slice(1),o=e.parseChildren(a);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)=>mD(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)}}}),MTe={};STe(MTe,{findListItemPos:()=>nb,getNextListDepth:()=>ED,handleBackspace:()=>kk,handleDelete:()=>Rk,hasListBefore:()=>bX,hasListItemAfter:()=>ETe,hasListItemBefore:()=>vX,listItemHasSubList:()=>yX,nextListIsDeeper:()=>_X,nextListIsHigher:()=>SX});var nb=(t,e)=>{const{$from:n}=e.selection,r=Jr(t,e.schema);let i=null,s=n.depth,a=n.pos,o=null;for(;s>0&&o===null;)i=n.node(s),i.type===r?o=s:(s-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},ED=(t,e)=>{const n=nb(t,e);if(!n)return!1;const[,r]=u2e(e,t,n.$pos.pos+4);return r},bX=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},vX=(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)},yX=(t,e,n)=>{if(!n)return!1;const r=Jr(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},kk=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!rd(t.state,e)&&bX(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 d=c.at(-1);if(!d)return!1;const h=t.state.doc.resolve(l.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},h.end()).joinForward().run()}if(!rd(t.state,e)||!p2e(t.state))return!1;const r=nb(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=yX(e,t.state,s);return vX(e,t.state)&&!a?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},_X=(t,e)=>{const n=ED(t,e),r=nb(t,e);return!r||!n?!1:n>r.depth},SX=(t,e)=>{const n=ED(t,e),r=nb(t,e);return!r||!n?!1:n<r.depth},Rk=(t,e)=>{if(!rd(t.state,e)||!h2e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:_X(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():SX(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},ETe=(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)},wX=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&&Rk(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&&Rk(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&&kk(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&&kk(t,n,r)&&(e=!0)}),e}}}}),H6=/^(\s*)(\d+)\.\s+(.*)$/,ATe=/^\s/;function TTe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(H6);if(!s)break;const[,a,o,l]=s,c=a.length;let d=l,h=n+1;const g=[i];for(;h<t.length;){const m=t[h];if(m.match(H6))break;if(m.trim()==="")g.push(m),d+=`
  8168. `,h+=1;else if(m.match(ATe))g.push(m),d+=`
  8169. ${m.slice(c+2)}`,h+=1;else break}e.push({indent:c,number:parseInt(o,10),content:d.trim(),raw:g.join(`
  8170. `)}),r=h,n=h}return[e,r]}function MX(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const a=t[s];if(a.indent===e){const o=a.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 d=o.slice(1).join(`
  8172. `).trim();if(d){const m=n.blockTokens(d);c.push(...m)}let h=s+1;const g=[];for(;h<t.length&&t[h].indent>e;)g.push(t[h]),h+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),v=MX(g,m,n);c.push({type:"list",ordered:!0,start:g[0].number,items:v,raw:g.map(y=>y.raw).join(`
  8173. `)})}i.push({type:"list_item",raw:a.raw,tokens:c}),s=h}else s+=1}return i}function CTe(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 s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var NTe="listItem",$6="textStyle",V6=/^(\d+)\.\s$/,EX=Ks.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",Cr(this.options.HTMLAttributes,n),0]:["ol",Cr(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?CTe(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. `),[s,a]=TTe(i);if(s.length===0)return;const o=MX(s,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,a).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(NTe,this.editor.getAttributes($6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=gm({find:V6,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=gm({find:V6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes($6)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),kTe=/^\s*(\[([( |x])?\])\s$/,RTe=Ks.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",Cr(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 mD(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"),s=document.createElement("label"),a=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),c=d=>{var h,g;o.ariaLabel=((g=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:g.call(h,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(t),s.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:h}=d.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 v=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...v?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{i.setAttribute(d,h)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,s.append(o,a),i.append(s,l),Object.entries(e).forEach(([d,h])=>{i.setAttribute(d,h)}),{dom:i,contentDOM:l,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[gm({find:kTe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),PTe=Ks.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",Cr(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=s=>{const a=yk(s,{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 a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(s)},i=yk(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,a)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:a}),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(gX.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(xX.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(wX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(EX.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(RTe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(PTe.configure(this.options.taskList)),t}});var DTe=Ks.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Cr(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()}}}),OTe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,LTe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jTe=pd.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",Cr(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[mm({find:OTe,type:this.type})]},addPasteRules(){return[Vf({find:LTe,type:this.type})]}}),ITe=Ks.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),AX=pd.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",Cr(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 s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},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()}}}),UTe=AX;function FTe(t={}){return new yr({view(e){return new zTe(e,t)}})}class zTe{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 s=a=>{this[i](a)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}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,s=i.getBoundingClientRect(),a=s.width/i.offsetWidth,o=s.height/i.offsetHeight;if(n){let h=e.nodeBefore,g=e.nodeAfter;if(h||g){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let v=m.getBoundingClientRect(),y=h?v.bottom:v.top;h&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*o;r={left:v.left,right:v.right,top:y-b,bottom:y+b}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*a;r={left:h.left-g,right:h.left+g,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let h=l.getBoundingClientRect(),g=h.width/l.offsetWidth,m=h.height/l.offsetHeight;c=h.left-l.scrollLeft*g,d=h.top-l.scrollTop*m}this.element.style.left=(r.left-c)/a+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/a+"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,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=EW(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Tr extends ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Tr.valid(r)?new Tr(r):ln.near(r)}content(){return Et.empty}eq(e){return e instanceof Tr&&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 Tr(e.resolve(n.pos))}getBookmark(){return new AD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!BTe(e)||!HTe(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&&Tr.valid(e))return e;let i=e.pos,s=null;for(let a=e.depth;;a--){let o=e.node(a);if(n>0?e.indexAfter(a)<o.childCount:e.index(a)>0){s=o.child(n>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;i+=n;let l=e.doc.resolve(i);if(Tr.valid(l))return l}for(;;){let a=n>0?s.firstChild:s.lastChild;if(!a){if(s.isAtom&&!s.isText&&!Ht.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=a,i+=n;let o=e.doc.resolve(i);if(Tr.valid(o))return o}return null}}}Tr.prototype.visible=!1;Tr.findFrom=Tr.findGapCursorFrom;ln.jsonID("gapcursor",Tr);class AD{constructor(e){this.pos=e}map(e){return new AD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Tr.valid(n)?new Tr(n):ln.near(n)}}function TX(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function BTe(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||TX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function HTe(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||TX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $Te(){return new yr({props:{decorations:qTe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Tr.valid(n)?new Tr(n):null},handleClick:GTe,handleKeyDown:VTe,handleDOMEvents:{beforeinput:WTe}}})}const VTe=Eq({ArrowLeft:t_("horiz",-1),ArrowRight:t_("horiz",1),ArrowUp:t_("vert",-1),ArrowDown:t_("vert",1)});function t_(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let a=r.selection,o=e>0?a.$to:a.$from,l=a.empty;if(a instanceof Wt){if(!s.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let c=Tr.findGapCursorFrom(o,e,l);return c?(i&&i(r.tr.setSelection(new Tr(c))),!0):!1}}function GTe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Tr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ht.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Tr(r))),!0)}function WTe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Tr))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=pt.empty;for(let a=r.length-1;a>=0;a--)i=pt.from(r[a].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Et(i,0,0));return s.setSelection(Wt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function qTe(t){if(!(t.selection instanceof Tr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",xr.create(t.doc,[ys.widget(t.selection.head,e,{key:"gapcursor"})])}var sS=200,Pi=function(){};Pi.prototype.append=function(e){return e.length?(e=Pi.from(e),!this.length&&e||e.length<sS&&this.leafAppend(e)||this.length<sS&&e.leafPrepend(this)||this.appendInner(e)):this};Pi.prototype.prepend=function(e){return e.length?Pi.from(e).append(this):this};Pi.prototype.appendInner=function(e){return new XTe(this,e)};Pi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Pi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Pi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Pi.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)};Pi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,a){return i.push(e(s,a))},n,r),i};Pi.from=function(e){return e instanceof Pi?e:e&&e.length?new CX(e):Pi.empty};var CX=(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,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,a,o){for(var l=s;l<a;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,o){for(var l=s-1;l>=a;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=sS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=sS)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})(Pi);Pi.empty=new CX([]);var XTe=(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,s,a){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(s,o),a)===!1||s>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,s)-o,a+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,a){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(s,o)-o,a+o)===!1||s<o&&this.left.forEachInvertedInner(r,Math.min(i,o),s,a)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},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})(Pi);const KTe=500;class vo{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,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let a=e.tr,o,l,c=[],d=[];return this.items.forEach((h,g)=>{if(!h.step){i||(i=this.remapping(r,g+1),s=i.maps.length),s--,d.push(h);return}if(i){d.push(new qo(h.map));let m=h.step.map(i.slice(s)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],c.push(new qo(v,void 0,void 0,c.length+d.length))),s--,v&&i.appendMap(v,s)}else a.maybeStep(h.step);if(h.selection)return o=i?h.selection.map(i.slice(s)):h.selection,l=new vo(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:a,selection:o}}addTransform(e,n,r,i){let s=[],a=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let h=e.steps[d].invert(e.docs[d]),g=new qo(e.mapping.maps[d],h,n),m;(m=l&&l.merge(g))&&(g=m,d?s.pop():o=o.slice(0,o.length-1)),s.push(g),n&&(a++,n=void 0),i||(l=g)}let c=a-r.depth;return c>ZTe&&(o=YTe(o,c),a-=c),new vo(o.append(s),a)}remapping(e,n){let r=new b0;return this.items.forEach((i,s)=>{let a=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},e,n),r}addMaps(e){return this.eventCount==0?this:new vo(this.items.append(e.map(n=>new qo(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=s.getMirror(--l);if(m==null)return;a=Math.min(a,m);let v=s.maps[m];if(g.step){let y=e.steps[m].invert(e.docs[m]),b=g.selection&&g.selection.map(s.slice(l+1,m));b&&o++,r.push(new qo(v,y,b))}else r.push(new qo(v))},i);let c=[];for(let g=n;g<a;g++)c.push(new qo(s.maps[g]));let d=this.items.slice(0,i).append(c).append(r),h=new vo(d,o);return h.emptyItemCount()>KTe&&(h=h.compress(this.items.length-r.length)),h}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=[],s=0;return this.items.forEach((a,o)=>{if(o>=e)i.push(a),a.selection&&s++;else if(a.step){let l=a.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let d=a.selection&&a.selection.map(n.slice(r));d&&s++;let h=new qo(c.invert(),l,d),g,m=i.length-1;(g=i.length&&i[m].merge(h))?i[m]=g:i.push(h)}}else a.map&&r--},this.items.length,0),new vo(Pi.from(i.reverse()),s)}}vo.empty=new vo(Pi.empty,0);function YTe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class qo{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 qo(n.getMap().invert(),n,this.selection)}}}class Au{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const ZTe=20;function QTe(t,e,n,r){let i=n.getMeta(yf),s;if(i)return i.historyState;n.getMeta(tCe)&&(t=new Au(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(yf))return a.getMeta(yf).redo?new Au(t.done.addTransform(n,void 0,r,z_(e)),t.undone,G6(n.mapping.maps),t.prevTime,t.prevComposition):new Au(t.done,t.undone.addTransform(n,void 0,r,z_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!JTe(n,t.prevRanges)),c=a?WT(t.prevRanges,n.mapping):G6(n.mapping.maps);return new Au(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,z_(e)),vo.empty,c,n.time,o??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Au(t.done.rebased(n,s),t.undone.rebased(n,s),WT(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Au(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),WT(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function JTe(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function G6(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,a)=>e.push(s,a));return e}function WT(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function eCe(t,e,n){let r=z_(e),i=yf.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let a=s.selection.resolve(s.transform.doc),o=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new Au(n?o:s.remaining,n?s.remaining:o,null,0,-1);return s.transform.setSelection(a).setMeta(yf,{redo:n,historyState:l})}let qT=!1,W6=null;function z_(t){let e=t.plugins;if(W6!=e){qT=!1,W6=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){qT=!0;break}}return qT}const yf=new hi("history"),tCe=new hi("closeHistory");function nCe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new yr({key:yf,state:{init(){return new Au(vo.empty,vo.empty,null,0,-1)},apply(e,n,r){return QTe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?kX:r=="historyRedo"?RX:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function NX(t,e){return(n,r)=>{let i=yf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=eCe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const kX=NX(!1,!0),RX=NX(!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 yr({key:new hi("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const a=s-i,o=0,l=a;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}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=s-r,c=o-l,d=o;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var rCe=Wn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FTe(this.options)]}});Wn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new yr({key:new hi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return xr.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;a+=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"&&a-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";s.push(ys.node(c,c+l.nodeSize,{class:this.options.className}))}),xr.create(t,s)}}})]}});var iCe=Wn.create({name:"gapCursor",addProseMirrorPlugins(){return[$Te()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ln(Bt(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 yr({key:new hi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((a,o)=>{const l=r>=o&&r<=o+a.nodeSize,c=!a.isLeaf&&Ow(a);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const h=ys.node(o,o+a.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:o,hasAnchor:l}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),xr.create(t,i)}}})]}});Wn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new yr({key:new hi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Bq(n.selection)||t.view.dragging?null:xr.create(n.doc,[ys.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function q6({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var sCe=Wn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new hi(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 yr({key:e,appendTransaction:(i,s,a)=>{const{doc:o,tr:l,schema:c}=a,d=e.getState(a),h=o.content.size,g=c.nodes[n];if(d)return l.insert(h,g.create())},state:{init:(i,s)=>{const a=s.tr.doc.lastChild;return!q6({node:a,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const a=i.doc.lastChild;return!q6({node:a,types:r})}}})]}}),aCe=Wn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kX(t,e),redo:()=>({state:t,dispatch:e})=>RX(t,e)}},addProseMirrorPlugins(){return[nCe(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()}}}),oCe=Wn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(OAe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(NAe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(gX.configure(this.options.bulletList)),this.options.code!==!1&&i.push(IAe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(zAe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(BAe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(rCe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(iCe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(HAe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push($Ae.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(aCe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(VAe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(KAe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(xX.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(wX.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(mX.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(EX.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(DTe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(jTe.configure(this.options.strike)),this.options.text!==!1&&i.push(ITe.configure(this.options.text)),this.options.underline!==!1&&i.push(AX.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(sCe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),lCe=oCe,cCe=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")}}}),uCe=cCe,dCe=20,PX=(t,e=0)=>{const n=[];return!t.children.length||e>dCe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...PX(r,e+1))}),n},fCe=t=>{if(!t.children.length)return;const e=PX(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),a=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${a};${s}`)})},DX=pd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&fCe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Cr(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(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),hCe=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 s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="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()}}}),OX=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 s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="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()}}}),pCe=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()}}}),mCe=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()}}}),gCe=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(hCe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(OX.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(pCe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(mCe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(gCe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(DX.configure(this.options.textStyle)),t}});var xCe=OX,bCe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,vCe=Ks.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",Cr(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,s,a;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=(a=(s=t.attrs)==null?void 0:s.title)!=null?a:"";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:s,HTMLAttributes:a})=>{const o=document.createElement("img");Object.entries(a).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,h);break}}),o.src=a.src;const l=new Q2e({element:o,node:i,getPos:s,onResize:(d,h)=>{o.style.width=`${d}px`,o.style.height=`${h}px`},onCommit:(d,h)=>{const g=s();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,g)=>d.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[nX({find:bCe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),yCe=vCe;function X6({content:t,onChange:e,placeholder:n}){const r=MAe({extensions:[lCe.configure({heading:!1,codeBlock:!1,code:!1}),UTe,yTe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),uCe.configure({types:["paragraph"]}),DX,xCe,yCe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:a})=>{e(a.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:a,isActive:o=!1,children:l,title:c})=>u.jsx("button",{type:"button",onClick:a,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}),s=()=>{const a=window.prompt("Enter URL:");a&&r.chain().focus().setLink({href:a}).run()};return u.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[u.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[u.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:u.jsx(iae,{className:"w-4 h-4"})}),u.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:u.jsx(_oe,{className:"w-4 h-4"})}),u.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:u.jsx(Zle,{className:"w-4 h-4"})}),u.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),u.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:u.jsx(oP,{className:"w-4 h-4"})}),u.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:u.jsx(w9,{className:"w-4 h-4"})}),u.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),u.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:u.jsx($le,{className:"w-4 h-4"})}),u.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:u.jsx(Fle,{className:"w-4 h-4"})}),u.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:u.jsx(Ble,{className:"w-4 h-4"})}),u.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),u.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:u.jsx(S9,{className:"w-4 h-4"})}),r.isActive("link")&&u.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:u.jsx(A9,{className:"w-4 h-4"})})]}),u.jsx(xAe,{editor:r})]})}function _Ce({archiveId:t,archiveName:e,onClose:n}){const r=Nn(),[i,s]=E.useState(!1),[a,o]=E.useState(null),[l,c]=E.useState({}),{data:d,isLoading:h,error:g}=Mt({queryKey:["archive-project-page",t],queryFn:()=>Le.getArchiveProjectPage(t)}),m=At({mutationFn:T=>Le.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),c({})}});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&(a!==null?o(null):i?x():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[a,i,n]);const v=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{c({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},b=()=>{m.mutate(l)},x=()=>{s(!1),c({})},M=T=>{const R=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(T,"text/html"),I=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const D=N,z=D.tagName.toLowerCase();if(!R.includes(z))return Array.from(D.childNodes).map(I).join("");let j="";if(z==="a"&&D.getAttribute("href")){const P=D.getAttribute("href");P?.toLowerCase().startsWith("http")&&(j=` href="${P}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const P=D.getAttribute("src");if(!P?.toLowerCase().startsWith("http"))return"";j=` src="${P}" style="max-width: 100%; height: auto;"`}const W=Array.from(D.childNodes).map(I).join("");return["br","img"].includes(z)?`<${z}${j} />`:`<${z}${j}>${W}</${z}>`}return""};return Array.from(C.body.childNodes).map(I).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||v.length>0),A=T=>{T.target===T.currentTarget&&n()};return u.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(rc,{className:"w-5 h-5 text-bambu-green"}),u.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&u.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&u.jsxs(Ue,{variant:"ghost",size:"sm",onClick:y,children:[u.jsx(r1,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&u.jsxs(u.Fragment,{children:[u.jsx(Ue,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),u.jsxs(Ue,{variant:"primary",size:"sm",onClick:b,disabled:m.isPending,children:[u.jsx(Qo,{className:"w-4 h-4 mr-1"}),"Save"]})]}),u.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&u.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&u.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[u.jsx(rc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),u.jsx("p",{children:"No project page data found in this 3MF file."}),u.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-4",children:[i?u.jsx("input",{type:"text",value:l.title||"",onChange:T=>c({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&u.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),u.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(bF,{className:"w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:l.designer||"",onChange:T=>c({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[u.jsx(bF,{className:"w-4 h-4"}),u.jsx("span",{children:d.designer}),d.designer_user_id&&u.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:u.jsx(vc,{className:"w-3 h-3"})})]}),d.creation_date&&u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[u.jsx(Wr,{className:"w-4 h-4"}),u.jsx("span",{children:d.creation_date})]}),i?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(rc,{className:"w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:l.license||"",onChange:T=>c({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[u.jsx(rc,{className:"w-4 h-4"}),u.jsx("span",{children:d.license})]}),d.origin&&u.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?u.jsx(X6,{content:l.description||"",onChange:T=>c({...l,description:T}),placeholder:"Enter description..."}):u.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&u.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?u.jsxs("div",{className:"space-y-2",children:[u.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"}),u.jsx(X6,{content:l.profile_description||"",onChange:T=>c({...l,profile_description:T}),placeholder:"Profile description..."})]}):u.jsxs(u.Fragment,{children:[d.profile_title&&u.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&u.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.profile_description)}}),d.profile_user_name&&u.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),v.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[u.jsx(uw,{className:"w-4 h-4"}),"Images (",v.length,")"]}),u.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:v.map((T,R)=>u.jsx("button",{onClick:()=>o(R),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:u.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[u.jsx(vc,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),a!==null&&v[a]&&u.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[u.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,a-1))},disabled:a===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:u.jsx(Nf,{className:"w-6 h-6 text-white"})}),u.jsx("img",{src:v[a].url,alt:v[a].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),u.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(v.length-1,a+1))},disabled:a===v.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:u.jsx(Rm,{className:"w-6 h-6 text-white"})}),u.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:u.jsx(Qt,{className:"w-6 h-6 text-white"})}),u.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",v.length]})]})]})}const SCe=[.25,.5,.75,1,1.5,2,3,4];function wCe({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[s,a]=E.useState(!0),[o,l]=E.useState(.5),[c,d]=E.useState(0),[h,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=()=>d(w.currentTime),T=()=>g(w.duration),R=()=>a(!0),C=()=>a(!1);return w.addEventListener("timeupdate",A),w.addEventListener("durationchange",T),w.addEventListener("play",R),w.addEventListener("pause",C),()=>{w.removeEventListener("timeupdate",A),w.removeEventListener("durationchange",T),w.removeEventListener("play",R),w.removeEventListener("pause",C)}},[]);const m=()=>{const w=i.current;w&&(s?w.pause():w.play())},v=w=>{const A=i.current;A&&(A.currentTime=parseFloat(w.target.value))},y=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},b=()=>{const w=i.current;w&&(w.currentTime=Math.min(h,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 u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:u.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(jp,{className:"w-5 h-5 text-bambu-green"}),e]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:M,children:[u.jsx(va,{className:"w-4 h-4"}),"Download"]}),u.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),u.jsxs("div",{className:"p-4",children:[u.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),u.jsxs("div",{className:"mt-4 space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),u.jsx("input",{type:"range",min:0,max:h||100,value:c,onChange:v,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`}),u.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(h)})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:u.jsx(Ele,{className:"w-5 h-5 text-bambu-gray"})}),u.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:s?u.jsx(Joe,{className:"w-5 h-5 text-white"}):u.jsx(dw,{className:"w-5 h-5 text-white"})}),u.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:u.jsx(i1,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),u.jsx("div",{className:"flex gap-1",children:SCe.map(w=>u.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 MCe({archiveId:t,archiveName:e,onClose:n}){const r=Nn(),{showToast:i}=Di(),[s,a]=E.useState(null),[o,l]=E.useState("asap"),[c,d]=E.useState(""),[h,g]=E.useState(!1),[m,v]=E.useState(!1),{data:y}=Mt({queryKey:["printers"],queryFn:()=>Le.getPrinters()});E.useEffect(()=>{y?.length===1&&!s&&a(y[0].id)},[y,s]),E.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const b=At({mutationFn:w=>Le.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(),!s){i("Please select a printer","error");return}const A={printer_id:s,archive_id:t,require_previous_success:h,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 u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Wr,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),u.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),u.jsx("p",{className:"text-white font-medium truncate",children:e})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?u.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[u.jsx(No,{className:"w-4 h-4"}),"No printers configured"]}):u.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:s||"",onChange:w=>a(w.target.value?Number(w.target.value):null),required:!0,children:[u.jsx("option",{value:"",children:"Select printer..."}),y?.map(w=>u.jsx("option",{value:w.id,children:w.name},w.id))]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),u.jsxs("div",{className:"flex gap-2",children:[u.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:[u.jsx(Qr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),u.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:[u.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),u.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>d(w.target.value),min:M(),required:!0})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),u.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>v(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),u.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[u.jsx(dd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),u.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."}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{type:"submit",className:"flex-1",disabled:b.isPending||!s||y?.length===0,children:b.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function Pk(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ax(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function K6(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ECe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i}){const s=Nn(),{showToast:a}=Di(),[o,l]=E.useState(!1),[c,d]=E.useState(!1),[h,g]=E.useState(!1),[m,v]=E.useState(!1),[y,b]=E.useState(!1),[x,M]=E.useState(!1),[w,A]=E.useState([]),[T,R]=E.useState(!1),[C,I]=E.useState(!1),[N,D]=E.useState(!1),[z,j]=E.useState(!1),[W,P]=E.useState(!1),[$,K]=E.useState(null),G=E.useRef(null),Z=At({mutationFn:re=>Le.uploadSource3mf(t.id,re),onSuccess:re=>{s.invalidateQueries({queryKey:["archives"]}),a(`Source 3MF attached: ${re.filename}`)},onError:re=>{a(re.message||"Failed to upload source 3MF","error")}}),Q=At({mutationFn:()=>Le.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),a("Source 3MF removed")},onError:re=>{a(re.message||"Failed to remove source 3MF","error")}}),ee=At({mutationFn:()=>Le.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),a(`Timelapse attached: ${re.filename}`)):re.status==="exists"?a("Timelapse already attached"):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(A(re.available_files),M(!0)):a(re.message||"No matching timelapse found","warning")},onError:re=>{a(re.message||"Failed to scan for timelapse","error")}}),H=At({mutationFn:re=>Le.selectArchiveTimelapse(t.id,re),onSuccess:re=>{s.invalidateQueries({queryKey:["archives"]}),a(`Timelapse attached: ${re.filename}`),M(!1),A([])},onError:re=>{a(re.message||"Failed to attach timelapse","error")}}),q=At({mutationFn:()=>Le.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),a("Archive deleted")},onError:()=>{a("Failed to delete archive","error")}}),te=At({mutationFn:()=>Le.toggleFavorite(t.id),onSuccess:re=>{s.invalidateQueries({queryKey:["archives"]}),a(re.is_favorite?"Added to favorites":"Removed from favorites")}}),ae=re=>{re.preventDefault(),K({x:re.clientX,y:re.clientY})},xe=[{label:"Print",icon:u.jsx(ko,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"Schedule",icon:u.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"Open in Bambu Studio",icon:u.jsx(vc,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",pe=`${window.location.origin}${Le.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(pe)}`}},{label:"View on MakerWorld",icon:u.jsx(e1,{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:u.jsx(Zp,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:u.jsx(jp,{className:"w-4 h-4"}),onClick:()=>b(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:u.jsx(xle,{className:"w-4 h-4"}),onClick:()=>ee.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ee.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:u.jsx(fF,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=Le.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else G.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:u.jsx(Ka,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},{label:"Remove Source 3MF",icon:u.jsx(Qn,{className:"w-4 h-4"}),onClick:()=>P(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:u.jsx(va,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=Le.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()}},{label:"Copy Download Link",icon:u.jsx(Jp,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${Le.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{a("Link copied to clipboard")}).catch(()=>{a("Failed to copy link","error")})}},{label:"QR Code",icon:u.jsx(ule,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:u.jsx(J_,{className:"w-4 h-4"}),onClick:()=>I(!0),disabled:!t.photos?.length},{label:"Project Page",icon:u.jsx(rc,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:u.jsx(r0,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>te.mutate()},{label:"Edit",icon:u.jsx(Rf,{className:"w-4 h-4"}),onClick:()=>v(!0)},{label:n?"Deselect":"Select",icon:n?u.jsx(Pf,{className:"w-4 h-4"}):u.jsx(em,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:u.jsx(Qn,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return u.jsxs(Lt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:ae,onClick:i?()=>r(t.id):void 0,children:[i&&u.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),r(t.id)},children:n?u.jsx(Pf,{className:"w-5 h-5 text-bambu-green"}):u.jsx(em,{className:"w-5 h-5 text-white"})}),u.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?u.jsx("img",{src:Le.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):u.jsx("div",{className:"w-full h-full flex items-center justify-center",children:u.jsx(uw,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),u.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),te.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:u.jsx(r0,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&u.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&&u.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:[u.jsx(Jp,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&u.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const pe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ce=`${window.location.origin}${Le.getSource3mfForSlicer(t.id,pe)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Ce)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:u.jsx(fF,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&u.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),b(!0)},title:"View timelapse",children:u.jsx(jp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&u.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),I(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[u.jsx(J_,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&u.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})]})]}),u.jsxs(Ft,{className:"p-4 flex-1 flex flex-col",children:[u.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),u.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),u.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)&&u.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${ax(t.print_time_seconds||0)}
  8181. Actual: ${ax(t.actual_time_seconds||0)}
  8182. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${ax(t.actual_time_seconds)}`:`Estimated: ${ax(t.print_time_seconds||0)}`,children:[u.jsx(Qr,{className:"w-3 h-3"}),ax(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&u.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&&u.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[u.jsx(n1,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&u.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[u.jsx(kf,{className:"w-3 h-3"}),t.total_layers&&u.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&u.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&u.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&u.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[u.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&u.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,pe)=>u.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},pe))})]})]}),(t.tags||t.notes)&&u.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&u.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:u.jsx(M9,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,pe)=>u.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},pe))]}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[u.jsx("span",{children:K6(t.created_at)}),u.jsx("span",{children:Pk(t.file_size)})]}),u.jsxs("div",{className:"flex gap-1 mt-3",children:[u.jsxs(Ue,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>d(!0),children:[u.jsx(ko,{className:"w-3 h-3 flex-shrink-0"}),u.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),u.jsx(Ue,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",pe=`${window.location.origin}${Le.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(pe)}`},title:"Open in Bambu Studio",children:u.jsx(vc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),u.jsx(Ue,{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:u.jsx(e1,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),u.jsx(Ue,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:u.jsx(Zp,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),u.jsx(Ue,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=Le.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:"Download",children:u.jsx(va,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),u.jsx(Ue,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>v(!0),title:"Edit",children:u.jsx(Rf,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),u.jsx(Ue,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"Delete",children:u.jsx(Qn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),m&&u.jsx(K1e,{archive:t,onClose:()=>v(!1)}),o&&u.jsx(G1e,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&u.jsx(W1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>d(!1),onSuccess:()=>{}}),h&&u.jsx(Zi,{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:()=>{q.mutate(),g(!1)},onCancel:()=>g(!1)}),W&&u.jsx(Zi,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Q.mutate(),P(!1)},onCancel:()=>P(!1)}),$&&u.jsx(Y1e,{x:$.x,y:$.y,items:xe,onClose:()=>K(null)}),y&&t.timelapse_path&&u.jsx(wCe,{src:Le.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&&u.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),u.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),u.jsx("button",{onClick:()=>{M(!1),A([])},className:"text-gray-400 hover:text-white p-1",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(re=>u.jsxs("button",{onClick:()=>H.mutate(re.name),disabled:H.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[u.jsx(jp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-white font-medium truncate",children:re.name}),u.jsxs("p",{className:"text-sm text-gray-400",children:[Pk(re.size),re.mtime&&` • ${K6(re.mtime)}`]})]})]},re.name))}),u.jsx("div",{className:"p-4 border-t border-gray-700",children:u.jsx(Ue,{variant:"secondary",onClick:()=>{M(!1),A([])},className:"w-full",children:"Cancel"})})]})}),T&&u.jsx(rSe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),C&&t.photos&&t.photos.length>0&&u.jsx(iSe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>I(!1),onDelete:async re=>{try{await Le.deleteArchivePhoto(t.id,re),s.invalidateQueries({queryKey:["archives"]}),a("Photo deleted")}catch{a("Failed to delete photo","error")}}}),N&&u.jsx(_Ce,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),z&&u.jsx(MCe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),u.jsx("input",{ref:G,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const pe=re.target.files?.[0];pe&&Z.mutate(pe),re.target.value=""}})]})}const ACe=[{id:"all",label:"All Archives",icon:u.jsx(ooe,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:u.jsx(Qr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:u.jsx(Wr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:u.jsx(Wr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:u.jsx(r0,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:u.jsx(No,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:u.jsx(Jp,{className:"w-4 h-4"})}];function TCe(){const t=Nn(),{showToast:e}=Di(),n=E.useRef(null),[r,i]=E.useState(""),[s,a]=E.useState(null),[o,l]=E.useState(null),[c,d]=E.useState(new Set),[h,g]=E.useState("or"),[m,v]=E.useState(!1),[y,b]=E.useState(null),[x,M]=E.useState(!1),[w,A]=E.useState([]),[T,R]=E.useState(!1),[C,I]=E.useState(new Set),[N,D]=E.useState(!1),[z,j]=E.useState(!1),[W,P]=E.useState(!1),[$,K]=E.useState("grid"),[G,Z]=E.useState("date-desc"),[Q,ee]=E.useState("all"),{data:H,isLoading:q}=Mt({queryKey:["archives",s],queryFn:()=>Le.getArchives(s||void 0)}),{data:te}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),ae=At({mutationFn:async se=>(await Promise.all(se.map(U=>Le.deleteArchive(U))),se.length),onSuccess:se=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${se} archive${se!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),xe=new Map(te?.map(se=>[se.id,se.name])||[]),re=[...new Set(H?.flatMap(se=>se.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),pe=[...new Set(H?.flatMap(se=>se.filament_color?.split(",")||[]).filter(Boolean)||[])],Ce=[...new Set(H?.flatMap(se=>se.tags?.split(",").map(U=>U.trim())||[]).filter(Boolean)||[])].sort(),fe=H?.filter(se=>{const U=new Date,L=new Date(se.created_at);let X=!0;switch(Q){case"recent":X=U.getTime()-L.getTime()<1440*60*1e3;break;case"this-week":X=U.getTime()-L.getTime()<10080*60*1e3;break;case"this-month":X=L.getMonth()===U.getMonth()&&L.getFullYear()===U.getFullYear();break;case"favorites":X=se.is_favorite===!0;break;case"failed":X=se.status==="failed";break;case"duplicates":X=se.duplicate_count>0;break}const me=(se.print_name||se.filename).toLowerCase().includes(r.toLowerCase()),ve=!o||se.filament_type?.split(", ").includes(o),ge=se.filament_color?.split(",")||[],Ke=c.size===0||(h==="or"?ge.some(Fe=>c.has(Fe)):[...c].every(Fe=>ge.includes(Fe))),Ie=Q==="favorites"||!m||se.is_favorite,ze=se.tags?.split(",").map(Fe=>Fe.trim())||[],at=!y||ze.includes(y);return X&&me&&ve&&Ke&&Ie&&at}).sort((se,U)=>{switch(G){case"date-desc":return new Date(U.created_at).getTime()-new Date(se.created_at).getTime();case"date-asc":return new Date(se.created_at).getTime()-new Date(U.created_at).getTime();case"name-asc":return(se.print_name||se.filename).localeCompare(U.print_name||U.filename);case"name-desc":return(U.print_name||U.filename).localeCompare(se.print_name||se.filename);case"size-desc":return U.file_size-se.file_size;case"size-asc":return se.file_size-U.file_size;default:return 0}}),Se=N||C.size>0,Re=se=>{I(U=>{const L=new Set(U);return L.has(se)?L.delete(se):L.add(se),L})},ue=()=>{fe&&I(new Set(fe.map(se=>se.id)))},ct=()=>{I(new Set),D(!1)},B=se=>{d(U=>{const L=new Set(U);return L.has(se)?L.delete(se):L.add(se),L})},F=()=>{d(new Set)},ie=()=>{i(""),a(null),l(null),v(!1),b(null)},V=r||s||o||m||y,J=E.useCallback(se=>{se.preventDefault(),se.dataTransfer.types.includes("Files")&&R(!0)},[]),le=E.useCallback(se=>{se.preventDefault(),se.currentTarget===se.target&&R(!1)},[]),Ae=E.useCallback(se=>{se.preventDefault(),R(!1);const U=Array.from(se.dataTransfer.files).filter(L=>L.name.endsWith(".3mf"));U.length>0?(A(U),M(!0)):se.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Ee=E.useCallback(se=>{const U=se.target;if(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable){se.key==="Escape"&&U.blur();return}switch(se.key){case"/":se.preventDefault(),n.current?.focus();break;case"u":case"U":!se.metaKey&&!se.ctrlKey&&(se.preventDefault(),M(!0));break;case"Escape":Se&&ct();break}},[Se]);return E.useEffect(()=>(document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)),[Ee]),u.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:J,onDragLeave:le,onDrop:Ae,children:[T&&u.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:u.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[u.jsx(Ka,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),u.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),u.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),Se&&u.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:[u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:ct,children:[u.jsx(Qt,{className:"w-4 h-4"}),"Close"]}),u.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),u.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),u.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),u.jsx(Ue,{variant:"secondary",size:"sm",onClick:ue,children:"Select All"}),u.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>P(!0),children:[u.jsx(i0,{className:"w-4 h-4"}),"Tags"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>{const se=Array.from(C);Promise.all(se.map(U=>Le.toggleFavorite(U))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${se.length} archive${se.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[u.jsx(r0,{className:"w-4 h-4"}),"Favorite"]}),u.jsxs(Ue,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>j(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]}),u.jsxs("div",{className:"flex items-center justify-between mb-8",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),u.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Q,onChange:se=>ee(se.target.value),children:ACe.map(se=>u.jsx("option",{value:se.id,children:se.label},se.id))})]}),u.jsxs("p",{className:"text-bambu-gray",children:[fe?.length||0," of ",H?.length||0," prints"]})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[!Se&&u.jsxs(Ue,{variant:"secondary",onClick:()=>D(!0),children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select"]}),u.jsxs(Ue,{onClick:()=>M(!0),children:[u.jsx(Ka,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),u.jsx(Lt,{className:"mb-6",children:u.jsxs(Ft,{className:"py-4",children:[u.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[u.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.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:se=>i(se.target.value)})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(iP,{className:"w-4 h-4 text-bambu-gray"}),u.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:s||"",onChange:se=>a(se.target.value?Number(se.target.value):null),children:[u.jsx("option",{value:"",children:"All Printers"}),te?.map(se=>u.jsx("option",{value:se.id,children:se.name},se.id))]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(n1,{className:"w-4 h-4 text-bambu-gray"}),u.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:se=>l(se.target.value||null),children:[u.jsx("option",{value:"",children:"All Materials"}),re.map(se=>u.jsx("option",{value:se,children:se},se))]})]}),u.jsxs("button",{onClick:()=>v(!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:[u.jsx(r0,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),u.jsx("span",{className:"text-sm",children:"Favorites"})]}),Ce.length>0&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(i0,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:y||"",onChange:se=>b(se.target.value||null),children:[u.jsx("option",{value:"",children:"All Tags"}),Ce.map(se=>u.jsx("option",{value:se,children:se},se))]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(eae,{className:"w-4 h-4 text-bambu-gray"}),u.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:se=>Z(se.target.value),children:[u.jsx("option",{value:"date-desc",children:"Newest first"}),u.jsx("option",{value:"date-asc",children:"Oldest first"}),u.jsx("option",{value:"name-asc",children:"Name A-Z"}),u.jsx("option",{value:"name-desc",children:"Name Z-A"}),u.jsx("option",{value:"size-desc",children:"Largest first"}),u.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),u.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[u.jsx("button",{className:`p-2 ${$==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("grid"),title:"Grid view",children:u.jsx(_9,{className:"w-4 h-4"})}),u.jsx("button",{className:`p-2 ${$==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("list"),title:"List view",children:u.jsx(oP,{className:"w-4 h-4"})}),u.jsx("button",{className:`p-2 ${$==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("calendar"),title:"Calendar view",children:u.jsx(cae,{className:"w-4 h-4"})})]}),V&&u.jsxs(Ue,{variant:"ghost",size:"sm",onClick:ie,className:"text-bambu-gray hover:text-white",children:[u.jsx(Qt,{className:"w-4 h-4"}),"Reset"]})]}),pe.length>0&&u.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&u.jsx("button",{onClick:()=>g(se=>se==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${h==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:h==="or"?"Match ANY selected color":"Match ALL selected colors",children:h.toUpperCase()}),u.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:pe.map(se=>u.jsx("button",{onClick:()=>B(se),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(se)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:se},title:se},se))}),c.size>0&&u.jsxs("button",{onClick:F,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[u.jsx(Qt,{className:"w-3 h-3"}),"Clear"]})]})]})}),q?u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):fe?.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"text-center py-12",children:[u.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):$==="calendar"?u.jsx(Lt,{className:"p-6",children:u.jsx(nSe,{archives:fe||[],onArchiveClick:se=>{i(se.print_name||se.filename),K("grid")}})}):$==="grid"?u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:fe?.map(se=>u.jsx(ECe,{archive:se,printerName:se.printer_id?xe.get(se.printer_id)||"Unknown":"No Printer",isSelected:C.has(se.id),onSelect:Re,selectionMode:Se},se.id))}):$==="list"?u.jsx(Lt,{children:u.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[u.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[u.jsx("div",{className:"col-span-1"}),u.jsx("div",{className:"col-span-4",children:"Name"}),u.jsx("div",{className:"col-span-2",children:"Printer"}),u.jsx("div",{className:"col-span-2",children:"Date"}),u.jsx("div",{className:"col-span-1",children:"Size"}),u.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),fe?.map(se=>u.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(se.id)?"bg-bambu-green/10":""}`,children:[u.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[Se&&u.jsx("button",{onClick:()=>Re(se.id),children:C.has(se.id)?u.jsx(Pf,{className:"w-4 h-4 text-bambu-green"}):u.jsx(em,{className:"w-4 h-4 text-bambu-gray"})}),se.thumbnail_path?u.jsx("img",{src:Le.getArchiveThumbnail(se.id),alt:"",className:"w-10 h-10 object-cover rounded"}):u.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:u.jsx(uw,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),u.jsxs("div",{className:"col-span-4",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("p",{className:"text-white text-sm truncate",children:se.print_name||se.filename}),se.timelapse_path&&u.jsx("span",{title:"Has timelapse",children:u.jsx(jp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),se.filament_type&&u.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:se.filament_type}),se.filament_color&&u.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:se.filament_color.split(",").map((U,L)=>u.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:U},title:U},L))})]})]}),u.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:se.printer_id?xe.get(se.printer_id)||"Unknown":"No Printer"}),u.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(se.created_at).toLocaleDateString()}),u.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:Pk(se.file_size)}),u.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{const U=se.print_name||se.filename||"model",L=`${window.location.origin}${Le.getArchiveForSlicer(se.id,U)}`;window.location.href=`bambustudioopen://${encodeURIComponent(L)}`},title:"Open in Slicer",children:u.jsx(vc,{className:"w-4 h-4"})}),se.makerworld_url&&u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>window.open(se.makerworld_url,"_blank"),title:"MakerWorld",children:u.jsx(e1,{className:"w-4 h-4"})}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{const U=document.createElement("a");U.href=Le.getArchiveDownload(se.id),U.download=`${se.print_name||se.filename}.3mf`,U.click()},title:"Download",children:u.jsx(va,{className:"w-4 h-4"})})]})]},se.id))]})}):null,x&&u.jsx(q1e,{onClose:()=>{M(!1),A([])},initialFiles:w}),z&&u.jsx(Zi,{title:"Delete Archives",message:`Are you sure you want to delete ${C.size} archive${C.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${C.size}`,variant:"danger",onConfirm:()=>{ae.mutate(Array.from(C)),j(!1)},onCancel:()=>j(!1)}),W&&u.jsx(Z1e,{selectedIds:Array.from(C),existingTags:Ce,onClose:()=>P(!1)})]})}function CCe(){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 Uw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Um(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function TD(t){return"nodeType"in t}function Ys(t){var e,n;return t?Um(t)?t:TD(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function CD(t){const{Document:e}=Ys(t);return t instanceof e}function rb(t){return Um(t)?!1:t instanceof Ys(t).HTMLElement}function LX(t){return t instanceof Ys(t).SVGElement}function Fm(t){return t?Um(t)?t.document:TD(t)?CD(t)?t:rb(t)||LX(t)?t.ownerDocument:document:document:document}const cl=Uw?E.useLayoutEffect:E.useEffect;function ND(t){const e=E.useRef(t);return cl(()=>{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 NCe(){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 A0(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return cl(()=>{n.current!==t&&(n.current=t)},e),n}function ib(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function aS(t){const e=ND(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Dk(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let XT={};function sb(t,e){return E.useMemo(()=>{if(e)return e;const n=XT[t]==null?0:XT[t]+1;return XT[t]=n,t+"-"+n},[t,e])}function jX(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((s,a)=>{const o=Object.entries(a);for(const[l,c]of o){const d=s[l];d!=null&&(s[l]=d+t*c)}return s},{...e})}}const Wp=jX(1),T0=jX(-1);function kCe(t){return"clientX"in t&&"clientY"in t}function kD(t){if(!t)return!1;const{KeyboardEvent:e}=Ys(t.target);return e&&t instanceof e}function RCe(t){if(!t)return!1;const{TouchEvent:e}=Ys(t.target);return e&&t instanceof e}function Ok(t){if(RCe(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 kCe(t)?{x:t.clientX,y:t.clientY}:null}const xm=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[xm.Translate.toString(t),xm.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),Y6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function PCe(t){return t.matches(Y6)?t:t.querySelector(Y6)}const DCe={display:"none"};function OCe(t){let{id:e,value:n}=t;return fr.createElement("div",{id:e,style:DCe},n)}function LCe(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 fr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function jCe(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const IX=E.createContext(null);function ICe(t){const e=E.useContext(IX);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function UCe(){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:s}=r;t.forEach(a=>{var o;return(o=a[i])==null?void 0:o.call(a,s)})},[t]),e]}const FCe={draggable:`
  8183. To pick up a draggable item, press the space bar.
  8184. While dragging, use the arrow keys to move the item.
  8185. Press space again to drop the item in its new position, or press escape to cancel.
  8186. `},zCe={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 BCe(t){let{announcements:e=zCe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=FCe}=t;const{announce:s,announcement:a}=jCe(),o=sb("DndLiveRegion"),[l,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),ICe(E.useMemo(()=>({onDragStart(h){let{active:g}=h;s(e.onDragStart({active:g}))},onDragMove(h){let{active:g,over:m}=h;e.onDragMove&&s(e.onDragMove({active:g,over:m}))},onDragOver(h){let{active:g,over:m}=h;s(e.onDragOver({active:g,over:m}))},onDragEnd(h){let{active:g,over:m}=h;s(e.onDragEnd({active:g,over:m}))},onDragCancel(h){let{active:g,over:m}=h;s(e.onDragCancel({active:g,over:m}))}}),[s,e])),!l)return null;const d=fr.createElement(fr.Fragment,null,fr.createElement(OCe,{id:r,value:i.draggable}),fr.createElement(LCe,{id:o,announcement:a}));return n?nc.createPortal(d,n):d}var ai;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(ai||(ai={}));function oS(){}function lS(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function UX(){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 Ro=Object.freeze({x:0,y:0});function FX(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function zX(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function HCe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function Z6(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 BX(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function Q6(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 HX=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=Q6(e,e.left,e.top),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=FX(Q6(l),i);s.push({id:o,data:{droppableContainer:a,value:c}})}}return s.sort(zX)},$Ce=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=Z6(e),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=Z6(l),d=i.reduce((g,m,v)=>g+FX(c[v],m),0),h=Number((d/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:h}})}}return s.sort(zX)};function VCe(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),s=Math.min(e.top+e.height,t.top+t.height),a=i-r,o=s-n;if(r<i&&n<s){const l=e.width*e.height,c=t.width*t.height,d=a*o,h=d/(l+c-d);return Number(h.toFixed(4))}return 0}const GCe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:a}=s,o=n.get(a);if(o){const l=VCe(o,e);l>0&&i.push({id:a,data:{droppableContainer:s,value:l}})}}return i.sort(HCe)};function WCe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function $X(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ro}function qCe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return i.reduce((a,o)=>({...a,top:a.top+t*o.y,bottom:a.bottom+t*o.y,left:a.left+t*o.x,right:a.right+t*o.x}),{...n})}}const XCe=qCe(1);function KCe(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 YCe(t,e,n){const r=KCe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:a,y:o}=r,l=t.left-a-(1-i)*parseFloat(n),c=t.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:d,height:h,top:c,right:l+d,bottom:c+h,left:l}}const ZCe={ignoreTransform:!1};function zm(t,e){e===void 0&&(e=ZCe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:d}=Ys(t).getComputedStyle(t);c&&(n=YCe(n,c,d))}const{top:r,left:i,width:s,height:a,bottom:o,right:l}=n;return{top:r,left:i,width:s,height:a,bottom:o,right:l}}function J6(t){return zm(t,{ignoreTransform:!0})}function QCe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function JCe(t,e){return e===void 0&&(e=Ys(t).getComputedStyle(t)),e.position==="fixed"}function eNe(t,e){e===void 0&&(e=Ys(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function Fw(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(CD(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!rb(i)||LX(i)||n.includes(i))return n;const s=Ys(t).getComputedStyle(i);return i!==t&&eNe(i,s)&&n.push(i),JCe(i,s)?n:r(i.parentNode)}return t?r(t):n}function VX(t){const[e]=Fw(t,1);return e??null}function KT(t){return!Uw||!t?null:Um(t)?t:TD(t)?CD(t)||t===Fm(t).scrollingElement?window:rb(t)?t:null:null}function GX(t){return Um(t)?t.scrollX:t.scrollLeft}function WX(t){return Um(t)?t.scrollY:t.scrollTop}function Lk(t){return{x:GX(t),y:WX(t)}}var Ci;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ci||(Ci={}));function qX(t){return!Uw||!t?!1:t===document.scrollingElement}function XX(t){const e={x:0,y:0},n=qX(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,s=t.scrollLeft<=e.x,a=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:a,isRight:o,maxScroll:r,minScroll:e}}const tNe={x:.2,y:.2};function nNe(t,e,n,r,i){let{top:s,left:a,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=tNe);const{isTop:c,isBottom:d,isLeft:h,isRight:g}=XX(t),m={x:0,y:0},v={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!c&&s<=e.top+y.height?(m.y=Ci.Backward,v.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&l>=e.bottom-y.height&&(m.y=Ci.Forward,v.y=r*Math.abs((e.bottom-y.height-l)/y.height)),!g&&o>=e.right-y.width?(m.x=Ci.Forward,v.x=r*Math.abs((e.right-y.width-o)/y.width)):!h&&a<=e.left+y.width&&(m.x=Ci.Backward,v.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:v}}function rNe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}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 KX(t){return t.reduce((e,n)=>Wp(e,Lk(n)),Ro)}function iNe(t){return t.reduce((e,n)=>e+GX(n),0)}function sNe(t){return t.reduce((e,n)=>e+WX(n),0)}function aNe(t,e){if(e===void 0&&(e=zm),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);VX(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const oNe=[["x",["left","right"],iNe],["y",["top","bottom"],sNe]];class RD{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=Fw(n),i=KX(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of oNe)for(const l of a)Object.defineProperty(this,l,{get:()=>{const c=o(r),d=i[s]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Wx{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 lNe(t){const{EventTarget:e}=Ys(t);return t instanceof e?t:Fm(t)}function YT(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 Ba;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ba||(Ba={}));function e8(t){t.preventDefault()}function cNe(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 YX={start:[_n.Space,_n.Enter],cancel:[_n.Esc],end:[_n.Space,_n.Enter,_n.Tab]},uNe=(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 zw{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 Wx(Fm(n)),this.windowListeners=new Wx(Ys(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ba.Resize,this.handleCancel),this.windowListeners.add(Ba.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ba.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&aNe(r),n(Ro)}handleKeyDown(e){if(kD(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=YX,coordinateGetter:a=uNe,scrollBehavior:o="smooth"}=i,{code:l}=e;if(s.end.includes(l)){this.handleEnd(e);return}if(s.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,d=c?{x:c.left,y:c.top}:Ro;this.referenceCoordinates||(this.referenceCoordinates=d);const h=a(e,{active:n,context:r.current,currentCoordinates:d});if(h){const g=T0(h,d),m={x:0,y:0},{scrollableAncestors:v}=r.current;for(const y of v){const b=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:A,maxScroll:T,minScroll:R}=XX(y),C=rNe(y),I={x:Math.min(b===_n.Right?C.right-C.width/2:C.right,Math.max(b===_n.Right?C.left:C.left+C.width/2,h.x)),y:Math.min(b===_n.Down?C.bottom-C.height/2:C.bottom,Math.max(b===_n.Down?C.top:C.top+C.height/2,h.y))},N=b===_n.Right&&!M||b===_n.Left&&!w,D=b===_n.Down&&!A||b===_n.Up&&!x;if(N&&I.x!==h.x){const z=y.scrollLeft+g.x,j=b===_n.Right&&z<=T.x||b===_n.Left&&z>=R.x;if(j&&!g.y){y.scrollTo({left:z,behavior:o});return}j?m.x=y.scrollLeft-z:m.x=b===_n.Right?y.scrollLeft-T.x:y.scrollLeft-R.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==h.y){const z=y.scrollTop+g.y,j=b===_n.Down&&z<=T.y||b===_n.Up&&z>=R.y;if(j&&!g.x){y.scrollTo({top:z,behavior:o});return}j?m.y=y.scrollTop-z:m.y=b===_n.Down?y.scrollTop-T.y:y.scrollTop-R.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Wp(T0(h,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()}}zw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=YX,onActivation:i}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(r.start.includes(a)){const o=s.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function t8(t){return!!(t&&"distance"in t)}function n8(t){return!!(t&&"delay"in t)}class PD{constructor(e,n,r){var i;r===void 0&&(r=lNe(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:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=Fm(a),this.documentListeners=new Wx(this.document),this.listeners=new Wx(r),this.windowListeners=new Wx(Ys(a)),this.initialCoordinates=(i=Ok(s))!=null?i:Ro,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(Ba.Resize,this.handleCancel),this.windowListeners.add(Ba.DragStart,e8),this.windowListeners.add(Ba.VisibilityChange,this.handleCancel),this.windowListeners.add(Ba.ContextMenu,e8),this.documentListeners.add(Ba.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(n8(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(t8(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(Ba.Click,cNe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ba.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:a,options:{activationConstraint:o}}=s;if(!i)return;const l=(n=Ok(e))!=null?n:Ro,c=T0(i,l);if(!r&&o){if(t8(o)){if(o.tolerance!=null&&YT(c,o.tolerance))return this.handleCancel();if(YT(c,o.distance))return this.handleStart()}if(n8(o)&&YT(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),a(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 dNe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Bw extends PD{constructor(e){const{event:n}=e,r=Fm(n.target);super(e,dNe,r)}}Bw.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 fNe={move:{name:"mousemove"},end:{name:"mouseup"}};var jk;(function(t){t[t.RightClick=2]="RightClick"})(jk||(jk={}));class hNe extends PD{constructor(e){super(e,fNe,Fm(e.event.target))}}hNe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===jk.RightClick?!1:(r?.({event:n}),!0)}}];const ZT={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class pNe extends PD{constructor(e){super(e,ZT)}static setup(){return window.addEventListener(ZT.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ZT.move.name,e)};function e(){}}}pNe.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 qx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(qx||(qx={}));var cS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(cS||(cS={}));function mNe(t){let{acceleration:e,activator:n=qx.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:a=5,order:o=cS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:h,threshold:g}=t;const m=xNe({delta:h,disabled:!s}),[v,y]=NCe(),b=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case qx.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case qx.DraggableRect:return i}},[n,i,l]),w=E.useRef(null),A=E.useCallback(()=>{const R=w.current;if(!R)return;const C=b.current.x*x.current.x,I=b.current.y*x.current.y;R.scrollBy(C,I)},[]),T=E.useMemo(()=>o===cS.TreeOrder?[...c].reverse():c,[o,c]);E.useEffect(()=>{if(!s||!c.length||!M){y();return}for(const R of T){if(r?.(R)===!1)continue;const C=c.indexOf(R),I=d[C];if(!I)continue;const{direction:N,speed:D}=nNe(R,I,M,e,g);for(const z of["x","y"])m[z][N[z]]||(D[z]=0,N[z]=0);if(D.x>0||D.y>0){y(),w.current=R,v(A,a),b.current=D,x.current=N;return}}b.current={x:0,y:0},x.current={x:0,y:0},y()},[e,A,r,y,s,a,JSON.stringify(M),JSON.stringify(m),v,c,T,d,JSON.stringify(g)])}const gNe={x:{[Ci.Backward]:!1,[Ci.Forward]:!1},y:{[Ci.Backward]:!1,[Ci.Forward]:!1}};function xNe(t){let{delta:e,disabled:n}=t;const r=Dk(e);return ib(i=>{if(n||!r||!i)return gNe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ci.Backward]:i.x[Ci.Backward]||s.x===-1,[Ci.Forward]:i.x[Ci.Forward]||s.x===1},y:{[Ci.Backward]:i.y[Ci.Backward]||s.y===-1,[Ci.Forward]:i.y[Ci.Forward]||s.y===1}}},[n,e,r])}function bNe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ib(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function vNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,r)}));return[...n,...s]},[]),[t,e])}var C0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(C0||(C0={}));var Ik;(function(t){t.Optimized="optimized"})(Ik||(Ik={}));const r8=new Map;function yNe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,a]=E.useState(null),{frequency:o,measure:l,strategy:c}=i,d=E.useRef(t),h=b(),g=A0(h),m=E.useCallback(function(x){x===void 0&&(x=[]),!g.current&&a(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[g]),v=E.useRef(null),y=ib(x=>{if(h&&!n)return r8;if(!x||x===r8||d.current!==t||s!=null){const M=new Map;for(let w of t){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const A=w.node.current,T=A?new RD(l(A),A):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,s,n,h,l]);return E.useEffect(()=>{d.current=t},[t]),E.useEffect(()=>{h||m()},[n,h]),E.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),E.useEffect(()=>{h||typeof o!="number"||v.current!==null||(v.current=setTimeout(()=>{m(),v.current=null},o))},[o,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function b(){switch(c){case C0.Always:return!1;case C0.BeforeDragging:return n;default:return!n}}}function ZX(t,e){return ib(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function _Ne(t,e){return ZX(t,e)}function SNe(t){let{callback:e,disabled:n}=t;const r=ND(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function Hw(t){let{callback:e,disabled:n}=t;const r=ND(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function wNe(t){return new RD(zm(t),t)}function i8(t,e,n){e===void 0&&(e=wNe);const[r,i]=E.useState(null);function s(){i(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const a=SNe({callback(l){if(t)for(const c of l){const{type:d,target:h}=c;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),o=Hw({callback:s});return cl(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function MNe(t){const e=ZX(t);return $X(t,e)}const s8=[];function ENe(t){const e=E.useRef(t),n=ib(r=>t?r&&r!==s8&&t&&e.current&&t.parentNode===e.current.parentNode?r:Fw(t):s8,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function ANe(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(s=>{const a=KT(s.target);a&&n(o=>o?(o.set(a,Lk(a)),new Map(o)):null)},[]);return E.useEffect(()=>{const s=r.current;if(t!==s){a(s);const o=t.map(l=>{const c=KT(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,Lk(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),r.current=t}return()=>{a(t),a(s)};function a(o){o.forEach(l=>{const c=KT(l);c?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,a)=>Wp(s,a),Ro):KX(t):Ro,[t,e])}function a8(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==Ro;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?T0(t,n.current):Ro}function TNe(t){E.useEffect(()=>{if(!Uw)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 CNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=a=>{s(a,e)},n},{}),[t,e])}function QX(t){return E.useMemo(()=>t?QCe(t):null,[t])}const o8=[];function NNe(t,e){e===void 0&&(e=zm);const[n]=t,r=QX(n?Ys(n):null),[i,s]=E.useState(o8);function a(){s(()=>t.length?t.map(l=>qX(l)?r:new RD(e(l),l)):o8)}const o=Hw({callback:a});return cl(()=>{o?.disconnect(),a(),t.forEach(l=>o?.observe(l))},[t]),i}function kNe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return rb(e)?e:t}function RNe(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(c=>{for(const{target:d}of c)if(rb(d)){r(h=>{const g=e(d);return h?{...h,width:g.width,height:g.height}:g});break}},[e]),s=Hw({callback:i}),a=E.useCallback(c=>{const d=kNe(c);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[o,l]=aS(a);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const PNe=[{sensor:Bw,options:{}},{sensor:zw,options:{}}],DNe={current:{}},B_={draggable:{measure:J6},droppable:{measure:J6,strategy:C0.WhileDragging,frequency:Ik.Optimized},dragOverlay:{measure:zm}};class Xx 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 ONe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Xx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:oS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:B_,measureDroppableContainers:oS,windowRect:null,measuringScheduled:!1},LNe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:oS,draggableNodes:new Map,over:null,measureDroppableContainers:oS},$w=E.createContext(LNe),JX=E.createContext(ONe);function jNe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Xx}}}function INe(t,e){switch(e.type){case ai.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ai.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case ai.DragEnd:case ai.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ai.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Xx(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ai.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const a=new Xx(t.droppable.containers);return a.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case ai.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Xx(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function UNe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext($w),s=Dk(r),a=Dk(n?.id);return E.useEffect(()=>{if(!e&&!r&&s&&a!=null){if(!kD(s)||document.activeElement===s.target)return;const o=i.get(a);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const h=PCe(d);if(h){h.focus();break}}})}},[r,e,i,a,s]),null}function FNe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function zNe(t){return E.useMemo(()=>({draggable:{...B_.draggable,...t?.draggable},droppable:{...B_.droppable,...t?.droppable},dragOverlay:{...B_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function BNe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=E.useRef(!1),{x:a,y:o}=typeof i=="boolean"?{x:i,y:i}:i;cl(()=>{if(!a&&!o||!e){s.current=!1;return}if(s.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const d=n(c),h=$X(d,r);if(a||(h.x=0),o||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=VX(c);g&&g.scrollBy({top:h.y,left:h.x})}},[e,a,o,r,n])}const eK=E.createContext({...Ro,scaleX:1,scaleY:1});var Tu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Tu||(Tu={}));const tK=E.memo(function(e){var n,r,i,s;let{id:a,accessibility:o,autoScroll:l=!0,children:c,sensors:d=PNe,collisionDetection:h=GCe,measuring:g,modifiers:m,...v}=e;const y=E.useReducer(INe,void 0,jNe),[b,x]=y,[M,w]=UCe(),[A,T]=E.useState(Tu.Uninitialized),R=A===Tu.Initialized,{draggable:{active:C,nodes:I,translate:N},droppable:{containers:D}}=b,z=C!=null?I.get(C):null,j=E.useRef({initial:null,translated:null}),W=E.useMemo(()=>{var je;return C!=null?{id:C,data:(je=z?.data)!=null?je:DNe,rect:j}:null},[C,z]),P=E.useRef(null),[$,K]=E.useState(null),[G,Z]=E.useState(null),Q=A0(v,Object.values(v)),ee=sb("DndDescribedBy",a),H=E.useMemo(()=>D.getEnabled(),[D]),q=zNe(g),{droppableRects:te,measureDroppableContainers:ae,measuringScheduled:xe}=yNe(H,{dragging:R,dependencies:[N.x,N.y],config:q.droppable}),re=bNe(I,C),pe=E.useMemo(()=>G?Ok(G):null,[G]),Ce=be(),fe=_Ne(re,q.draggable.measure);BNe({activeNode:C!=null?I.get(C):null,config:Ce.layoutShiftCompensation,initialRect:fe,measure:q.draggable.measure});const Se=i8(re,q.draggable.measure,fe),Re=i8(re?re.parentElement:null),ue=E.useRef({activatorEvent:null,active:null,activeNode:re,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ct=D.getNodeFor((n=ue.current.over)==null?void 0:n.id),B=RNe({measure:q.dragOverlay.measure}),F=(r=B.nodeRef.current)!=null?r:re,ie=R?(i=B.rect)!=null?i:Se:null,V=!!(B.nodeRef.current&&B.rect),J=MNe(V?null:Se),le=QX(F?Ys(F):null),Ae=ENe(R?ct??re:null),Ee=NNe(Ae),se=FNe(m,{transform:{x:N.x-J.x,y:N.y-J.y,scaleX:1,scaleY:1},activatorEvent:G,active:W,activeNodeRect:Se,containerNodeRect:Re,draggingNodeRect:ie,over:ue.current.over,overlayNodeRect:B.rect,scrollableAncestors:Ae,scrollableAncestorRects:Ee,windowRect:le}),U=pe?Wp(pe,N):null,L=ANe(Ae),X=a8(L),me=a8(L,[Se]),ve=Wp(se,X),ge=ie?XCe(ie,se):null,Ke=W&&ge?h({active:W,collisionRect:ge,droppableRects:te,droppableContainers:H,pointerCoordinates:U}):null,Ie=BX(Ke,"id"),[ze,at]=E.useState(null),Fe=V?se:Wp(se,me),ce=WCe(Fe,(s=ze?.rect)!=null?s:null,Se),Qe=E.useRef(null),He=E.useCallback((je,Te)=>{let{sensor:ye,options:Ge}=Te;if(P.current==null)return;const ft=I.get(P.current);if(!ft)return;const yt=je.nativeEvent,Rt=new ye({active:P.current,activeNode:ft,event:yt,options:Ge,context:ue,onAbort(jt){if(!I.get(jt))return;const{onDragAbort:qn}=Q.current,bi={id:jt};qn?.(bi),M({type:"onDragAbort",event:bi})},onPending(jt,Rn,qn,bi){if(!I.get(jt))return;const{onDragPending:vi}=Q.current,Li={id:jt,constraint:Rn,initialCoordinates:qn,offset:bi};vi?.(Li),M({type:"onDragPending",event:Li})},onStart(jt){const Rn=P.current;if(Rn==null)return;const qn=I.get(Rn);if(!qn)return;const{onDragStart:bi}=Q.current,ti={activatorEvent:yt,active:{id:Rn,data:qn.data,rect:j}};nc.unstable_batchedUpdates(()=>{bi?.(ti),T(Tu.Initializing),x({type:ai.DragStart,initialCoordinates:jt,active:Rn}),M({type:"onDragStart",event:ti}),K(Qe.current),Z(yt)})},onMove(jt){x({type:ai.DragMove,coordinates:jt})},onEnd:cn(ai.DragEnd),onCancel:cn(ai.DragCancel)});Qe.current=Rt;function cn(jt){return async function(){const{active:qn,collisions:bi,over:ti,scrollAdjustedTranslate:vi}=ue.current;let Li=null;if(qn&&vi){const{cancelDrop:Qi}=Q.current;Li={activatorEvent:yt,active:qn,collisions:bi,delta:vi,over:ti},jt===ai.DragEnd&&typeof Qi=="function"&&await Promise.resolve(Qi(Li))&&(jt=ai.DragCancel)}P.current=null,nc.unstable_batchedUpdates(()=>{x({type:jt}),T(Tu.Uninitialized),at(null),K(null),Z(null),Qe.current=null;const Qi=jt===ai.DragEnd?"onDragEnd":"onDragCancel";if(Li){const Ir=Q.current[Qi];Ir?.(Li),M({type:Qi,event:Li})}})}}},[I]),Ye=E.useCallback((je,Te)=>(ye,Ge)=>{const ft=ye.nativeEvent,yt=I.get(Ge);if(P.current!==null||!yt||ft.dndKit||ft.defaultPrevented)return;const Rt={active:yt};je(ye,Te.options,Rt)===!0&&(ft.dndKit={capturedBy:Te.sensor},P.current=Ge,He(ye,Te))},[I,He]),ut=vNe(d,Ye);TNe(d),cl(()=>{Se&&A===Tu.Initializing&&T(Tu.Initialized)},[Se,A]),E.useEffect(()=>{const{onDragMove:je}=Q.current,{active:Te,activatorEvent:ye,collisions:Ge,over:ft}=ue.current;if(!Te||!ye)return;const yt={active:Te,activatorEvent:ye,collisions:Ge,delta:{x:ve.x,y:ve.y},over:ft};nc.unstable_batchedUpdates(()=>{je?.(yt),M({type:"onDragMove",event:yt})})},[ve.x,ve.y]),E.useEffect(()=>{const{active:je,activatorEvent:Te,collisions:ye,droppableContainers:Ge,scrollAdjustedTranslate:ft}=ue.current;if(!je||P.current==null||!Te||!ft)return;const{onDragOver:yt}=Q.current,Rt=Ge.get(Ie),cn=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,jt={active:je,activatorEvent:Te,collisions:ye,delta:{x:ft.x,y:ft.y},over:cn};nc.unstable_batchedUpdates(()=>{at(cn),yt?.(jt),M({type:"onDragOver",event:jt})})},[Ie]),cl(()=>{ue.current={activatorEvent:G,active:W,activeNode:re,collisionRect:ge,collisions:Ke,droppableRects:te,draggableNodes:I,draggingNode:F,draggingNodeRect:ie,droppableContainers:D,over:ze,scrollableAncestors:Ae,scrollAdjustedTranslate:ve},j.current={initial:ie,translated:ge}},[W,re,Ke,ge,I,F,ie,te,D,ze,Ae,ve]),mNe({...Ce,delta:N,draggingRect:ge,pointerCoordinates:U,scrollableAncestors:Ae,scrollableAncestorRects:Ee});const de=E.useMemo(()=>({active:W,activeNode:re,activeNodeRect:Se,activatorEvent:G,collisions:Ke,containerNodeRect:Re,dragOverlay:B,draggableNodes:I,droppableContainers:D,droppableRects:te,over:ze,measureDroppableContainers:ae,scrollableAncestors:Ae,scrollableAncestorRects:Ee,measuringConfiguration:q,measuringScheduled:xe,windowRect:le}),[W,re,Se,G,Ke,Re,B,I,D,te,ze,ae,Ae,Ee,q,xe,le]),Je=E.useMemo(()=>({activatorEvent:G,activators:ut,active:W,activeNodeRect:Se,ariaDescribedById:{draggable:ee},dispatch:x,draggableNodes:I,over:ze,measureDroppableContainers:ae}),[G,ut,W,Se,x,ee,I,ze,ae]);return fr.createElement(IX.Provider,{value:w},fr.createElement($w.Provider,{value:Je},fr.createElement(JX.Provider,{value:de},fr.createElement(eK.Provider,{value:ce},c)),fr.createElement(UNe,{disabled:o?.restoreFocus===!1})),fr.createElement(BCe,{...o,hiddenTextDescribedById:ee}));function be(){const je=$?.autoScrollEnabled===!1,Te=typeof l=="object"?l.enabled===!1:l===!1,ye=R&&!je&&!Te;return typeof l=="object"?{...l,enabled:ye}:{enabled:ye}}}),HNe=E.createContext(null),l8="button",$Ne="Draggable";function VNe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=sb($Ne),{activators:a,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:h,over:g}=E.useContext($w),{role:m=l8,roleDescription:v="draggable",tabIndex:y=0}=i??{},b=l?.id===e,x=E.useContext(b?eK:HNe),[M,w]=aS(),[A,T]=aS(),R=CNe(a,e),C=A0(n);cl(()=>(h.set(e,{id:e,key:s,node:M,activatorNode:A,data:C}),()=>{const N=h.get(e);N&&N.key===s&&h.delete(e)}),[h,e]);const I=E.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&m===l8?!0:void 0,"aria-roledescription":v,"aria-describedby":d.draggable}),[r,m,y,b,v,d.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:I,isDragging:b,listeners:r?void 0:R,node:M,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function GNe(){return E.useContext(JX)}const WNe="Droppable",qNe={timeout:25};function XNe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=sb(WNe),{active:a,dispatch:o,over:l,measureDroppableContainers:c}=E.useContext($w),d=E.useRef({disabled:n}),h=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:v,updateMeasurementsFor:y,timeout:b}={...qNe,...i},x=A0(y??r),M=E.useCallback(()=>{if(!h.current){h.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=Hw({callback:M,disabled:v||!a}),A=E.useCallback((I,N)=>{w&&(N&&(w.unobserve(N),h.current=!1),I&&w.observe(I))},[w]),[T,R]=aS(A),C=A0(e);return E.useEffect(()=>{!w||!T.current||(w.disconnect(),h.current=!1,w.observe(T.current))},[T,w]),E.useEffect(()=>(o({type:ai.RegisterDroppable,element:{id:r,key:s,disabled:n,node:T,rect:g,data:C}}),()=>o({type:ai.UnregisterDroppable,key:s,id:r})),[r]),E.useEffect(()=>{n!==d.current.disabled&&(o({type:ai.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,o]),{active:a,rect:g,isOver:l?.id===r,node:T,over:l,setNodeRef:R}}function Vw(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function KNe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function n_(t){return t!==null&&t>=0}function YNe(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 ZNe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const DD=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=Vw(e,r,n),a=e[i],o=s[i];return!o||!a?null:{x:o.left-a.left,y:o.top-a.top,scaleX:o.width/a.width,scaleY:o.height/a.height}},r_={scaleX:1,scaleY:1},QNe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:a}=t;const o=(e=s[n])!=null?e:r;if(!o)return null;if(i===n){const c=s[a];return c?{x:0,y:n<a?c.top+c.height-(o.top+o.height):c.top-o.top,...r_}:null}const l=JNe(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-l,...r_}:i<n&&i>=a?{x:0,y:o.height+l,...r_}:{x:0,y:0,...r_}};function JNe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const nK="Sortable",rK=fr.createContext({activeIndex:-1,containerId:nK,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:DD,disabled:{draggable:!1,droppable:!1}});function iK(t){let{children:e,id:n,items:r,strategy:i=DD,disabled:s=!1}=t;const{active:a,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:d}=GNe(),h=sb(nK,n),g=o.rect!==null,m=E.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),v=a!=null,y=a?m.indexOf(a.id):-1,b=c?m.indexOf(c.id):-1,x=E.useRef(m),M=!YNe(m,x.current),w=b!==-1&&y===-1||M,A=ZNe(s);cl(()=>{M&&v&&d(m)},[M,m,v,d]),E.useEffect(()=>{x.current=m},[m]);const T=E.useMemo(()=>({activeIndex:y,containerId:h,disabled:A,disableTransforms:w,items:m,overIndex:b,useDragOverlay:g,sortedRects:KNe(m,l),strategy:i}),[y,h,A.draggable,A.droppable,w,m,b,l,g,i]);return fr.createElement(rK.Provider,{value:T},e)}const e3e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return Vw(n,r,i).indexOf(e)},t3e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:a,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!r||o!==s&&i===a?!1:n?!0:a!==i&&e===l},n3e={duration:200,easing:"ease"},sK="transform",r3e=xm.Transition.toString({property:sK,duration:0,easing:"linear"}),i3e={roleDescription:"sortable"};function s3e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=E.useState(null),o=E.useRef(n);return cl(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const c=zm(r.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&a(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{s&&a(null)},[s]),s}function aK(t){let{animateLayoutChanges:e=t3e,attributes:n,disabled:r,data:i,getNewIndex:s=e3e,id:a,strategy:o,resizeObserverConfig:l,transition:c=n3e}=t;const{items:d,containerId:h,activeIndex:g,disabled:m,disableTransforms:v,sortedRects:y,overIndex:b,useDragOverlay:x,strategy:M}=E.useContext(rK),w=a3e(r,m),A=d.indexOf(a),T=E.useMemo(()=>({sortable:{containerId:h,index:A,items:d},...i}),[h,i,A,d]),R=E.useMemo(()=>d.slice(d.indexOf(a)),[d,a]),{rect:C,node:I,isOver:N,setNodeRef:D}=XNe({id:a,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:z,activatorEvent:j,activeNodeRect:W,attributes:P,setNodeRef:$,listeners:K,isDragging:G,over:Z,setActivatorNodeRef:Q,transform:ee}=VNe({id:a,data:T,attributes:{...i3e,...n},disabled:w.draggable}),H=CCe(D,$),q=!!z,te=q&&!v&&n_(g)&&n_(b),ae=!x&&G,xe=ae&&te?ee:null,pe=te?xe??(o??M)({rects:y,activeNodeRect:W,activeIndex:g,overIndex:b,index:A}):null,Ce=n_(g)&&n_(b)?s({id:a,items:d,activeIndex:g,overIndex:b}):A,fe=z?.id,Se=E.useRef({activeId:fe,items:d,newIndex:Ce,containerId:h}),Re=d!==Se.current.items,ue=e({active:z,containerId:h,isDragging:G,isSorting:q,id:a,index:A,items:d,newIndex:Se.current.newIndex,previousItems:Se.current.items,previousContainerId:Se.current.containerId,transition:c,wasDragging:Se.current.activeId!=null}),ct=s3e({disabled:!ue,index:A,node:I,rect:C});return E.useEffect(()=>{q&&Se.current.newIndex!==Ce&&(Se.current.newIndex=Ce),h!==Se.current.containerId&&(Se.current.containerId=h),d!==Se.current.items&&(Se.current.items=d)},[q,Ce,h,d]),E.useEffect(()=>{if(fe===Se.current.activeId)return;if(fe!=null&&Se.current.activeId==null){Se.current.activeId=fe;return}const F=setTimeout(()=>{Se.current.activeId=fe},50);return()=>clearTimeout(F)},[fe]),{active:z,activeIndex:g,attributes:P,data:T,rect:C,index:A,newIndex:Ce,items:d,isOver:N,isSorting:q,isDragging:G,listeners:K,node:I,overIndex:b,over:Z,setNodeRef:H,setActivatorNodeRef:Q,setDroppableNodeRef:D,setDraggableNodeRef:$,transform:ct??pe,transition:B()};function B(){if(ct||Re&&Se.current.newIndex===A)return r3e;if(!(ae&&!kD(j)||!c)&&(q||ue))return xm.Transition.toString({...c,property:sK})}}function a3e(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 uS(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 o3e=[_n.Down,_n.Right,_n.Up,_n.Left],oK=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(o3e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=i.get(h.id);if(g)switch(t.code){case _n.Down:r.top<g.top&&l.push(h);break;case _n.Up:r.top>g.top&&l.push(h);break;case _n.Left:r.left>g.left&&l.push(h);break;case _n.Right:r.left<g.left&&l.push(h);break}});const c=$Ce({collisionRect:r,droppableRects:i,droppableContainers:l});let d=BX(c,"id");if(d===a?.id&&c.length>1&&(d=c[1].id),d!=null){const h=s.get(n.id),g=s.get(d),m=g?i.get(g.id):null,v=g?.node.current;if(v&&m&&h&&g){const b=Fw(v).some((R,C)=>o[C]!==R),x=lK(h,g),M=l3e(h,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:T0(A,w)}}}};function lK(t,e){return!uS(t)||!uS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function l3e(t,e){return!uS(t)||!uS(e)||!lK(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function c3e({item:t,onClose:e}){const n=Nn(),{showToast:r}=Di(),[i,s]=E.useState(t.printer_id),a=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=E.useState(t.scheduled_time&&!a?"scheduled":"asap"),[c,d]=E.useState(()=>t.scheduled_time&&!a?new Date(t.scheduled_time).toISOString().slice(0,16):""),[h,g]=E.useState(t.require_previous_success),[m,v]=E.useState(t.auto_off_after),{data:y}=Mt({queryKey:["printers"],queryFn:()=>Le.getPrinters()});E.useEffect(()=>{const w=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const b=At({mutationFn:w=>Le.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:w=>{r(w.message||"Failed to update queue item","error")}}),x=w=>{w.preventDefault();const A={printer_id:i,require_previous_success:h,auto_off_after:m};o==="scheduled"&&c?A.scheduled_time=new Date(c).toISOString():A.scheduled_time=null,b.mutate(A)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:u.jsx(Lt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Rf,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),u.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?u.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[u.jsx(No,{className:"w-4 h-4"}),"No printers configured"]}):u.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:w=>s(Number(w.target.value)),required:!0,children:y?.map(w=>u.jsx("option",{value:w.id,children:w.name},w.id))})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),u.jsxs("div",{className:"flex gap-2",children:[u.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:[u.jsx(Qr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),u.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:[u.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),u.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>d(w.target.value),min:M(),required:!0})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),u.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>v(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),u.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[u.jsx(dd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),u.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."}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsx(Ue,{type:"submit",className:"flex-1",disabled:b.isPending||y?.length===0,children:b.isPending?"Saving...":"Save Changes"})]})]})]})})})}function cK(t){if(!t)return"--";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function u3e(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 d3e({status:t}){const e={pending:{icon:Qr,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:dw,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Ss,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:ud,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:i1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Qt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return u.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[u.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function QT({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:d,transition:h,isDragging:g}=aK({id:t.id,disabled:t.status!=="pending"}),m={transform:xm.Transform.toString(d),transition:h},v=t.status==="printing",y=t.status==="pending",b=["completed","failed","skipped","cancelled"].includes(t.status);return u.jsx("div",{ref:c,style:m,className:`
  8187. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8188. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8189. ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8190. ${v?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8191. `,children:u.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?u.jsx("div",{...o,...l,className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors",children:u.jsx(aP,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?u.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):u.jsx("div",{className:"w-8"}),u.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?u.jsx("img",{src:Le.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):u.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:u.jsx(kf,{className:"w-6 h-6"})})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),u.jsx(lw,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:u.jsx(vc,{className:"w-3.5 h-3.5"})})]}),u.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(ko,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ou,{className:"w-3.5 h-3.5"}),cK(t.print_time_seconds)]}),y&&u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Qr,{className:"w-3.5 h-3.5"}),u3e(t.scheduled_time)]})]}),u.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&u.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&u.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[u.jsx(dd,{className:"w-3 h-3"}),"Auto power off"]})]}),v&&u.jsxs("div",{className:"mt-3",children:[u.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&u.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[u.jsx(No,{className:"w-3 h-3"}),t.error_message]})]}),u.jsx(d3e,{status:t.status}),u.jsxs("div",{className:"flex items-center gap-1",children:[v&&u.jsx(Ue,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:u.jsx(Eae,{className:"w-4 h-4"})}),y&&u.jsxs(u.Fragment,{children:[u.jsx(Ue,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:u.jsx(Rf,{className:"w-4 h-4"})}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:u.jsx(Qt,{className:"w-4 h-4"})})]}),b&&u.jsxs(u.Fragment,{children:[u.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:u.jsx(qs,{className:"w-4 h-4"})}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})})}function f3e(){const t=Nn(),{showToast:e}=Di(),[n,r]=E.useState(null),[i,s]=E.useState(""),[a,o]=E.useState(!1),[l,c]=E.useState(null),[d,h]=E.useState(null),[g,m]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[v,y]=E.useState(()=>{const Q=localStorage.getItem("queue.historySortAsc");return Q!==null?Q==="true":!1}),[b,x]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,w]=E.useState(()=>{const Q=localStorage.getItem("queue.pendingSortAsc");return Q!==null?Q==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(v))},[v]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",b)},[b]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const A=UX(lS(Bw,{activationConstraint:{distance:8}}),lS(zw,{coordinateGetter:oK})),{data:T,isLoading:R}=Mt({queryKey:["queue",n,i],queryFn:()=>Le.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:C}=Mt({queryKey:["printers"],queryFn:()=>Le.getPrinters()}),I=At({mutationFn:Q=>Le.cancelQueueItem(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=At({mutationFn:Q=>Le.removeFromQueue(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=At({mutationFn:Q=>Le.stopQueueItem(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),z=At({mutationFn:Q=>Le.reorderQueue(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),j=At({mutationFn:Q=>{const ee=new Date;return ee.setFullYear(ee.getFullYear()+1),Le.addToQueue({printer_id:Q.printer_id,archive_id:Q.archive_id,scheduled_time:ee.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Q=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),c(Q)},onError:Q=>e(Q.message||"Failed to re-queue item","error")}),W=At({mutationFn:async()=>{const Q=T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[];for(const ee of Q)await Le.removeFromQueue(ee.id);return Q.length},onSuccess:Q=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Q} history item${Q!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),P=E.useMemo(()=>{const Q=T?.filter(H=>H.status==="pending")||[],ee=H=>{if(!H.scheduled_time)return 0;const q=new Date(H.scheduled_time).getTime(),te=Date.now()+4320*60*60*1e3;return q>te?0:q};return[...Q].sort((H,q)=>{let te;return b==="name"?te=(H.archive_name||"").localeCompare(q.archive_name||""):b==="printer"?te=(H.printer_name||"").localeCompare(q.printer_name||""):b==="time"?te=ee(H)-ee(q):te=H.position-q.position,M?te:-te})},[T,b,M]),$=T?.filter(Q=>Q.status==="printing")||[],K=E.useMemo(()=>[...T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[]].sort((ee,H)=>{let q;return g==="name"?q=(ee.archive_name||"").localeCompare(H.archive_name||""):g==="printer"?q=(ee.printer_name||"").localeCompare(H.printer_name||""):q=new Date(H.completed_at||H.created_at).getTime()-new Date(ee.completed_at||ee.created_at).getTime(),v?-q:q}),[T,g,v]),G=E.useMemo(()=>P.reduce((Q,ee)=>Q+(ee.print_time_seconds||0),0),[P]),Z=Q=>{const{active:ee,over:H}=Q;if(!H||ee.id===H.id)return;const q=P.findIndex(ae=>ae.id===ee.id),te=P.findIndex(ae=>ae.id===H.id);if(q!==-1&&te!==-1){const xe=Vw(P,q,te).map((re,pe)=>({id:re.id,position:pe+1}));z.mutate(xe)}};return u.jsxs("div",{className:"p-8",children:[u.jsx("div",{className:"flex items-center justify-between mb-8",children:u.jsxs("div",{children:[u.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[u.jsx(w9,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),u.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[u.jsx(Lt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:u.jsx(Ft,{className:"p-4",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:u.jsx(dw,{className:"w-5 h-5 text-blue-400"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-2xl font-bold text-white",children:$.length}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),u.jsx(Lt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:u.jsx(Ft,{className:"p-4",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:u.jsx(Qr,{className:"w-5 h-5 text-yellow-400"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-2xl font-bold text-white",children:P.length}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),u.jsx(Lt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:u.jsx(Ft,{className:"p-4",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:u.jsx(Ou,{className:"w-5 h-5 text-bambu-green"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-2xl font-bold text-white",children:cK(G)}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),u.jsx(Lt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:u.jsx(Ft,{className:"p-4",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:u.jsx(Ss,{className:"w-5 h-5 text-gray-400"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),u.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[u.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Q=>r(Q.target.value?Number(Q.target.value):null),children:[u.jsx("option",{value:"",children:"All Printers"}),C?.map(Q=>u.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),u.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Q=>s(Q.target.value),children:[u.jsx("option",{value:"",children:"All Status"}),u.jsx("option",{value:"pending",children:"Pending"}),u.jsx("option",{value:"printing",children:"Printing"}),u.jsx("option",{value:"completed",children:"Completed"}),u.jsx("option",{value:"failed",children:"Failed"}),u.jsx("option",{value:"skipped",children:"Skipped"}),u.jsx("option",{value:"cancelled",children:"Cancelled"})]}),u.jsx("div",{className:"flex-1"}),K.length>0&&u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Clear History"]})]}),R?u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?u.jsxs(Lt,{className:"p-12 text-center border-dashed",children:[u.jsx(Wr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),u.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),u.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):u.jsxs("div",{className:"space-y-8",children:[$.length>0&&u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[u.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),u.jsx("div",{className:"space-y-3",children:$.map(Q=>u.jsx(QT,{item:Q,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>h({type:"stop",item:Q}),onRequeue:()=>{}},Q.id))})]}),P.length>0&&u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Qr,{className:"w-5 h-5 text-yellow-400"}),"Queued",u.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",P.length," item",P.length!==1?"s":"",")"]}),u.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:b,onChange:Q=>x(Q.target.value),children:[u.jsx("option",{value:"position",children:"Sort by Position"}),u.jsx("option",{value:"name",children:"Sort by Name"}),u.jsx("option",{value:"printer",children:"Sort by Printer"}),u.jsx("option",{value:"time",children:"Sort by Schedule"})]}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>w(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?u.jsx(Yp,{className:"w-4 h-4"}):u.jsx(e0,{className:"w-4 h-4"})})]})]}),u.jsx(tK,{sensors:A,collisionDetection:HX,onDragEnd:Z,children:u.jsx(iK,{items:P.map(Q=>Q.id),strategy:QNe,children:u.jsx("div",{className:"space-y-3",children:P.map((Q,ee)=>u.jsx(QT,{item:Q,position:ee+1,onEdit:()=>c(Q),onCancel:()=>h({type:"cancel",item:Q}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Q.id))})})})]}),K.length>0&&u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Ss,{className:"w-5 h-5 text-bambu-gray"}),"History",u.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Q=>m(Q.target.value),children:[u.jsx("option",{value:"date",children:"Sort by Date"}),u.jsx("option",{value:"name",children:"Sort by Name"}),u.jsx("option",{value:"printer",children:"Sort by Printer"})]}),u.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>y(!v),title:v?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:v?u.jsx(Yp,{className:"w-4 h-4"}):u.jsx(e0,{className:"w-4 h-4"})})]})]}),u.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Q,ee)=>u.jsx(QT,{item:Q,position:ee+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>h({type:"remove",item:Q}),onStop:()=>{},onRequeue:()=>j.mutate(Q)},Q.id))})]})]}),l&&u.jsx(c3e,{item:l,onClose:()=>c(null)}),d&&u.jsx(Zi,{title:d.type==="cancel"?"Cancel Scheduled Print":d.type==="stop"?"Stop Print":"Remove from History",message:d.type==="cancel"?`Are you sure you want to cancel "${d.item.archive_name||"this print"}"?`:d.type==="stop"?`Are you sure you want to stop the current print "${d.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${d.item.archive_name||"this item"}" from the queue history?`,confirmText:d.type==="cancel"?"Cancel Print":d.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{d.type==="cancel"?I.mutate(d.item.id):d.type==="stop"?D.mutate(d.item.id):N.mutate(d.item.id),h(null)},onCancel:()=>h(null)}),a&&u.jsx(Zi,{title:"Clear History",message:`Are you sure you want to remove all ${K.length} item${K.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{W.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function h3e({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,d=new Date(c);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const h=[],g=[];let m=[],v=-1;const y=new Date(d);let b=0;for(;y<=c;)y.getDay()===0&&m.length>0&&(h.push(m),m=[],b++),y.getMonth()!==v&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:b}),v=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&h.push(m),{weeks:h,monthLabels:g,printCounts:l}},[t,e]),s=Math.max(1,...Object.values(i)),a=l=>{if(l===0)return"bg-bambu-dark";const c=l/s;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 u.jsxs("div",{className:"overflow-x-auto",children:[u.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:c},d)=>u.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(c-(r[d-1]?.weekIndex||0))*14-24}px`},children:l},d))}),u.jsxs("div",{className:"flex gap-0.5",children:[u.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>u.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)=>u.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const h=l.find(y=>y.getDay()===d);if(!h)return u.jsx("div",{className:"w-3 h-3"},d);const g=h.toISOString().split("T")[0],m=i[g]||0,v=g===new Date().toISOString().split("T")[0];return u.jsx("div",{className:`w-3 h-3 rounded-sm ${a(m)} ${v?"ring-1 ring-white":""}`,title:`${h.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},c))]}),u.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[u.jsx("span",{children:"Less"}),u.jsxs("div",{className:"flex gap-0.5",children:[u.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),u.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),u.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),u.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),u.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),u.jsx("span",{children:"More"})]})]})}function uK(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=uK(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=uK(t))&&(r&&(r+=" "),r+=e);return r}var p3e=["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=p3e;return e.includes(t)}var m3e=["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"],g3e=new Set(m3e);function dK(t){return typeof t!="string"?!1:g3e.has(t)}function fK(t){return typeof t=="string"&&t.startsWith("data-")}function Xs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dK(n)||fK(n))&&(e[n]=t[n]);return e}function Gf(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Xs(e)}return typeof t=="object"&&!Array.isArray(t)?Xs(t):null}function Cs(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(dK(n)||fK(n)||OD(n))&&(e[n]=t[n]);return e}function x3e(t){return t==null?null:E.isValidElement(t)?Cs(t.props):typeof t=="object"&&!Array.isArray(t)?Cs(t):null}var b3e=["children","width","height","viewBox","className","style","title","desc"];function Uk(){return Uk=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},Uk.apply(null,arguments)}function v3e(t,e){if(t==null)return{};var n,r,i=y3e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function y3e(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:s,className:a,style:o,title:l,desc:c}=t,d=v3e(t,b3e),h=s||{width:r,height:i,x:0,y:0},g=An("recharts-surface",a);return E.createElement("svg",Uk({},Cs(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),E.createElement("title",null,l),E.createElement("desc",null,c),n)}),_3e=["children","className"];function Fk(){return Fk=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},Fk.apply(null,arguments)}function S3e(t,e){if(t==null)return{};var n,r,i=w3e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function w3e(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 jr=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=S3e(t,_3e),s=An("recharts-layer",r);return E.createElement("g",Fk({className:s},Cs(i),{ref:e}),n)}),hK=E.createContext(null),M3e=()=>E.useContext(hK);function Jn(t){return function(){return t}}const pK=Math.cos,dS=Math.sin,Lo=Math.sqrt,fS=Math.PI,Gw=2*fS,zk=Math.PI,Bk=2*zk,qd=1e-6,E3e=Bk-qd;function mK(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function A3e(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return mK;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class T3e{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?mK:A3e(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,s,a){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-e,c=i-n,d=a-e,h=o-n,g=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>qd)if(!(Math.abs(h*l-c*d)>qd)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,v=i-o,y=l*l+c*c,b=m*m+v*v,x=Math.sqrt(y),M=Math.sqrt(g),w=s*Math.tan((zk-Math.acos((y+g-b)/(2*x*M)))/2),A=w/M,T=w/x;Math.abs(A-1)>qd&&this._append`L${e+A*d},${n+A*h}`,this._append`A${s},${s},0,0,${+(h*m>d*v)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,r,i,s,a){if(e=+e,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),c=e+o,d=n+l,h=1^a,g=a?i-s:s-i;this._x1===null?this._append`M${c},${d}`:(Math.abs(this._x1-c)>qd||Math.abs(this._y1-d)>qd)&&this._append`L${c},${d}`,r&&(g<0&&(g=g%Bk+Bk),g>E3e?this._append`A${r},${r},0,1,${h},${e-o},${n-l}A${r},${r},0,1,${h},${this._x1=c},${this._y1=d}`:g>qd&&this._append`A${r},${r},0,${+(g>=zk)},${h},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}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 jD(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 T3e(e)}function ID(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function gK(t){this._context=t}gK.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 Ww(t){return new gK(t)}function xK(t){return t[0]}function bK(t){return t[1]}function vK(t,e){var n=Jn(!0),r=null,i=Ww,s=null,a=jD(o);t=typeof t=="function"?t:t===void 0?xK:Jn(t),e=typeof e=="function"?e:e===void 0?bK:Jn(e);function o(l){var c,d=(l=ID(l)).length,h,g=!1,m;for(r==null&&(s=i(m=a())),c=0;c<=d;++c)!(c<d&&n(h=l[c],c,l))===g&&((g=!g)?s.lineStart():s.lineEnd()),g&&s.point(+t(h,c,l),+e(h,c,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Jn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Jn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Jn(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function i_(t,e,n){var r=null,i=Jn(!0),s=null,a=Ww,o=null,l=jD(c);t=typeof t=="function"?t:t===void 0?xK:Jn(+t),e=typeof e=="function"?e:Jn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?bK:Jn(+n);function c(h){var g,m,v,y=(h=ID(h)).length,b,x=!1,M,w=new Array(y),A=new Array(y);for(s==null&&(o=a(M=l())),g=0;g<=y;++g){if(!(g<y&&i(b=h[g],g,h))===x)if(x=!x)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),v=g-1;v>=m;--v)o.point(w[v],A[v]);o.lineEnd(),o.areaEnd()}x&&(w[g]=+t(b,g,h),A[g]=+e(b,g,h),o.point(r?+r(b,g,h):w[g],n?+n(b,g,h):A[g]))}if(M)return o=null,M+""||null}function d(){return vK().defined(i).curve(a).context(s)}return c.x=function(h){return arguments.length?(t=typeof h=="function"?h:Jn(+h),r=null,c):t},c.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Jn(+h),c):t},c.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Jn(+h),c):r},c.y=function(h){return arguments.length?(e=typeof h=="function"?h:Jn(+h),n=null,c):e},c.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Jn(+h),c):e},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Jn(+h),c):n},c.lineX0=c.lineY0=function(){return d().x(t).y(e)},c.lineY1=function(){return d().x(t).y(n)},c.lineX1=function(){return d().x(r).y(e)},c.defined=function(h){return arguments.length?(i=typeof h=="function"?h:Jn(!!h),c):i},c.curve=function(h){return arguments.length?(a=h,s!=null&&(o=a(s)),c):a},c.context=function(h){return arguments.length?(h==null?s=o=null:o=a(s=h),c):s},c}class yK{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 C3e(t){return new yK(t,!0)}function N3e(t){return new yK(t,!1)}const UD={draw(t,e){const n=Lo(e/fS);t.moveTo(n,0),t.arc(0,0,n,0,Gw)}},k3e={draw(t,e){const n=Lo(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()}},_K=Lo(1/3),R3e=_K*2,P3e={draw(t,e){const n=Lo(e/R3e),r=n*_K;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},D3e={draw(t,e){const n=Lo(e),r=-n/2;t.rect(r,r,n,n)}},O3e=.8908130915292852,SK=dS(fS/10)/dS(7*fS/10),L3e=dS(Gw/10)*SK,j3e=-pK(Gw/10)*SK,I3e={draw(t,e){const n=Lo(e*O3e),r=L3e*n,i=j3e*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const a=Gw*s/5,o=pK(a),l=dS(a);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},JT=Lo(3),U3e={draw(t,e){const n=-Lo(e/(JT*3));t.moveTo(0,n*2),t.lineTo(-JT*n,-n),t.lineTo(JT*n,-n),t.closePath()}},Da=-.5,Oa=Lo(3)/2,Hk=1/Lo(12),F3e=(Hk/2+1)*3,z3e={draw(t,e){const n=Lo(e/F3e),r=n/2,i=n*Hk,s=r,a=n*Hk+n,o=-s,l=a;t.moveTo(r,i),t.lineTo(s,a),t.lineTo(o,l),t.lineTo(Da*r-Oa*i,Oa*r+Da*i),t.lineTo(Da*s-Oa*a,Oa*s+Da*a),t.lineTo(Da*o-Oa*l,Oa*o+Da*l),t.lineTo(Da*r+Oa*i,Da*i-Oa*r),t.lineTo(Da*s+Oa*a,Da*a-Oa*s),t.lineTo(Da*o+Oa*l,Da*l-Oa*o),t.closePath()}};function B3e(t,e){let n=null,r=jD(i);t=typeof t=="function"?t:Jn(t||UD),e=typeof e=="function"?e:Jn(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:Jn(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:Jn(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function hS(){}function pS(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 wK(t){this._context=t}wK.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:pS(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:pS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function H3e(t){return new wK(t)}function MK(t){this._context=t}MK.prototype={areaStart:hS,areaEnd:hS,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:pS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function $3e(t){return new MK(t)}function EK(t){this._context=t}EK.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:pS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function V3e(t){return new EK(t)}function AK(t){this._context=t}AK.prototype={areaStart:hS,areaEnd:hS,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 G3e(t){return new AK(t)}function c8(t){return t<0?-1:1}function u8(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(c8(s)+c8(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function d8(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function eC(t,e,n){var r=t._x0,i=t._y0,s=t._x1,a=t._y1,o=(s-r)/3;t._context.bezierCurveTo(r+o,i+o*e,s-o,a-o*n,s,a)}function mS(t){this._context=t}mS.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:eC(this,this._t0,d8(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,eC(this,d8(this,n=u8(this,t,e)),n);break;default:eC(this,this._t0,n=u8(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function TK(t){this._context=new CK(t)}(TK.prototype=Object.create(mS.prototype)).point=function(t,e){mS.prototype.point.call(this,e,t)};function CK(t){this._context=t}CK.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,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function W3e(t){return new mS(t)}function q3e(t){return new TK(t)}function NK(t){this._context=t}NK.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=f8(t),i=f8(e),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[a],e[a]);(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 f8(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,a[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,a[e]-=r*a[e-1];for(i[n-1]=a[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(a[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function X3e(t){return new NK(t)}function qw(t,e){this._context=t,this._t=e}qw.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 K3e(t){return new qw(t,.5)}function Y3e(t){return new qw(t,0)}function Z3e(t){return new qw(t,1)}function bm(t,e){if((a=t.length)>1)for(var n=1,r,i,s=t[e[0]],a,o=s.length;n<a;++n)for(i=s,s=t[e[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function $k(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Q3e(t,e){return t[e]}function J3e(t){const e=[];return e.key=t,e}function eke(){var t=Jn([]),e=$k,n=bm,r=Q3e;function i(s){var a=Array.from(t.apply(this,arguments),J3e),o,l=a.length,c=-1,d;for(const h of s)for(o=0,++c;o<l;++o)(a[o][c]=[0,+r(h,a[o].key,c,s)]).data=h;for(o=0,d=ID(e(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:Jn(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Jn(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?$k:typeof s=="function"?s:Jn(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??bm,i):n},i}function tke(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=t[n][i][1]||0;if(a)for(n=0;n<r;++n)t[n][i][1]/=a}bm(t,e)}}function nke(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=t[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}bm(t,e)}}function rke(t,e){if(!(!((a=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,c=0;o<a;++o){for(var d=t[e[o]],h=d[r][1]||0,g=d[r-1][1]||0,m=(h-g)/2,v=0;v<o;++v){var y=t[e[v]],b=y[r][1]||0,x=y[r-1][1]||0;m+=b-x}l+=h,c+=m*h}i[r-1][1]+=i[r-1][0]=n,l&&(n-=c/l)}i[r-1][1]+=i[r-1][0]=n,bm(t,e)}}var tC={},nC={},h8;function ike(){return h8||(h8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(nC)),nC}var rC={},p8;function kK(){return p8||(p8=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})(rC)),rC}var iC={},m8;function FD(){return m8||(m8=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})(iC)),iC}var sC={},aC={},g8;function ske(){return g8||(g8=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})(aC)),aC}var x8;function zD(){return x8||(x8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ske(),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 s=[],a=i.length;if(a===0)return s;let o=0,l="",c="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),o++);o<a;){const h=i[o];c?h==="\\"&&o+1<a?(o++,l+=i[o]):h===c?c="":l+=h:d?h==='"'||h==="'"?c=h:h==="]"?(d=!1,s.push(l),l=""):l+=h:h==="["?(d=!0,l&&(s.push(l),l="")):h==="."?l&&(s.push(l),l=""):l+=h,o++}return l&&s.push(l),s}t.toPath=r})(sC)),sC}var b8;function BD(){return b8||(b8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ike(),n=kK(),r=FD(),i=zD();function s(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const d=o[l];return d===void 0?n.isDeepKey(l)?s(o,i.toPath(l),c):c:d}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const d=o[l];return d===void 0?c:d}default:{if(Array.isArray(l))return a(o,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return c;const d=o[l];return d===void 0?c:d}}}function a(o,l,c){if(l.length===0)return c;let d=o;for(let h=0;h<l.length;h++){if(d==null||e.isUnsafeProperty(l[h]))return c;d=d[l[h]]}return d===void 0?c:d}t.get=s})(tC)),tC}var oC,v8;function ake(){return v8||(v8=1,oC=BD().get),oC}var oke=ake();const Wf=ro(oke);var ki=t=>t===0?0:t>0?1:-1,eo=t=>typeof t=="number"&&t!=+t,Sc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Tt=t=>(typeof t=="number"||t instanceof Number)&&!eo(t),ul=t=>Tt(t)||typeof t=="string",lke=0,N0=t=>{var e=++lke;return"".concat(t||"").concat(e)},us=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(!Tt(e)&&typeof e!="string")return r;var s;if(Sc(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return eo(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},RK=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 lr(t,e,n){return Tt(t)&&Tt(e)?t+n*(e-t):e}function PK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Wf(r,e))===n)}var vr=t=>t===null||typeof t>"u",ab=t=>vr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function cke(t){return t!=null}function ob(){}var uke=["type","size","sizeType"];function Vk(){return Vk=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},Vk.apply(null,arguments)}function y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y8(Object(n),!0).forEach(function(r){dke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dke(t,e,n){return(e=fke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fke(t){var e=hke(t,"string");return typeof e=="symbol"?e:e+""}function hke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 pke(t,e){if(t==null)return{};var n,r,i=mke(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function mke(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 DK={symbolCircle:UD,symbolCross:k3e,symbolDiamond:P3e,symbolSquare:D3e,symbolStar:I3e,symbolTriangle:U3e,symbolWye:z3e},gke=Math.PI/180,xke=t=>{var e="symbol".concat(ab(t));return DK[e]||UD},bke=(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*gke;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}},vke=(t,e)=>{DK["symbol".concat(ab(t))]=e},HD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=pke(t,uke),s=_8(_8({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=xke(a),m=B3e().type(g).size(bke(n,r,a)),v=m();if(v!==null)return v},{className:l,cx:c,cy:d}=s,h=Cs(s);return Tt(c)&&Tt(d)&&Tt(n)?E.createElement("path",Vk({},h,{className:An("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(d,")"),d:o()})):null};HD.registerSymbol=vke;var OK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,$D=(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]=(s=>n[i](n,s)))}),r},yke=(t,e,n)=>r=>(t(e,n,r),null),lb=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];OD(i)&&typeof s=="function"&&(r||(r={}),r[i]=yke(s,e,n))}),r};function S8(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 _ke(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S8(Object(n),!0).forEach(function(r){Ske(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S8(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)}function ei(t,e){var n=_ke({},t),r=e,i=Object.keys(e),s=i.reduce((a,o)=>(a[o]===void 0&&r[o]!==void 0&&(a[o]=r[o]),a),n);return s}function gS(){return gS=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},gS.apply(null,arguments)}function w8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Eke(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w8(Object(n),!0).forEach(function(r){Ake(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ake(t,e,n){return(e=Tke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tke(t){var e=Cke(t,"string");return typeof e=="symbol"?e:e+""}function Cke(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 Ia=32,Nke={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function kke(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Ia/2,s=Ia/6,a=Ia/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:Ia,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(a,`
  8192. A`).concat(s,",").concat(s,",0,1,1,").concat(2*a,",").concat(i,`
  8193. H`).concat(Ia,"M").concat(2*a,",").concat(i,`
  8194. A`).concat(s,",").concat(s,",0,1,1,").concat(a,",").concat(i),className:"recharts-legend-icon"});if(l==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Ia/8,"h").concat(Ia,"v").concat(Ia*3/4,"h").concat(-Ia,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var d=Eke({},e);return delete d.legendIcon,E.cloneElement(e.legendIcon,d)}return E.createElement(HD,{fill:o,cx:i,cy:i,size:Ia,sizeType:"diameter",type:l})}function Rke(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Ia,height:Ia},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,h)=>{var g=d.formatter||i,m=An({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:d.inactive});if(d.type==="none")return null;var v=d.inactive?s:d.color,y=g?g(d.value,d,h):d.value;return E.createElement("li",gS({className:m,style:l,key:"legend-item-".concat(h)},lb(t,d,h)),E.createElement(LD,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(y," legend icon")},E.createElement(kke,{data:d,iconType:a,inactiveColor:s})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:v}},y))})}var Pke=t=>{var e=ei(t,Nke),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return E.createElement("ul",{className:"recharts-default-legend",style:s},E.createElement(Rke,gS({},e,{payload:n})))},lC={},cC={},M8;function Dke(){return M8||(M8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const a=n[s],o=r(a);i.has(o)||i.set(o,a)}return Array.from(i.values())}t.uniqBy=e})(cC)),cC}var uC={},E8;function LK(){return E8||(E8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(uC)),uC}var dC={},fC={},hC={},A8;function Oke(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(hC)),hC}var T8;function VD(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oke();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(fC)),fC}var pC={},C8;function Lke(){return C8||(C8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(pC)),pC}var N8;function jke(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VD(),n=Lke();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(dC)),dC}var mC={},gC={},k8;function Ike(){return k8||(k8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=BD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(gC)),gC}var xC={},bC={},vC={},yC={},R8;function jK(){return R8||(R8=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})(yC)),yC}var _C={},P8;function IK(){return P8||(P8=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})(_C)),_C}var SC={},D8;function UK(){return D8||(D8=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})(SC)),SC}var O8;function Uke(){return O8||(O8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jK(),n=IK(),r=UK();function i(d,h,g){return typeof g!="function"?i(d,h,()=>{}):s(d,h,function m(v,y,b,x,M,w){const A=g(v,y,b,x,M,w);return A!==void 0?!!A:s(v,y,m,w)},new Map)}function s(d,h,g,m){if(h===d)return!0;switch(typeof h){case"object":return a(d,h,g,m);case"function":return Object.keys(h).length>0?s(d,{...h},g,m):r.eq(d,h);default:return e.isObject(d)?typeof h=="string"?h==="":!0:r.eq(d,h)}}function a(d,h,g,m){if(h==null)return!0;if(Array.isArray(h))return l(d,h,g,m);if(h instanceof Map)return o(d,h,g,m);if(h instanceof Set)return c(d,h,g,m);const v=Object.keys(h);if(d==null)return v.length===0;if(v.length===0)return!0;if(m?.has(h))return m.get(h)===d;m?.set(h,d);try{for(let y=0;y<v.length;y++){const b=v[y];if(!n.isPrimitive(d)&&!(b in d)||h[b]===void 0&&d[b]!==void 0||h[b]===null&&d[b]!==null||!g(d[b],h[b],b,d,h,m))return!1}return!0}finally{m?.delete(h)}}function o(d,h,g,m){if(h.size===0)return!0;if(!(d instanceof Map))return!1;for(const[v,y]of h.entries()){const b=d.get(v);if(g(b,y,v,d,h,m)===!1)return!1}return!0}function l(d,h,g,m){if(h.length===0)return!0;if(!Array.isArray(d))return!1;const v=new Set;for(let y=0;y<h.length;y++){const b=h[y];let x=!1;for(let M=0;M<d.length;M++){if(v.has(M))continue;const w=d[M];let A=!1;if(g(w,b,y,d,h,m)&&(A=!0),A){v.add(M),x=!0;break}}if(!x)return!1}return!0}function c(d,h,g,m){return h.size===0?!0:d instanceof Set?l([...d],[...h],g,m):!1}t.isMatchWith=i,t.isSetMatch=c})(vC)),vC}var L8;function FK(){return L8||(L8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uke();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(bC)),bC}var wC={},MC={},EC={},j8;function Fke(){return j8||(j8=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})(EC)),EC}var AC={},I8;function zK(){return I8||(I8=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})(AC)),AC}var TC={},U8;function BK(){return U8||(U8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",a="[object Symbol]",o="[object Date]",l="[object Map]",c="[object Set]",d="[object Array]",h="[object Function]",g="[object ArrayBuffer]",m="[object Object]",v="[object Error]",y="[object DataView]",b="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",R="[object Int16Array]",C="[object Int32Array]",I="[object BigInt64Array]",N="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=I,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=v,t.float32ArrayTag=N,t.float64ArrayTag=D,t.functionTag=h,t.int16ArrayTag=R,t.int32ArrayTag=C,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=a,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=x})(TC)),TC}var CC={},F8;function zke(){return F8||(F8=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 z8;function HK(){return z8||(z8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fke(),n=zK(),r=BK(),i=IK(),s=zke();function a(d,h){return o(d,void 0,d,new Map,h)}function o(d,h,g,m=new Map,v=void 0){const y=v?.(d,h,g,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const b=new Array(d.length);m.set(d,b);for(let x=0;x<d.length;x++)b[x]=o(d[x],x,g,m,v);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;m.set(d,b);for(const[x,M]of d)b.set(x,o(M,x,g,m,v));return b}if(d instanceof Set){const b=new Set;m.set(d,b);for(const x of d)b.add(o(x,void 0,g,m,v));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,b);for(let x=0;x<d.length;x++)b[x]=o(d[x],x,g,m,v);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,b),l(b,d,g,m,v),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return m.set(d,b),l(b,d,g,m,v),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return m.set(d,b),l(b,d,g,m,v),b}if(d instanceof Error){const b=new d.constructor;return m.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,l(b,d,g,m,v),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return m.set(d,b),l(b,d,g,m,v),b}if(d instanceof Number){const b=new Number(d.valueOf());return m.set(d,b),l(b,d,g,m,v),b}if(d instanceof String){const b=new String(d.valueOf());return m.set(d,b),l(b,d,g,m,v),b}if(typeof d=="object"&&c(d)){const b=Object.create(Object.getPrototypeOf(d));return m.set(d,b),l(b,d,g,m,v),b}return d}function l(d,h,g=d,m,v){const y=[...Object.keys(h),...e.getSymbols(h)];for(let b=0;b<y.length;b++){const x=y[b],M=Object.getOwnPropertyDescriptor(d,x);(M==null||M.writable)&&(d[x]=o(h[x],x,g,m,v))}}function c(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=a,t.cloneDeepWithImpl=o,t.copyProperties=l})(MC)),MC}var B8;function Bke(){return B8||(B8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(wC)),wC}var H8;function Hke(){return H8||(H8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FK(),n=Bke();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(xC)),xC}var NC={},kC={},RC={},$8;function $ke(){return $8||($8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HK(),n=BK();function r(i,s){return e.cloneDeepWith(i,(a,o,l,c)=>{const d=s?.(a,o,l,c);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(RC)),RC}var V8;function Vke(){return V8||(V8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$ke();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(kC)),kC}var PC={},DC={},G8;function $K(){return G8||(G8=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})(DC)),DC}var OC={},W8;function Gke(){return W8||(W8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(OC)),OC}var q8;function Wke(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kK(),n=$K(),r=Gke(),i=zD();function s(a,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&a?.[o]==null?l=i.toPath(o):l=[o],l.length===0)return!1;let c=a;for(let d=0;d<l.length;d++){const h=l[d];if((c==null||!Object.hasOwn(c,h))&&!((Array.isArray(c)||r.isArguments(c))&&n.isIndex(h)&&h<c.length))return!1;c=c[h]}return!0}t.has=s})(PC)),PC}var X8;function qke(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FK(),n=FD(),r=Vke(),i=BD(),s=Wke();function a(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 d=i.get(c,o);return d===void 0?s.has(c,o):l===void 0?d===void 0:e.isMatch(d,l)}}t.matchesProperty=a})(NC)),NC}var K8;function Xke(){return K8||(K8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LK(),n=Ike(),r=Hke(),i=qke();function s(a){if(a==null)return e.identity;switch(typeof a){case"function":return a;case"object":return Array.isArray(a)&&a.length===2?i.matchesProperty(a[0],a[1]):r.matches(a);case"string":case"symbol":case"number":return n.property(a)}}t.iteratee=s})(mC)),mC}var Y8;function Kke(){return Y8||(Y8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dke(),n=LK(),r=jke(),i=Xke();function s(a,o=n.identity){return r.isArrayLikeObject(a)?e.uniqBy(Array.from(a),i.iteratee(o)):[]}t.uniqBy=s})(lC)),lC}var LC,Z8;function Yke(){return Z8||(Z8=1,LC=Kke().uniqBy),LC}var Zke=Yke();const Q8=ro(Zke);function VK(t,e,n){return e===!0?Q8(t,n):typeof e=="function"?Q8(t,e):t}var GD=E.createContext(null),Qke=t=>t,nr=()=>{var t=E.useContext(GD);return t?t.store.dispatch:Qke},H_=()=>{},Jke=()=>H_,eRe=(t,e)=>t===e;function Ct(t){var e=E.useContext(GD);return iX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Jke,e?e.store.getState:H_,e?e.store.getState:H_,e?t:H_,eRe)}function tRe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function nRe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function rRe(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 J8=t=>Array.isArray(t)?t:[t];function iRe(t){const e=Array.isArray(t[0])?t[0]:t;return rRe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function sRe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var aRe=class{constructor(t){this.value=t}deref(){return this.value}},oRe=typeof WeakRef<"u"?WeakRef:aRe,lRe=0,eH=1;function s_(){return{s:lRe,v:void 0,o:null,p:null}}function GK(t,e={}){let n=s_();const{resultEqualityCheck:r}=e;let i,s=0;function a(){let o=n;const{length:l}=arguments;for(let h=0,g=l;h<g;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let v=o.o;v===null&&(o.o=v=new WeakMap);const y=v.get(m);y===void 0?(o=s_(),v.set(m,o)):o=y}else{let v=o.p;v===null&&(o.p=v=new Map);const y=v.get(m);y===void 0?(o=s_(),v.set(m,o)):o=y}}const c=o;let d;if(o.s===eH)d=o.v;else if(d=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,d)&&(d=h,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new oRe(d):d}return c.s=eH,c.v=d,d}return a.clearCache=()=>{n=s_(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function cRe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,a=0,o,l={},c=i.pop();typeof c=="object"&&(l=c,c=i.pop()),tRe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const d={...n,...l},{memoize:h,memoizeOptions:g=[],argsMemoize:m=GK,argsMemoizeOptions:v=[]}=d,y=J8(g),b=J8(v),x=iRe(i),M=h(function(){return s++,c.apply(null,arguments)},...y),w=m(function(){a++;const T=sRe(x,arguments);return o=M.apply(null,T),o},...b);return Object.assign(w,{resultFunc:c,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var We=cRe(GK),uRe=Object.assign((t,e=We)=>{nRe(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(s=>t[s]);return e(r,(...s)=>s.reduce((a,o,l)=>(a[n[l]]=o,a),{}))},{withTypes:()=>uRe}),jC={},IC={},UC={},tH;function dRe(){return tH||(tH=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,s)=>{if(r!==i){const a=e(r),o=e(i);if(a===o&&a===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?o-a:a-o}return 0};t.compareValues=n})(UC)),UC}var FC={},zC={},nH;function WK(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(zC)),zC}var rH;function fRe(){return rH||(rH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||a!=null&&Object.hasOwn(a,s)}t.isKey=i})(FC)),FC}var iH;function hRe(){return iH||(iH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dRe(),n=fRe(),r=zD();function i(s,a,o,l){if(s==null)return[];o=l?void 0:o,Array.isArray(s)||(s=Object.values(s)),Array.isArray(a)||(a=a==null?[null]:[a]),a.length===0&&(a=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const c=(m,v)=>{let y=m;for(let b=0;b<v.length&&y!=null;++b)y=y[v[b]];return y},d=(m,v)=>v==null||m==null?v:typeof m=="object"&&"key"in m?Object.hasOwn(v,m.key)?v[m.key]:c(v,m.path):typeof m=="function"?m(v):Array.isArray(m)?c(v,m):typeof v=="object"?v[m]:v,h=a.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 s.map(m=>({original:m,criteria:h.map(v=>d(v,m))})).slice().sort((m,v)=>{for(let y=0;y<h.length;y++){const b=e.compareValues(m.criteria[y],v.criteria[y],o[y]);if(b!==0)return b}return 0}).map(m=>m.original)}t.orderBy=i})(IC)),IC}var BC={},sH;function pRe(){return sH||(sH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),a=(o,l)=>{for(let c=0;c<o.length;c++){const d=o[c];Array.isArray(d)&&l<s?a(d,l+1):i.push(d)}};return a(n,0),i}t.flatten=e})(BC)),BC}var HC={},aH;function qK(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$K(),n=VD(),r=jK(),i=UK();function s(a,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],a):!1}t.isIterateeCall=s})(HC)),HC}var oH;function mRe(){return oH||(oH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hRe(),n=pRe(),r=qK();function i(s,...a){const o=a.length;return o>1&&r.isIterateeCall(s,a[0],a[1])?a=[]:o>2&&r.isIterateeCall(a[0],a[1],a[2])&&(a=[a[0]]),e.orderBy(s,n.flatten(a),["asc"])}t.sortBy=i})(jC)),jC}var $C,lH;function gRe(){return lH||(lH=1,$C=mRe().sortBy),$C}var xRe=gRe();const Xw=ro(xRe);var XK=t=>t.legend.settings,bRe=t=>t.legend.size,vRe=t=>t.legend.payload,yRe=We([vRe,XK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Xw(r,n):r});function _Re(){return Ct(yRe)}var a_=1;function KK(){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 s=i.getBoundingClientRect(),a={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(a.height-e.height)>a_||Math.abs(a.left-e.left)>a_||Math.abs(a.top-e.top)>a_||Math.abs(a.width-e.width)>a_)&&n({height:a.height,left:a.left,top:a.top,width:a.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Vi(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 SRe=typeof Symbol=="function"&&Symbol.observable||"@@observable",cH=SRe,VC=()=>Math.random().toString(36).substring(7).split("").join("."),wRe={INIT:`@@redux/INIT${VC()}`,REPLACE:`@@redux/REPLACE${VC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${VC()}`},xS=wRe;function WD(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 YK(t,e,n){if(typeof t!="function")throw new Error(Vi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Vi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Vi(1));return n(YK)(t,e)}let r=t,i=e,s=new Map,a=s,o=0,l=!1;function c(){a===s&&(a=new Map,s.forEach((b,x)=>{a.set(x,b)}))}function d(){if(l)throw new Error(Vi(3));return i}function h(b){if(typeof b!="function")throw new Error(Vi(4));if(l)throw new Error(Vi(5));let x=!0;c();const M=o++;return a.set(M,b),function(){if(x){if(l)throw new Error(Vi(6));x=!1,c(),a.delete(M),s=null}}}function g(b){if(!WD(b))throw new Error(Vi(7));if(typeof b.type>"u")throw new Error(Vi(8));if(typeof b.type!="string")throw new Error(Vi(17));if(l)throw new Error(Vi(9));try{l=!0,i=r(i,b)}finally{l=!1}return(s=a).forEach(M=>{M()}),b}function m(b){if(typeof b!="function")throw new Error(Vi(10));r=b,g({type:xS.REPLACE})}function v(){const b=h;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(Vi(11));function M(){const A=x;A.next&&A.next(d())}return M(),{unsubscribe:b(M)}},[cH](){return this}}}return g({type:xS.INIT}),{dispatch:g,subscribe:h,getState:d,replaceReducer:m,[cH]:v}}function MRe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:xS.INIT})>"u")throw new Error(Vi(12));if(typeof n(void 0,{type:xS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Vi(13))})}function ZK(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const a=e[s];typeof t[a]=="function"&&(n[a]=t[a])}const r=Object.keys(n);let i;try{MRe(n)}catch(s){i=s}return function(a={},o){if(i)throw i;let l=!1;const c={};for(let d=0;d<r.length;d++){const h=r[d],g=n[h],m=a[h],v=g(m,o);if(typeof v>"u")throw o&&o.type,new Error(Vi(14));c[h]=v,l=l||v!==m}return l=l||r.length!==Object.keys(a).length,l?c:a}}function bS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function ERe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Vi(15))};const a={getState:i.getState,dispatch:(l,...c)=>s(l,...c)},o=t.map(l=>l(a));return s=bS(...o)(i.dispatch),{...i,dispatch:s}}}function QK(t){return WD(t)&&"type"in t&&typeof t.type=="string"}var JK=Symbol.for("immer-nothing"),uH=Symbol.for("immer-draftable"),Ns=Symbol.for("immer-state");function yo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var pa=Object,vm=pa.getPrototypeOf,vS="constructor",Kw="prototype",Gk="configurable",yS="enumerable",$_="writable",k0="value",wc=t=>!!t&&!!t[Ns];function Po(t){return t?eY(t)||Yw(t)||!!t[uH]||!!t[vS]?.[uH]||Zw(t)||Qw(t):!1}var ARe=pa[Kw][vS].toString(),dH=new WeakMap;function eY(t){if(!t||!qD(t))return!1;const e=vm(t);if(e===null||e===pa[Kw])return!0;const n=pa.hasOwnProperty.call(e,vS)&&e[vS];if(n===Object)return!0;if(!Np(n))return!1;let r=dH.get(n);return r===void 0&&(r=Function.toString.call(n),dH.set(n,r)),r===ARe}function cb(t,e,n=!0){ub(t)===0?(n?Reflect.ownKeys(t):pa.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function ub(t){const e=t[Ns];return e?e.type_:Yw(t)?1:Zw(t)?2:Qw(t)?3:0}var fH=(t,e,n=ub(t))=>n===2?t.has(e):pa[Kw].hasOwnProperty.call(t,e),Wk=(t,e,n=ub(t))=>n===2?t.get(e):t[e],_S=(t,e,n,r=ub(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function TRe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Yw=Array.isArray,Zw=t=>t instanceof Map,Qw=t=>t instanceof Set,qD=t=>typeof t=="object",Np=t=>typeof t=="function",GC=t=>typeof t=="boolean",Ql=t=>t.copy_||t.base_,XD=t=>t.modified_?t.copy_:t.base_;function qk(t,e){if(Zw(t))return new Map(t);if(Qw(t))return new Set(t);if(Yw(t))return Array[Kw].slice.call(t);const n=eY(t);if(e===!0||e==="class_only"&&!n){const r=pa.getOwnPropertyDescriptors(t);delete r[Ns];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o[$_]===!1&&(o[$_]=!0,o[Gk]=!0),(o.get||o.set)&&(r[a]={[Gk]:!0,[$_]:!0,[yS]:o[yS],[k0]:t[a]})}return pa.create(vm(t),r)}else{const r=vm(t);if(r!==null&&n)return{...t};const i=pa.create(r);return pa.assign(i,t)}}function KD(t,e=!1){return Jw(t)||wc(t)||!Po(t)||(ub(t)>1&&pa.defineProperties(t,{set:o_,add:o_,clear:o_,delete:o_}),pa.freeze(t),e&&cb(t,(n,r)=>{KD(r,!0)},!1)),t}function CRe(){yo(2)}var o_={[k0]:CRe};function Jw(t){return t===null||!qD(t)?!0:pa.isFrozen(t)}var SS="MapSet",Xk="Patches",tY={};function ym(t){const e=tY[t];return e||yo(0,t),e}var NRe=t=>!!tY[t],R0,nY=()=>R0,kRe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:NRe(SS)?ym(SS):void 0});function hH(t,e){e&&(t.patchPlugin_=ym(Xk),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Kk(t){Yk(t),t.drafts_.forEach(RRe),t.drafts_=null}function Yk(t){t===R0&&(R0=t.parent_)}var pH=t=>R0=kRe(R0,t);function RRe(t){const e=t[Ns];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function mH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ns].modified_&&(Kk(e),yo(4)),Po(t)&&(t=gH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ns].base_,t,e)}else t=gH(e,n);return PRe(e,t,!0),Kk(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==JK?t:void 0}function gH(t,e){if(Jw(e))return e;const n=e[Ns];if(!n)return YD(e,t.handledSet_,t);if(!eM(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);sY(n,t)}return n.copy_}function PRe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&KD(e,n)}function rY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var eM=(t,e)=>t.scope_===e,DRe=[];function iY(t,e,n,r){const i=Ql(t),s=t.type_;if(r!==void 0&&Wk(i,r,s)===e){_S(i,r,n,s);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;cb(i,(l,c)=>{if(wc(c)){const d=o.get(c)||[];d.push(l),o.set(c,d)}})}const a=t.draftLocations_.get(e)??DRe;for(const o of a)_S(i,o,n,s)}function ORe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!eM(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const a=XD(s);iY(t,s.draft_??s,a,n),sY(s,i)})}function sY(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)}rY(t)}}function LRe(t,e,n){const{scope_:r}=t;if(wc(n)){const i=n[Ns];eM(i,r)&&i.callbacks_.push(function(){V_(t);const a=XD(i);iY(t,n,a,e)})}else Po(n)&&t.callbacks_.push(function(){const s=Ql(t);Wk(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&YD(Wk(t.copy_,e,t.type_),r.handledSet_,r)})}function YD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||wc(t)||e.has(t)||!Po(t)||Jw(t)||(e.add(t),cb(t,(r,i)=>{if(wc(i)){const s=i[Ns];if(eM(s,n)){const a=XD(s);_S(t,r,a,t.type_),rY(s)}}else Po(i)&&YD(i,e,n)})),t}function jRe(t,e){const n=Yw(t),r={type_:n?1:0,scope_:e?e.scope_:nY(),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,s=ZD;n&&(i=[r],s=P0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,[o,r]}var ZD={get(t,e){if(e===Ns)return t;const n=Ql(t);if(!fH(n,e,t.type_))return IRe(t,n,e);const r=n[e];if(t.finalized_||!Po(r))return r;if(r===WC(t.base_,e)){V_(t);const i=t.type_===1?+e:e,s=Qk(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in Ql(t)},ownKeys(t){return Reflect.ownKeys(Ql(t))},set(t,e,n){const r=aY(Ql(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=WC(Ql(t),e),s=i?.[Ns];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(TRe(n,i)&&(n!==void 0||fH(t.base_,e,t.type_)))return!0;V_(t),Zk(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),LRe(t,e,n)),!0},deleteProperty(t,e){return V_(t),WC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Zk(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ql(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[$_]:!0,[Gk]:t.type_!==1||e!=="length",[yS]:r[yS],[k0]:n[e]}},defineProperty(){yo(11)},getPrototypeOf(t){return vm(t.base_)},setPrototypeOf(){yo(12)}},P0={};cb(ZD,(t,e)=>{P0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});P0.deleteProperty=function(t,e){return P0.set.call(this,t,e,void 0)};P0.set=function(t,e,n){return ZD.set.call(this,t[0],e,n,t[0])};function WC(t,e){const n=t[Ns];return(n?Ql(n):t)[e]}function IRe(t,e,n){const r=aY(e,n);return r?k0 in r?r[k0]:r.get?.call(t.draft_):void 0}function aY(t,e){if(!(e in t))return;let n=vm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=vm(n)}}function Zk(t){t.modified_||(t.modified_=!0,t.parent_&&Zk(t.parent_))}function V_(t){t.copy_||(t.assigned_=new Map,t.copy_=qk(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var URe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Np(n)&&!Np(r)){const a=r;r=n;const o=this;return function(c=a,...d){return o.produce(c,h=>r.call(this,h,...d))}}Np(r)||yo(6),i!==void 0&&!Np(i)&&yo(7);let s;if(Po(n)){const a=pH(this),o=Qk(a,n,void 0);let l=!0;try{s=r(o),l=!1}finally{l?Kk(a):Yk(a)}return hH(a,i),mH(s,a)}else if(!n||!qD(n)){if(s=r(n),s===void 0&&(s=n),s===JK&&(s=void 0),this.autoFreeze_&&KD(s,!0),i){const a=[],o=[];ym(Xk).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else yo(1,n)},this.produceWithPatches=(n,r)=>{if(Np(n))return(o,...l)=>this.produceWithPatches(o,c=>n(c,...l));let i,s;return[this.produce(n,r,(o,l)=>{i=o,s=l}),i,s]},GC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),GC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),GC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Po(e)||yo(8),wc(e)&&(e=To(e));const n=pH(this),r=Qk(n,e,void 0);return r[Ns].isManual_=!0,Yk(n),r}finishDraft(e,n){const r=e&&e[Ns];(!r||!r.isManual_)&&yo(9);const{scope_:i}=r;return hH(i,n),mH(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 s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=ym(Xk).applyPatches_;return wc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function Qk(t,e,n,r){const[i,s]=Zw(e)?ym(SS).proxyMap_(e,n):Qw(e)?ym(SS).proxySet_(e,n):jRe(e,n);return(n?.scope_??nY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?ORe(n,s,r):s.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:c}=l;s.modified_&&c&&c.generatePatches_(s,[],l)}),i}function To(t){return wc(t)||yo(10,t),oY(t)}function oY(t){if(!Po(t)||Jw(t))return t;const e=t[Ns];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=qk(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=qk(t,!0);return cb(n,(i,s)=>{_S(n,i,oY(s))},r),e&&(e.finalized_=!1),n}var FRe=new URe,lY=FRe.produce;function cY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var zRe=cY(),BRe=cY,HRe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?bS:bS.apply(null,arguments)};function to(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(ba(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=>QK(r)&&r.type===t,n}var uY=class wx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,wx.prototype)}static get[Symbol.species](){return wx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new wx(...e[0].concat(this)):new wx(...e.concat(this))}};function xH(t){return Po(t)?lY(t,()=>{}):t}function l_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function $Re(t){return typeof t=="boolean"}var VRe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new uY;return n&&($Re(n)?a.push(zRe):a.push(BRe(n.extraArgument))),a},dY="RTK_autoBatch",dr=()=>t=>({payload:t,meta:{[dY]:!0}}),bH=t=>e=>{setTimeout(e,t)},fY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,a=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:bH(10):t.type==="callback"?t.queueNotification:bH(t.timeout),c=()=>{a=!1,s&&(s=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const h=()=>i&&d(),g=r.subscribe(h);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[dY],s=!i,s&&(a||(a=!0,l(c))),r.dispatch(d)}finally{i=!0}}})},GRe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new uY(t);return r&&i.push(fY(typeof r=="object"?r:void 0)),i};function WRe(t){const e=VRe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:a=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(WD(n))o=ZK(n);else throw new Error(ba(1));let l;typeof r=="function"?l=r(e):l=e();let c=bS;i&&(c=HRe({trace:!1,...typeof i=="object"&&i}));const d=ERe(...l),h=GRe(d);let g=typeof a=="function"?a(h):h();const m=c(...g);return YK(o,s,m)}function hY(t){const e={},n=[];let r;const i={addCase(s,a){const o=typeof s=="string"?s:s.type;if(!o)throw new Error(ba(28));if(o in e)throw new Error(ba(29));return e[o]=a,i},addAsyncThunk(s,a){return a.pending&&(e[s.pending.type]=a.pending),a.rejected&&(e[s.rejected.type]=a.rejected),a.fulfilled&&(e[s.fulfilled.type]=a.fulfilled),a.settled&&n.push({matcher:s.settled,reducer:a.settled}),i},addMatcher(s,a){return n.push({matcher:s,reducer:a}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function qRe(t){return typeof t=="function"}function XRe(t,e){let[n,r,i]=hY(e),s;if(qRe(t))s=()=>xH(t());else{const o=xH(t);s=()=>o}function a(o=s(),l){let c=[n[l.type],...r.filter(({matcher:d})=>d(l)).map(({reducer:d})=>d)];return c.filter(d=>!!d).length===0&&(c=[i]),c.reduce((d,h)=>{if(h)if(wc(d)){const m=h(d,l);return m===void 0?d:m}else{if(Po(d))return lY(d,g=>h(g,l));{const g=h(d,l);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return a.getInitialState=s,a}var KRe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",YRe=(t=21)=>{let e="",n=t;for(;n--;)e+=KRe[Math.random()*64|0];return e},ZRe=Symbol.for("rtk-slice-createasyncthunk");function QRe(t,e){return`${t}/${e}`}function JRe({creators:t}={}){const e=t?.asyncThunk?.[ZRe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(ba(11));const a=(typeof r.reducers=="function"?r.reducers(tPe()):r.reducers)||{},o=Object.keys(a),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,A){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(ba(12));if(T in l.sliceCaseReducersByType)throw new Error(ba(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=a[w],T={reducerName:w,type:QRe(i,w),createNotation:typeof r.reducers=="function"};rPe(A)?sPe(T,A,c,e):nPe(T,A,c)});function d(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?hY(r.extraReducers):[r.extraReducers],R={...w,...l.sliceCaseReducersByType};return XRe(r.initialState,C=>{for(let I in R)C.addCase(I,R[I]);for(let I of l.sliceMatchers)C.addMatcher(I.matcher,I.reducer);for(let I of A)C.addMatcher(I.matcher,I.reducer);T&&C.addDefaultCase(T)})}const h=w=>w,g=new Map,m=new WeakMap;let v;function y(w,A){return v||(v=d()),v(w,A)}function b(){return v||(v=d()),v.getInitialState()}function x(w,A=!1){function T(C){let I=C[w];return typeof I>"u"&&A&&(I=l_(m,T,b)),I}function R(C=h){const I=l_(g,A,()=>new WeakMap);return l_(I,C,()=>{const N={};for(const[D,z]of Object.entries(r.selectors??{}))N[D]=ePe(z,C,()=>l_(m,C,b),A);return N})}return{reducerPath:w,getSelectors:R,get selectors(){return R(T)},selectSlice:T}}const M={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:b,...x(s),injectInto(w,{reducerPath:A,...T}={}){const R=A??s;return w.inject({reducerPath:R,reducer:y},T),{...M,...x(R,!0)}}};return M}}function ePe(t,e,n,r){function i(s,...a){let o=e(s);return typeof o>"u"&&r&&(o=n()),t(o,...a)}return i.unwrapped=t,i}var Zs=JRe();function tPe(){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 nPe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!iPe(r))throw new Error(ba(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?to(t,a):to(t))}function rPe(t){return t._reducerDefinitionType==="asyncThunk"}function iPe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function sPe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(ba(18));const{payloadCreator:s,fulfilled:a,pending:o,rejected:l,settled:c,options:d}=n,h=i(t,s,d);r.exposeAction(e,h),a&&r.addCase(h.fulfilled,a),o&&r.addCase(h.pending,o),l&&r.addCase(h.rejected,l),c&&r.addMatcher(h.settled,c),r.exposeCaseReducer(e,{fulfilled:a||c_,pending:o||c_,rejected:l||c_,settled:c||c_})}function c_(){}var aPe="task",pY="listener",mY="completed",QD="cancelled",oPe=`task-${QD}`,lPe=`task-${mY}`,Jk=`${pY}-${QD}`,cPe=`${pY}-${mY}`,tM=class{constructor(t){this.code=t,this.message=`${aPe} ${QD} (reason: ${t})`}name="TaskAbortError";message},JD=(t,e)=>{if(typeof t!="function")throw new TypeError(ba(32))},wS=()=>{},gY=(t,e=wS)=>(t.catch(e),t),xY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),_f=(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))},Sf=t=>{if(t.aborted){const{reason:e}=t;throw new tM(e)}};function bY(t,e){let n=wS;return new Promise((r,i)=>{const s=()=>i(new tM(t.reason));if(t.aborted){s();return}n=xY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=wS})}var uPe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof tM?"cancelled":"rejected",error:n}}finally{e?.()}},MS=t=>e=>gY(bY(t,e).then(n=>(Sf(t),n))),vY=t=>{const e=MS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:qp}=Object,vH={},nM="listenerMiddleware",dPe=(t,e)=>{const n=r=>xY(t,()=>_f(r,t.reason));return(r,i)=>{JD(r);const s=new AbortController;n(s);const a=uPe(async()=>{Sf(t),Sf(s.signal);const o=await r({pause:MS(s.signal),delay:vY(s.signal),signal:s.signal});return Sf(s.signal),o},()=>_f(s,lPe));return i?.autoJoin&&e.push(a.catch(wS)),{result:MS(t)(a),cancel(){_f(s,oPe)}}}},fPe=(t,e)=>{const n=async(r,i)=>{Sf(e);let s=()=>{};const o=[new Promise((l,c)=>{let d=t({predicate:r,effect:(h,g)=>{g.unsubscribe(),l([h,g.getState(),g.getOriginalState()])}});s=()=>{d(),c()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await bY(e,Promise.race(o));return Sf(e),l}finally{s()}};return(r,i)=>gY(n(r,i))},yY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=to(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ba(21));return JD(s),{predicate:i,type:e,effect:s}},_Y=qp(t=>{const{type:e,predicate:n,effect:r}=yY(t);return{id:YRe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ba(22))}}},{withTypes:()=>_Y}),yH=(t,e)=>{const{type:n,effect:r,predicate:i}=yY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},eR=t=>{t.pending.forEach(e=>{_f(e,Jk)})},hPe=(t,e)=>()=>{for(const n of e.keys())eR(n);t.clear()},_H=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},SY=qp(to(`${nM}/add`),{withTypes:()=>SY}),pPe=to(`${nM}/removeAll`),wY=qp(to(`${nM}/remove`),{withTypes:()=>wY}),mPe=(...t)=>{console.error(`${nM}/error`,...t)},db=(t={})=>{const e=new Map,n=new Map,r=m=>{const v=n.get(m)??0;n.set(m,v+1)},i=m=>{const v=n.get(m)??1;v===1?n.delete(m):n.set(m,v-1)},{extra:s,onError:a=mPe}=t;JD(a);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),v=>{m.unsubscribe(),v?.cancelActive&&eR(m)}),l=m=>{const v=yH(e,m)??_Y(m);return o(v)};qp(l,{withTypes:()=>l});const c=m=>{const v=yH(e,m);return v&&(v.unsubscribe(),m.cancelActive&&eR(v)),!!v};qp(c,{withTypes:()=>c});const d=async(m,v,y,b)=>{const x=new AbortController,M=fPe(l,x.signal),w=[];try{m.pending.add(x),r(m),await Promise.resolve(m.effect(v,qp({},y,{getOriginalState:b,condition:(A,T)=>M(A,T).then(Boolean),take:M,delay:vY(x.signal),pause:MS(x.signal),extra:s,signal:x.signal,fork:dPe(x.signal,w),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,R)=>{A!==x&&(_f(A,Jk),R.delete(A))})},cancel:()=>{_f(x,Jk),m.pending.delete(x)},throwIfCancelled:()=>{Sf(x.signal)}})))}catch(A){A instanceof tM||_H(a,A,{raisedBy:"effect"})}finally{await Promise.all(w),_f(x,cPe),i(m),m.pending.delete(x)}},h=hPe(e,n);return{middleware:m=>v=>y=>{if(!QK(y))return v(y);if(SY.match(y))return l(y.payload);if(pPe.match(y)){h();return}if(wY.match(y))return c(y.payload);let b=m.getState();const x=()=>{if(b===vH)throw new Error(ba(23));return b};let M;try{if(M=v(y),e.size>0){const w=m.getState(),A=Array.from(e.values());for(const T of A){let R=!1;try{R=T.predicate(y,w,b)}catch(C){R=!1,_H(a,C,{raisedBy:"predicate"})}R&&d(T,y,m,x)}}}finally{b=vH}return M},startListening:l,stopListening:c,clearListeners:h}};function ba(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 gPe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},MY=Zs({name:"chartLayout",initialState:gPe,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,s;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=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:xPe,setLayout:bPe,setChartSize:vPe,setScale:yPe}=MY.actions,_Pe=MY.reducer;function EY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function SH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SH(Object(n),!0).forEach(function(r){SPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SPe(t,e,n){return(e=wPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wPe(t){var e=MPe(t,"string");return typeof e=="symbol"?e:e+""}function MPe(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 vr(t)||vr(e)?n:ul(e)?Wf(t,e,n):typeof e=="function"?e(t):n}var EPe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:a,layout:o}=e;if((o==="vertical"||o==="horizontal"&&a==="middle")&&s!=="center"&&Tt(t[s]))return Dp(Dp({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Tt(t[a]))return Dp(Dp({},t),{},{[a]:t[a]+(i||0)})}return t},kc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",AY=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,s,a=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(s=!0),o.coordinate));return i||a.push(e),s||a.push(n),a},TY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:a,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:d,ticks:h,niceTicks:g,axisType:m}=t;if(!a)return null;var v=o==="scaleBand"&&a.bandwidth?a.bandwidth()/2:2,y=i==="category"&&a.bandwidth?a.bandwidth()/v:0;if(y=m==="angleAxis"&&s&&s.length>=2?ki(s[0]-s[1])*2*y:y,h||g){var b=(h||g||[]).map((x,M)=>{var w=r?r.indexOf(x):x;return{coordinate:a(w)+y,value:x,offset:y,index:M}});return b.filter(x=>!eo(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:a(x)+y,value:x,index:M,offset:y})):a.ticks&&d!=null?a.ticks(d).map((x,M)=>({coordinate:a(x)+y,value:x,offset:y,index:M})):a.domain().map((x,M)=>({coordinate:a(x)+y,value:r?r[x]:x,index:M,offset:y}))},wH=1e-4,APe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-wH,s=Math.max(r[0],r[1])+wH,a=t(e[0]),o=t(e[n-1]);(a<i||a>s||o<i||o>s)&&t.domain([e[0],e[n-1]])}},TPe=(t,e)=>{if(!e||e.length!==2||!Tt(e[0])||!Tt(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(!Tt(t[0])||t[0]<n)&&(i[0]=n),(!Tt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},CPe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,a=0;a<e;++a){var o=eo(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=s,t[a][n][1]=s+o,s=t[a][n][1])}},NPe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var a=eo(t[s][n][1])?t[s][n][0]:t[s][n][1];a>=0?(t[s][n][0]=i,t[s][n][1]=i+a,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},kPe={sign:CPe,expand:tke,none:bm,silhouette:nke,wiggle:rke,positive:NPe},RPe=(t,e,n)=>{var r=kPe[n],i=eke().keys(e).value((s,a)=>Number(Yn(s,a,0))).order($k).offset(r);return i(t)};function CY(t){return t==null?void 0:String(t)}function MH(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:a}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!vr(i[e.dataKey])){var o=PK(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var l=Yn(i,vr(a)?e.dataKey:a);return vr(l)?null:e.scale(l)}var EH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:a}=t;if(e.type==="category")return n[a]?n[a].coordinate+r:null;var o=Yn(s,e.dataKey,e.scale.domain()[a]);return vr(o)?null:e.scale(o)-i/2+r},PPe=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]},DPe=t=>{var e=t.flat(2).filter(Tt);return[Math.min(...e),Math.max(...e)]},OPe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],LPe=(t,e,n)=>{if(t!=null)return OPe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:a}=s,o=a.reduce((l,c)=>{var d=EY(c,e,n),h=DPe(d);return[Math.min(l[0],h[0]),Math.max(l[1],h[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},AH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,TH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_m=(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=Xw(e,d=>d.coordinate),s=1/0,a=1,o=i.length;a<o;a++){var l=i[a],c=i[a-1];s=Math.min((l.coordinate||0)-(c.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function CH(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Dp(Dp({},e),{},{dataKey:n,payload:r,value:i,name:s})}function Bm(t,e){if(t)return String(t);if(typeof e=="string")return e}var jPe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},IPe=(t,e)=>e==="centric"?t.angle:t.radius,Rc=t=>t.layout.width,Pc=t=>t.layout.height,UPe=t=>t.layout.scale,NY=t=>t.layout.margin,rM=We(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),iM=We(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),kY="data-recharts-item-index",RY="data-recharts-item-data-key",fb=60;function NH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NH(Object(n),!0).forEach(function(r){FPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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)}var HPe=t=>t.brush.height;function $Pe(t){var e=iM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:fb;return n+i}return n},0)}function VPe(t){var e=iM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:fb;return n+i}return n},0)}function GPe(t){var e=rM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function WPe(t){var e=rM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var pi=We([Rc,Pc,NY,HPe,$Pe,VPe,GPe,WPe,XK,bRe],(t,e,n,r,i,s,a,o,l,c)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+a,bottom:(n.bottom||0)+o},g=u_(u_({},h),d),m=g.bottom;g.bottom+=r,g=EPe(g,l,c);var v=t-g.left-g.right,y=e-g.top-g.bottom;return u_(u_({brushBottom:m},g),{},{width:Math.max(v,0),height:Math.max(y,0)})}),qPe=We(pi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),eO=We(Rc,Pc,(t,e)=>({x:0,y:0,width:t,height:e})),XPe=E.createContext(null),hs=()=>E.useContext(XPe)!=null,sM=t=>t.brush,aM=We([sM,pi,NY],(t,e,n)=>({height:t.height,x:Tt(t.x)?t.x:e.left,y:Tt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Tt(t.width)?t.width:e.width})),qC={},XC={},KC={},kH;function KPe(){return kH||(kH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let a,o=null;const l=s!=null&&s.includes("leading"),c=s==null||s.includes("trailing"),d=()=>{o!==null&&(n.apply(a,o),a=void 0,o=null)},h=()=>{c&&d(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,h()},r)},v=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{v(),a=void 0,o=null},b=()=>{d()},x=function(...M){if(i?.aborted)return;a=this,o=M;const w=g==null;m(),l&&w&&d()};return x.schedule=m,x.cancel=y,x.flush=b,i?.addEventListener("abort",y,{once:!0}),x}t.debounce=e})(KC)),KC}var RH;function YPe(){return RH||(RH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KPe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:a=!1,trailing:o=!0,maxWait:l}=s,c=Array(2);a&&(c[0]="leading"),o&&(c[1]="trailing");let d,h=null;const g=e.debounce(function(...y){d=r.apply(this,y),h=null},i,{edges:c}),m=function(...y){return l!=null&&(h===null&&(h=Date.now()),Date.now()-h>=l)?(d=r.apply(this,y),h=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},v=()=>(g.flush(),d);return m.cancel=g.cancel,m.flush=v,m}t.debounce=n})(XC)),XC}var PH;function ZPe(){return PH||(PH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YPe();function n(r,i=0,s={}){const{leading:a=!0,trailing:o=!0}=s;return e.debounce(r,i,{leading:a,maxWait:i,trailing:o})}t.throttle=n})(qC)),qC}var YC,DH;function QPe(){return DH||(DH=1,YC=ZPe().throttle),YC}var JPe=QPe();const eDe=ro(JPe);var ES=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];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 a=0;console.warn(n.replace(/%s/g,()=>i[a++]))}},PY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:a}=n,o=Sc(r)?t:Number(r),l=Sc(i)?e:Number(i);return s&&s>0&&(o?l=o/s:l&&(o=l*s),a&&l!=null&&l>a&&(l=a)),{calculatedWidth:o,calculatedHeight:l}},tDe={width:0,height:0,overflow:"visible"},nDe={width:0,overflowX:"visible"},rDe={height:0,overflowY:"visible"},iDe={},sDe=t=>{var{width:e,height:n}=t,r=Sc(e),i=Sc(n);return r&&i?tDe:r?nDe:i?rDe:iDe};function aDe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function cr(t){return Number.isFinite(t)}function dl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function tR(){return tR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tR.apply(null,arguments)}function OH(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 LH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OH(Object(n),!0).forEach(function(r){oDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oDe(t,e,n){return(e=lDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lDe(t){var e=cDe(t,"string");return typeof e=="symbol"?e:e+""}function cDe(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 DY=E.createContext({width:-1,height:-1});function uDe(t){return dl(t.width)&&dl(t.height)}function OY(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return uDe(i)?E.createElement(DY.Provider,{value:i},e):null}var tO=()=>E.useContext(DY),dDe=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:a=0,minHeight:o,maxHeight:l,children:c,debounce:d=0,id:h,className:g,onResize:m,style:v={}}=t,y=E.useRef(null),b=E.useRef();b.current=m,E.useImperativeHandle(e,()=>y.current);var[x,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),w=E.useCallback((I,N)=>{M(D=>{var z=Math.round(I),j=Math.round(N);return D.containerWidth===z&&D.containerHeight===j?D:{containerWidth:z,containerHeight:j}})},[]);E.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return ob;var I=j=>{var W,{width:P,height:$}=j[0].contentRect;w(P,$),(W=b.current)===null||W===void 0||W.call(b,P,$)};d>0&&(I=eDe(I,d,{trailing:!0,leading:!1}));var N=new ResizeObserver(I),{width:D,height:z}=y.current.getBoundingClientRect();return w(D,z),N.observe(y.current),()=>{N.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:T}=x;ES(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:R,calculatedHeight:C}=PY(A,T,{width:i,height:s,aspect:n,maxHeight:l});return ES(R!=null&&R>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8195. please check the style of container, or the props width(%s) and height(%s),
  8196. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8197. height and width.`,R,C,i,s,a,o,n),E.createElement("div",{id:h?"".concat(h):void 0,className:An("recharts-responsive-container",g),style:LH(LH({},v),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:l}),ref:y},E.createElement("div",{style:sDe({width:i,height:s})},E.createElement(OY,{width:R,height:C},c)))}),ZC=E.forwardRef((t,e)=>{var n=tO();if(dl(n.width)&&dl(n.height))return t.children;var{width:r,height:i}=aDe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:a}=PY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Tt(s)&&Tt(a)?E.createElement(OY,{width:s,height:a},t.children):E.createElement(dDe,tR({},t,{width:r,height:i,ref:e}))});function LY(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 oM=()=>{var t,e=hs(),n=Ct(qPe),r=Ct(aM),i=(t=Ct(sM))===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}},fDe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},jY=()=>{var t;return(t=Ct(pi))!==null&&t!==void 0?t:fDe},nO=()=>Ct(Rc),rO=()=>Ct(Pc),hDe=()=>Ct(t=>t.layout.margin),Sn=t=>t.layout.layoutType,Hm=()=>Ct(Sn),pDe=()=>{var t=Hm();if(t==="horizontal"||t==="vertical")return t},mDe=()=>{var t=Hm();return t!==void 0},lM=t=>{var e=nr(),n=hs(),{width:r,height:i}=t,s=tO(),a=r,o=i;return s&&(a=s.width>0?s.width:r,o=s.height>0?s.height:i),E.useEffect(()=>{!n&&dl(a)&&dl(o)&&e(vPe({width:a,height:o}))},[e,n,a,o]),null},IY=Symbol.for("immer-nothing"),jH=Symbol.for("immer-draftable"),_a=Symbol.for("immer-state");function _o(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var D0=Object.getPrototypeOf;function Sm(t){return!!t&&!!t[_a]}function qf(t){return t?UY(t)||Array.isArray(t)||!!t[jH]||!!t.constructor?.[jH]||hb(t)||uM(t):!1}var gDe=Object.prototype.constructor.toString(),IH=new WeakMap;function UY(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=IH.get(n);return r===void 0&&(r=Function.toString.call(n),IH.set(n,r)),r===gDe}function AS(t,e,n=!0){cM(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 cM(t){const e=t[_a];return e?e.type_:Array.isArray(t)?1:hb(t)?2:uM(t)?3:0}function nR(t,e){return cM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function FY(t,e,n){const r=cM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function xDe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function hb(t){return t instanceof Map}function uM(t){return t instanceof Set}function Xd(t){return t.copy_||t.base_}function rR(t,e){if(hb(t))return new Map(t);if(uM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=UY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[_a];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(D0(t),r)}else{const r=D0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function iO(t,e=!1){return dM(t)||Sm(t)||!qf(t)||(cM(t)>1&&Object.defineProperties(t,{set:d_,add:d_,clear:d_,delete:d_}),Object.freeze(t),e&&Object.values(t).forEach(n=>iO(n,!0))),t}function bDe(){_o(2)}var d_={value:bDe};function dM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var vDe={};function Xf(t){const e=vDe[t];return e||_o(0,t),e}var O0;function zY(){return O0}function yDe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function UH(t,e){e&&(Xf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function iR(t){sR(t),t.drafts_.forEach(_De),t.drafts_=null}function sR(t){t===O0&&(O0=t.parent_)}function FH(t){return O0=yDe(O0,t)}function _De(t){const e=t[_a];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function zH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[_a].modified_&&(iR(e),_o(4)),qf(t)&&(t=TS(e,t),e.parent_||CS(e,t)),e.patches_&&Xf("Patches").generateReplacementPatches_(n[_a].base_,t,e.patches_,e.inversePatches_)):t=TS(e,n,[]),iR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==IY?t:void 0}function TS(t,e,n){if(dM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[_a];if(!i)return AS(e,(s,a)=>BH(t,i,e,s,a,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return CS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let a=s,o=!1;i.type_===3&&(a=new Set(s),s.clear(),o=!0),AS(a,(l,c)=>BH(t,i,s,l,c,n,o),r),CS(t,s,!1),n&&t.patches_&&Xf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function BH(t,e,n,r,i,s,a){if(i==null||typeof i!="object"&&!a)return;const o=dM(i);if(!(o&&!a)){if(Sm(i)){const l=s&&e&&e.type_!==3&&!nR(e.assigned_,r)?s.concat(r):void 0,c=TS(t,i,l);if(FY(n,r,c),Sm(c))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if(qf(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;TS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(hb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&CS(t,i)}}}function CS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&iO(e,n)}function SDe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:zY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=sO;n&&(i=[r],s=L0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var sO={get(t,e){if(e===_a)return t;const n=Xd(t);if(!nR(n,e))return wDe(t,n,e);const r=n[e];return t.finalized_||!qf(r)?r:r===QC(t.base_,e)?(JC(t),t.copy_[e]=oR(r,t)):r},has(t,e){return e in Xd(t)},ownKeys(t){return Reflect.ownKeys(Xd(t))},set(t,e,n){const r=BY(Xd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=QC(Xd(t),e),s=i?.[_a];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(xDe(n,i)&&(n!==void 0||nR(t.base_,e)))return!0;JC(t),aR(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 QC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,JC(t),aR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Xd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){_o(11)},getPrototypeOf(t){return D0(t.base_)},setPrototypeOf(){_o(12)}},L0={};AS(sO,(t,e)=>{L0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});L0.deleteProperty=function(t,e){return L0.set.call(this,t,e,void 0)};L0.set=function(t,e,n){return sO.set.call(this,t[0],e,n,t[0])};function QC(t,e){const n=t[_a];return(n?Xd(n):t)[e]}function wDe(t,e,n){const r=BY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function BY(t,e){if(!(e in t))return;let n=D0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=D0(n)}}function aR(t){t.modified_||(t.modified_=!0,t.parent_&&aR(t.parent_))}function JC(t){t.copy_||(t.copy_=rR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var MDe=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 s=n;n=e;const a=this;return function(l=s,...c){return a.produce(l,d=>n.call(this,d,...c))}}typeof n!="function"&&_o(6),r!==void 0&&typeof r!="function"&&_o(7);let i;if(qf(e)){const s=FH(this),a=oR(e,void 0);let o=!0;try{i=n(a),o=!1}finally{o?iR(s):sR(s)}return UH(s,r),zH(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===IY&&(i=void 0),this.autoFreeze_&&iO(i,!0),r){const s=[],a=[];Xf("Patches").generateReplacementPatches_(e,i,s,a),r(s,a)}return i}else _o(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let r,i;return[this.produce(e,n,(a,o)=>{r=a,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){qf(t)||_o(8),Sm(t)&&(t=EDe(t));const e=FH(this),n=oR(t,void 0);return n[_a].isManual_=!0,sR(e),n}finishDraft(t,e){const n=t&&t[_a];(!n||!n.isManual_)&&_o(9);const{scope_:r}=n;return UH(r,e),zH(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=Xf("Patches").applyPatches_;return Sm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function oR(t,e){const n=hb(t)?Xf("MapSet").proxyMap_(t,e):uM(t)?Xf("MapSet").proxySet_(t,e):SDe(t,e);return(e?e.scope_:zY()).drafts_.push(n),n}function EDe(t){return Sm(t)||_o(10,t),HY(t)}function HY(t){if(!qf(t)||dM(t))return t;const e=t[_a];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=rR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=rR(t,!0);return AS(n,(i,s)=>{FY(n,i,HY(s))},r),e&&(e.finalized_=!1),n}var ADe=new MDe;ADe.produce;var TDe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},$Y=Zs({name:"legend",initialState:TDe,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:dr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:dr()},removeLegendPayload:{reducer(t,e){var n=To(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:dr()}}}),{setLegendSize:HH,setLegendSettings:CDe,addLegendPayload:VY,replaceLegendPayload:GY,removeLegendPayload:WY}=$Y.actions,NDe=$Y.reducer,kDe=["contextPayload"];function lR(){return lR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},lR.apply(null,arguments)}function $H(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 wm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$H(Object(n),!0).forEach(function(r){RDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RDe(t,e,n){return(e=PDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PDe(t){var e=DDe(t,"string");return typeof e=="symbol"?e:e+""}function DDe(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 ODe(t,e){if(t==null)return{};var n,r,i=LDe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function LDe(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 jDe(t){return t.value}function IDe(t){var{contextPayload:e}=t,n=ODe(t,kDe),r=VK(e,t.payloadUniqBy,jDe),i=wm(wm({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(Pke,i)}function UDe(t,e,n,r,i,s){var{layout:a,align:o,verticalAlign:l}=e,c,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&a==="vertical"?c={left:((r||0)-s.width)/2}:c=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?d={top:((i||0)-s.height)/2}:d=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),wm(wm({},c),d)}function FDe(t){var e=nr();return E.useEffect(()=>{e(CDe(t))},[e,t]),null}function zDe(t){var e=nr();return E.useEffect(()=>(e(HH(t)),()=>{e(HH({width:0,height:0}))}),[e,t]),null}function BDe(t,e,n,r){return t==="vertical"&&Tt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var HDe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function qY(t){var e=ei(t,HDe),n=_Re(),r=M3e(),i=hDe(),{width:s,height:a,wrapperStyle:o,portal:l}=e,[c,d]=KK([n]),h=nO(),g=rO();if(h==null||g==null)return null;var m=h-(i?.left||0)-(i?.right||0),v=BDe(e.layout,a,s,m),y=l?o:wm(wm({position:"absolute",width:v?.width||s||"auto",height:v?.height||a||"auto"},UDe(o,e,i,h,g,c)),o),b=l??r;if(b==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},E.createElement(FDe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&E.createElement(zDe,{width:c.width,height:c.height}),E.createElement(IDe,lR({},e,v,{margin:i,chartWidth:h,chartHeight:g,contextPayload:n})));return nc.createPortal(x,b)}qY.displayName="Legend";function cR(){return cR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},cR.apply(null,arguments)}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 eN(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){$De(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 $De(t,e,n){return(e=VDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VDe(t){var e=GDe(t,"string");return typeof e=="symbol"?e:e+""}function GDe(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 WDe(t){return Array.isArray(t)&&ul(t[0])&&ul(t[1])?t.join(" ~ "):t}var qDe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:a,itemSorter:o,wrapperClassName:l,labelClassName:c,label:d,labelFormatter:h,accessibilityLayer:g=!1}=t,m=()=>{if(s&&s.length){var T={padding:0,margin:0},R=(o?Xw(s,o):s).map((C,I)=>{if(C.type==="none")return null;var N=C.formatter||a||WDe,{value:D,name:z}=C,j=D,W=z;if(N){var P=N(D,z,C,I,s);if(Array.isArray(P))[j,W]=P;else if(P!=null)j=P;else return null}var $=eN({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(I),style:$},ul(W)?E.createElement("span",{className:"recharts-tooltip-item-name"},W):null,ul(W)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},j),E.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:T},R)}return null},v=eN({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=eN({margin:0},i),b=!vr(d),x=b?d:"",M=An("recharts-default-tooltip",l),w=An("recharts-tooltip-label",c);b&&h&&s!==void 0&&s!==null&&(x=h(d,s));var A=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",cR({className:M,style:v},A),E.createElement("p",{className:w,style:y},E.isValidElement(x)?x:"".concat(x)),m())},ox="recharts-tooltip-wrapper",XDe={visibility:"hidden"};function KDe(t){var{coordinate:e,translateX:n,translateY:r}=t;return An(ox,{["".concat(ox,"-right")]:Tt(n)&&e&&Tt(e.x)&&n>=e.x,["".concat(ox,"-left")]:Tt(n)&&e&&Tt(e.x)&&n<e.x,["".concat(ox,"-bottom")]:Tt(r)&&e&&Tt(e.y)&&r>=e.y,["".concat(ox,"-top")]:Tt(r)&&e&&Tt(e.y)&&r<e.y})}function GH(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:a,tooltipDimension:o,viewBox:l,viewBoxDimension:c}=t;if(s&&Tt(s[r]))return s[r];var d=n[r]-o-(i>0?i:0),h=n[r]+i;if(e[r])return a[r]?d:h;var g=l[r];if(g==null)return 0;if(a[r]){var m=d,v=g;return m<v?Math.max(h,g):Math.max(d,g)}if(c==null)return 0;var y=h+o,b=g+c;return y>b?Math.max(d,g):Math.max(h,g)}function YDe(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 ZDe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:a,useTranslate3d:o,viewBox:l}=t,c,d,h;return a.height>0&&a.width>0&&n?(d=GH({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.width,viewBox:l,viewBoxDimension:l.width}),h=GH({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.height,viewBox:l,viewBoxDimension:l.height}),c=YDe({translateX:d,translateY:h,useTranslate3d:o})):c=XDe,{cssProperties:c,cssClasses:KDe({translateX:d,translateY:h,coordinate:n})}}function WH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function f_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WH(Object(n),!0).forEach(function(r){uR(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uR(t,e,n){return(e=QDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QDe(t){var e=JDe(t,"string");return typeof e=="symbol"?e:e+""}function JDe(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 eOe extends E.PureComponent{constructor(){super(...arguments),uR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),uR(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;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=(s=this.props.coordinate)===null||s===void 0?void 0:s.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:s,coordinate:a,hasPayload:o,isAnimationActive:l,offset:c,position:d,reverseDirection:h,useTranslate3d:g,viewBox:m,wrapperStyle:v,lastBoundingBox:y,innerRef:b,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=ZDe({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:c,position:d,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=x?{}:f_(f_({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=f_(f_({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},v);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:b},s)}}var XY=()=>{var t;return(t=Ct(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function dR(){return dR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},dR.apply(null,arguments)}function qH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qH(Object(n),!0).forEach(function(r){tOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tOe(t,e,n){return(e=nOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nOe(t){var e=rOe(t,"string");return typeof e=="symbol"?e:e+""}function rOe(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 KH={curveBasisClosed:$3e,curveBasisOpen:V3e,curveBasis:H3e,curveBumpX:C3e,curveBumpY:N3e,curveLinearClosed:G3e,curveLinear:Ww,curveMonotoneX:W3e,curveMonotoneY:q3e,curveNatural:X3e,curveStep:K3e,curveStepAfter:Z3e,curveStepBefore:Y3e},NS=t=>cr(t.x)&&cr(t.y),YH=t=>t.base!=null&&NS(t.base)&&NS(t),lx=t=>t.x,cx=t=>t.y,iOe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(ab(t));return(n==="curveMonotone"||n==="curveBump")&&e?KH["".concat(n).concat(e==="vertical"?"Y":"X")]:KH[n]||Ww},sOe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=iOe(e,i),o=s?n.filter(NS):n,l;if(Array.isArray(r)){var c=n.map((m,v)=>XH(XH({},m),{},{base:r[v]}));i==="vertical"?l=i_().y(cx).x1(lx).x0(m=>m.base.x):l=i_().x(lx).y1(cx).y0(m=>m.base.y);var d=l.defined(YH).curve(a),h=s?c.filter(YH):c;return d(h)}i==="vertical"&&Tt(r)?l=i_().y(cx).x1(lx).x0(r):Tt(r)?l=i_().x(lx).y1(cx).y0(r):l=vK().x(lx).y(cx);var g=l.defined(NS).curve(a);return g(o)},Xp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?sOe(t):r;return E.createElement("path",dR({},Xs(t),$D(t),{className:An("recharts-curve",e),d:s===null?void 0:s,ref:i}))},aOe=["x","y","top","left","width","height","className"];function fR(){return fR=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},fR.apply(null,arguments)}function ZH(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 oOe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZH(Object(n),!0).forEach(function(r){lOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lOe(t,e,n){return(e=cOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cOe(t){var e=uOe(t,"string");return typeof e=="symbol"?e:e+""}function uOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 dOe(t,e){if(t==null)return{};var n,r,i=fOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fOe(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 hOe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),pOe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,l=dOe(t,aOe),c=oOe({x:e,y:n,top:r,left:i,width:s,height:a},l);return!Tt(e)||!Tt(n)||!Tt(s)||!Tt(a)||!Tt(r)||!Tt(i)?null:E.createElement("path",fR({},Cs(c),{className:An("recharts-cross",o),d:hOe(e,n,s,a,r,i)}))};function mOe(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 QH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function JH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QH(Object(n),!0).forEach(function(r){gOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gOe(t,e,n){return(e=xOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xOe(t){var e=bOe(t,"string");return typeof e=="symbol"?e:e+""}function bOe(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 vOe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),KY=(t,e,n)=>t.map(r=>"".concat(vOe(r)," ").concat(e,"ms ").concat(n)).join(","),yOe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),j0=(t,e)=>Object.keys(e).reduce((n,r)=>JH(JH({},n),{},{[r]:t(r,e[r])}),{});function e$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function si(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e$(Object(n),!0).forEach(function(r){_Oe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Oe(t,e,n){return(e=SOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SOe(t){var e=wOe(t,"string");return typeof e=="symbol"?e:e+""}function wOe(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 kS=(t,e,n)=>t+(e-t)*n,hR=t=>{var{from:e,to:n}=t;return e!==n},YY=(t,e,n)=>{var r=j0((i,s)=>{if(hR(s)){var[a,o]=t(s.from,s.to,s.velocity);return si(si({},s),{},{from:a,velocity:o})}return s},e);return n<1?j0((i,s)=>hR(s)?si(si({},s),{},{velocity:kS(s.velocity,r[i].velocity,n),from:kS(s.from,r[i].from,n)}):s,e):YY(t,r,n-1)};function MOe(t,e,n,r,i,s){var a,o=r.reduce((g,m)=>si(si({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>j0((g,m)=>m.from,o),c=()=>!Object.values(o).filter(hR).length,d=null,h=g=>{a||(a=g);var m=g-a,v=m/n.dt;o=YY(n,o,v),i(si(si(si({},t),e),l())),a=g,c()||(d=s.setTimeout(h))};return()=>(d=s.setTimeout(h),()=>{var g;(g=d)===null||g===void 0||g()})}function EOe(t,e,n,r,i,s,a){var o=null,l=i.reduce((h,g)=>si(si({},h),{},{[g]:[t[g],e[g]]}),{}),c,d=h=>{c||(c=h);var g=(h-c)/r,m=j0((y,b)=>kS(...b,n(g)),l);if(s(si(si(si({},t),e),m)),g<1)o=a.setTimeout(d);else{var v=j0((y,b)=>kS(...b,n(1)),l);s(si(si(si({},t),e),v))}};return()=>(o=a.setTimeout(d),()=>{var h;(h=o)===null||h===void 0||h()})}const AOe=(t,e,n,r,i,s)=>{var a=yOe(t,e);return n==null?()=>(i(si(si({},t),e)),()=>{}):n.isStepper===!0?MOe(t,e,n,a,i,s):EOe(t,e,n,r,a,i,s)};var RS=1e-4,ZY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],QY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),t$=(t,e)=>n=>{var r=ZY(t,e);return QY(r,n)},TOe=(t,e)=>n=>{var r=ZY(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return QY(i,n)},COe=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,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var a=s[1].split(")")[0].split(",").map(o=>parseFloat(o));return[a[0],a[1],a[2],a[3]]}}}return n.length===4?n:[0,0,1,1]},NOe=(t,e,n,r)=>{var i=t$(t,n),s=t$(e,r),a=TOe(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var d=c>1?1:c,h=d,g=0;g<8;++g){var m=i(h)-d,v=a(h);if(Math.abs(m-d)<RS||v<RS)return s(h);h=o(h-m/v)}return s(h)};return l.isStepper=!1,l},n$=function(){return NOe(...COe(...arguments))},kOe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(a,o,l)=>{var c=-(a-o)*n,d=l*r,h=l+(c-d)*i/1e3,g=l*i/1e3+a;return Math.abs(g-o)<RS&&Math.abs(h)<RS?[o,0]:[g,h]};return s.isStepper=!0,s.dt=i,s},ROe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return n$(t);case"spring":return kOe();default:if(t.split("(")[0]==="cubic-bezier")return n$(t)}return typeof t=="function"?t:null};function POe(t){var e,n=()=>null,r=!1,i=null,s=a=>{if(!r){if(Array.isArray(a)){if(!a.length)return;var o=a,[l,...c]=o;if(typeof l=="number"){i=t.setTimeout(s.bind(null,c),l);return}s(l),i=t.setTimeout(s.bind(null,c));return}typeof a=="string"&&(e=a,n(e)),typeof a=="object"&&(e=a,n(e)),typeof a=="function"&&a()}};return{stop:()=>{r=!0},start:a=>{r=!1,i&&(i(),i=null),s(a)},subscribe:a=>(n=a,()=>{n=()=>null}),getTimeoutController:()=>t}}class DOe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=a=>{a-r>=n?e(a):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function OOe(){return POe(new DOe)}var LOe=E.createContext(OOe);function jOe(t,e){var n=E.useContext(LOe);return E.useMemo(()=>e??n(t),[t,e,n])}var IOe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),$m={devToolsEnabled:!1,isSsr:IOe()},UOe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},r$={t:0},tN={t:1};function pb(t){var e=ei(t,UOe),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:l,children:c}=e,d=n==="auto"?!$m.isSsr:n,h=jOe(e.animationId,e.animationManager),[g,m]=E.useState(d?r$:tN),v=E.useRef(null);return E.useEffect(()=>{d||m(tN)},[d]),E.useEffect(()=>{if(!d||!r)return ob;var y=AOe(r$,tN,ROe(s),i,m,h.getTimeoutController()),b=()=>{v.current=y()};return h.start([l,a,b,i,o]),()=>{h.stop(),v.current&&v.current(),o()}},[d,r,i,s,a,l,o,h]),c(g.t)}function mb(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(N0(e)),r=E.useRef(t);return r.current!==t&&(n.current=N0(e),r.current=t),n.current}var FOe=["radius"],zOe=["radius"];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 s$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i$(Object(n),!0).forEach(function(r){BOe(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 BOe(t,e,n){return(e=HOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HOe(t){var e=$Oe(t,"string");return typeof e=="symbol"?e:e+""}function $Oe(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 PS(){return PS=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},PS.apply(null,arguments)}function a$(t,e){if(t==null)return{};var n,r,i=VOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VOe(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 o$=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),a=r>=0?1:-1,o=n>=0?1:-1,l=r>=0&&n>=0||r<0&&n<0?1:0,c;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],h=0,g=4;h<g;h++)d[h]=i[h]>s?s:i[h];c="M".concat(t,",").concat(e+a*d[0]),d[0]>0&&(c+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(l,",").concat(t+o*d[0],",").concat(e)),c+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(c+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(l,`,
  8198. `).concat(t+n,",").concat(e+a*d[1])),c+="L ".concat(t+n,",").concat(e+r-a*d[2]),d[2]>0&&(c+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(l,`,
  8199. `).concat(t+n-o*d[2],",").concat(e+r)),c+="L ".concat(t+o*d[3],",").concat(e+r),d[3]>0&&(c+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(l,`,
  8200. `).concat(t,",").concat(e+r-a*d[3])),c+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);c="M ".concat(t,",").concat(e+a*m,`
  8201. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
  8202. L `).concat(t+n-o*m,",").concat(e,`
  8203. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+a*m,`
  8204. L `).concat(t+n,",").concat(e+r-a*m,`
  8205. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+r,`
  8206. L `).concat(t+o*m,",").concat(e+r,`
  8207. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+r-a*m," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return c},l$={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},JY=t=>{var e=ei(t,l$),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:s,y:a,width:o,height:l,radius:c,className:d}=e,{animationEasing:h,animationDuration:g,animationBegin:m,isAnimationActive:v,isUpdateAnimationActive:y}=e,b=E.useRef(o),x=E.useRef(l),M=E.useRef(s),w=E.useRef(a),A=E.useMemo(()=>({x:s,y:a,width:o,height:l,radius:c}),[s,a,o,l,c]),T=mb(A,"rectangle-");if(s!==+s||a!==+a||o!==+o||l!==+l||o===0||l===0)return null;var R=An("recharts-rectangle",d);if(!y){var C=Cs(e),{radius:I}=C,N=a$(C,FOe);return E.createElement("path",PS({},N,{radius:typeof c=="number"?c:void 0,className:R,d:o$(s,a,o,l,c)}))}var D=b.current,z=x.current,j=M.current,W=w.current,P="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),K=KY(["strokeDasharray"],g,typeof h=="string"?h:l$.animationEasing);return E.createElement(pb,{animationId:T,key:T,canBegin:r>0,duration:g,easing:h,isActive:y,begin:m},G=>{var Z=lr(D,o,G),Q=lr(z,l,G),ee=lr(j,s,G),H=lr(W,a,G);n.current&&(b.current=Z,x.current=Q,M.current=ee,w.current=H);var q;v?G>0?q={transition:K,strokeDasharray:$}:q={strokeDasharray:P}:q={strokeDasharray:$};var te=Cs(e),{radius:ae}=te,xe=a$(te,zOe);return E.createElement("path",PS({},xe,{radius:typeof c=="number"?c:void 0,className:R,d:o$(ee,H,Z,Q,c),ref:n,style:s$(s$({},q),e.style)}))})};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 u$(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){GOe(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 GOe(t,e,n){return(e=WOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WOe(t){var e=qOe(t,"string");return typeof e=="symbol"?e:e+""}function qOe(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=Math.PI/180,XOe=t=>t*180/Math.PI,Xr=(t,e,n,r)=>({x:t+Math.cos(-DS*r)*n,y:e+Math.sin(-DS*r)*n}),eZ=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},KOe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},YOe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=KOe({x:n,y:r},{x:i,y:s});if(a<=0)return{radius:a,angle:0};var o=(n-i)/a,l=Math.acos(o);return r>s&&(l=2*Math.PI-l),{radius:a,angle:XOe(l),angleInRadian:l}},ZOe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},QOe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),a=Math.min(i,s);return t+a*360},JOe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=YOe({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:l,endAngle:c}=ZOe(e),d=s,h;if(l<=c){for(;d>c;)d-=360;for(;d<l;)d+=360;h=d>=l&&d<=c}else{for(;d>l;)d-=360;for(;d<c;)d+=360;h=d>=c&&d<=l}return h?u$(u$({},e),{},{radius:i,angle:QOe(d,e)}):null};function tZ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,a=Xr(e,n,r,i),o=Xr(e,n,r,s);return{points:[a,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function pR(){return pR=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},pR.apply(null,arguments)}var eLe=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},h_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:a,cornerRadius:o,cornerIsExternal:l}=t,c=o*(a?1:-1)+r,d=Math.asin(o/c)/DS,h=l?i:i+s*d,g=Xr(e,n,c,h),m=Xr(e,n,r,h),v=l?i-s*d:i,y=Xr(e,n,c*Math.cos(d*DS),v);return{center:g,circleTangency:m,lineTangency:y,theta:d}},nZ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:a}=t,o=eLe(s,a),l=s+o,c=Xr(e,n,i,s),d=Xr(e,n,i,l),h="M ".concat(c.x,",").concat(c.y,`
  8208. A `).concat(i,",").concat(i,`,0,
  8209. `).concat(+(Math.abs(o)>180),",").concat(+(s>l),`,
  8210. `).concat(d.x,",").concat(d.y,`
  8211. `);if(r>0){var g=Xr(e,n,r,s),m=Xr(e,n,r,l);h+="L ".concat(m.x,",").concat(m.y,`
  8212. A `).concat(r,",").concat(r,`,0,
  8213. `).concat(+(Math.abs(o)>180),",").concat(+(s<=l),`,
  8214. `).concat(g.x,",").concat(g.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},tLe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:l,endAngle:c}=t,d=ki(c-l),{circleTangency:h,lineTangency:g,theta:m}=h_({cx:e,cy:n,radius:i,angle:l,sign:d,cornerRadius:s,cornerIsExternal:o}),{circleTangency:v,lineTangency:y,theta:b}=h_({cx:e,cy:n,radius:i,angle:c,sign:-d,cornerRadius:s,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-m-b;if(x<0)return a?"M ".concat(g.x,",").concat(g.y,`
  8215. a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
  8216. a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
  8217. `):nZ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:c});var M="M ".concat(g.x,",").concat(g.y,`
  8218. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(h.x,",").concat(h.y,`
  8219. A`).concat(i,",").concat(i,",0,").concat(+(x>180),",").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
  8220. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  8221. `);if(r>0){var{circleTangency:w,lineTangency:A,theta:T}=h_({cx:e,cy:n,radius:r,angle:l,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:R,lineTangency:C,theta:I}=h_({cx:e,cy:n,radius:r,angle:c,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),N=o?Math.abs(l-c):Math.abs(l-c)-T-I;if(N<0&&s===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(C.x,",").concat(C.y,`
  8222. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(R.x,",").concat(R.y,`
  8223. A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
  8224. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},nLe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},rZ=t=>{var e=ei(t,nLe),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d,className:h}=e;if(s<i||c===d)return null;var g=An("recharts-sector",h),m=s-i,v=us(a,m,0,!0),y;return v>0&&Math.abs(c-d)<360?y=tLe({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(v,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d}):y=nZ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:c,endAngle:d}),E.createElement("path",pR({},Cs(e),{className:g,d:y}))};function rLe(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(OK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,l=Xr(r,i,s,o),c=Xr(r,i,a,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return tZ(e)}}var nN={},rN={},iN={},d$;function iLe(){return d$||(d$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(iN)),iN}var f$;function sLe(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iLe();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})(rN)),rN}var h$;function aLe(){return h$||(h$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qK(),n=sLe();function r(i,s,a){a&&typeof a!="number"&&e.isIterateeCall(i,s,a)&&(s=a=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),a=a===void 0?i<s?1:-1:n.toFinite(a);const o=Math.max(Math.ceil((s-i)/(a||1)),0),l=new Array(o);for(let c=0;c<o;c++)l[c]=i,i+=a;return l}t.range=r})(nN)),nN}var sN,p$;function oLe(){return p$||(p$=1,sN=aLe().range),sN}var lLe=oLe();const iZ=ro(lLe);function Yu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function cLe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function aO(t){let e,n,r;t.length!==2?(e=Yu,n=(o,l)=>Yu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Yu||t===cLe?t:uLe,n=t,r=t);function i(o,l,c=0,d=o.length){if(c<d){if(e(l,l)!==0)return d;do{const h=c+d>>>1;n(o[h],l)<0?c=h+1:d=h}while(c<d)}return c}function s(o,l,c=0,d=o.length){if(c<d){if(e(l,l)!==0)return d;do{const h=c+d>>>1;n(o[h],l)<=0?c=h+1:d=h}while(c<d)}return c}function a(o,l,c=0,d=o.length){const h=i(o,l,c,d-1);return h>c&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:a,right:s}}function uLe(){return 0}function sZ(t){return t===null?NaN:+t}function*dLe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const fLe=aO(Yu),gb=fLe.right;aO(sZ).center;class m$ extends Map{constructor(e,n=mLe){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(g$(this,e))}has(e){return super.has(g$(this,e))}set(e,n){return super.set(hLe(this,e),n)}delete(e){return super.delete(pLe(this,e))}}function g$({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function hLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function pLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function mLe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function gLe(t=Yu){if(t===Yu)return aZ;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 aZ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const xLe=Math.sqrt(50),bLe=Math.sqrt(10),vLe=Math.sqrt(2);function OS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=xLe?10:s>=bLe?5:s>=vLe?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,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)*a,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?OS(t,e,n*2):[o,l,c]}function mR(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,a]=r?OS(e,t,n):OS(t,e,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let c=0;c<o;++c)l[c]=(s-c)/-a;else for(let c=0;c<o;++c)l[c]=(s-c)*a;else if(a<0)for(let c=0;c<o;++c)l[c]=(i+c)/-a;else for(let c=0;c<o;++c)l[c]=(i+c)*a;return l}function gR(t,e,n){return e=+e,t=+t,n=+n,OS(t,e,n)[2]}function xR(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?gR(e,t,n):gR(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function x$(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function b$(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function oZ(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?aZ:gLe(i);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,d=Math.log(l),h=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*h*(l-h)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*h/l+g)),v=Math.min(r,Math.floor(e+(l-c)*h/l+g));oZ(t,e,m,v,i)}const s=t[e];let a=n,o=r;for(ux(t,n,e),i(t[r],s)>0&&ux(t,n,r);a<o;){for(ux(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?ux(t,n,o):(++o,ux(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ux(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function yLe(t,e,n){if(t=Float64Array.from(dLe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return b$(t);if(e>=1)return x$(t);var r,i=(r-1)*e,s=Math.floor(i),a=x$(oZ(t,s).subarray(0,s+1)),o=b$(t.subarray(s+1));return a+(o-a)*(i-s)}}function _Le(t,e,n=sZ){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,s=Math.floor(i),a=+n(t[s],s,t),o=+n(t[s+1],s+1,t);return a+(o-a)*(i-s)}}function SLe(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,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function io(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Dc(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 bR=Symbol("implicit");function oO(){var t=new m$,e=[],n=[],r=bR;function i(s){let a=t.get(s);if(a===void 0){if(r!==bR)return r;t.set(s,a=e.push(s)-1)}return n[a%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new m$;for(const a of s)t.has(a)||t.set(a,e.push(a)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return oO(e,n).unknown(r)},io.apply(i,arguments),i}function lO(){var t=oO().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,a,o=!1,l=0,c=0,d=.5;delete t.unknown;function h(){var g=e().length,m=i<r,v=m?i:r,y=m?r:i;s=(y-v)/Math.max(1,g-l+c*2),o&&(s=Math.floor(s)),v+=(y-v-s*(g-l))*d,a=s*(1-l),o&&(v=Math.round(v),a=Math.round(a));var b=SLe(g).map(function(x){return v+s*x});return n(m?b.reverse():b)}return t.domain=function(g){return arguments.length?(e(g),h()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,h()},t.bandwidth=function(){return a},t.step=function(){return s},t.round=function(g){return arguments.length?(o=!!g,h()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,c=+g),h()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),h()):l},t.paddingOuter=function(g){return arguments.length?(c=+g,h()):c},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),h()):d},t.copy=function(){return lO(e(),[r,i]).round(o).paddingInner(l).paddingOuter(c).align(d)},io.apply(h(),arguments)}function lZ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return lZ(e())},t}function wLe(){return lZ(lO.apply(null,arguments).paddingInner(1))}function cO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function cZ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function xb(){}var I0=.7,LS=1/I0,Kp="\\s*([+-]?\\d+)\\s*",U0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",il="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",MLe=/^#([0-9a-f]{3,8})$/,ELe=new RegExp(`^rgb\\(${Kp},${Kp},${Kp}\\)$`),ALe=new RegExp(`^rgb\\(${il},${il},${il}\\)$`),TLe=new RegExp(`^rgba\\(${Kp},${Kp},${Kp},${U0}\\)$`),CLe=new RegExp(`^rgba\\(${il},${il},${il},${U0}\\)$`),NLe=new RegExp(`^hsl\\(${U0},${il},${il}\\)$`),kLe=new RegExp(`^hsla\\(${U0},${il},${il},${U0}\\)$`),v$={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};cO(xb,F0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:y$,formatHex:y$,formatHex8:RLe,formatHsl:PLe,formatRgb:_$,toString:_$});function y$(){return this.rgb().formatHex()}function RLe(){return this.rgb().formatHex8()}function PLe(){return uZ(this).formatHsl()}function _$(){return this.rgb().formatRgb()}function F0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=MLe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?S$(e):n===3?new Hs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?p_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?p_(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=ELe.exec(t))?new Hs(e[1],e[2],e[3],1):(e=ALe.exec(t))?new Hs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=TLe.exec(t))?p_(e[1],e[2],e[3],e[4]):(e=CLe.exec(t))?p_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=NLe.exec(t))?E$(e[1],e[2]/100,e[3]/100,1):(e=kLe.exec(t))?E$(e[1],e[2]/100,e[3]/100,e[4]):v$.hasOwnProperty(t)?S$(v$[t]):t==="transparent"?new Hs(NaN,NaN,NaN,0):null}function S$(t){return new Hs(t>>16&255,t>>8&255,t&255,1)}function p_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Hs(t,e,n,r)}function DLe(t){return t instanceof xb||(t=F0(t)),t?(t=t.rgb(),new Hs(t.r,t.g,t.b,t.opacity)):new Hs}function vR(t,e,n,r){return arguments.length===1?DLe(t):new Hs(t,e,n,r??1)}function Hs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}cO(Hs,vR,cZ(xb,{brighter(t){return t=t==null?LS:Math.pow(LS,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?I0:Math.pow(I0,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Hs(wf(this.r),wf(this.g),wf(this.b),jS(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:w$,formatHex:w$,formatHex8:OLe,formatRgb:M$,toString:M$}));function w$(){return`#${cf(this.r)}${cf(this.g)}${cf(this.b)}`}function OLe(){return`#${cf(this.r)}${cf(this.g)}${cf(this.b)}${cf((isNaN(this.opacity)?1:this.opacity)*255)}`}function M$(){const t=jS(this.opacity);return`${t===1?"rgb(":"rgba("}${wf(this.r)}, ${wf(this.g)}, ${wf(this.b)}${t===1?")":`, ${t})`}`}function jS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function wf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function cf(t){return t=wf(t),(t<16?"0":"")+t.toString(16)}function E$(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new So(t,e,n,r)}function uZ(t){if(t instanceof So)return new So(t.h,t.s,t.l,t.opacity);if(t instanceof xb||(t=F0(t)),!t)return new So;if(t instanceof So)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-e)/o+2:a=(e-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new So(a,o,l,t.opacity)}function LLe(t,e,n,r){return arguments.length===1?uZ(t):new So(t,e,n,r??1)}function So(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}cO(So,LLe,cZ(xb,{brighter(t){return t=t==null?LS:Math.pow(LS,t),new So(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?I0:Math.pow(I0,t),new So(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 Hs(aN(t>=240?t-240:t+120,i,r),aN(t,i,r),aN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new So(A$(this.h),m_(this.s),m_(this.l),jS(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=jS(this.opacity);return`${t===1?"hsl(":"hsla("}${A$(this.h)}, ${m_(this.s)*100}%, ${m_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function A$(t){return t=(t||0)%360,t<0?t+360:t}function m_(t){return Math.max(0,Math.min(1,t||0))}function aN(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 uO=t=>()=>t;function jLe(t,e){return function(n){return t+n*e}}function ILe(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 ULe(t){return(t=+t)==1?dZ:function(e,n){return n-e?ILe(e,n,t):uO(isNaN(e)?n:e)}}function dZ(t,e){var n=e-t;return n?jLe(t,n):uO(isNaN(t)?e:t)}const T$=(function t(e){var n=ULe(e);function r(i,s){var a=n((i=vR(i)).r,(s=vR(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=dZ(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=t,r})(1);function FLe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function zLe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function BLe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=Vm(t[a],e[a]);for(;a<n;++a)s[a]=e[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function HLe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function IS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function $Le(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]=Vm(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var yR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,oN=new RegExp(yR.source,"g");function VLe(t){return function(){return t}}function GLe(t){return function(e){return t(e)+""}}function WLe(t,e){var n=yR.lastIndex=oN.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(t=t+"",e=e+"";(r=yR.exec(t))&&(i=oN.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:IS(r,i)})),n=oN.lastIndex;return n<e.length&&(s=e.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?GLe(l[0].x):VLe(e):(e=l.length,function(c){for(var d=0,h;d<e;++d)o[(h=l[d]).i]=h.x(c);return o.join("")})}function Vm(t,e){var n=typeof e,r;return e==null||n==="boolean"?uO(e):(n==="number"?IS:n==="string"?(r=F0(e))?(e=r,T$):WLe:e instanceof F0?T$:e instanceof Date?HLe:zLe(e)?FLe:Array.isArray(e)?BLe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?$Le:IS)(t,e)}function dO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function qLe(t,e){e===void 0&&(e=t,t=Vm);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(a){var o=Math.max(0,Math.min(r-1,Math.floor(a*=r)));return s[o](a-o)}}function XLe(t){return function(){return t}}function US(t){return+t}var C$=[0,1];function _s(t){return t}function _R(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:XLe(isNaN(e)?NaN:.5)}function KLe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function YLe(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i<r?(r=_R(i,r),s=n(a,s)):(r=_R(r,i),s=n(s,a)),function(o){return s(r(o))}}function ZLe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=_R(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(o){var l=gb(t,o,1,r)-1;return s[l](i[l](o))}}function bb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function fM(){var t=C$,e=C$,n=Vm,r,i,s,a=_s,o,l,c;function d(){var g=Math.min(t.length,e.length);return a!==_s&&(a=KLe(t[0],t[g-1])),o=g>2?ZLe:YLe,l=c=null,h}function h(g){return g==null||isNaN(g=+g)?s:(l||(l=o(t.map(r),e,n)))(r(a(g)))}return h.invert=function(g){return a(i((c||(c=o(e,t.map(r),IS)))(g)))},h.domain=function(g){return arguments.length?(t=Array.from(g,US),d()):t.slice()},h.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},h.rangeRound=function(g){return e=Array.from(g),n=dO,d()},h.clamp=function(g){return arguments.length?(a=g?!0:_s,d()):a!==_s},h.interpolate=function(g){return arguments.length?(n=g,d()):n},h.unknown=function(g){return arguments.length?(s=g,h):s},function(g,m){return r=g,i=m,d()}}function fO(){return fM()(_s,_s)}function QLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function FS(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 Mm(t){return t=FS(Math.abs(t)),t?t[1]:NaN}function JLe(t,e){return function(n,r){for(var i=n.length,s=[],a=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[a=(a+1)%t.length];return s.reverse().join(e)}}function eje(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var tje=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function z0(t){if(!(e=tje.exec(t)))throw new Error("invalid format: "+t);var e;return new hO({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]})}z0.prototype=hO.prototype;function hO(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+""}hO.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 nje(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 fZ;function rje(t,e){var n=FS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(fZ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+FS(t,Math.max(0,e+s-1))[0]}function N$(t,e){var n=FS(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const k$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:QLe,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)=>N$(t*100,e),r:N$,s:rje,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function R$(t){return t}var P$=Array.prototype.map,D$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ije(t){var e=t.grouping===void 0||t.thousands===void 0?R$:JLe(P$.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+"",s=t.numerals===void 0?R$:eje(P$.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h){h=z0(h);var g=h.fill,m=h.align,v=h.sign,y=h.symbol,b=h.zero,x=h.width,M=h.comma,w=h.precision,A=h.trim,T=h.type;T==="n"?(M=!0,T="g"):k$[T]||(w===void 0&&(w=12),A=!0,T="g"),(b||g==="0"&&m==="=")&&(b=!0,g="0",m="=");var R=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",C=y==="$"?r:/[%p]/.test(T)?a:"",I=k$[T],N=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function D(z){var j=R,W=C,P,$,K;if(T==="c")W=I(z)+W,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?l:I(Math.abs(z),w),A&&(z=nje(z)),G&&+z==0&&v!=="+"&&(G=!1),j=(G?v==="("?v:o:v==="-"||v==="("?"":v)+j,W=(T==="s"?D$[8+fZ/3]:"")+W+(G&&v==="("?")":""),N){for(P=-1,$=z.length;++P<$;)if(K=z.charCodeAt(P),48>K||K>57){W=(K===46?i+z.slice(P+1):z.slice(P))+W,z=z.slice(0,P);break}}}M&&!b&&(z=e(z,1/0));var Z=j.length+z.length+W.length,Q=Z<x?new Array(x-Z+1).join(g):"";switch(M&&b&&(z=e(Q+z,Q.length?x-W.length:1/0),Q=""),m){case"<":z=j+z+W+Q;break;case"=":z=j+Q+z+W;break;case"^":z=Q.slice(0,Z=Q.length>>1)+j+z+W+Q.slice(Z);break;default:z=Q+j+z+W;break}return s(z)}return D.toString=function(){return h+""},D}function d(h,g){var m=c((h=z0(h),h.type="f",h)),v=Math.max(-8,Math.min(8,Math.floor(Mm(g)/3)))*3,y=Math.pow(10,-v),b=D$[8+v/3];return function(x){return m(y*x)+b}}return{format:c,formatPrefix:d}}var g_,pO,hZ;sje({thousands:",",grouping:[3],currency:["$",""]});function sje(t){return g_=ije(t),pO=g_.format,hZ=g_.formatPrefix,g_}function aje(t){return Math.max(0,-Mm(Math.abs(t)))}function oje(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Mm(e)/3)))*3-Mm(Math.abs(t)))}function lje(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Mm(e)-Mm(t))+1}function pZ(t,e,n,r){var i=xR(t,e,n),s;switch(r=z0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=oje(i,a))&&(r.precision=s),hZ(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=lje(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=aje(i))&&(r.precision=s-(r.type==="%")*2);break}}return pO(r)}function md(t){var e=t.domain;return t.ticks=function(n){var r=e();return mR(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return pZ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,a=r[i],o=r[s],l,c,d=10;for(o<a&&(c=a,a=o,o=c,c=i,i=s,s=c);d-- >0;){if(c=gR(a,o,n),c===l)return r[i]=a,r[s]=o,e(r);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function mZ(){var t=fO();return t.copy=function(){return bb(t,mZ())},io.apply(t,arguments),md(t)}function gZ(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,US),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return gZ(t).unknown(e)},t=arguments.length?Array.from(t,US):[0,1],md(n)}function xZ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],a;return s<i&&(a=n,n=r,r=a,a=i,i=s,s=a),t[n]=e.floor(i),t[r]=e.ceil(s),t}function O$(t){return Math.log(t)}function L$(t){return Math.exp(t)}function cje(t){return-Math.log(-t)}function uje(t){return-Math.exp(-t)}function dje(t){return isFinite(t)?+("1e"+t):t<0?0:t}function fje(t){return t===10?dje:t===Math.E?Math.exp:e=>Math.pow(t,e)}function hje(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 j$(t){return(e,n)=>-t(-e,n)}function mO(t){const e=t(O$,L$),n=e.domain;let r=10,i,s;function a(){return i=hje(r),s=fje(r),n()[0]<0?(i=j$(i),s=j$(s),t(cje,uje)):t(O$,L$),e}return e.base=function(o){return arguments.length?(r=+o,a()):r},e.domain=function(o){return arguments.length?(n(o),a()):n()},e.ticks=o=>{const l=n();let c=l[0],d=l[l.length-1];const h=d<c;h&&([c,d]=[d,c]);let g=i(c),m=i(d),v,y;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(v=1;v<r;++v)if(y=g<0?v/s(-g):v*s(g),!(y<c)){if(y>d)break;x.push(y)}}else for(;g<=m;++g)for(v=r-1;v>=1;--v)if(y=g>0?v/s(-g):v*s(g),!(y<c)){if(y>d)break;x.push(y)}x.length*2<b&&(x=mR(c,d,b))}else x=mR(g,m,Math.min(m-g,b)).map(s);return h?x.reverse():x},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=z0(l)).precision==null&&(l.trim=!0),l=pO(l)),o===1/0)return l;const c=Math.max(1,r*o/e.ticks().length);return d=>{let h=d/s(Math.round(i(d)));return h*r<r-.5&&(h*=r),h<=c?l(d):""}},e.nice=()=>n(xZ(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function bZ(){const t=mO(fM()).domain([1,10]);return t.copy=()=>bb(t,bZ()).base(t.base()),io.apply(t,arguments),t}function I$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function U$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function gO(t){var e=1,n=t(I$(e),U$(e));return n.constant=function(r){return arguments.length?t(I$(e=+r),U$(e)):e},md(n)}function vZ(){var t=gO(fM());return t.copy=function(){return bb(t,vZ()).constant(t.constant())},io.apply(t,arguments)}function F$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function pje(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function mje(t){return t<0?-t*t:t*t}function xO(t){var e=t(_s,_s),n=1;function r(){return n===1?t(_s,_s):n===.5?t(pje,mje):t(F$(n),F$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},md(e)}function bO(){var t=xO(fM());return t.copy=function(){return bb(t,bO()).exponent(t.exponent())},io.apply(t,arguments),t}function gje(){return bO.apply(null,arguments).exponent(.5)}function z$(t){return Math.sign(t)*t*t}function xje(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function yZ(){var t=fO(),e=[0,1],n=!1,r;function i(s){var a=xje(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(z$(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,US)).map(z$)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return yZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},io.apply(i,arguments),md(i)}function _Z(){var t=[],e=[],n=[],r;function i(){var a=0,o=Math.max(1,e.length);for(n=new Array(o-1);++a<o;)n[a-1]=_Le(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[gb(n,a)]}return s.invertExtent=function(a){var o=e.indexOf(a);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},s.domain=function(a){if(!arguments.length)return t.slice();t=[];for(let o of a)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Yu),i()},s.range=function(a){return arguments.length?(e=Array.from(a),i()):e.slice()},s.unknown=function(a){return arguments.length?(r=a,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return _Z().domain(t).range(e).unknown(r)},io.apply(s,arguments)}function SZ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function a(l){return l!=null&&l<=l?i[gb(r,l,0,n)]:s}function o(){var l=-1;for(r=new Array(n);++l<n;)r[l]=((l+1)*e-(l-n)*t)/(n+1);return a}return a.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},a.range=function(l){return arguments.length?(n=(i=Array.from(l)).length-1,o()):i.slice()},a.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]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return SZ().domain([t,e]).range(i).unknown(s)},io.apply(md(a),arguments)}function wZ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[gb(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var a=e.indexOf(s);return[t[a-1],t[a]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return wZ().domain(t).range(e).unknown(n)},io.apply(i,arguments)}const lN=new Date,cN=new Date;function mi(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const a=i(s),o=i.ceil(s);return s-a<o-s?a:o},i.offset=(s,a)=>(e(s=new Date(+s),a==null?1:Math.floor(a)),s),i.range=(s,a,o)=>{const l=[];if(s=i.ceil(s),o=o==null?1:Math.floor(o),!(s<a)||!(o>0))return l;let c;do l.push(c=new Date(+s)),e(s,o),t(s);while(c<s&&s<a);return l},i.filter=s=>mi(a=>{if(a>=a)for(;t(a),!s(a);)a.setTime(a-1)},(a,o)=>{if(a>=a)if(o<0)for(;++o<=0;)for(;e(a,-1),!s(a););else for(;--o>=0;)for(;e(a,1),!s(a););}),n&&(i.count=(s,a)=>(lN.setTime(+s),cN.setTime(+a),t(lN),t(cN),Math.floor(n(lN,cN))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?a=>r(a)%s===0:a=>i.count(0,a)%s===0):i)),i}const zS=mi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);zS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?mi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):zS);zS.range;const lc=1e3,Xa=lc*60,cc=Xa*60,Mc=cc*24,vO=Mc*7,B$=Mc*30,uN=Mc*365,uf=mi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*lc)},(t,e)=>(e-t)/lc,t=>t.getUTCSeconds());uf.range;const yO=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*lc)},(t,e)=>{t.setTime(+t+e*Xa)},(t,e)=>(e-t)/Xa,t=>t.getMinutes());yO.range;const _O=mi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Xa)},(t,e)=>(e-t)/Xa,t=>t.getUTCMinutes());_O.range;const SO=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*lc-t.getMinutes()*Xa)},(t,e)=>{t.setTime(+t+e*cc)},(t,e)=>(e-t)/cc,t=>t.getHours());SO.range;const wO=mi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*cc)},(t,e)=>(e-t)/cc,t=>t.getUTCHours());wO.range;const vb=mi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Xa)/Mc,t=>t.getDate()-1);vb.range;const hM=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Mc,t=>t.getUTCDate()-1);hM.range;const MZ=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Mc,t=>Math.floor(t/Mc));MZ.range;function nh(t){return mi(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())*Xa)/vO)}const pM=nh(0),BS=nh(1),bje=nh(2),vje=nh(3),Em=nh(4),yje=nh(5),_je=nh(6);pM.range;BS.range;bje.range;vje.range;Em.range;yje.range;_je.range;function rh(t){return mi(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)/vO)}const mM=rh(0),HS=rh(1),Sje=rh(2),wje=rh(3),Am=rh(4),Mje=rh(5),Eje=rh(6);mM.range;HS.range;Sje.range;wje.range;Am.range;Mje.range;Eje.range;const MO=mi(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());MO.range;const EO=mi(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());EO.range;const Ec=mi(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());Ec.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(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)});Ec.range;const Ac=mi(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());Ac.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(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)});Ac.range;function EZ(t,e,n,r,i,s){const a=[[uf,1,lc],[uf,5,5*lc],[uf,15,15*lc],[uf,30,30*lc],[s,1,Xa],[s,5,5*Xa],[s,15,15*Xa],[s,30,30*Xa],[i,1,cc],[i,3,3*cc],[i,6,6*cc],[i,12,12*cc],[r,1,Mc],[r,2,2*Mc],[n,1,vO],[e,1,B$],[e,3,3*B$],[t,1,uN]];function o(c,d,h){const g=d<c;g&&([c,d]=[d,c]);const m=h&&typeof h.range=="function"?h:l(c,d,h),v=m?m.range(c,+d+1):[];return g?v.reverse():v}function l(c,d,h){const g=Math.abs(d-c)/h,m=aO(([,,b])=>b).right(a,g);if(m===a.length)return t.every(xR(c/uN,d/uN,h));if(m===0)return zS.every(Math.max(xR(c,d,h),1));const[v,y]=a[g/a[m-1][2]<a[m][2]/g?m-1:m];return v.every(y)}return[o,l]}const[Aje,Tje]=EZ(Ac,EO,mM,MZ,wO,_O),[Cje,Nje]=EZ(Ec,MO,pM,vb,SO,yO);function dN(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 fN(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 dx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function kje(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,a=t.shortDays,o=t.months,l=t.shortMonths,c=fx(i),d=hx(i),h=fx(s),g=hx(s),m=fx(a),v=hx(a),y=fx(o),b=hx(o),x=fx(l),M=hx(l),w={a:G,A:Z,b:Q,B:ee,c:null,d:q$,e:q$,f:Jje,g:cIe,G:dIe,H:Yje,I:Zje,j:Qje,L:AZ,m:eIe,M:tIe,p:H,q,Q:Y$,s:Z$,S:nIe,u:rIe,U:iIe,V:sIe,w:aIe,W:oIe,x:null,X:null,y:lIe,Y:uIe,Z:fIe,"%":K$},A={a:te,A:ae,b:xe,B:re,c:null,d:X$,e:X$,f:gIe,g:AIe,G:CIe,H:hIe,I:pIe,j:mIe,L:CZ,m:xIe,M:bIe,p:pe,q:Ce,Q:Y$,s:Z$,S:vIe,u:yIe,U:_Ie,V:SIe,w:wIe,W:MIe,x:null,X:null,y:EIe,Y:TIe,Z:NIe,"%":K$},T={a:D,A:z,b:j,B:W,c:P,d:G$,e:G$,f:Wje,g:V$,G:$$,H:W$,I:W$,j:Hje,L:Gje,m:Bje,M:$je,p:N,q:zje,Q:Xje,s:Kje,S:Vje,u:Lje,U:jje,V:Ije,w:Oje,W:Uje,x:$,X:K,y:V$,Y:$$,Z:Fje,"%":qje};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(fe,Se){return function(Re){var ue=[],ct=-1,B=0,F=fe.length,ie,V,J;for(Re instanceof Date||(Re=new Date(+Re));++ct<F;)fe.charCodeAt(ct)===37&&(ue.push(fe.slice(B,ct)),(V=H$[ie=fe.charAt(++ct)])!=null?ie=fe.charAt(++ct):V=ie==="e"?" ":"0",(J=Se[ie])&&(ie=J(Re,V)),ue.push(ie),B=ct+1);return ue.push(fe.slice(B,ct)),ue.join("")}}function C(fe,Se){return function(Re){var ue=dx(1900,void 0,1),ct=I(ue,fe,Re+="",0),B,F;if(ct!=Re.length)return null;if("Q"in ue)return new Date(ue.Q);if("s"in ue)return new Date(ue.s*1e3+("L"in ue?ue.L:0));if(Se&&!("Z"in ue)&&(ue.Z=0),"p"in ue&&(ue.H=ue.H%12+ue.p*12),ue.m===void 0&&(ue.m="q"in ue?ue.q:0),"V"in ue){if(ue.V<1||ue.V>53)return null;"w"in ue||(ue.w=1),"Z"in ue?(B=fN(dx(ue.y,0,1)),F=B.getUTCDay(),B=F>4||F===0?HS.ceil(B):HS(B),B=hM.offset(B,(ue.V-1)*7),ue.y=B.getUTCFullYear(),ue.m=B.getUTCMonth(),ue.d=B.getUTCDate()+(ue.w+6)%7):(B=dN(dx(ue.y,0,1)),F=B.getDay(),B=F>4||F===0?BS.ceil(B):BS(B),B=vb.offset(B,(ue.V-1)*7),ue.y=B.getFullYear(),ue.m=B.getMonth(),ue.d=B.getDate()+(ue.w+6)%7)}else("W"in ue||"U"in ue)&&("w"in ue||(ue.w="u"in ue?ue.u%7:"W"in ue?1:0),F="Z"in ue?fN(dx(ue.y,0,1)).getUTCDay():dN(dx(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-(F+5)%7:ue.w+ue.U*7-(F+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,fN(ue)):dN(ue)}}function I(fe,Se,Re,ue){for(var ct=0,B=Se.length,F=Re.length,ie,V;ct<B;){if(ue>=F)return-1;if(ie=Se.charCodeAt(ct++),ie===37){if(ie=Se.charAt(ct++),V=T[ie in H$?Se.charAt(ct++):ie],!V||(ue=V(fe,Re,ue))<0)return-1}else if(ie!=Re.charCodeAt(ue++))return-1}return ue}function N(fe,Se,Re){var ue=c.exec(Se.slice(Re));return ue?(fe.p=d.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function D(fe,Se,Re){var ue=m.exec(Se.slice(Re));return ue?(fe.w=v.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function z(fe,Se,Re){var ue=h.exec(Se.slice(Re));return ue?(fe.w=g.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function j(fe,Se,Re){var ue=x.exec(Se.slice(Re));return ue?(fe.m=M.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function W(fe,Se,Re){var ue=y.exec(Se.slice(Re));return ue?(fe.m=b.get(ue[0].toLowerCase()),Re+ue[0].length):-1}function P(fe,Se,Re){return I(fe,e,Se,Re)}function $(fe,Se,Re){return I(fe,n,Se,Re)}function K(fe,Se,Re){return I(fe,r,Se,Re)}function G(fe){return a[fe.getDay()]}function Z(fe){return s[fe.getDay()]}function Q(fe){return l[fe.getMonth()]}function ee(fe){return o[fe.getMonth()]}function H(fe){return i[+(fe.getHours()>=12)]}function q(fe){return 1+~~(fe.getMonth()/3)}function te(fe){return a[fe.getUTCDay()]}function ae(fe){return s[fe.getUTCDay()]}function xe(fe){return l[fe.getUTCMonth()]}function re(fe){return o[fe.getUTCMonth()]}function pe(fe){return i[+(fe.getUTCHours()>=12)]}function Ce(fe){return 1+~~(fe.getUTCMonth()/3)}return{format:function(fe){var Se=R(fe+="",w);return Se.toString=function(){return fe},Se},parse:function(fe){var Se=C(fe+="",!1);return Se.toString=function(){return fe},Se},utcFormat:function(fe){var Se=R(fe+="",A);return Se.toString=function(){return fe},Se},utcParse:function(fe){var Se=C(fe+="",!0);return Se.toString=function(){return fe},Se}}}var H$={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,Rje=/^%/,Pje=/[\\^$*+?|[\]().{}]/g;function Tn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function Dje(t){return t.replace(Pje,"\\$&")}function fx(t){return new RegExp("^(?:"+t.map(Dje).join("|")+")","i")}function hx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Oje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Lje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function jje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Ije(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Uje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function $$(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function V$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Fje(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 zje(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Bje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function G$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Hje(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function W$(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function $je(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Vje(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Gje(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Wje(t,e,n){var r=Oi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function qje(t,e,n){var r=Rje.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Xje(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Kje(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function q$(t,e){return Tn(t.getDate(),e,2)}function Yje(t,e){return Tn(t.getHours(),e,2)}function Zje(t,e){return Tn(t.getHours()%12||12,e,2)}function Qje(t,e){return Tn(1+vb.count(Ec(t),t),e,3)}function AZ(t,e){return Tn(t.getMilliseconds(),e,3)}function Jje(t,e){return AZ(t,e)+"000"}function eIe(t,e){return Tn(t.getMonth()+1,e,2)}function tIe(t,e){return Tn(t.getMinutes(),e,2)}function nIe(t,e){return Tn(t.getSeconds(),e,2)}function rIe(t){var e=t.getDay();return e===0?7:e}function iIe(t,e){return Tn(pM.count(Ec(t)-1,t),e,2)}function TZ(t){var e=t.getDay();return e>=4||e===0?Em(t):Em.ceil(t)}function sIe(t,e){return t=TZ(t),Tn(Em.count(Ec(t),t)+(Ec(t).getDay()===4),e,2)}function aIe(t){return t.getDay()}function oIe(t,e){return Tn(BS.count(Ec(t)-1,t),e,2)}function lIe(t,e){return Tn(t.getFullYear()%100,e,2)}function cIe(t,e){return t=TZ(t),Tn(t.getFullYear()%100,e,2)}function uIe(t,e){return Tn(t.getFullYear()%1e4,e,4)}function dIe(t,e){var n=t.getDay();return t=n>=4||n===0?Em(t):Em.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function fIe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function X$(t,e){return Tn(t.getUTCDate(),e,2)}function hIe(t,e){return Tn(t.getUTCHours(),e,2)}function pIe(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function mIe(t,e){return Tn(1+hM.count(Ac(t),t),e,3)}function CZ(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function gIe(t,e){return CZ(t,e)+"000"}function xIe(t,e){return Tn(t.getUTCMonth()+1,e,2)}function bIe(t,e){return Tn(t.getUTCMinutes(),e,2)}function vIe(t,e){return Tn(t.getUTCSeconds(),e,2)}function yIe(t){var e=t.getUTCDay();return e===0?7:e}function _Ie(t,e){return Tn(mM.count(Ac(t)-1,t),e,2)}function NZ(t){var e=t.getUTCDay();return e>=4||e===0?Am(t):Am.ceil(t)}function SIe(t,e){return t=NZ(t),Tn(Am.count(Ac(t),t)+(Ac(t).getUTCDay()===4),e,2)}function wIe(t){return t.getUTCDay()}function MIe(t,e){return Tn(HS.count(Ac(t)-1,t),e,2)}function EIe(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function AIe(t,e){return t=NZ(t),Tn(t.getUTCFullYear()%100,e,2)}function TIe(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function CIe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Am(t):Am.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function NIe(){return"+0000"}function K$(){return"%"}function Y$(t){return+t}function Z$(t){return Math.floor(+t/1e3)}var vp,kZ,RZ;kIe({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 kIe(t){return vp=kje(t),kZ=vp.format,vp.parse,RZ=vp.utcFormat,vp.utcParse,vp}function RIe(t){return new Date(t)}function PIe(t){return t instanceof Date?+t:+new Date(+t)}function AO(t,e,n,r,i,s,a,o,l,c){var d=fO(),h=d.invert,g=d.domain,m=c(".%L"),v=c(":%S"),y=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?v:a(R)<R?y:s(R)<R?b:r(R)<R?i(R)<R?x:M:n(R)<R?w:A)(R)}return d.invert=function(R){return new Date(h(R))},d.domain=function(R){return arguments.length?g(Array.from(R,PIe)):g().map(RIe)},d.ticks=function(R){var C=g();return t(C[0],C[C.length-1],R??10)},d.tickFormat=function(R,C){return C==null?T:c(C)},d.nice=function(R){var C=g();return(!R||typeof R.range!="function")&&(R=e(C[0],C[C.length-1],R??10)),R?g(xZ(C,R)):d},d.copy=function(){return bb(d,AO(t,e,n,r,i,s,a,o,l,c))},d}function DIe(){return io.apply(AO(Cje,Nje,Ec,MO,pM,vb,SO,yO,uf,kZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function OIe(){return io.apply(AO(Aje,Tje,Ac,EO,mM,hM,wO,_O,uf,RZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function gM(){var t=0,e=1,n,r,i,s,a=_s,o=!1,l;function c(h){return h==null||isNaN(h=+h)?l:a(i===0?.5:(h=(s(h)-n)*i,o?Math.max(0,Math.min(1,h)):h))}c.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),c):[t,e]},c.clamp=function(h){return arguments.length?(o=!!h,c):o},c.interpolator=function(h){return arguments.length?(a=h,c):a};function d(h){return function(g){var m,v;return arguments.length?([m,v]=g,a=h(m,v),c):[a(0),a(1)]}}return c.range=d(Vm),c.rangeRound=d(dO),c.unknown=function(h){return arguments.length?(l=h,c):l},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),c}}function gd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function PZ(){var t=md(gM()(_s));return t.copy=function(){return gd(t,PZ())},Dc.apply(t,arguments)}function DZ(){var t=mO(gM()).domain([1,10]);return t.copy=function(){return gd(t,DZ()).base(t.base())},Dc.apply(t,arguments)}function OZ(){var t=gO(gM());return t.copy=function(){return gd(t,OZ()).constant(t.constant())},Dc.apply(t,arguments)}function TO(){var t=xO(gM());return t.copy=function(){return gd(t,TO()).exponent(t.exponent())},Dc.apply(t,arguments)}function LIe(){return TO.apply(null,arguments).exponent(.5)}function LZ(){var t=[],e=_s;function n(r){if(r!=null&&!isNaN(r=+r))return e((gb(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(Yu),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,s)=>yLe(t,s/r))},n.copy=function(){return LZ(e).domain(t)},Dc.apply(n,arguments)}function xM(){var t=0,e=.5,n=1,r=1,i,s,a,o,l,c=_s,d,h=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-s)*(r*y<r*s?o:l),c(h?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),a=d(n=+n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(c=y,m):c};function v(y){return function(b){var x,M,w;return arguments.length?([x,M,w]=b,c=qLe(y,[x,M,w]),m):[c(0),c(.5),c(1)]}}return m.range=v(Vm),m.rangeRound=v(dO),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return d=y,i=y(t),s=y(e),a=y(n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m}}function jZ(){var t=md(xM()(_s));return t.copy=function(){return gd(t,jZ())},Dc.apply(t,arguments)}function IZ(){var t=mO(xM()).domain([.1,1,10]);return t.copy=function(){return gd(t,IZ()).base(t.base())},Dc.apply(t,arguments)}function UZ(){var t=gO(xM());return t.copy=function(){return gd(t,UZ()).constant(t.constant())},Dc.apply(t,arguments)}function CO(){var t=xO(xM());return t.copy=function(){return gd(t,CO()).exponent(t.exponent())},Dc.apply(t,arguments)}function jIe(){return CO.apply(null,arguments).exponent(.5)}const Mx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:lO,scaleDiverging:jZ,scaleDivergingLog:IZ,scaleDivergingPow:CO,scaleDivergingSqrt:jIe,scaleDivergingSymlog:UZ,scaleIdentity:gZ,scaleImplicit:bR,scaleLinear:mZ,scaleLog:bZ,scaleOrdinal:oO,scalePoint:wLe,scalePow:bO,scaleQuantile:_Z,scaleQuantize:SZ,scaleRadial:yZ,scaleSequential:PZ,scaleSequentialLog:DZ,scaleSequentialPow:TO,scaleSequentialQuantile:LZ,scaleSequentialSqrt:LIe,scaleSequentialSymlog:OZ,scaleSqrt:gje,scaleSymlog:vZ,scaleThreshold:wZ,scaleTime:DIe,scaleUtc:OIe,tickFormat:pZ},Symbol.toStringTag,{value:"Module"}));var xd=t=>t.chartData,NO=We([xd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),bM=(t,e,n,r)=>r?NO(t):xd(t);function id(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(cr(e)&&cr(n))return!0}return!1}function Q$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function FZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(cr(n))i=n;else if(typeof n=="function")return;if(cr(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(id(a))return a}}function IIe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(id(r))return Q$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,a,o;if(i==="auto")e!=null&&(a=Math.min(...e));else if(Tt(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&AH.test(i)){var l=AH.exec(i);if(l==null||e==null)a=void 0;else{var c=+l[1];a=e[0]-c}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Tt(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&TH.test(s)){var d=TH.exec(s);if(d==null||e==null)o=void 0;else{var h=+d[1];o=e[1]+h}}else o=e?.[1];var g=[a,o];if(id(g))return e==null?g:Q$(g,e,n)}}}var Gm=1e9,UIe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},RO,hr=!0,no="[DecimalError] ",Mf=no+"Invalid argument: ",kO=no+"Exponent out of range: ",Wm=Math.floor,Kd=Math.pow,FIe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ha,Ti=1e7,or=7,zZ=9007199254740991,$S=Wm(zZ/or),Nt={};Nt.absoluteValue=Nt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Nt.comparedTo=Nt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Nt.decimalPlaces=Nt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*or;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Nt.dividedBy=Nt.div=function(t){return gc(this,new this.constructor(t))};Nt.dividedToIntegerBy=Nt.idiv=function(t){var e=this,n=e.constructor;return Zn(gc(e,new n(t),0,1),n.precision)};Nt.equals=Nt.eq=function(t){return!this.cmp(t)};Nt.exponent=function(){return Zr(this)};Nt.greaterThan=Nt.gt=function(t){return this.cmp(t)>0};Nt.greaterThanOrEqualTo=Nt.gte=function(t){return this.cmp(t)>=0};Nt.isInteger=Nt.isint=function(){return this.e>this.d.length-2};Nt.isNegative=Nt.isneg=function(){return this.s<0};Nt.isPositive=Nt.ispos=function(){return this.s>0};Nt.isZero=function(){return this.s===0};Nt.lessThan=Nt.lt=function(t){return this.cmp(t)<0};Nt.lessThanOrEqualTo=Nt.lte=function(t){return this.cmp(t)<1};Nt.logarithm=Nt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(ha))throw Error(no+"NaN");if(n.s<1)throw Error(no+(n.s?"NaN":"-Infinity"));return n.eq(ha)?new r(0):(hr=!1,e=gc(B0(n,s),B0(t,s),s),hr=!0,Zn(e,i))};Nt.minus=Nt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?$Z(e,t):BZ(e,(t.s=-t.s,t))};Nt.modulo=Nt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(no+"NaN");return n.s?(hr=!1,e=gc(n,t,0,1).times(t),hr=!0,n.minus(e)):Zn(new r(n),i)};Nt.naturalExponential=Nt.exp=function(){return HZ(this)};Nt.naturalLogarithm=Nt.ln=function(){return B0(this)};Nt.negated=Nt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Nt.plus=Nt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?BZ(e,t):$Z(e,(t.s=-t.s,t))};Nt.precision=Nt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Mf+t);if(e=Zr(i)+1,r=i.d.length-1,n=r*or+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};Nt.squareRoot=Nt.sqrt=function(){var t,e,n,r,i,s,a,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(no+"NaN")}for(t=Zr(o),hr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=tl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Wm((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=a=n+3;;)if(s=r,r=s.plus(gc(o,s,a+2)).times(.5),tl(s.d).slice(0,a)===(e=tl(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(Zn(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return hr=!0,Zn(r,n)};Nt.times=Nt.mul=function(t){var e,n,r,i,s,a,o,l,c,d=this,h=d.constructor,g=d.d,m=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,l=g.length,c=m.length,l<c&&(s=g,g=m,m=s,a=l,l=c,c=a),s=[],a=l+c,r=a;r--;)s.push(0);for(r=c;--r>=0;){for(e=0,i=l+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%Ti|0,e=o/Ti|0;s[i]=(s[i]+e)%Ti|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,hr?Zn(t,h.precision):t};Nt.toDecimalPlaces=Nt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(fl(t,0,Gm),e===void 0?e=r.rounding:fl(e,0,8),Zn(n,t+Zr(n)+1,e))};Nt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Kf(r,!0):(fl(t,0,Gm),e===void 0?e=i.rounding:fl(e,0,8),r=Zn(new i(r),t+1,e),n=Kf(r,!0,t+1)),n};Nt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Kf(i):(fl(t,0,Gm),e===void 0?e=s.rounding:fl(e,0,8),r=Zn(new s(i),t+Zr(i)+1,e),n=Kf(r.abs(),!1,t+Zr(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Nt.toInteger=Nt.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Zr(t)+1,e.rounding)};Nt.toNumber=function(){return+this};Nt.toPower=Nt.pow=function(t){var e,n,r,i,s,a,o=this,l=o.constructor,c=12,d=+(t=new l(t));if(!t.s)return new l(ha);if(o=new l(o),!o.s){if(t.s<1)throw Error(no+"Infinity");return o}if(o.eq(ha))return o;if(r=l.precision,t.eq(ha))return Zn(o,r);if(e=t.e,n=t.d.length-1,a=e>=n,s=o.s,a){if((n=d<0?-d:d)<=zZ){for(i=new l(ha),e=Math.ceil(r/or+4),hr=!1;n%2&&(i=i.times(o),eV(i.d,e)),n=Wm(n/2),n!==0;)o=o.times(o),eV(o.d,e);return hr=!0,t.s<0?new l(ha).div(i):Zn(i,r)}}else if(s<0)throw Error(no+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,hr=!1,i=t.times(B0(o,r+c)),hr=!0,i=HZ(i),i.s=s,i};Nt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=Zr(i),r=Kf(i,n<=s.toExpNeg||n>=s.toExpPos)):(fl(t,1,Gm),e===void 0?e=s.rounding:fl(e,0,8),i=Zn(new s(i),t,e),n=Zr(i),r=Kf(i,t<=n||n<=s.toExpNeg,t)),r};Nt.toSignificantDigits=Nt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(fl(t,1,Gm),e===void 0?e=r.rounding:fl(e,0,8)),Zn(new r(n),t,e)};Nt.toString=Nt.valueOf=Nt.val=Nt.toJSON=Nt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Zr(t),n=t.constructor;return Kf(t,e<=n.toExpNeg||e>=n.toExpPos)};function BZ(t,e){var n,r,i,s,a,o,l,c,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),hr?Zn(e,h):e;if(l=t.d,c=e.d,a=t.e,i=e.e,l=l.slice(),s=a-i,s){for(s<0?(r=l,s=-s,o=c.length):(r=c,i=a,o=l.length),a=Math.ceil(h/or),o=a>o?a+1:o+1,s>o&&(s=o,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(o=l.length,s=c.length,o-s<0&&(s=o,r=c,c=l,l=r),n=0;s;)n=(l[--s]=l[s]+c[s]+n)/Ti|0,l[s]%=Ti;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,hr?Zn(e,h):e}function fl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Mf+t)}function tl(t){var e,n,r,i=t.length-1,s="",a=t[0];if(i>0){for(s+=a,e=1;e<i;e++)r=t[e]+"",n=or-r.length,n&&(s+=Cu(n)),s+=r;a=t[e],r=a+"",n=or-r.length,n&&(s+=Cu(n))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}var gc=(function(){function t(r,i){var s,a=0,o=r.length;for(r=r.slice();o--;)s=r[o]*i+a,r[o]=s%Ti|0,a=s/Ti|0;return a&&r.unshift(a),r}function e(r,i,s,a){var o,l;if(s!=a)l=s>a?1:-1;else for(o=l=0;o<s;o++)if(r[o]!=i[o]){l=r[o]>i[o]?1:-1;break}return l}function n(r,i,s){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*Ti+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,a){var o,l,c,d,h,g,m,v,y,b,x,M,w,A,T,R,C,I,N=r.constructor,D=r.s==i.s?1:-1,z=r.d,j=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(no+"Division by zero");for(l=r.e-i.e,C=j.length,T=z.length,m=new N(D),v=m.d=[],c=0;j[c]==(z[c]||0);)++c;if(j[c]>(z[c]||0)&&--l,s==null?M=s=N.precision:a?M=s+(Zr(r)-Zr(i))+1:M=s,M<0)return new N(0);if(M=M/or+2|0,c=0,C==1)for(d=0,j=j[0],M++;(c<T||d)&&M--;c++)w=d*Ti+(z[c]||0),v[c]=w/j|0,d=w%j|0;else{for(d=Ti/(j[0]+1)|0,d>1&&(j=t(j,d),z=t(z,d),C=j.length,T=z.length),A=C,y=z.slice(0,C),b=y.length;b<C;)y[b++]=0;I=j.slice(),I.unshift(0),R=j[0],j[1]>=Ti/2&&++R;do d=0,o=e(j,y,C,b),o<0?(x=y[0],C!=b&&(x=x*Ti+(y[1]||0)),d=x/R|0,d>1?(d>=Ti&&(d=Ti-1),h=t(j,d),g=h.length,b=y.length,o=e(h,y,g,b),o==1&&(d--,n(h,C<g?I:j,g))):(d==0&&(o=d=1),h=j.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b),o==-1&&(b=y.length,o=e(j,y,C,b),o<1&&(d++,n(y,C<b?I:j,b))),b=y.length):o===0&&(d++,y=[0]),v[c++]=d,o&&y[0]?y[b++]=z[A]||0:(y=[z[A]],b=1);while((A++<T||y[0]!==void 0)&&M--)}return v[0]||v.shift(),m.e=l,Zn(m,a?s+Zr(m)+1:s)}})();function HZ(t,e){var n,r,i,s,a,o,l=0,c=0,d=t.constructor,h=d.precision;if(Zr(t)>16)throw Error(kO+Zr(t));if(!t.s)return new d(ha);for(hr=!1,o=h,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),c+=5;for(r=Math.log(Kd(2,c))/Math.LN10*2+5|0,o+=r,n=i=s=new d(ha),d.precision=o;;){if(i=Zn(i.times(t),o),n=n.times(++l),a=s.plus(gc(i,n,o)),tl(a.d).slice(0,o)===tl(s.d).slice(0,o)){for(;c--;)s=Zn(s.times(s),o);return d.precision=h,e==null?(hr=!0,Zn(s,h)):s}s=a}}function Zr(t){for(var e=t.e*or,n=t.d[0];n>=10;n/=10)e++;return e}function hN(t,e,n){if(e>t.LN10.sd())throw hr=!0,n&&(t.precision=n),Error(no+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Cu(t){for(var e="";t--;)e+="0";return e}function B0(t,e){var n,r,i,s,a,o,l,c,d,h=1,g=10,m=t,v=m.d,y=m.constructor,b=y.precision;if(m.s<1)throw Error(no+(m.s?"NaN":"-Infinity"));if(m.eq(ha))return new y(0);if(e==null?(hr=!1,c=b):c=e,m.eq(10))return e==null&&(hr=!0),hN(y,c);if(c+=g,y.precision=c,n=tl(v),r=n.charAt(0),s=Zr(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=tl(m.d),r=n.charAt(0),h++;s=Zr(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return l=hN(y,c+2,b).times(s+""),m=B0(new y(r+"."+n.slice(1)),c-g).plus(l),y.precision=b,e==null?(hr=!0,Zn(m,b)):m;for(o=a=m=gc(m.minus(ha),m.plus(ha),c),d=Zn(m.times(m),c),i=3;;){if(a=Zn(a.times(d),c),l=o.plus(gc(a,new y(i),c)),tl(l.d).slice(0,c)===tl(o.d).slice(0,c))return o=o.times(2),s!==0&&(o=o.plus(hN(y,c+2,b).times(s+""))),o=gc(o,new y(h),c),y.precision=b,e==null?(hr=!0,Zn(o,b)):o;o=l,i+=2}}function J$(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=Wm(n/or),t.d=[],r=(n+1)%or,n<0&&(r+=or),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=or;r<i;)t.d.push(+e.slice(r,r+=or));e=e.slice(r),r=or-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),hr&&(t.e>$S||t.e<-$S))throw Error(kO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var r,i,s,a,o,l,c,d,h=t.d;for(a=1,s=h[0];s>=10;s/=10)a++;if(r=e-a,r<0)r+=or,i=e,c=h[d=0];else{if(d=Math.ceil((r+1)/or),s=h.length,d>=s)return t;for(c=s=h[d],a=1;s>=10;s/=10)a++;r%=or,i=r-or+a}if(n!==void 0&&(s=Kd(10,a-i-1),o=c/s%10|0,l=e<0||h[d+1]!==void 0||c%s,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/Kd(10,a-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return l?(s=Zr(t),h.length=1,e=e-s-1,h[0]=Kd(10,(or-e%or)%or),t.e=Wm(-e/or)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=d,s=1,d--):(h.length=d+1,s=Kd(10,or-r),h[d]=i>0?(c/Kd(10,a-i)%Kd(10,i)|0)*s:0),l)for(;;)if(d==0){(h[0]+=s)==Ti&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=Ti)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(hr&&(t.e>$S||t.e<-$S))throw Error(kO+Zr(t));return t}function $Z(t,e){var n,r,i,s,a,o,l,c,d,h,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),hr?Zn(e,m):e;if(l=t.d,h=e.d,r=e.e,c=t.e,l=l.slice(),a=c-r,a){for(d=a<0,d?(n=l,a=-a,o=h.length):(n=h,r=c,o=l.length),i=Math.max(Math.ceil(m/or),o)+2,a>i&&(a=i,n.length=1),n.reverse(),i=a;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=h.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(l[i]!=h[i]){d=l[i]<h[i];break}a=0}for(d&&(n=l,l=h,h=n,e.s=-e.s),o=l.length,i=h.length-o;i>0;--i)l[o++]=0;for(i=h.length;i>a;){if(l[--i]<h[i]){for(s=i;s&&l[--s]===0;)l[s]=Ti-1;--l[s],l[i]+=Ti}l[i]-=h[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,hr?Zn(e,m):e):new g(0)}function Kf(t,e,n){var r,i=Zr(t),s=tl(t.d),a=s.length;return e?(n&&(r=n-a)>0?s=s.charAt(0)+"."+s.slice(1)+Cu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Cu(-i-1)+s,n&&(r=n-a)>0&&(s+=Cu(r))):i>=a?(s+=Cu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Cu(r))):((r=i+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-a)>0&&(i+1===a&&(s+="."),s+=Cu(r))),t.s<0?"-"+s:s}function eV(t,e){if(t.length>e)return t.length=e,!0}function VZ(t){var e,n,r;function i(s){var a=this;if(!(a instanceof i))return new i(s);if(a.constructor=i,s instanceof i){a.s=s.s,a.e=s.e,a.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(Mf+s);if(s>0)a.s=1;else if(s<0)s=-s,a.s=-1;else{a.s=0,a.e=0,a.d=[0];return}if(s===~~s&&s<1e7){a.e=0,a.d=[s];return}return J$(a,s.toString())}else if(typeof s!="string")throw Error(Mf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,FIe.test(s))J$(a,s);else throw Error(Mf+s)}if(i.prototype=Nt,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=VZ,i.config=i.set=zIe,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 zIe(t){if(!t||typeof t!="object")throw Error(no+"Object expected");var e,n,r,i=["precision",1,Gm,"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(Wm(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Mf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Mf+n+": "+r);return this}var RO=VZ(UIe);ha=new RO(1);const jn=RO;var BIe=t=>t,GZ={},WZ=t=>t===GZ,tV=t=>function e(){return arguments.length===0||arguments.length===1&&WZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},qZ=(t,e)=>t===1?e:tV(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(a=>a!==GZ).length;return s>=t?e(...r):qZ(t-s,tV(function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];var c=r.map(d=>WZ(d)?o.shift():d);return e(...c,...o)}))}),HIe=t=>qZ(t.length,t),SR=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},$Ie=HIe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),VIe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return BIe;var i=n.reverse(),s=i[0],a=i.slice(1);return function(){return a.reduce((o,l)=>l(o),s(...arguments))}},wR=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function XZ(t){var e;return t===0?e=1:e=Math.floor(new jn(t).abs().log(10).toNumber())+1,e}function KZ(t,e,n){for(var r=new jn(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var YZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},ZZ=(t,e,n)=>{if(t.lte(0))return new jn(0);var r=XZ(t.toNumber()),i=new jn(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new jn(Math.ceil(s.div(a).toNumber())).add(n).mul(a),l=o.mul(i);return e?new jn(l.toNumber()):new jn(Math.ceil(l.toNumber()))},GIe=(t,e,n)=>{var r=new jn(1),i=new jn(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new jn(10).pow(XZ(t)-1),i=new jn(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new jn(Math.floor(t)))}else t===0?i=new jn(Math.floor((e-1)/2)):n||(i=new jn(Math.floor(t)));var a=Math.floor((e-1)/2),o=VIe($Ie(l=>i.add(new jn(l-a).mul(r)).toNumber()),SR);return o(0,e)},QZ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new jn(0),tickMin:new jn(0),tickMax:new jn(0)};var a=ZZ(new jn(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new jn(0):(o=new jn(e).add(n).div(2),o=o.sub(new jn(o).mod(a)));var l=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new jn(n).sub(o).div(a).toNumber()),d=l+c+1;return d>r?QZ(e,n,r,i,s+1):(d<r&&(c=n>0?c+(r-d):c,l=n>0?l:l+(r-d)),{step:a,tickMin:o.sub(new jn(l).mul(a)),tickMax:o.add(new jn(c).mul(a))})},WIe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(i,2),[o,l]=YZ([n,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...SR(0,i-1).map(()=>1/0)]:[...SR(0,i-1).map(()=>-1/0),l];return n>r?wR(c):c}if(o===l)return GIe(o,i,s);var{step:d,tickMin:h,tickMax:g}=QZ(o,l,a,s,0),m=KZ(h,g.add(new jn(.1).mul(d)),d);return n>r?wR(m):m},qIe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=YZ([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var l=Math.max(n,2),c=ZZ(new jn(o).sub(a).div(l-1),s,0),d=[...KZ(new jn(a),new jn(o),c),o];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?wR(d):d},JZ=t=>t.rootProps.maxBarSize,XIe=t=>t.rootProps.barGap,eQ=t=>t.rootProps.barCategoryGap,KIe=t=>t.rootProps.barSize,yb=t=>t.rootProps.stackOffset,tQ=t=>t.rootProps.reverseStackOrder,PO=t=>t.options.chartName,DO=t=>t.rootProps.syncId,nQ=t=>t.rootProps.syncMethod,OO=t=>t.options.eventEmitter,YIe=t=>t.rootProps.baseValue,Kr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},ec={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ua={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},vM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},ZIe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:ec.angleAxisId,includeHidden:!1,name:void 0,reversed:ec.reversed,scale:ec.scale,tick:ec.tick,tickCount:void 0,ticks:void 0,type:ec.type,unit:void 0},QIe={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,ticks:void 0,type:ua.type,unit:void 0},JIe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:ec.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ec.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ec.scale,tick:ec.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},e4e={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.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"?JIe:ZIe,jO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?e4e:QIe,yM=t=>t.polarOptions,IO=We([Rc,Pc,pi],eZ),rQ=We([yM,IO],(t,e)=>{if(t!=null)return us(t.innerRadius,e,0)}),iQ=We([yM,IO],(t,e)=>{if(t!=null)return us(t.outerRadius,e,e*.8)}),t4e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},sQ=We([yM],t4e);We([LO,sQ],vM);var aQ=We([IO,rQ,iQ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});We([jO,aQ],vM);var oQ=We([Sn,yM,rQ,iQ,Rc,Pc],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:a,cy:o,startAngle:l,endAngle:c}=e;return{cx:us(a,i,i/2),cy:us(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:c,clockWise:!1}}}),pr=(t,e)=>e,_b=(t,e,n)=>n;function _M(t){return t?.id}function lQ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=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 d=_M(o);c.forEach((h,g)=>{var m=s==null||i?g:String(Yn(h,s,null)),v=Yn(h,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[d]:v}),a.set(m,y)})}}),Array.from(a.values())}function SM(t){return t.stackId!=null&&t.dataKey!=null}var wM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function MM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function n4e(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 gi=t=>{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},qm=t=>t.tooltip.settings.axisId;function nV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function VS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nV(Object(n),!0).forEach(function(r){r4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r4e(t,e,n){return(e=i4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i4e(t){var e=s4e(t,"string");return typeof e=="symbol"?e:e+""}function s4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 MR=[0,"auto"],Ei={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},cQ=(t,e)=>t.cartesianAxis.xAxis[e],Oc=(t,e)=>{var n=cQ(t,e);return n??Ei},Ai={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:MR,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:fb},uQ=(t,e)=>t.cartesianAxis.yAxis[e],Lc=(t,e)=>{var n=uQ(t,e);return n??Ai},a4e={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:""},UO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??a4e},_r=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);case"zAxis":return UO(t,n);case"angleAxis":return LO(t,n);case"radiusAxis":return jO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},o4e=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Sb=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return Lc(t,n);case"angleAxis":return LO(t,n);case"radiusAxis":return jO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dQ=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 EM=t=>t.graphicalItems.cartesianItems,l4e=We([pr,_b],FO),zO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),wb=We([EM,_r,l4e],zO,{memoizeOptions:{resultEqualityCheck:MM}}),fQ=We([wb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(SM)),hQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),c4e=We([wb],hQ),BO=t=>t.map(e=>e.data).filter(Boolean).flat(1),u4e=We([wb],BO,{memoizeOptions:{resultEqualityCheck:MM}}),HO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},$O=We([u4e,bM],HO),VO=(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})),AM=We([$O,_r,wb],VO);function pQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function G_(t){if(ul(t)||t instanceof Date){var e=Number(t);if(cr(e))return e}}function rV(t){if(Array.isArray(t)){var e=[G_(t[0]),G_(t[1])];return id(e)?e:void 0}var n=G_(t);if(n!=null)return[n,n]}function Tc(t){return t.map(G_).filter(cke)}function d4e(t,e,n){return!n||typeof e!="number"||eo(e)?[]:n.length?Tc(n.flatMap(r=>{var i=Yn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!cr(s)||!cr(a)))return[e-s,e+a]})):[]}var xi=t=>{var e=gi(t),n=qm(t);return Sb(t,e,n)},Mb=We([xi],t=>t?.dataKey),f4e=We([fQ,bM,xi],lQ),mQ=(t,e,n,r)=>{var i={},s=e.reduce((a,o)=>(o.stackId==null||(a[o.stackId]==null&&(a[o.stackId]=[]),a[o.stackId].push(o)),a),i);return Object.fromEntries(Object.entries(s).map(a=>{var[o,l]=a,c=r?[...l].reverse():l,d=c.map(_M);return[o,{stackedData:RPe(t,d,n),graphicalItems:c}]}))},H0=We([f4e,fQ,yb,tQ],mQ),gQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=LPe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},h4e=We([_r],t=>t.allowDataOverflow),GO=t=>{var e;if(t==null||!("domain"in t))return MR;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Tc(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:MR},WO=We([_r],GO),qO=We([WO,h4e],FZ),p4e=We([H0,xd,pr,qO],gQ,{memoizeOptions:{resultEqualityCheck:wM}}),TM=t=>t.errorBars,m4e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>pQ(n,r)),GS=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 s=i.flat(),a=Math.min(...s),o=Math.max(...s);return[a,o]}},XO=(t,e,n,r,i)=>{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,d,h=(c=r[l.id])===null||c===void 0?void 0:c.filter(x=>pQ(i,x)),g=Yn(o,(d=e.dataKey)!==null&&d!==void 0?d:l.dataKey),m=d4e(o,g,h);if(m.length>=2){var v=Math.min(...m),y=Math.max(...m);(s==null||v<s)&&(s=v),(a==null||y>a)&&(a=y)}var b=rV(g);b!=null&&(s=s==null?b[0]:Math.min(s,b[0]),a=a==null?b[1]:Math.max(a,b[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=rV(Yn(o,e.dataKey));l!=null&&(s=s==null?l[0]:Math.min(s,l[0]),a=a==null?l[1]:Math.max(a,l[1]))}),cr(s)&&cr(a))return[s,a]},g4e=We([$O,_r,c4e,TM,pr],XO,{memoizeOptions:{resultEqualityCheck:wM}});function x4e(t){var{value:e}=t;if(ul(e)||e instanceof Date)return e}var b4e=(t,e,n)=>{var r=t.map(x4e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&RK(r))?iZ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},xQ=t=>t.referenceElements.dots,Xm=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),v4e=We([xQ,pr,_b],Xm),bQ=t=>t.referenceElements.areas,y4e=We([bQ,pr,_b],Xm),vQ=t=>t.referenceElements.lines,_4e=We([vQ,pr,_b],Xm),yQ=(t,e)=>{var n=Tc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},S4e=We(v4e,pr,yQ),_Q=(t,e)=>{var n=Tc(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)]},w4e=We([y4e,pr],_Q);function M4e(t){var e;if(t.x!=null)return Tc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Tc(n)}function E4e(t){var e;if(t.y!=null)return Tc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Tc(n)}var SQ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?M4e(r):E4e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},A4e=We([_4e,pr],SQ),T4e=We(S4e,A4e,w4e,(t,e,n)=>GS(t,n,e)),KO=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var l=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",c=l?GS(r,s,i):GS(s,i);return IIe(e,c,t.allowDataOverflow)},C4e=We([_r,WO,qO,p4e,g4e,T4e,Sn,pr],KO,{memoizeOptions:{resultEqualityCheck:wM}}),N4e=[0,1],YO=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:l}=t,c=kc(e,s);if(c&&o==null){var d;return iZ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return l==="category"?b4e(r,t,c):i==="expand"?N4e:a}},ZO=We([_r,Sn,$O,AM,yb,pr,C4e],YO),wQ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:a}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":a==="category"?"band":"linear";if(typeof s=="string"){var o="scale".concat(ab(s));return o in Mx?o:"point"}}},Km=We([_r,Sn,dQ,PO,pr],wQ);function k4e(t){if(t!=null){if(t in Mx)return Mx[t]();var e="scale".concat(ab(t));if(e in Mx)return Mx[e]()}}function QO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=k4e(e);if(i!=null){var s=i.domain(n).range(r);return APe(s),s}}}var JO=(t,e,n)=>{var r=GO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&id(t))return WIe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&id(t))return qIe(t,e.tickCount,e.allowDecimals)}},eL=We([ZO,Sb,Km],JO),tL=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&id(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],a=e[1],o=n[n.length-1];return[Math.min(i,s),Math.max(a,o)]}return e},R4e=We([_r,ZO,eL,pr],tL),P4e=We(AM,_r,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Tc(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 s=0;s<r.length-1;s++){var a=r[s+1]-r[s];n=Math.min(n,a)}return n/i}}),MQ=We(P4e,Sn,eQ,pi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!cr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=us(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),D4e=(t,e)=>{var n=Oc(t,e);return n==null||typeof n.padding!="string"?0:MQ(t,"xAxis",e,n.padding)},O4e=(t,e)=>{var n=Lc(t,e);return n==null||typeof n.padding!="string"?0:MQ(t,"yAxis",e,n.padding)},L4e=We(Oc,D4e,(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}}),j4e=We(Lc,O4e,(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}}),I4e=We([pi,L4e,aM,sM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),U4e=We([pi,Sn,j4e,aM,sM,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:a}=i;return s?[r.height-a.bottom,a.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Eb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return I4e(t,n,r);case"yAxis":return U4e(t,n,r);case"zAxis":return(i=UO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return sQ(t);case"radiusAxis":return aQ(t,n);default:return}},EQ=We([_r,Eb],vM),Ym=We([_r,Km,R4e,EQ],QO);We([wb,TM,pr],m4e);function AQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var CM=(t,e)=>e,NM=(t,e,n)=>n,F4e=We(rM,CM,NM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(AQ)),z4e=We(iM,CM,NM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(AQ)),TQ=(t,e)=>({width:t.width,height:e.height}),B4e=(t,e)=>{var n=typeof e.width=="number"?e.width:fb;return{width:n,height:t.height}},CQ=We(pi,Oc,TQ),H4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},$4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},V4e=We(Pc,pi,F4e,CM,NM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=TQ(e,o);a==null&&(a=H4e(e,r,t));var c=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(c)*l.height,a+=(c?-1:1)*l.height}),s}),G4e=We(Rc,pi,z4e,CM,NM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=B4e(e,o);a==null&&(a=$4e(e,r,t));var c=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(c)*l.width,a+=(c?-1:1)*l.width}),s}),W4e=(t,e)=>{var n=Oc(t,e);if(n!=null)return V4e(t,n.orientation,n.mirror)},q4e=We([pi,Oc,W4e,(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}}}),X4e=(t,e)=>{var n=Lc(t,e);if(n!=null)return G4e(t,n.orientation,n.mirror)},K4e=We([pi,Lc,X4e,(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}}}),NQ=We(pi,Lc,(t,e)=>{var n=typeof e.width=="number"?e.width:fb;return{width:n,height:t.height}}),iV=(t,e,n)=>{switch(e){case"xAxis":return CQ(t,n).width;case"yAxis":return NQ(t,n).height;default:return}},kQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=kc(t,r),l=e.map(c=>c.value);if(a&&o&&s==="category"&&i&&RK(l))return l}},nL=We([Sn,AM,_r,pr],kQ),RQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=kc(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},rL=We([Sn,AM,Sb,pr],RQ),sV=We([Sn,o4e,Km,Ym,nL,rL,Eb,eL,pr],(t,e,n,r,i,s,a,o,l)=>{if(e!=null){var c=kc(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:s,duplicateDomain:i,isCategorical:c,niceTicks:o,range:a,realScaleType:n,scale:r}}}),Y4e=(t,e,n,r,i,s,a,o,l)=>{if(!(e==null||r==null)){var c=kc(t,l),{type:d,ticks:h,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,v=d==="category"&&r.bandwidth?r.bandwidth()/m:0;v=l==="angleAxis"&&s!=null&&s.length>=2?ki(s[0]-s[1])*2*v:v;var y=h||i;if(y){var b=y.map((x,M)=>{var w=a?a.indexOf(x):x;return{index:M,coordinate:r(w)+v,value:x,offset:v}});return b.filter(x=>cr(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:r(x)+v,value:x,index:M,offset:v})).filter(x=>cr(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+v,value:x,offset:v})):r.domain().map((x,M)=>({coordinate:r(x)+v,value:a?a[x]:x,index:M,offset:v}))}},PQ=We([Sn,Sb,Km,Ym,eL,Eb,nL,rL,pr],Y4e),Z4e=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=kc(t,a),{tickCount:l}=e,c=0;return c=a==="angleAxis"&&r?.length>=2?ki(r[0]-r[1])*2*c:c,o&&s?s.map((d,h)=>({coordinate:n(d)+c,value:d,index:h,offset:c})):n.ticks?n.ticks(l).map(d=>({coordinate:n(d)+c,value:d,offset:c})):n.domain().map((d,h)=>({coordinate:n(d)+c,value:i?i[d]:d,index:h,offset:c}))}},sd=We([Sn,Sb,Ym,Eb,nL,rL,pr],Z4e),ad=We(_r,Ym,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})}),Q4e=We([_r,Km,ZO,EQ],QO);We((t,e,n)=>UO(t,n),Q4e,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})});var J4e=We([Sn,rM,iM],(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}}),DQ=t=>t.options.defaultTooltipEventType,OQ=t=>t.options.validateTooltipEventTypes;function LQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function iL(t,e){var n=DQ(t),r=OQ(t);return LQ(e,n,r)}function eUe(t){return Ct(e=>iL(e,t))}var jQ=(t,e)=>{var n,r=Number(e);if(!(eo(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},tUe=t=>t.tooltip.settings,Du={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},nUe={itemInteraction:{click:Du,hover:Du},axisInteraction:{click:Du,hover:Du},keyboardInteraction:Du,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}},IQ=Zs({name:"tooltip",initialState:nUe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:dr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:dr()},removeTooltipEntrySettings:{reducer(t,e){var n=To(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:dr()},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:rUe,replaceTooltipEntrySettings:iUe,removeTooltipEntrySettings:sUe,setTooltipSettingsState:aUe,setActiveMouseOverItemIndex:UQ,mouseLeaveItem:oUe,mouseLeaveChart:FQ,setActiveClickItemIndex:lUe,setMouseOverAxisIndex:zQ,setMouseClickAxisIndex:cUe,setSyncInteraction:ER,setKeyboardInteraction:AR}=IQ.actions,uUe=IQ.reducer;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 x_(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){dUe(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 dUe(t,e,n){return(e=fUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fUe(t){var e=hUe(t,"string");return typeof e=="symbol"?e:e+""}function hUe(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 pUe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function mUe(t){return t.index!=null}var BQ=(t,e,n,r)=>{if(e==null)return Du;var i=pUe(t,e,n);if(i==null)return Du;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(mUe(i)){if(s)return x_(x_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return x_(x_({},Du),{},{coordinate:i.coordinate})};function gUe(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 xUe(t,e){var n=gUe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),a=Math.max(r,i);return n>=s&&n<=a}function bUe(t,e,n){if(n==null||e==null)return!0;var r=Yn(t,e);return r==null||!id(n)?!0:xUe(r,n)}var sL=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!cr(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(a,Math.min(s,o)),c=e[l];return c==null||bUe(c,n,r)?String(l):null},HQ=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var l=a[0],c=l==null?void 0:o(l.positions,s);if(c!=null)return c;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},$Q=(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(s=>{var a;return((a=s.settings)===null||a===void 0?void 0:a.dataKey)===i})},Ab=t=>t.options.tooltipPayloadSearcher,Zm=t=>t.tooltip;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){vUe(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 vUe(t,e,n){return(e=yUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yUe(t){var e=_Ue(t,"string");return typeof e=="symbol"?e:e+""}function _Ue(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 SUe(t,e){return t??e}var VQ=(t,e,n,r,i,s,a)=>{if(!(e==null||s==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:d}=n,h=[];return t.reduce((g,m)=>{var v,{dataDefinedOnItem:y,settings:b}=m,x=SUe(y,o),M=Array.isArray(x)?EY(x,c,d):x,w=(v=b?.dataKey)!==null&&v!==void 0?v:r,A=b?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&a==="axis"?T=PK(M,r,i):T=s(M,e,l,A),Array.isArray(T))T.forEach(C=>{var I=lV(lV({},b),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});g.push(CH({tooltipEntrySettings:I,dataKey:C.dataKey,payload:C.payload,value:Yn(C.payload,C.dataKey),name:C.name}))});else{var R;g.push(CH({tooltipEntrySettings:b,dataKey:w,payload:T,value:Yn(T,w),name:(R=Yn(T,A))!==null&&R!==void 0?R:b?.name}))}return g},h)}},aL=We([xi,Sn,dQ,PO,gi],wQ),wUe=We([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),MUe=We([gi,qm],FO),Tb=We([wUe,xi,MUe],zO,{memoizeOptions:{resultEqualityCheck:MM}}),EUe=We([Tb],t=>t.filter(SM)),AUe=We([Tb],BO,{memoizeOptions:{resultEqualityCheck:MM}}),Qm=We([AUe,xd],HO),TUe=We([EUe,xd,xi],lQ),oL=We([Qm,xi,Tb],VO),GQ=We([xi],GO),CUe=We([xi],t=>t.allowDataOverflow),WQ=We([GQ,CUe],FZ),NUe=We([Tb],t=>t.filter(SM)),kUe=We([TUe,NUe,yb,tQ],mQ),RUe=We([kUe,xd,gi,WQ],gQ),PUe=We([Tb],hQ),DUe=We([Qm,xi,PUe,TM,gi],XO,{memoizeOptions:{resultEqualityCheck:wM}}),OUe=We([xQ,gi,qm],Xm),LUe=We([OUe,gi],yQ),jUe=We([bQ,gi,qm],Xm),IUe=We([jUe,gi],_Q),UUe=We([vQ,gi,qm],Xm),FUe=We([UUe,gi],SQ),zUe=We([LUe,FUe,IUe],GS),BUe=We([xi,GQ,WQ,RUe,DUe,zUe,Sn,gi],KO),Cb=We([xi,Sn,Qm,oL,yb,gi,BUe],YO),HUe=We([Cb,xi,aL],JO),$Ue=We([xi,Cb,HUe,gi],tL),qQ=t=>{var e=gi(t),n=qm(t),r=!1;return Eb(t,e,n,r)},XQ=We([xi,qQ],vM),KQ=We([xi,aL,$Ue,XQ],QO),VUe=We([Sn,oL,xi,gi],kQ),GUe=We([Sn,oL,xi,gi],RQ),WUe=(t,e,n,r,i,s,a,o)=>{if(e){var{type:l}=e,c=kc(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=l==="category"&&r.bandwidth?r.bandwidth()/d:0;return h=o==="angleAxis"&&i!=null&&i?.length>=2?ki(i[0]-i[1])*2*h:h,c&&a?a.map((g,m)=>({coordinate:r(g)+h,value:g,index:m,offset:h})):r.domain().map((g,m)=>({coordinate:r(g)+h,value:s?s[g]:g,index:m,offset:h}))}}},jc=We([Sn,xi,aL,KQ,qQ,VUe,GUe,gi],WUe),lL=We([DQ,OQ,tUe],(t,e,n)=>LQ(n.shared,t,e)),YQ=t=>t.tooltip.settings.trigger,cL=t=>t.tooltip.settings.defaultIndex,Nb=We([Zm,lL,YQ,cL],BQ),od=We([Nb,Qm,Mb,Cb],sL),ZQ=We([jc,od],jQ),uL=We([Nb],t=>{if(t)return t.dataKey}),qUe=We([Nb],t=>{if(t)return t.graphicalItemId}),QQ=We([Zm,lL,YQ,cL],$Q),XUe=We([Rc,Pc,Sn,pi,jc,cL,QQ,Ab],HQ),KUe=We([Nb,XUe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),YUe=We([Nb],t=>t.active),ZUe=We([QQ,od,xd,Mb,ZQ,Ab,lL],VQ),QUe=We([ZUe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function cV(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 uV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cV(Object(n),!0).forEach(function(r){JUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JUe(t,e,n){return(e=eFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eFe(t){var e=tFe(t,"string");return typeof e=="symbol"?e:e+""}function tFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 nFe=()=>Ct(xi),rFe=()=>{var t=nFe(),e=Ct(jc),n=Ct(KQ);return _m(!t||!n?void 0:uV(uV({},t),{},{scale:n}),e)};function dV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dV(Object(n),!0).forEach(function(r){iFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iFe(t,e,n){return(e=sFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sFe(t){var e=aFe(t,"string");return typeof e=="symbol"?e:e+""}function aFe(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 oFe=(t,e,n,r)=>{var i=e.find(s=>s&&s.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}},lFe=(t,e,n,r)=>{var i=e.find(c=>c&&c.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:a}=r;return yp(yp(yp({},r),Xr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:l}=r;return yp(yp(yp({},r),Xr(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 cFe(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 JQ=(t,e,n,r,i)=>{var s,a=-1,o=(s=e?.length)!==null&&s!==void 0?s: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,d=n[l].coordinate,h=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(ki(d-c)!==ki(h-d)){var m=[];if(ki(h-d)===ki(i[1]-i[0])){g=h;var v=d+i[1]-i[0];m[0]=Math.min(v,(v+c)/2),m[1]=Math.max(v,(v+c)/2)}else{g=c;var y=h+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>b[0]&&t<=b[1]||t>=m[0]&&t<=m[1]){({index:a}=n[l]);break}}else{var x=Math.min(c,h),M=Math.max(c,h);if(t>(x+d)/2&&t<=(M+d)/2){({index:a}=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:a}=e[w]);break}}return a},eJ=()=>Ct(PO),dL=(t,e)=>e,tJ=(t,e,n)=>n,fL=(t,e,n,r)=>r,uFe=We(jc,t=>Xw(t,e=>e.coordinate)),hL=We([Zm,dL,tJ,fL],BQ),pL=We([hL,Qm,Mb,Cb],sL),dFe=(t,e,n)=>{if(e!=null){var r=Zm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},nJ=We([Zm,dL,tJ,fL],$Q),WS=We([Rc,Pc,Sn,pi,jc,fL,nJ,Ab],HQ),fFe=We([hL,WS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),rJ=We([jc,pL],jQ),hFe=We([nJ,pL,xd,Mb,rJ,Ab,dL],VQ),pFe=We([hL,pL],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),mFe=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&cFe(t,a)){var o=jPe(t,e),l=JQ(o,s,i,n,r),c=oFe(e,i,l,t);return{activeIndex:String(l),activeCoordinate:c}}},gFe=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=JOe(t,n);if(o){var l=IPe(o,e),c=JQ(l,a,s,r,i),d=lFe(e,s,c,o);return{activeIndex:String(c),activeCoordinate:d}}}},xFe=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?mFe(t,e,r,i,s,a,o):gFe(t,e,n,r,i,s,a)},bFe=We(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}}),vFe=We(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Kr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:n4e}});function fV(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 hV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fV(Object(n),!0).forEach(function(r){yFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fV(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)}var wFe={},MFe={zIndexMap:Object.values(Kr).reduce((t,e)=>hV(hV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),wFe)},EFe=new Set(Object.values(Kr));function AFe(t){return EFe.has(t)}var iJ=Zs({name:"zIndex",initialState:MFe,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:dr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!AFe(n)&&delete t.zIndexMap[n])},prepare:dr()},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:dr()},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:dr()}}}),{registerZIndexPortal:TFe,unregisterZIndexPortal:CFe,registerZIndexPortalId:NFe,unregisterZIndexPortalId:kFe}=iJ.actions,RFe=iJ.reducer;function Qs(t){var{zIndex:e,children:n}=t,r=mDe(),i=r&&e!==void 0&&e!==0,s=hs(),a=nr();E.useLayoutEffect(()=>i?(a(TFe({zIndex:e})),()=>{a(CFe({zIndex:e}))}):ob,[a,e,i]);var o=Ct(c=>bFe(c,e,s));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?nc.createPortal(n,l):null}function TR(){return TR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},TR.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 b_(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){PFe(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 PFe(t,e,n){return(e=DFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DFe(t){var e=OFe(t,"string");return typeof e=="symbol"?e:e+""}function OFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 LFe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function jFe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:a,layout:o,cursor:l,tooltipEventType:c,chartName:d}=t,h=n,g=r,m=i;if(!l||!h||d!=="ScatterChart"&&c!=="axis")return null;var v,y,b;if(d==="ScatterChart")v=h,y=pOe,b=Kr.cursorLine;else if(d==="BarChart")v=mOe(o,h,s,a),y=JY,b=Kr.cursorRectangle;else if(o==="radial"&&OK(h)){var{cx:x,cy:M,radius:w,startAngle:A,endAngle:T}=tZ(h);v={cx:x,cy:M,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},y=rZ,b=Kr.cursorLine}else v={points:rLe(o,h,s)},y=Xp,b=Kr.cursorLine;var R=typeof l=="object"&&"className"in l?l.className:void 0,C=b_(b_(b_(b_({stroke:"#ccc",pointerEvents:"none"},s),v),Gf(l)),{},{payload:g,payloadIndex:m,className:An("recharts-tooltip-cursor",R)});return E.createElement(Qs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},E.createElement(LFe,{cursor:l,cursorComp:y,cursorProps:C}))}function IFe(t){var e=rFe(),n=jY(),r=Hm(),i=eJ();return e==null||n==null||r==null||i==null?null:E.createElement(jFe,TR({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var sJ=E.createContext(null),UFe=()=>E.useContext(sJ),pN={exports:{}},mV;function FFe(){return mV||(mV=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,d){this.fn=l,this.context=c,this.once=d||!1}function s(l,c,d,h,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,h||l,g),v=n?n+c:c;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],m]:l._events[v].push(m):(l._events[v]=m,l._eventsCount++),l}function a(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=[],d,h;if(this._eventsCount===0)return c;for(h in d=this._events)e.call(d,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c},o.prototype.listeners=function(c){var d=n?n+c:c,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,m=h.length,v=new Array(m);g<m;g++)v[g]=h[g].fn;return v},o.prototype.listenerCount=function(c){var d=n?n+c:c,h=this._events[d];return h?h.fn?1:h.length:0},o.prototype.emit=function(c,d,h,g,m,v){var y=n?n+c:c;if(!this._events[y])return!1;var b=this._events[y],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,d),!0;case 3:return b.fn.call(b.context,d,h),!0;case 4:return b.fn.call(b.context,d,h,g),!0;case 5:return b.fn.call(b.context,d,h,g,m),!0;case 6:return b.fn.call(b.context,d,h,g,m,v),!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,d);break;case 3:b[w].fn.call(b[w].context,d,h);break;case 4:b[w].fn.call(b[w].context,d,h,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,d,h){return s(this,c,d,h,!1)},o.prototype.once=function(c,d,h){return s(this,c,d,h,!0)},o.prototype.removeListener=function(c,d,h,g){var m=n?n+c:c;if(!this._events[m])return this;if(!d)return a(this,m),this;var v=this._events[m];if(v.fn)v.fn===d&&(!g||v.once)&&(!h||v.context===h)&&a(this,m);else{for(var y=0,b=[],x=v.length;y<x;y++)(v[y].fn!==d||g&&!v[y].once||h&&v[y].context!==h)&&b.push(v[y]);b.length?this._events[m]=b.length===1?b[0]:b:a(this,m)}return this},o.prototype.removeAllListeners=function(c){var d;return c?(d=n?n+c:c,this._events[d]&&a(this,d)):(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})(pN)),pN.exports}var zFe=FFe();const BFe=ro(zFe);var $0=new BFe,CR="recharts.syncEvent.tooltip",gV="recharts.syncEvent.brush";function mL(t,e){if(e){var n=Number.parseInt(e,10);if(!eo(n))return t?.[n]}}var HFe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},aJ=Zs({name:"options",initialState:HFe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),$Fe=aJ.reducer,{createEventEmitter:VFe}=aJ.actions;function GFe(t){return t.tooltip.syncInteraction}var WFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},oJ=Zs({name:"chartData",initialState:WFe,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:xV,setDataStartEndIndexes:qFe,setComputedData:b9e}=oJ.actions,XFe=oJ.reducer,KFe=["x","y"];function bV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _p(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bV(Object(n),!0).forEach(function(r){YFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YFe(t,e,n){return(e=ZFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZFe(t){var e=QFe(t,"string");return typeof e=="symbol"?e:e+""}function QFe(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 JFe(t,e){if(t==null)return{};var n,r,i=e5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function e5e(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 t5e(){var t=Ct(DO),e=Ct(OO),n=nr(),r=Ct(nQ),i=Ct(jc),s=Hm(),a=oM(),o=Ct(l=>l.rootProps.className);E.useEffect(()=>{if(t==null)return ob;var l=(c,d,h)=>{if(e!==h&&t===c){if(r==="index"){var g;if(a&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x:v,y}=m,b=JFe(m,KFe),{x,y:M,width:w,height:A}=d.payload.sourceViewBox,T=_p(_p({},b),{},{x:a.x+(w?(v-x)/w:0)*a.width,y:a.y+(A?(y-M)/A:0)*a.height});n(_p(_p({},d),{},{payload:_p(_p({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var R;if(typeof r=="function"){var C={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},I=r(i,C);R=i[I]}else r==="value"&&(R=i.find(K=>String(K.value)===d.payload.label));var{coordinate:N}=d.payload;if(R==null||d.payload.active===!1||N==null||a==null){n(ER({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:z}=N,j=Math.min(D,a.x+a.width),W=Math.min(z,a.y+a.height),P={x:s==="horizontal"?R.coordinate:j,y:s==="horizontal"?W:R.coordinate},$=ER({active:d.payload.active,coordinate:P,dataKey:d.payload.dataKey,index:String(R.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n($)}}};return $0.on(CR,l),()=>{$0.off(CR,l)}},[o,n,e,t,r,i,s,a])}function n5e(){var t=Ct(DO),e=Ct(OO),n=nr();E.useEffect(()=>{if(t==null)return ob;var r=(i,s,a)=>{e!==a&&t===i&&n(qFe(s))};return $0.on(gV,r),()=>{$0.off(gV,r)}},[n,e,t])}function r5e(){var t=nr();E.useEffect(()=>{t(VFe())},[t]),t5e(),n5e()}function i5e(t,e,n,r,i,s){var a=Ct(m=>dFe(m,t,e)),o=Ct(OO),l=Ct(DO),c=Ct(nQ),d=Ct(GFe),h=d?.active,g=oM();E.useEffect(()=>{if(!h&&l!=null&&o!=null){var m=ER({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});$0.emit(CR,l,m,o)}},[h,n,a,i,r,o,l,c,s,g])}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 yV(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){s5e(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 s5e(t,e,n){return(e=a5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a5e(t){var e=o5e(t,"string");return typeof e=="symbol"?e:e+""}function o5e(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 l5e(t){return t.dataKey}function c5e(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(qDe,e)}var _V=[],u5e={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 mN(t){var e,n,r=ei(t,u5e),{active:i,allowEscapeViewBox:s,animationDuration:a,animationEasing:o,content:l,filterNull:c,isAnimationActive:d,offset:h,payloadUniqBy:g,position:m,reverseDirection:v,useTranslate3d:y,wrapperStyle:b,cursor:x,shared:M,trigger:w,defaultIndex:A,portal:T,axisId:R}=r,C=nr(),I=typeof A=="number"?String(A):A;E.useEffect(()=>{C(aUe({shared:M,trigger:w,axisId:R,active:i,defaultIndex:I}))},[C,M,w,R,i,I]);var N=oM(),D=XY(),z=eUe(M),{activeIndex:j,isActive:W}=(e=Ct(pe=>pFe(pe,z,w,I)))!==null&&e!==void 0?e:{},P=Ct(pe=>hFe(pe,z,w,I)),$=Ct(pe=>rJ(pe,z,w,I)),K=Ct(pe=>fFe(pe,z,w,I)),G=P,Z=UFe(),Q=(n=i??W)!==null&&n!==void 0?n:!1,[ee,H]=KK([G,Q]),q=z==="axis"?$:void 0;i5e(z,w,K,q,j,Q);var te=T??Z;if(te==null||N==null||z==null)return null;var ae=G??_V;Q||(ae=_V),c&&ae.length&&(ae=VK(ae.filter(pe=>pe.value!=null&&(pe.hide!==!0||r.includeHidden)),g,l5e));var xe=ae.length>0,re=E.createElement(eOe,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Q,coordinate:K,hasPayload:xe,offset:h,position:m,reverseDirection:v,useTranslate3d:y,viewBox:N,wrapperStyle:b,lastBoundingBox:ee,innerRef:H,hasPortalFromProps:!!T},c5e(l,yV(yV({},r),{},{payload:ae,label:q,active:Q,activeIndex:j,coordinate:K,accessibilityLayer:D})));return E.createElement(E.Fragment,null,nc.createPortal(re,te),Q&&E.createElement(IFe,{cursor:x,tooltipEventType:z,coordinate:K,payload:ae,index:j}))}var kb=t=>null;kb.displayName="Cell";function d5e(t,e,n){return(e=f5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f5e(t){var e=h5e(t,"string");return typeof e=="symbol"?e:e+""}function h5e(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 p5e{constructor(e){d5e(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 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 m5e(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){g5e(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 g5e(t,e,n){return(e=x5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x5e(t){var e=b5e(t,"string");return typeof e=="symbol"?e:e+""}function b5e(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 v5e={cacheSize:2e3,enableCache:!0},lJ=m5e({},v5e),wV=new p5e(lJ.cacheSize),y5e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},MV="recharts_measurement_span";function _5e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",a=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(a,"|").concat(o)}var EV=(t,e)=>{try{var n=document.getElementById(MV);n||(n=document.createElement("span"),n.setAttribute("id",MV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,y5e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Kx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||$m.isSsr)return{width:0,height:0};if(!lJ.enableCache)return EV(e,n);var r=_5e(e,n),i=wV.get(r);if(i)return i;var s=EV(e,n);return wV.set(r,s),s},AV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,TV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,S5e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,w5e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,cJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},M5e=Object.keys(cJ),Op="NaN";function E5e(t,e){return t*cJ[e]}class Fs{static parse(e){var n,[,r,i]=(n=w5e.exec(e))!==null&&n!==void 0?n:[];return new Fs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,eo(e)&&(this.unit=""),n!==""&&!S5e.test(n)&&(this.num=NaN,this.unit=""),M5e.includes(n)&&(this.num=E5e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return eo(this.num)}}function uJ(t){if(t.includes(Op))return Op;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=AV.exec(e))!==null&&n!==void 0?n:[],a=Fs.parse(r??""),o=Fs.parse(s??""),l=i==="*"?a.multiply(o):a.divide(o);if(l.isNaN())return Op;e=e.replace(AV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,d,h,g]=(c=TV.exec(e))!==null&&c!==void 0?c:[],m=Fs.parse(d??""),v=Fs.parse(g??""),y=h==="+"?m.add(v):m.subtract(v);if(y.isNaN())return Op;e=e.replace(TV,y.toString())}return e}var CV=/\(([^()]*)\)/;function A5e(t){for(var e=t,n;(n=CV.exec(e))!=null;){var[,r]=n;e=e.replace(CV,uJ(r))}return e}function T5e(t){var e=t.replace(/\s+/g,"");return e=A5e(e),e=uJ(e),e}function C5e(t){try{return T5e(t)}catch{return Op}}function gN(t){var e=C5e(t.slice(5,-1));return e===Op?"":e}var N5e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],k5e=["dx","dy","angle","className","breakAll"];function NR(){return NR=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},NR.apply(null,arguments)}function NV(t,e){if(t==null)return{};var n,r,i=R5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[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 dJ=/[ \f\n\r\t\v\u2028\u2029]+/,fJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];vr(e)||(n?i=e.toString().split(""):i=e.toString().split(dJ));var s=i.map(o=>({word:o,width:Kx(o,r).width})),a=n?0:Kx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function P5e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var hJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:a,width:o}=s,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+n<Number(e)))l.words.push(a),l.width+=o+n;else{var c={words:[a],width:o};i.push(c)}return i},[]),pJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),D5e="…",kV=(t,e,n,r,i,s,a,o)=>{var l=t.slice(0,e),c=fJ({breakAll:n,style:r,children:l+D5e});if(!c)return[!1,[]];var d=hJ(c.wordsWithComputedWidth,s,a,o),h=d.length>i||pJ(d).width>Number(s);return[h,d]},O5e=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:l}=t,c=Tt(s),d=String(a),h=hJ(e,r,n,i);if(!c||i)return h;var g=h.length>s||pJ(h).width>Number(r);if(!g)return h;for(var m=0,v=d.length-1,y=0,b;m<=v&&y<=d.length-1;){var x=Math.floor((m+v)/2),M=x-1,[w,A]=kV(d,M,l,o,s,r,n,i),[T]=kV(d,x,l,o,s,r,n,i);if(!w&&!T&&(m=x+1),w&&T&&(v=x-1),!w&&T){b=A;break}y++}return b||h},RV=t=>{var e=vr(t)?[]:t.toString().split(dJ);return[{words:e,width:void 0}]},L5e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!$m.isSsr){var o,l,c=fJ({breakAll:s,children:r,style:i});if(c){var{wordsWithComputedWidth:d,spaceWidth:h}=c;o=d,l=h}else return RV(r);return O5e({breakAll:s,children:r,maxLines:a,style:i},o,l,e,!!n)}return RV(r)},mJ="#808080",j5e={angle:0,breakAll:!1,capHeight:"0.71em",fill:mJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},kM=E.forwardRef((t,e)=>{var n=ei(t,j5e),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:d}=n,h=NV(n,N5e),g=E.useMemo(()=>L5e({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:l,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,l,h.style,h.width]),{dx:m,dy:v,angle:y,className:b,breakAll:x}=h,M=NV(h,k5e);if(!ul(r)||!ul(i)||g.length===0)return null;var w=Number(r)+(Tt(m)?m:0),A=Number(i)+(Tt(v)?v:0);if(!cr(w)||!cr(A))return null;var T;switch(d){case"start":T=gN("calc(".concat(a,")"));break;case"middle":T=gN("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:T=gN("calc(".concat(g.length-1," * -").concat(s,")"));break}var R=[];if(l){var C=g[0].width,{width:I}=h;R.push("scale(".concat(Tt(I)&&Tt(C)?I/C:1,")"))}return y&&R.push("rotate(".concat(y,", ").concat(w,", ").concat(A,")")),R.length&&(M.transform=R.join(" ")),E.createElement("text",NR({},Cs(M),{ref:e,x:w,y:A,className:An("recharts-text",b),textAnchor:c,fill:o.includes("url")?mJ:o}),g.map((N,D)=>{var z=N.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:D===0?T:s,key:"".concat(z,"-").concat(D)},z)}))});kM.displayName="Text";var I5e=["labelRef"];function U5e(t,e){if(t==null)return{};var n,r,i=F5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function F5e(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 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 Dr(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){z5e(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 z5e(t,e,n){return(e=B5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B5e(t){var e=H5e(t,"string");return typeof e=="symbol"?e:e+""}function H5e(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 tc(){return tc=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},tc.apply(null,arguments)}var gJ=E.createContext(null),$5e=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return E.createElement(gJ.Provider,{value:l},o)},xJ=()=>{var t=E.useContext(gJ),e=oM();return t||LY(e)},V5e=E.createContext(null),G5e=()=>{var t=E.useContext(V5e),e=Ct(oQ);return t||e},W5e=t=>{var{value:e,formatter:n}=t,r=vr(t.children)?e:t.children;return typeof n=="function"?n(r):r},gL=t=>t!=null&&typeof t=="function",q5e=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r},X5e=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:l,innerRadius:c,outerRadius:d,startAngle:h,endAngle:g,clockWise:m}=i,v=(c+d)/2,y=q5e(h,g),b=y>=0?1:-1,x,M;switch(e){case"insideStart":x=h+b*s,M=m;break;case"insideEnd":x=g-b*s,M=!m;break;case"end":x=g+b*s,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var w=Xr(o,l,v,x),A=Xr(o,l,v,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
  8225. A`).concat(v,",").concat(v,",0,1,").concat(M?0:1,`,
  8226. `).concat(A.x,",").concat(A.y),R=vr(t.id)?N0("recharts-radial-line-"):t.id;return E.createElement("text",tc({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",a)}),E.createElement("defs",null,E.createElement("path",{id:R,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(R)},n))},K5e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:d,y:h}=Xr(r,i,a+e,c);return{x:d,y:h,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:v}=Xr(r,i,g,c);return{x:m,y:v,textAnchor:"middle",verticalAnchor:"middle"}},kR=t=>"cx"in t&&Tt(t.cx),Y5e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!kR(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:c,height:d}=e,h=a,g=a+(l-c)/2,m=(h+g)/2,v=(l+c)/2,y=h+l/2,b=d>=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",C=A>0?"start":"end";if(i==="top"){var I={x:h+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Dr(Dr({},I),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+c/2,y:o+d+x,textAnchor:"middle",verticalAnchor:w};return Dr(Dr({},N),s?{height:Math.max(s.y+s.height-(o+d),0),width:c}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"};return Dr(Dr({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var z={x:m+v+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"};return Dr(Dr({},z),s?{width:Math.max(s.x+s.width-z.x,0),height:d}:{})}var j=s?{width:v,height:d}:{};return i==="insideLeft"?Dr({x:m+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"},j):i==="insideRight"?Dr({x:m+v-T,y:o+d/2,textAnchor:R,verticalAnchor:"middle"},j):i==="insideTop"?Dr({x:h+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},j):i==="insideBottom"?Dr({x:g+c/2,y:o+d-x,textAnchor:"middle",verticalAnchor:M},j):i==="insideTopLeft"?Dr({x:h+T,y:o+x,textAnchor:C,verticalAnchor:w},j):i==="insideTopRight"?Dr({x:h+l-T,y:o+x,textAnchor:R,verticalAnchor:w},j):i==="insideBottomLeft"?Dr({x:g+T,y:o+d-x,textAnchor:C,verticalAnchor:M},j):i==="insideBottomRight"?Dr({x:g+c-T,y:o+d-x,textAnchor:R,verticalAnchor:M},j):i&&typeof i=="object"&&(Tt(i.x)||Sc(i.x))&&(Tt(i.y)||Sc(i.y))?Dr({x:a+us(i.x,v),y:o+us(i.y,d),textAnchor:"end",verticalAnchor:"end"},j):Dr({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},j)},Z5e={angle:0,offset:5,zIndex:Kr.label,position:"middle",textBreakAll:!1};function Nu(t){var e=ei(t,Z5e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:c}=e,d=G5e(),h=xJ(),g=r==="center"?h:d??h,m,v,y;if(n==null?m=g:kR(n)?m=n:m=LY(n),!m||vr(i)&&vr(s)&&!E.isValidElement(a)&&typeof a!="function")return null;var b=Dr(Dr({},e),{},{viewBox:m});if(E.isValidElement(a)){var{labelRef:x}=b,M=U5e(b,I5e);return E.cloneElement(a,M)}if(typeof a=="function"){if(v=E.createElement(a,b),E.isValidElement(v))return v}else v=W5e(e);var w=Cs(e);if(kR(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return X5e(e,r,v,w,m);y=K5e(m,e.offset,e.position)}else y=Y5e(e,m);return E.createElement(Qs,{zIndex:e.zIndex},E.createElement(kM,tc({ref:c,className:An("recharts-label",o)},w,y,{textAnchor:P5e(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:l}),v))}Nu.displayName="Label";var Q5e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Nu,tc({key:"label-implicit"},r)):ul(t)?E.createElement(Nu,tc({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Nu?E.cloneElement(t,Dr({key:"label-implicit"},r)):E.createElement(Nu,tc({key:"label-implicit",content:t},r)):gL(t)?E.createElement(Nu,tc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Nu,tc({},t,{key:"label-implicit"},r)):null};function J5e(t){var{label:e,labelRef:n}=t,r=xJ();return Q5e(e,r,n)||null}var xN={},bN={},DV;function eze(){return DV||(DV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(bN)),bN}var vN={},OV;function tze(){return OV||(OV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(vN)),vN}var LV;function nze(){return LV||(LV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eze(),n=tze(),r=VD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(xN)),xN}var yN,jV;function rze(){return jV||(jV=1,yN=nze().last),yN}var ize=rze();const sze=ro(ize);var aze=["valueAccessor"],oze=["dataKey","clockWise","id","textBreakAll","zIndex"];function qS(){return qS=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},qS.apply(null,arguments)}function IV(t,e){if(t==null)return{};var n,r,i=lze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lze(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 cze=t=>Array.isArray(t.value)?sze(t.value):t.value,bJ=E.createContext(void 0),vJ=bJ.Provider,yJ=E.createContext(void 0),uze=yJ.Provider;function dze(){return E.useContext(bJ)}function fze(){return E.useContext(yJ)}function W_(t){var{valueAccessor:e=cze}=t,n=IV(t,aze),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=IV(n,oze),c=dze(),d=fze(),h=c||d;return!h||!h.length?null:E.createElement(Qs,{zIndex:o??Kr.label},E.createElement(jr,{className:"recharts-label-list"},h.map((g,m)=>{var v,y=vr(r)?e(g,m):Yn(g&&g.payload,r),b=vr(s)?{}:{id:"".concat(s,"-").concat(m)};return E.createElement(Nu,qS({key:"label-".concat(m)},Cs(g),l,b,{fill:(v=n.fill)!==null&&v!==void 0?v:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}W_.displayName="LabelList";function xL(t){var{label:e}=t;return e?e===!0?E.createElement(W_,{key:"labelList-implicit"}):E.isValidElement(e)||gL(e)?E.createElement(W_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(W_,qS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function RR(){return RR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},RR.apply(null,arguments)}var _J=t=>{var{cx:e,cy:n,r,className:i}=t,s=An("recharts-dot",i);return Tt(e)&&Tt(n)&&Tt(r)?E.createElement("circle",RR({},Xs(t),$D(t),{className:s,cx:e,cy:n,r})):null},SJ=t=>t.graphicalItems.polarItems,hze=We([pr,_b],FO),RM=We([SJ,_r,hze],zO),pze=We([RM],BO),PM=We([pze,NO],HO),mze=We([PM,_r,RM],VO);We([PM,_r,RM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Yn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var UV=()=>{},gze=We([PM,_r,RM,TM,pr],XO),xze=We([_r,WO,qO,UV,gze,UV,Sn,pr],KO),wJ=We([_r,Sn,PM,mze,yb,pr,xze],YO),bze=We([wJ,_r,Km],JO);We([_r,wJ,bze,pr],tL);var vze={radiusAxis:{},angleAxis:{}},MJ=Zs({name:"polarAxis",initialState:vze,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:v9e,removeRadiusAxis:y9e,addAngleAxis:_9e,removeAngleAxis:S9e}=MJ.actions,yze=MJ.reducer;function FV(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 zV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FV(Object(n),!0).forEach(function(r){_ze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _ze(t,e,n){return(e=Sze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sze(t){var e=wze(t,"string");return typeof e=="symbol"?e:e+""}function wze(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 Mze=(t,e)=>e,bL=We([SJ,Mze],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Eze=[],vL=(t,e,n)=>n?.length===0?Eze:n,EJ=We([NO,bL,vL],(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(s=>zV(zV({},e.presentationProps),s.props))),i!=null)return i}}),Aze=We([EJ,bL,vL],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Yn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Bm(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),Tze=We([EJ,bL,vL,pi],(t,e,n,r)=>{if(!(e==null||t==null))return CBe({offset:r,pieSettings:e,displayedData:t,cells:n})}),_N={exports:{}},zn={};var BV;function Cze(){if(BV)return zn;BV=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"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function v(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case l:case c:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case h:case d:return y;case s:return y;default:return b}}case e:return b}}}return zn.ContextConsumer=s,zn.ContextProvider=a,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=h,zn.Memo=d,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(y){return v(y)===s},zn.isContextProvider=function(y){return v(y)===a},zn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},zn.isForwardRef=function(y){return v(y)===o},zn.isFragment=function(y){return v(y)===n},zn.isLazy=function(y){return v(y)===h},zn.isMemo=function(y){return v(y)===d},zn.isPortal=function(y){return v(y)===e},zn.isProfiler=function(y){return v(y)===i},zn.isStrictMode=function(y){return v(y)===r},zn.isSuspense=function(y){return v(y)===l},zn.isSuspenseList=function(y){return v(y)===c},zn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===c||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===d||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},zn.typeOf=v,zn}var HV;function Nze(){return HV||(HV=1,_N.exports=Cze()),_N.exports}var kze=Nze(),$V=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",VV=null,SN=null,AJ=t=>{if(t===VV&&Array.isArray(SN))return SN;var e=[];return E.Children.forEach(t,n=>{vr(n)||(kze.isFragment(n)?e=e.concat(AJ(n.props.children)):e.push(n))}),SN=e,VV=t,e};function yL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>$V(i)):r=[$V(e)],AJ(t).forEach(i=>{var s=Wf(i,"type.displayName")||Wf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var TJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,wN={},GV;function Rze(){return GV||(GV=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})(wN)),wN}var MN,WV;function Pze(){return WV||(WV=1,MN=Rze().isPlainObject),MN}var Dze=Pze();const Oze=ro(Dze);function qV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qV(Object(n),!0).forEach(function(r){Lze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lze(t,e,n){return(e=jze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jze(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)}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)}var KV=(t,e,n,r,i)=>{var s=n-r,a;return a="M ".concat(t,",").concat(e),a+="L ".concat(t+n,",").concat(e),a+="L ".concat(t+n-s/2,",").concat(e+i),a+="L ".concat(t+n-s/2-r,",").concat(e+i),a+="L ".concat(t,",").concat(e," Z"),a},Uze={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Fze=t=>{var e=ei(t,Uze),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:d,isUpdateAnimationActive:h}=e,g=E.useRef(null),[m,v]=E.useState(-1),y=E.useRef(i),b=E.useRef(s),x=E.useRef(a),M=E.useRef(n),w=E.useRef(r),A=mb(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var P=g.current.getTotalLength();P&&v(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=An("recharts-trapezoid",o);if(!h)return E.createElement("g",null,E.createElement("path",XS({},Cs(e),{className:T,d:KV(n,r,i,s,a)})));var R=y.current,C=b.current,I=x.current,N=M.current,D=w.current,z="0px ".concat(m===-1?1:m,"px"),j="".concat(m,"px 0px"),W=KY(["strokeDasharray"],c,l);return E.createElement(pb,{animationId:A,key:A,canBegin:m>0,duration:c,easing:l,isActive:h,begin:d},P=>{var $=lr(R,i,P),K=lr(C,s,P),G=lr(I,a,P),Z=lr(N,n,P),Q=lr(D,r,P);g.current&&(y.current=$,b.current=K,x.current=G,M.current=Z,w.current=Q);var ee=P>0?{transition:W,strokeDasharray:j}:{strokeDasharray:z};return E.createElement("path",XS({},Cs(e),{className:T,d:KV(Z,Q,$,K,G),ref:g,style:XV(XV({},ee),e.style)}))})},zze=["option","shapeType","propTransformer","activeClassName"];function Bze(t,e){if(t==null)return{};var n,r,i=Hze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Hze(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 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 KS(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){$ze(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 $ze(t,e,n){return(e=Vze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vze(t){var e=Gze(t,"string");return typeof e=="symbol"?e:e+""}function Gze(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 Wze(t,e){return KS(KS({},e),t)}function qze(t,e){return t==="symbols"}function ZV(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(JY,n);case"trapezoid":return E.createElement(Fze,n);case"sector":return E.createElement(rZ,n);case"symbols":if(qze(e))return E.createElement(HD,n);break;case"curve":return E.createElement(Xp,n);default:return null}}function Xze(t){return E.isValidElement(t)?t.props:t}function CJ(t){var{option:e,shapeType:n,propTransformer:r=Wze,activeClassName:i="recharts-active-shape"}=t,s=Bze(t,zze),a;if(E.isValidElement(e))a=E.cloneElement(e,KS(KS({},s),Xze(e)));else if(typeof e=="function")a=e(s,s.index);else if(Oze(e)&&typeof e!="boolean"){var o=r(e,s);a=E.createElement(ZV,{shapeType:n,elementProps:o})}else{var l=s;a=E.createElement(ZV,{shapeType:n,elementProps:l})}return s.isActive?E.createElement(jr,{className:i},a):a}var _L=(t,e,n)=>{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(UQ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},SL=t=>{var e=nr();return(n,r)=>i=>{t?.(n,r,i),e(oUe())}},wL=(t,e,n)=>{var r=nr();return(i,s)=>a=>{t?.(i,s,a),r(lUe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function ML(t){var{tooltipEntrySettings:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(rUe(e)):i.current!==e&&n(iUe({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(sUe(i.current)),i.current=null)},[n]),null}function NJ(t){var{legendPayload:e}=t,n=nr(),r=hs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}function Kze(t){var{legendPayload:e}=t,n=nr(),r=Ct(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(VY(e)):i.current!==e&&n(GY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(WY(i.current)),i.current=null)},[n]),null}var EN,Yze=()=>{var[t]=E.useState(()=>N0("uid-"));return t},Zze=(EN=Cne.useId)!==null&&EN!==void 0?EN:Yze;function kJ(t,e){var n=Zze();return e||(t?"".concat(t,"-").concat(n):n)}var Qze=E.createContext(void 0),EL=t=>{var{id:e,type:n,children:r}=t,i=kJ("recharts-".concat(n),e);return E.createElement(Qze.Provider,{value:i},r(i))},Jze={cartesianItems:[],polarItems:[]},RJ=Zs({name:"graphicalItems",initialState:Jze,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:dr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=To(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:dr()},removeCartesianGraphicalItem:{reducer(t,e){var n=To(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:dr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:dr()},removePolarGraphicalItem:{reducer(t,e){var n=To(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:dr()}}}),{addCartesianGraphicalItem:eBe,replaceCartesianGraphicalItem:tBe,removeCartesianGraphicalItem:nBe,addPolarGraphicalItem:rBe,removePolarGraphicalItem:iBe}=RJ.actions,sBe=RJ.reducer,aBe=t=>{var e=nr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(eBe(t)):n.current!==t&&e(tBe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(nBe(n.current)),n.current=null)},[e]),null},PJ=E.memo(aBe);function oBe(t){var e=nr();return E.useLayoutEffect(()=>(e(rBe(t)),()=>{e(iBe(t))}),[e,t]),null}var lBe=["key"],cBe=["onMouseEnter","onClick","onMouseLeave"],uBe=["id"],dBe=["id"];function QV(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 Ar(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QV(Object(n),!0).forEach(function(r){fBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fBe(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=pBe(t,"string");return typeof e=="symbol"?e:e+""}function pBe(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 ld(){return ld=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},ld.apply(null,arguments)}function DM(t,e){if(t==null)return{};var n,r,i=mBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function mBe(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 gBe(t){var e=E.useMemo(()=>yL(t.children,kb),[t.children]),n=Ct(r=>Aze(r,t.id,e));return n==null?null:E.createElement(Kze,{legendPayload:n})}var xBe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:c}=t,d={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:Bm(o,e),hide:l,type:c,color:a,unit:""}};return E.createElement(ML,{tooltipEntrySettings:d})}),bBe=(t,e)=>t>e?"start":t<e?"end":"middle",vBe=(t,e,n)=>us(typeof e=="function"?e(t):e,n,n*.8),yBe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=eZ(s,a),l=i+us(t.cx,s,s/2),c=r+us(t.cy,a,a/2),d=us(t.innerRadius,o,0),h=vBe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:c,innerRadius:d,outerRadius:h,maxRadius:g}},_Be=(t,e)=>{var n=ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function SBe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var wBe=(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=DM(e,lBe);return E.createElement(Xp,ld({},i,{type:"linear",className:n}))},MBe=(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",SBe(t));return E.createElement(kM,ld({},e,{alignmentBaseline:"middle",className:i}),r)};function EBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Xs(n),l=Gf(i),c=Gf(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((g,m)=>{var v=(g.startAngle+g.endAngle)/2,y=Xr(g.cx,g.cy,g.outerRadius+d,v),b=Ar(Ar(Ar(Ar({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:bBe(y.x,g.cx)},y),x=Ar(Ar(Ar(Ar({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[Xr(g.cx,g.cy,g.outerRadius,v),y],key:"line"});return E.createElement(Qs,{zIndex:Kr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(jr,null,s&&wBe(s,x),MBe(i,b,Yn(g,a))))});return E.createElement(jr,{className:"recharts-pie-labels"},h)}function ABe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(xL,{label:i}):E.createElement(EBe,{sectors:e,props:n,showLabels:r})}function TBe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Ct(od),l=Ct(uL),c=Ct(qUe),{onMouseEnter:d,onClick:h,onMouseLeave:g}=i,m=DM(i,cBe),v=_L(d,i.dataKey,a),y=SL(g),b=wL(h,i.dataKey,a);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===a,A=String(M)===o&&(l==null||i.dataKey===l)&&w,T=o?r:null,R=n&&A?n:T,C=Ar(Ar({},x),{},{stroke:x.stroke,tabIndex:-1,[kY]:M,[RY]:i.dataKey});return E.createElement(jr,ld({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),E.createElement(CJ,ld({option:s??R,index:M,shapeType:"sector",isActive:A},C)))}))}function CBe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:c,nameKey:d,tooltipType:h}=n,g=Math.abs(n.minAngle),m=_Be(o,l),v=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(R=>Yn(R,c,0)!==0).length,x=(v>=360?b:b-1)*y,M=v-b*g-x,w=r.reduce((R,C)=>{var I=Yn(C,c,0);return R+(Tt(I)?I:0)},0),A;if(w>0){var T;A=r.map((R,C)=>{var I=Yn(R,c,0),N=Yn(R,d,C),D=yBe(n,s,R),z=(Tt(I)?I:0)/w,j,W=Ar(Ar({},R),i&&i[C]&&i[C].props);C?j=T.endAngle+ki(m)*y*(I!==0?1:0):j=o;var P=j+ki(m)*((I!==0?g:0)+z*M),$=(j+P)/2,K=(D.innerRadius+D.outerRadius)/2,G=[{name:N,value:I,payload:W,dataKey:c,type:h}],Z=Xr(D.cx,D.cy,K,$);return T=Ar(Ar(Ar(Ar({},n.presentationProps),{},{percent:z,cornerRadius:typeof a=="string"?parseFloat(a):a,name:N,tooltipPayload:G,midAngle:$,middleRadius:K,tooltipPosition:Z},W),D),{},{value:I,dataKey:c,startAngle:j,endAngle:P,payload:W,paddingAngle:ki(m)*y}),T})}return A}function NBe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return E.createElement(uze,{value:e?i:void 0},r)}function kBe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:d,onAnimationStart:h,onAnimationEnd:g}=e,m=mb(e,"recharts-pie-"),v=n.current,[y,b]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),M=E.useCallback(()=>{typeof h=="function"&&h(),b(!0)},[h]);return E.createElement(NBe,{showLabels:!y,sectors:i},E.createElement(pb,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var A=[],T=i&&i[0],R=T?.startAngle;return i?.forEach((C,I)=>{var N=v&&v[I],D=I>0?Wf(C,"paddingAngle",0):0;if(N){var z=lr(N.endAngle-N.startAngle,C.endAngle-C.startAngle,w),j=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+z+D});A.push(j),R=j.endAngle}else{var{endAngle:W,startAngle:P}=C,$=lr(0,W-P,w),K=Ar(Ar({},C),{},{startAngle:R+D,endAngle:R+$+D});A.push(K),R=K.endAngle}}),n.current=A,E.createElement(jr,null,E.createElement(TBe,{sectors:A,activeShape:c,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(ABe,{showLabels:!y,sectors:i,props:e}),e.children)}var RBe={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:Kr.area};function PBe(t){var{id:e}=t,n=DM(t,uBe),{hide:r,className:i,rootTabIndex:s}=t,a=E.useMemo(()=>yL(t.children,kb),[t.children]),o=Ct(d=>Tze(d,e,a)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(jr,{tabIndex:s,className:c})):E.createElement(Qs,{zIndex:t.zIndex},E.createElement(xBe,{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(jr,{tabIndex:s,className:c},E.createElement(kBe,{props:Ar(Ar({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function DJ(t){var e=ei(t,RBe),{id:n}=e,r=DM(e,dBe),i=Xs(r);return E.createElement(EL,{id:n,type:"pie"},s=>E.createElement(E.Fragment,null,E.createElement(oBe,{type:"pie",id:s,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(gBe,ld({},r,{id:s})),E.createElement(PBe,ld({},r,{id:s}))))}DJ.displayName="Pie";var DBe=["points"];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 AN(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){OBe(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 OBe(t,e,n){return(e=LBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LBe(t){var e=jBe(t,"string");return typeof e=="symbol"?e:e+""}function jBe(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 YS(){return YS=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},YS.apply(null,arguments)}function IBe(t,e){if(t==null)return{};var n,r,i=UBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UBe(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 FBe(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:""),s=n??{},{points:a}=s,o=IBe(s,DBe);return E.createElement(_J,YS({},o,{className:i}))}function zBe(t,e){return t==null?!1:e?!0:t.length===1}function BBe(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:a,needClip:o,clipPathId:l,zIndex:c=Kr.scatter}=t;if(!zBe(e,n))return null;var d=TJ(n),h=x3e(n),g=e.map((v,y)=>{var b,x,M=AN(AN(AN({r:3},a),h),{},{index:y,cx:(b=v.x)!==null&&b!==void 0?b:void 0,cy:(x=v.y)!==null&&x!==void 0?x:void 0,dataKey:s,value:v.value,payload:v.payload,points:e});return E.createElement(FBe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),E.createElement(Qs,{zIndex:c},E.createElement(jr,YS({className:r},m),g))}function eG(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 tG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eG(Object(n),!0).forEach(function(r){HBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HBe(t,e,n){return(e=$Be(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Be(t){var e=VBe(t,"string");return typeof e=="symbol"?e:e+""}function VBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var GBe={xAxis:{},yAxis:{},zAxis:{}},OJ=Zs({name:"cartesianAxis",initialState:GBe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:dr()},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:dr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:dr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:dr()},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:dr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:dr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:dr()},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:dr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:dr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var a=[...s,r].slice(-3);t.yAxis[n]=tG(tG({},t.yAxis[n]),{},{width:r,widthHistory:a})}}}}),{addXAxis:WBe,replaceXAxis:qBe,removeXAxis:XBe,addYAxis:KBe,replaceYAxis:YBe,removeYAxis:ZBe,addZAxis:w9e,replaceZAxis:M9e,removeZAxis:E9e,updateYAxisWidth:QBe}=OJ.actions,JBe=OJ.reducer,e6e=We([pi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),t6e=We([e6e,Rc,Pc],(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)}}),AL=()=>Ct(t6e),n6e=()=>Ct(QUe);function nG(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 TN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nG(Object(n),!0).forEach(function(r){r6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r6e(t,e,n){return(e=i6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i6e(t){var e=s6e(t,"string");return typeof e=="symbol"?e:e+""}function s6e(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 a6e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:a}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=TN(TN(TN({},o),Gf(i)),$D(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(_J,l),E.createElement(jr,{className:"recharts-active-dot",clipPath:a},c)};function rG(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Kr.activeDot}=t,o=Ct(od),l=n6e();if(e==null||l==null)return null;var c=e.find(d=>l.includes(d.payload));return vr(c)?null:E.createElement(Qs,{zIndex:a},E.createElement(a6e,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var o6e="Invariant failed";function l6e(t,e){throw new Error(o6e)}var c6e=["x","y"];function PR(){return PR=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},PR.apply(null,arguments)}function iG(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 px(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iG(Object(n),!0).forEach(function(r){u6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u6e(t,e,n){return(e=d6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d6e(t){var e=f6e(t,"string");return typeof e=="symbol"?e:e+""}function f6e(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 h6e(t,e){if(t==null)return{};var n,r,i=p6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function p6e(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 m6e(t,e){var{x:n,y:r}=t,i=h6e(t,c6e),s="".concat(n),a=parseInt(s,10),o="".concat(r),l=parseInt(o,10),c="".concat(e.height||i.height),d=parseInt(c,10),h="".concat(e.width||i.width),g=parseInt(h,10);return px(px(px(px(px({},e),i),a?{x:a}:{}),l?{y:l}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function ZS(t){return E.createElement(CJ,PR({shapeType:"rectangle",propTransformer:m6e,activeClassName:"recharts-active-bar"},t))}var g6e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Tt(e))return e;var s=Tt(r)||vr(r);return s?e(r,i):(s||l6e(),n)}},x6e={},LJ=Zs({name:"errorBars",initialState:x6e,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(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},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:A9e,replaceErrorBar:T9e,removeErrorBar:C9e}=LJ.actions,b6e=LJ.reducer,v6e=["children"];function y6e(t,e){if(t==null)return{};var n,r,i=_6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _6e(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 S6e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},w6e=E.createContext(S6e);function M6e(t){var{children:e}=t,n=y6e(t,v6e);return E.createElement(w6e.Provider,{value:n},e)}function TL(t,e){var n,r,i=Ct(c=>Oc(c,t)),s=Ct(c=>Lc(c,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ei.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ai.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function jJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=AL(),{needClipX:s,needClipY:a,needClip:o}=TL(e,n);if(!o||!i)return null;var{x:l,y:c,width:d,height:h}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:s?l:l-d/2,y:a?c:c-h/2,width:s?d:d*2,height:a?h:h*2}))}function E6e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&cr(t.zIndex)?t.zIndex:e}var CN={exports:{}},NN={};var sG;function A6e(){if(sG)return NN;sG=1;var t=Tm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return NN.useSyncExternalStoreWithSelector=function(l,c,d,h,g){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function b(T){if(!x){if(x=!0,M=T,T=h(T),g!==void 0&&v.hasValue){var R=v.value;if(g(R,T))return w=R}return w=T}if(R=w,n(M,T))return R;var C=h(T);return g!==void 0&&g(R,C)?(M=T,R):(M=T,w=C)}var x=!1,M,w,A=d===void 0?null:d;return[function(){return b(c())},A===null?void 0:function(){return b(A())}]},[c,d,h,g]);var y=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),o(y),y},NN}var aG;function T6e(){return aG||(aG=1,CN.exports=A6e()),CN.exports}T6e();function C6e(t){t()}function N6e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){C6e(()=>{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 oG={notify(){},get:()=>[]};function k6e(t,e){let n,r=oG,i=0,s=!1;function a(y){d();const b=r.subscribe(y);let x=!1;return()=>{x||(x=!0,b(),h())}}function o(){r.notify()}function l(){v.onStateChange&&v.onStateChange()}function c(){return s}function d(){i++,n||(n=t.subscribe(l),r=N6e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=oG)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const v={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return v}var R6e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",P6e=R6e(),D6e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",O6e=D6e(),L6e=()=>P6e||O6e?E.useLayoutEffect:E.useEffect,j6e=L6e();function lG(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function I6e(t,e){if(lG(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])||!lG(t[n[i]],e[n[i]]))return!1;return!0}var U6e=Symbol.for("react-redux-context"),F6e=typeof globalThis<"u"?globalThis:{};function z6e(){if(!E.createContext)return{};const t=F6e[U6e]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var B6e=z6e();function H6e(t){const{children:e,context:n,serverState:r,store:i}=t,s=E.useMemo(()=>{const l=k6e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=E.useMemo(()=>i.getState(),[i]);j6e(()=>{const{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,a]);const o=n||B6e;return E.createElement(o.Provider,{value:s},e)}var $6e=H6e,V6e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function G6e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function OM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(V6e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!I6e(t[r],e[r]))return!1}else if(!G6e(t[r],e[r]))return!1;return!0}var W6e=["onMouseEnter","onMouseLeave","onClick"],q6e=["value","background","tooltipPosition"],X6e=["id"],K6e=["onMouseEnter","onClick","onMouseLeave"];function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cc.apply(null,arguments)}function cG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cG(Object(n),!0).forEach(function(r){Y6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y6e(t,e,n){return(e=Z6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z6e(t){var e=Q6e(t,"string");return typeof e=="symbol"?e:e+""}function Q6e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 QS(t,e){if(t==null)return{};var n,r,i=J6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function J6e(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 e8e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Bm(n,e),payload:t}]},t8e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,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:Bm(s,e),hide:a,type:l,color:i,unit:o}};return E.createElement(ML,{tooltipEntrySettings:c})});function n8e(t){var e=Ct(od),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,c=QS(s,W6e),d=_L(a,r),h=SL(o),g=wL(l,r);if(!i||n==null)return null;var m=Gf(i);return E.createElement(Qs,{zIndex:E6e(i,Kr.barBackground)},n.map((v,y)=>{var{value:b,background:x,tooltipPosition:M}=v,w=QS(v,q6e);if(!x)return null;var A=d(v,y),T=h(v,y),R=g(v,y),C=vs(vs(vs(vs(vs({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},x),m),lb(c,v,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:R,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(ZS,Cc({key:"background-bar-".concat(y)},C))}))}function r8e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var a={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return vs(vs({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return E.createElement(vJ,{value:e?i:void 0},n)}function i8e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Ct(od),l=Ct(uL),c=n&&String(s)===o&&(l==null||a===l),d=c?n:e;return c?E.createElement(Qs,{zIndex:Kr.activeBar},E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))):E.createElement(ZS,Cc({},r,{name:String(r.name)},i,{isActive:c,option:d,index:s,dataKey:a}))}function s8e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return E.createElement(ZS,Cc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function a8e(t){var e,{data:n,props:r}=t,i=(e=Xs(r))!==null&&e!==void 0?e:{},{id:s}=i,a=QS(i,X6e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:d,onClick:h,onMouseLeave:g}=r,m=QS(r,K6e),v=_L(d,l),y=SL(g),b=wL(h,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(jr,Cc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},lb(m,x,M),{onMouseEnter:v(x,M),onMouseLeave:y(x,M),onClick:b(x,M)}),c?E.createElement(i8e,{shape:o,activeBar:c,baseProps:a,entry:x,index:M,dataKey:l}):E.createElement(s8e,{shape:o,baseProps:a,entry:x,index:M,dataKey:l})))):null}function o8e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:d}=e,h=n.current,g=mb(e,"recharts-bar-"),[m,v]=E.useState(!1),y=!m,b=E.useCallback(()=>{typeof c=="function"&&c(),v(!1)},[c]),x=E.useCallback(()=>{typeof d=="function"&&d(),v(!0)},[d]);return E.createElement(r8e,{showLabels:y,rects:r},E.createElement(pb,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:b,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((A,T)=>{var R=h&&h[T];if(R)return vs(vs({},A),{},{x:lr(R.x,A.x,M),y:lr(R.y,A.y,M),width:lr(R.width,A.width,M),height:lr(R.height,A.height,M)});if(i==="horizontal"){var C=lr(0,A.height,M),I=lr(A.stackedBarStart,A.y,M);return vs(vs({},A),{},{y:I,height:C})}var N=lr(0,A.width,M),D=lr(A.stackedBarStart,A.x,M);return vs(vs({},A),{},{width:N,x:D})});return M>0&&(n.current=w??null),w==null?null:E.createElement(jr,null,E.createElement(a8e,{props:e,data:w}))}),E.createElement(xL,{label:e.label}),e.children)}function l8e(t){var e=E.useRef(null);return E.createElement(o8e,{previousRectanglesRef:e,props:t})}var IJ=0,c8e=(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 u8e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var d=An("recharts-bar",i),h=c;return E.createElement(jr,{className:d,id:c},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:h,xAxisId:s,yAxisId:a})),E.createElement(jr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(h,")"):void 0},E.createElement(n8e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement(l8e,this.props)))}}var d8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:IJ,xAxisId:0,yAxisId:0,zIndex:Kr.bar};function f8e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d}=t,{needClip:h}=TL(e,n),g=Hm(),m=hs(),v=yL(t.children,kb),y=Ct(M=>z8e(M,e,n,m,t.id,v));if(g!=="vertical"&&g!=="horizontal")return null;var b,x=y?.[0];return x==null||x.height==null||x.width==null?b=0:b=g==="vertical"?x.height/2:x.width/2,E.createElement(M6e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:c8e,errorBarOffset:b},E.createElement(u8e,Cc({},t,{layout:g,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d})))}function h8e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:d,displayedData:h,offset:g,cells:m,parentViewBox:v,dataStartIndex:y}=t,b=e==="horizontal"?o:a,x=d?b.scale.domain():null,M=PPe({numericAxis:b}),w=b.scale(M);return h.map((A,T)=>{var R,C,I,N,D,z;d?R=TPe(d[T+y],x):(R=Yn(A,n),Array.isArray(R)||(R=[M,R]));var j=g6e(r,IJ)(R[1],T);if(e==="horizontal"){var W,[P,$]=[o.scale(R[0]),o.scale(R[1])];C=EH({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:A,index:T}),I=(W=$??P)!==null&&W!==void 0?W:void 0,N=i.size;var K=P-$;if(D=eo(K)?0:K,z={x:C,y:g.top,width:N,height:g.height},Math.abs(j)>0&&Math.abs(D)<Math.abs(j)){var G=ki(D||j)*(Math.abs(j)-Math.abs(D));I-=G,D+=G}}else{var[Z,Q]=[a.scale(R[0]),a.scale(R[1])];if(C=Z,I=EH({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:A,index:T}),N=Q-Z,D=i.size,z={x:g.left,y:I,width:g.width,height:D},Math.abs(j)>0&&Math.abs(N)<Math.abs(j)){var ee=ki(N||j)*(Math.abs(j)-Math.abs(N));N+=ee}}if(C==null||I==null||N==null||D==null)return null;var H=vs(vs({},A),{},{stackedBarStart:w,x:C,y:I,width:N,height:D,value:d?R:R[1],payload:A,background:z,tooltipPosition:{x:C+N/2,y:I+D/2},parentViewBox:v},m&&m[T]&&m[T].props);return H}).filter(Boolean)}function p8e(t){var e=ei(t,d8e),n=hs();return E.createElement(EL,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:e8e(e)}),E.createElement(t8e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:CY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Qs,{zIndex:e.zIndex},E.createElement(f8e,Cc({},e,{id:r})))))}var UJ=E.memo(p8e,OM);UJ.displayName="Bar";function uG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uG(Object(n),!0).forEach(function(r){m8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function m8e(t,e,n){return(e=g8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g8e(t){var e=x8e(t,"string");return typeof e=="symbol"?e:e+""}function x8e(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 b8e=(t,e)=>e,v8e=(t,e,n)=>n,y8e=(t,e,n,r)=>r,_8e=(t,e,n,r,i)=>i,Rb=We([EM,_8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),S8e=We([Rb],t=>t?.maxBarSize),w8e=(t,e,n,r,i,s)=>s,dG=(t,e,n)=>{var r=n??t;if(!vr(r))return us(r,e,0)},M8e=We([Sn,EM,b8e,v8e,y8e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),E8e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?H0(t,"yAxis",n,r):H0(t,"xAxis",e,r)},A8e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?iV(t,"xAxis",e):iV(t,"yAxis",n)},T8e=(t,e,n)=>{var r={},i=t.filter(SM),s=t.filter(c=>c.stackId==null),a=i.reduce((c,d)=>(c[d.stackId]||(c[d.stackId]=[]),c[d.stackId].push(d),c),r),o=Object.entries(a).map(c=>{var[d,h]=c,g=h.map(v=>v.dataKey),m=dG(e,n,h[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),l=s.map(c=>{var d=[c.dataKey].filter(g=>g!=null),h=dG(e,n,c.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...o,...l]},C8e=We([M8e,KIe,A8e],T8e),N8e=(t,e,n,r,i)=>{var s,a,o=Rb(t,e,n,r,i);if(o!=null){var l=Sn(t),c=JZ(t),{maxBarSize:d}=o,h=vr(d)?c:d,g,m;return l==="horizontal"?(g=ad(t,"xAxis",e,r),m=sd(t,"xAxis",e,r)):(g=ad(t,"yAxis",n,r),m=sd(t,"yAxis",n,r)),(s=(a=_m(g,m,!0))!==null&&a!==void 0?a:h)!==null&&s!==void 0?s:0}},FJ=(t,e,n,r)=>{var i=Sn(t),s,a;return i==="horizontal"?(s=ad(t,"xAxis",e,r),a=sd(t,"xAxis",e,r)):(s=ad(t,"yAxis",n,r),a=sd(t,"yAxis",n,r)),_m(s,a)};function k8e(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=us(t,n,0,!0),o,l=[];if(cr(r[0].barSize)){var c=!1,d=n/s,h=r.reduce((x,M)=>x+(M.barSize||0),0);h+=(s-1)*a,h>=n&&(h-=(s-1)*a,a=0),h>=n&&d>0&&(c=!0,d*=.9,h=s*d);var g=(n-h)/2>>0,m={offset:g-a,size:0};o=r.reduce((x,M)=>{var w,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+a,size:c?d:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,A];return m=T[T.length-1].position,T},l)}else{var v=us(e,n,0,!0);n-2*v-(s-1)*a<=0&&(a=0);var y=(n-2*v-(s-1)*a)/s;y>1&&(y>>=0);var b=cr(i)?Math.min(y,i):y;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:v+(y+a)*w+(y-b)/2,size:b}}],l)}return o}}var R8e=(t,e,n,r,i,s,a)=>{var o=vr(a)?e:a,l=k8e(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(c=>v_(v_({},c),{},{position:v_(v_({},c.position),{},{offset:c.position.offset-i/2})}))),l},P8e=We([C8e,JZ,XIe,eQ,N8e,FJ,S8e],R8e),D8e=(t,e,n,r)=>ad(t,"xAxis",e,r),O8e=(t,e,n,r)=>ad(t,"yAxis",n,r),L8e=(t,e,n,r)=>sd(t,"xAxis",e,r),j8e=(t,e,n,r)=>sd(t,"yAxis",n,r),I8e=We([P8e,Rb],(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}}),U8e=(t,e)=>{var n=_M(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},F8e=We([E8e,Rb],U8e),z8e=We([pi,eO,D8e,O8e,L8e,j8e,I8e,Sn,bM,FJ,F8e,Rb,w8e],(t,e,n,r,i,s,a,o,l,c,d,h,g)=>{var{chartData:m,dataStartIndex:v,dataEndIndex:y}=l;if(!(h==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||c==null)){var{data:b}=h,x;if(b!=null&&b.length>0?x=b:x=m?.slice(v,y+1),x!=null)return h8e({layout:o,barSettings:h,pos:a,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:x,offset:t,cells:g,dataStartIndex:v})}}),zJ=t=>{var{chartData:e}=t,n=nr(),r=hs();return E.useEffect(()=>r?()=>{}:(n(xV(e)),()=>{n(xV(void 0))}),[e,n,r]),null},fG={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},BJ=Zs({name:"brush",initialState:fG,reducers:{setBrushSettings(t,e){return e.payload==null?fG:e.payload}}}),{setBrushSettings:N9e}=BJ.actions,B8e=BJ.reducer;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)}class CL{static create(e){return new CL(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 s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+a}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}}H8e(CL,"EPS",1e-4);function G8e(t){return(t%180+180)%180}var W8e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=G8e(i),a=s*Math.PI/180,o=Math.atan(r/n),l=a>o&&a<Math.PI-o?r/Math.sin(a):n/Math.cos(a);return Math.abs(l)},q8e={dots:[],areas:[],lines:[]},HJ=Zs({name:"referenceElements",initialState:q8e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=To(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=To(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=To(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:k9e,removeDot:R9e,addArea:P9e,removeArea:D9e,addLine:O9e,removeLine:L9e}=HJ.actions,X8e=HJ.reducer,K8e=E.createContext(void 0),Y8e=t=>{var{children:e}=t,[n]=E.useState("".concat(N0("recharts"),"-clip")),r=AL();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return E.createElement(K8e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:s,height:o,width:a}))),e)};function $J(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 Z8e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return W8e(r,n)}function Q8e(t,e,n){var r=n==="width",{x:i,y:s,width:a,height:o}=t;return e===1?{start:r?i:s,end:r?i+a:s+o}:{start:r?i+a:s+o,end:r?i:s}}function JS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function J8e(t,e){return $J(t,e+1)}function eHe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,c=1,d=a,h=function(){var v=r?.[l];if(v===void 0)return{v:$J(r,c)};var y=l,b,x=()=>(b===void 0&&(b=n(v,y)),b),M=v.coordinate,w=l===0||JS(t,M,x,d,o);w||(l=0,d=a,c+=1),w&&(d=M+t*(x()/2+i),l+=c)},g;c<=s.length;)if(g=h(),g)return g.v;return[]}function hG(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 as(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hG(Object(n),!0).forEach(function(r){tHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hG(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 iHe(t,e,n,r,i){for(var s=(r||[]).slice(),a=s.length,{start:o}=e,{end:l}=e,c=function(g){var m=s[g],v,y=()=>(v===void 0&&(v=n(m,g)),v);if(g===a-1){var b=t*(m.coordinate+t*y()/2-l);s[g]=m=as(as({},m),{},{tickCoord:b>0?m.coordinate-b*t:m.coordinate})}else s[g]=m=as(as({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=JS(t,m.tickCoord,y,o,l);x&&(l=m.tickCoord-t*(y()/2+i),s[g]=as(as({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)c(d);return s}function sHe(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:c}=e;if(s){var d=r[o-1],h=n(d,o-1),g=t*(d.coordinate+t*h/2-c);if(a[o-1]=d=as(as({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=JS(t,d.tickCoord,()=>h,l,c);m&&(c=d.tickCoord-t*(h/2+i),a[o-1]=as(as({},d),{},{isShow:!0}))}}for(var v=s?o-1:o,y=function(M){var w=a[M],A,T=()=>(A===void 0&&(A=n(w,M)),A);if(M===0){var R=t*(w.coordinate-t*T()/2-l);a[M]=w=as(as({},w),{},{tickCoord:R<0?w.coordinate-R*t:w.coordinate})}else a[M]=w=as(as({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var C=JS(t,w.tickCoord,T,l,c);C&&(l=w.tickCoord+t*(T()/2+i),a[M]=as(as({},w),{},{isShow:!0}))}},b=0;b<v;b++)y(b);return a}function NL(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:a,orientation:o,interval:l,tickFormatter:c,unit:d,angle:h}=t;if(!i||!i.length||!r)return[];if(Tt(l)||$m.isSsr){var g;return(g=J8e(i,Tt(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],v=o==="top"||o==="bottom"?"width":"height",y=d&&v==="width"?Kx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(w,A)=>{var T=typeof c=="function"?c(w.value,A):w.value;return v==="width"?Z8e(Kx(T,{fontSize:e,letterSpacing:n}),y,h):Kx(T,{fontSize:e,letterSpacing:n})[v]},x=i.length>=2?ki(i[1].coordinate-i[0].coordinate):1,M=Q8e(s,x,v);return l==="equidistantPreserveStart"?eHe(x,M,b,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=sHe(x,M,b,i,a,l==="preserveStartEnd"):m=iHe(x,M,b,i,a),m.filter(w=>w.isShow))}var aHe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(d=>{if(d){var h=d.getBoundingClientRect();h.width>a&&(a=h.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,c=a+l+o+(n?r:0);return Math.round(c)}return 0},oHe=["axisLine","width","height","className","hide","ticks","axisType"];function lHe(t,e){if(t==null)return{};var n,r,i=cHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function cHe(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 Yf(){return Yf=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},Yf.apply(null,arguments)}function pG(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 Vr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pG(Object(n),!0).forEach(function(r){uHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uHe(t,e,n){return(e=dHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dHe(t){var e=fHe(t,"string");return typeof e=="symbol"?e:e+""}function fHe(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 xc={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:Kr.axis};function hHe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:a,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var c=Vr(Vr(Vr({},l),Xs(o)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!a||s==="bottom"&&a);c=Vr(Vr({},c),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var h=+(s==="left"&&!a||s==="right"&&a);c=Vr(Vr({},c),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return E.createElement("line",Yf({},c,{className:An("recharts-cartesian-axis-line",Wf(o,"className"))}))}function pHe(t,e,n,r,i,s,a,o,l){var c,d,h,g,m,v,y=o?-1:1,b=t.tickSize||a,x=Tt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":c=d=t.coordinate,g=n+ +!o*i,h=g-y*b,v=h-y*l,m=x;break;case"left":h=g=t.coordinate,d=e+ +!o*r,c=d-y*b,m=c-y*l,v=x;break;case"right":h=g=t.coordinate,d=e+ +o*r,c=d+y*b,m=c+y*l,v=x;break;default:c=d=t.coordinate,g=n+ +o*i,h=g+y*b,v=h+y*l,m=x;break}return{line:{x1:c,y1:h,x2:d,y2:g},tick:{x:m,y:v}}}function mHe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function gHe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function xHe(t){var{option:e,tickProps:n,value:r}=t,i,s=An(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,Vr(Vr({},n),{},{className:s}));else if(typeof e=="function")i=e(Vr(Vr({},n),{},{className:s}));else{var a="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(a=An(a,e?.className)),i=E.createElement(kM,Yf({},n,{className:a}),r)}return i}var bHe=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:c,orientation:d,mirror:h,x:g,y:m,width:v,height:y,tickSize:b,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:A,events:T,axisType:R}=t,C=NL(Vr(Vr({},A),{},{ticks:n}),M,w),I=mHe(d,h),N=gHe(d,h),D=Xs(A),z=Gf(r),j={};typeof i=="object"&&(j=i);var W=Vr(Vr({},D),{},{fill:"none"},j),P=C.map(G=>Vr({entry:G},pHe(G,g,m,v,y,d,b,h,x))),$=P.map(G=>{var{entry:Z,line:Q}=G;return E.createElement(jr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&E.createElement("line",Yf({},W,Q,{className:An("recharts-cartesian-axis-tick-line",Wf(i,"className"))})))}),K=P.map((G,Z)=>{var{entry:Q,tick:ee}=G,H=Vr(Vr(Vr(Vr({textAnchor:I,verticalAnchor:N},D),{},{stroke:"none",fill:s},z),ee),{},{index:Z,payload:Q,visibleTicksCount:C.length,tickFormatter:a,padding:l},c);return E.createElement(jr,Yf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},lb(T,Q,Z)),r&&E.createElement(xHe,{option:r,tickProps:H,value:"".concat(typeof a=="function"?a(Q.value,Z):Q.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(R,"-ticks")},K.length>0&&E.createElement(Qs,{zIndex:Kr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(R,"-tick-labels"),ref:e},K)),$.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(R,"-tick-lines")},$))}),vHe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,c=lHe(t,oHe),[d,h]=E.useState(""),[g,m]=E.useState(""),v=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return aHe({ticks:v.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(b=>{if(b){var x=b.getElementsByClassName("recharts-cartesian-axis-tick-value");v.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),A=w.fontSize,T=w.letterSpacing;(A!==d||T!==g)&&(h(A),m(T))}}},[d,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Qs,{zIndex:t.zIndex},E.createElement(jr,{className:An("recharts-cartesian-axis",s)},E.createElement(hHe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Xs(t)}),E.createElement(bHe,{ref:y,axisType:l,events:c,fontSize:d,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($5e,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(J5e,{label:t.label,labelRef:t.labelRef}),t.children)))}),kL=E.forwardRef((t,e)=>{var n=ei(t,xc);return E.createElement(vHe,Yf({},n,{ref:e}))});kL.displayName="CartesianAxis";var yHe=["x1","y1","x2","y2","key"],_He=["offset"],SHe=["xAxisId","yAxisId"],wHe=["xAxisId","yAxisId"];function mG(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 ls(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mG(Object(n),!0).forEach(function(r){MHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MHe(t,e,n){return(e=EHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EHe(t){var e=AHe(t,"string");return typeof e=="symbol"?e:e+""}function AHe(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 df(){return df=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},df.apply(null,arguments)}function ew(t,e){if(t==null)return{};var n,r,i=THe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function THe(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 CHe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:a,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function VJ(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:s,y1:a,x2:o,y2:l,key:c}=n,d=ew(n,yHe),h=(i=Xs(d))!==null&&i!==void 0?i:{},{offset:g}=h,m=ew(h,_He);r=E.createElement("line",df({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:c}))}return r}function NHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,SHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(d),index:d});return E.createElement(VJ,{key:"line-".concat(d),option:r,lineItemProps:h})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function kHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ew(t,wHe),l=i.map((c,d)=>{var h=ls(ls({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(d),index:d});return E.createElement(VJ,{option:r,lineItemProps:h,key:"line-".concat(d)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function RHe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:h,x:r,height:v,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function PHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var d=c.map((h,g)=>{var m=!c[g+1],v=m?i+a-h:c[g+1]-h;if(v<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:h,y:s,width:v,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var DHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},OHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return AY(NL(ls(ls(ls({},xc),n),{},{ticks:TY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},LHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Kr.grid};function DR(t){var e=nO(),n=rO(),r=jY(),i=ls(ls({},ei(t,LHe)),{},{x:Tt(t.x)?t.x:r.left,y:Tt(t.y)?t.y:r.top,width:Tt(t.width)?t.width:r.width,height:Tt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:c,height:d,syncWithTicks:h,horizontalValues:g,verticalValues:m}=i,v=hs(),y=Ct(N=>sV(N,"xAxis",s,v)),b=Ct(N=>sV(N,"yAxis",a,v));if(!dl(c)||!dl(d)||!Tt(o)||!Tt(l))return null;var x=i.verticalCoordinatesGenerator||DHe,M=i.horizontalCoordinatesGenerator||OHe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof M=="function"){var T=g&&g.length,R=M({yAxis:b?ls(ls({},b),{},{ticks:T?g:b.ticks}):void 0,width:e??c,height:n??d,offset:r},T?!0:h);ES(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 C=m&&m.length,I=x({xAxis:y?ls(ls({},y),{},{ticks:C?m:y.ticks}):void 0,width:e??c,height:n??d,offset:r},C?!0:h);ES(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return E.createElement(Qs,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(CHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(RHe,df({},i,{horizontalPoints:w})),E.createElement(PHe,df({},i,{verticalPoints:A})),E.createElement(NHe,df({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:b})),E.createElement(kHe,df({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:b}))))}DR.displayName="CartesianGrid";function jHe(t){var e=Gf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,a=Number(i),o=Number(s);return(Number.isNaN(a)||a<0)&&(a=n),(Number.isNaN(o)||o<0)&&(o=r),{r:a,strokeWidth:o}}return{r:n,strokeWidth:r}}var GJ=(t,e,n,r)=>ad(t,"xAxis",e,r),WJ=(t,e,n,r)=>sd(t,"xAxis",e,r),qJ=(t,e,n,r)=>ad(t,"yAxis",n,r),XJ=(t,e,n,r)=>sd(t,"yAxis",n,r),IHe=We([Sn,GJ,qJ,WJ,XJ],(t,e,n,r,i)=>kc(t,"xAxis")?_m(e,r,!1):_m(n,i,!1)),UHe=(t,e,n,r,i)=>i,KJ=We([EM,UHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),FHe=(t,e,n,r,i)=>{var s,a=KJ(t,e,n,r,i);if(a!=null){var o=Sn(t),l=kc(o,"xAxis"),c;if(l?c=H0(t,"yAxis",n,r):c=H0(t,"xAxis",e,r),c!=null){var{stackId:d}=a,h=_M(a);if(!(d==null||h==null)){var g=(s=c[d])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===h)}}}},zHe=We([Sn,GJ,qJ,WJ,XJ,FHe,bM,IHe,KJ,YIe],(t,e,n,r,i,s,a,o,l,c)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:g}=a;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,v;if(m&&m.length>0?v=m:v=d?.slice(h,g+1),v!=null)return s$e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:l,stackedData:s,displayedData:v,chartBaseValue:c,bandSize:o})}}),BHe=["id"],HHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ef(){return Ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ef.apply(null,arguments)}function YJ(t,e){if(t==null)return{};var n,r,i=$He(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[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 gG(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 Lp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gG(Object(n),!0).forEach(function(r){VHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VHe(t,e,n){return(e=GHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GHe(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 tw(t,e){return t&&t!=="none"?t:e}var qHe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:tw(r,i),value:Bm(n,e),payload:t}]},XHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:c}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Bm(a,e),hide:o,type:c,color:tw(r,s),unit:l}};return E.createElement(ML,{tooltipEntrySettings:d})});function KHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Xs(r);return E.createElement(BBe,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function YHe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,l={x:(a=s.x)!==null&&a!==void 0?a:0,y:(o=s.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Lp(Lp({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(vJ,{value:e?i:void 0},n)}function xG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:c,isRange:d}=s,{id:h}=s,g=YJ(s,BHe),m=Xs(g),v=Cs(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(jr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Xp,Ef({},v,{id:h,points:e,connectNulls:c,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&d&&E.createElement(Xp,Ef({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(KHe,{points:e,props:g,clipPathId:i}))}function ZHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!cr(s)||!cr(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.x||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Tt(l)?E.createElement("rect",{x:0,y:s<a?s:s-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function QHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!cr(s)||!cr(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.y||0));return Tt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Tt(l)?E.createElement("rect",{x:s<a?s:s-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function JHe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?E.createElement(ZHe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):E.createElement(QHe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function e$e(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:a,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:d,animationEasing:h,onAnimationStart:g,onAnimationEnd:m}=r,v=E.useMemo(()=>({points:a,baseLine:o}),[a,o]),y=mb(v,"recharts-area-"),b=pDe(),[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,C=s.current;return E.createElement(YHe,{showLabels:w,points:a},r.children,E.createElement(pb,{animationId:y,begin:c,duration:d,isActive:l,easing:h,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(R){var N=R.length/a.length,D=I===1?a:a.map((j,W)=>{var P=Math.floor(W*N);if(R[P]){var $=R[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),z;return Tt(o)?z=lr(C,o,I):vr(o)||eo(o)?z=lr(C,0,I):z=o.map((j,W)=>{var P=Math.floor(W*N);if(Array.isArray(C)&&C[P]){var $=C[P];return Lp(Lp({},j),{},{x:lr($.x,j.x,I),y:lr($.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=z),E.createElement(xG,{points:D,baseLine:z,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),E.createElement(jr,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(JHe,{alpha:I,points:a,baseLine:o,layout:b,strokeWidth:r.strokeWidth}))),E.createElement(jr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(xG,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(xL,{label:r.label}))}function t$e(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),s=E.useRef();return E.createElement(e$e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class n$e extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:c,width:d,height:h,id:g,baseLine:m,zIndex:v}=this.props;if(e)return null;var y=An("recharts-area",i),b=g,{r:x,strokeWidth:M}=jHe(n),w=TJ(n),A=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return E.createElement(Qs,{zIndex:v},E.createElement(jr,{className:y},o&&E.createElement("defs",null,E.createElement(jJ,{clipPathId:b,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(b)},E.createElement("rect",{x:a-A/2,y:s-A/2,width:d+A,height:h+A}))),E.createElement(t$e,{needClip:o,clipPathId:b,props:this.props})),E.createElement(rG,{points:r,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(rG,{points:m,mainColor:tw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var ZJ={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:Kr.area};function r$e(t){var e,n=ei(t,ZJ),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:c,fillOpacity:d,hide:h,isAnimationActive:g,legendType:m,stroke:v,xAxisId:y,yAxisId:b}=n,x=YJ(n,HHe),M=Hm(),w=eJ(),{needClip:A}=TL(y,b),T=hs(),{points:R,isRange:C,baseLine:I}=(e=Ct(P=>zHe(P,y,b,T,t.id)))!==null&&e!==void 0?e:{},N=AL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:D,width:z,x:j,y:W}=N;return!R||!R.length?null:E.createElement(n$e,Ef({},x,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:l,fill:c,fillOpacity:d,height:D,hide:h,layout:M,isAnimationActive:g==="auto"?!$m.isSsr:g,isRange:C,legendType:m,needClip:A,points:R,stroke:v,width:z,left:j,top:W,xAxisId:y,yAxisId:b}))}var i$e=(t,e,n,r,i)=>{var s=n??e;if(Tt(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return s==="dataMin"?c:s==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function s$e(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:d,xAxisTicks:h,yAxisTicks:g,bandSize:m}=t,v=i&&i.length,y=i$e(s,a,n,o,l),b=s==="horizontal",x=!1,M=c.map((A,T)=>{var R;v?R=i[d+T]:(R=Yn(A,r),Array.isArray(R)?x=!0:R=[y,R]);var C=R[1]==null||v&&!e&&Yn(A,r)==null;return b?{x:MH({axis:o,ticks:h,bandSize:m,entry:A,index:T}),y:C?null:l.scale(R[1]),value:R,payload:A}:{x:C?null:o.scale(R[1]),y:MH({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:R,payload:A}}),w;return v||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(y):o.scale(y),{points:M,baseLine:w,isRange:x}}function a$e(t){var e=ei(t,ZJ),n=hs();return E.createElement(EL,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(NJ,{legendPayload:qHe(e)}),E.createElement(XHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(PJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:CY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(r$e,Ef({},e,{id:r}))))}var QJ=E.memo(a$e,OM);QJ.displayName="Area";var o$e=["domain","range"],l$e=["domain","range"];function bG(t,e){if(t==null)return{};var n,r,i=c$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function c$e(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 vG(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 JJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=bG(t,o$e),{domain:s,range:a}=e,o=bG(e,l$e);return!vG(n,s)||!vG(r,a)?!1:OM(i,o)}var u$e=["dangerouslySetInnerHTML","ticks"],d$e=["id"];function OR(){return OR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OR.apply(null,arguments)}function yG(t,e){if(t==null)return{};var n,r,i=f$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function f$e(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 h$e(t){var e=nr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(WBe(t)):n.current!==t&&e(qBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(XBe(n.current)),n.current=null)},[e]),null}var p$e=t=>{var{xAxisId:e,className:n}=t,r=Ct(eO),i=hs(),s="xAxis",a=Ct(b=>Ym(b,s,e,i)),o=Ct(b=>PQ(b,s,e,i)),l=Ct(b=>CQ(b,e)),c=Ct(b=>q4e(b,e)),d=Ct(b=>cQ(b,e));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:g}=t,m=yG(t,u$e),{id:v}=d,y=yG(d,d$e);return E.createElement(kL,OR({},m,y,{scale:a,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},m$e={allowDataOverflow:Ei.allowDataOverflow,allowDecimals:Ei.allowDecimals,allowDuplicatedCategory:Ei.allowDuplicatedCategory,angle:Ei.angle,axisLine:xc.axisLine,height:Ei.height,hide:!1,includeHidden:Ei.includeHidden,interval:Ei.interval,minTickGap:Ei.minTickGap,mirror:Ei.mirror,orientation:Ei.orientation,padding:Ei.padding,reversed:Ei.reversed,scale:Ei.scale,tick:Ei.tick,tickCount:Ei.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ei.type,xAxisId:0},g$e=t=>{var e=ei(t,m$e);return E.createElement(E.Fragment,null,E.createElement(h$e,{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(p$e,e))},LR=E.memo(g$e,JJ);LR.displayName="XAxis";var x$e=["dangerouslySetInnerHTML","ticks"],b$e=["id"];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 _G(t,e){if(t==null)return{};var n,r,i=v$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function v$e(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 y$e(t){var e=nr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(KBe(t)):n.current!==t&&e(YBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(ZBe(n.current)),n.current=null)},[e]),null}var _$e=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=E.useRef(null),a=E.useRef(null),o=Ct(eO),l=hs(),c=nr(),d="yAxis",h=Ct(T=>Ym(T,d,e,l)),g=Ct(T=>NQ(T,e)),m=Ct(T=>K4e(T,e)),v=Ct(T=>PQ(T,d,e,l)),y=Ct(T=>uQ(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||gL(i)||E.isValidElement(i)||y==null)){var T=s.current;if(T){var R=T.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&c(QBe({id:e,width:R}))}}},[v,g,c,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:x}=t,M=_G(t,x$e),{id:w}=y,A=_G(y,b$e);return E.createElement(kL,jR({},M,A,{ref:s,labelRef:a,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:v,axisType:d}))},S$e={allowDataOverflow:Ai.allowDataOverflow,allowDecimals:Ai.allowDecimals,allowDuplicatedCategory:Ai.allowDuplicatedCategory,angle:Ai.angle,axisLine:xc.axisLine,hide:!1,includeHidden:Ai.includeHidden,interval:Ai.interval,minTickGap:Ai.minTickGap,mirror:Ai.mirror,orientation:Ai.orientation,padding:Ai.padding,reversed:Ai.reversed,scale:Ai.scale,tick:Ai.tick,tickCount:Ai.tickCount,tickLine:xc.tickLine,tickSize:xc.tickSize,type:Ai.type,width:Ai.width,yAxisId:0},w$e=t=>{var e=ei(t,S$e);return E.createElement(E.Fragment,null,E.createElement(y$e,{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(_$e,e))},IR=E.memo(w$e,JJ);IR.displayName="YAxis";var M$e=(t,e)=>e,RL=We([M$e,Sn,oQ,gi,XQ,jc,uFe,pi],xFe),PL=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)}},eee=to("mouseClick"),tee=db();tee.startListening({actionCreator:eee,effect:(t,e)=>{var n=t.payload,r=RL(e.getState(),PL(n));r?.activeIndex!=null&&e.dispatch(cUe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var UR=to("mouseMove"),nee=db(),y_=null;nee.startListening({actionCreator:UR,effect:(t,e)=>{var n=t.payload;y_!==null&&cancelAnimationFrame(y_);var r=PL(n);y_=requestAnimationFrame(()=>{var i=e.getState(),s=iL(i,i.tooltip.settings.shared);if(s==="axis"){var a=RL(i,r);a?.activeIndex!=null?e.dispatch(zQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(FQ())}y_=null})}});var SG={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},ree=Zs({name:"rootProps",initialState:SG,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:SG.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}}}),E$e=ree.reducer,{updateOptions:A$e}=ree.actions,iee=Zs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:T$e}=iee.actions,C$e=iee.reducer,see=to("keyDown"),aee=to("focus"),DL=db();DL.startListening({actionCreator:see,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var a=sL(i,Qm(n),Mb(n),Cb(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=jc(n);if(s==="Enter"){var c=WS(n,"axis","hover",String(i.index));e.dispatch(AR({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var d=J4e(n),h=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*h;if(!(l==null||m>=l.length||m<0)){var v=WS(n,"axis","hover",String(m));e.dispatch(AR({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:v}))}}}}}});DL.startListening({actionCreator:aee,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 s="0",a=WS(n,"axis","hover",String(s));e.dispatch(AR({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var La=to("externalEvent"),oee=db(),kN=new Map;oee.startListening({actionCreator:La,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=kN.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:KUe(o),activeDataKey:uL(o),activeIndex:od(o),activeLabel:ZQ(o),activeTooltipIndex:od(o),isTooltipActive:YUe(o)};n(l,r)}finally{kN.delete(i)}});kN.set(i,a)}}});var N$e=We([Zm],t=>t.tooltipItemPayloads),k$e=We([N$e,Ab,(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:s}=i;if(s!=null){var a=e(s,n);return a}}}),lee=to("touchMove"),cee=db();cee.startListening({actionCreator:lee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=iL(r,r.tooltip.settings.shared);if(i==="axis"){var s=RL(r,PL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(zQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var a,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(kY),d=(a=l.getAttribute(RY))!==null&&a!==void 0?a:void 0,h=k$e(e.getState(),c,d);e.dispatch(UQ({activeDataKey:d,activeIndex:c,activeCoordinate:h}))}}}});var R$e=ZK({brush:B8e,cartesianAxis:JBe,chartData:XFe,errorBars:b6e,graphicalItems:sBe,layout:_Pe,legend:NDe,options:$Fe,polarAxis:yze,polarOptions:C$e,referenceElements:X8e,rootProps:E$e,tooltip:uUe,zIndex:RFe}),P$e=function(e){return WRe({reducer:R$e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([tee.middleware,nee.middleware,DL.middleware,oee.middleware,cee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(fY({type:"raf"}))},devTools:$m.devToolsEnabled})};function uee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=hs(),s=E.useRef(null);if(i)return n;s.current==null&&(s.current=P$e(e));var a=GD;return E.createElement($6e,{context:a,store:s.current},n)}function D$e(t){var{layout:e,margin:n}=t,r=nr(),i=hs();return E.useEffect(()=>{i||(r(bPe(e)),r(xPe(n)))},[r,i,e,n]),null}var dee=E.memo(D$e,OM);function fee(t){var e=nr();return E.useEffect(()=>{e(A$e(t))},[e,t]),null}function wG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=kJ("".concat(r).concat(e)),s=nr();return E.useLayoutEffect(()=>(s(NFe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(kFe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function MG(t){var{children:e,isPanorama:n}=t,r=Ct(vFe);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return E.createElement(E.Fragment,null,i.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>E.createElement(wG,{key:a,zIndex:a,isPanorama:n})))}var O$e=["children"];function L$e(t,e){if(t==null)return{};var n,r,i=j$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function j$e(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 nw(){return nw=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},nw.apply(null,arguments)}var I$e={width:"100%",height:"100%",display:"block"},U$e=E.forwardRef((t,e)=>{var n=nO(),r=rO(),i=XY();if(!dl(n)||!dl(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,c,d;return a!=null&&(typeof a.tabIndex=="number"?c=a.tabIndex:c=i?0:void 0,typeof a.role=="string"?d=a.role:d=i?"application":void 0),E.createElement(LD,nw({},a,{title:o,desc:l,role:d,tabIndex:c,width:n,height:r,style:I$e,ref:e}),s)}),F$e=t=>{var{children:e}=t,n=Ct(aM);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return E.createElement(LD,{width:r,height:i,x:a,y:s},e)},EG=E.forwardRef((t,e)=>{var{children:n}=t,r=L$e(t,O$e),i=hs();return i?E.createElement(F$e,null,E.createElement(MG,{isPanorama:!0},n)):E.createElement(U$e,nw({ref:e},r),E.createElement(MG,{isPanorama:!1},n))});function z$e(){var t=nr(),[e,n]=E.useState(null),r=Ct(UPe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;cr(s)&&s!==r&&t(yPe(s))}},[e,t,r]),n}function AG(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 B$e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AG(Object(n),!0).forEach(function(r){H$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H$e(t,e,n){return(e=$$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $$e(t){var e=V$e(t,"string");return typeof e=="symbol"?e:e+""}function V$e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Zf(){return Zf=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},Zf.apply(null,arguments)}var G$e=()=>(r5e(),null);function rw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var W$e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[s,a]=E.useState({containerWidth:rw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:rw((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,d)=>{a(h=>{var g=Math.round(c),m=Math.round(d);return h.containerWidth===g&&h.containerHeight===m?h:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=c.getBoundingClientRect();o(d,h);var g=v=>{var{width:y,height:b}=v[0].contentRect;o(y,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(lM,{width:s.containerWidth,height:s.containerHeight}),E.createElement("div",Zf({ref:l},t)))}),q$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=E.useState({containerWidth:rw(n),containerHeight:rw(r)}),a=E.useCallback((l,c)=>{s(d=>{var h=Math.round(l),g=Math.round(c);return d.containerWidth===h&&d.containerHeight===g?d:{containerWidth:h,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:d}=l.getBoundingClientRect();a(c,d)}},[e,a]);return E.createElement(E.Fragment,null,E.createElement(lM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Zf({ref:o},t)))}),X$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement("div",Zf({ref:e},t)))}),K$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return Sc(n)||Sc(r)?E.createElement(q$e,Zf({},t,{ref:e})):E.createElement(X$e,Zf({},t,{ref:e}))});function Y$e(t){return t===!0?W$e:K$e}var Z$e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:d,onMouseMove:h,onMouseUp:g,onTouchEnd:m,onTouchMove:v,onTouchStart:y,style:b,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,A=E.useRef(null),T=nr(),[R,C]=E.useState(null),[I,N]=E.useState(null),D=z$e(),z=tO(),j=z?.width>0?z.width:x,W=z?.height>0?z.height:i,P=E.useCallback(fe=>{D(fe),typeof e=="function"&&e(fe),C(fe),N(fe),fe!=null&&(A.current=fe)},[D,e,C,N]),$=E.useCallback(fe=>{T(eee(fe)),T(La({handler:s,reactEvent:fe}))},[T,s]),K=E.useCallback(fe=>{T(UR(fe)),T(La({handler:c,reactEvent:fe}))},[T,c]),G=E.useCallback(fe=>{T(FQ()),T(La({handler:d,reactEvent:fe}))},[T,d]),Z=E.useCallback(fe=>{T(UR(fe)),T(La({handler:h,reactEvent:fe}))},[T,h]),Q=E.useCallback(()=>{T(aee())},[T]),ee=E.useCallback(fe=>{T(see(fe.key))},[T]),H=E.useCallback(fe=>{T(La({handler:a,reactEvent:fe}))},[T,a]),q=E.useCallback(fe=>{T(La({handler:o,reactEvent:fe}))},[T,o]),te=E.useCallback(fe=>{T(La({handler:l,reactEvent:fe}))},[T,l]),ae=E.useCallback(fe=>{T(La({handler:g,reactEvent:fe}))},[T,g]),xe=E.useCallback(fe=>{T(La({handler:y,reactEvent:fe}))},[T,y]),re=E.useCallback(fe=>{w&&T(lee(fe)),T(La({handler:v,reactEvent:fe}))},[T,w,v]),pe=E.useCallback(fe=>{T(La({handler:m,reactEvent:fe}))},[T,m]),Ce=Y$e(M);return E.createElement(sJ.Provider,{value:R},E.createElement(hK.Provider,{value:I},E.createElement(Ce,{width:j??b?.width,height:W??b?.height,className:An("recharts-wrapper",r),style:B$e({position:"relative",cursor:"default",width:j,height:W},b),onClick:$,onContextMenu:H,onDoubleClick:q,onFocus:Q,onKeyDown:ee,onMouseDown:te,onMouseEnter:K,onMouseLeave:G,onMouseMove:Z,onMouseUp:ae,onTouchEnd:pe,onTouchMove:re,onTouchStart:xe,ref:P},E.createElement(G$e,null),n)))}),Q$e=["width","height","responsive","children","className","style","compact","title","desc"];function J$e(t,e){if(t==null)return{};var n,r,i=eVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function eVe(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 hee=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:c,desc:d}=t,h=J$e(t,Q$e),g=Xs(h);return l?E.createElement(E.Fragment,null,E.createElement(lM,{width:n,height:r}),E.createElement(EG,{otherAttributes:g,title:c,desc:d},s)):E.createElement(Z$e,{className:a,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(EG,{otherAttributes:g,title:c,desc:d,ref:e},E.createElement(Y8e,null,s)))});function FR(){return FR=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},FR.apply(null,arguments)}var tVe={top:5,right:5,bottom:5,left:5},nVe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:tVe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},pee=E.forwardRef(function(e,n){var r,i=ei(e.categoricalChartProps,nVe),{chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,d={chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return E.createElement(uee,{preloadedState:{options:d},reduxStoreName:(r=c.id)!==null&&r!==void 0?r:s},E.createElement(zJ,{chartData:c.data}),E.createElement(dee,{layout:i.layout,margin:i.margin}),E.createElement(fee,{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(hee,FR({},i,{ref:n})))}),rVe=["axis","item"],iVe=E.forwardRef((t,e)=>E.createElement(pee,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));function sVe(t){var e=nr();return E.useEffect(()=>{e(T$e(t))},[e,t]),null}var aVe=["layout"];function zR(){return zR=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},zR.apply(null,arguments)}function oVe(t,e){if(t==null)return{};var n,r,i=lVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lVe(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 cVe={top:5,right:5,bottom:5,left:5},mee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:cVe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},uVe=E.forwardRef(function(e,n){var r,i=ei(e.categoricalChartProps,mee),{layout:s}=i,a=oVe(i,aVe),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:d}=e,h={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,eventEmitter:void 0};return E.createElement(uee,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(zJ,{chartData:i.data}),E.createElement(dee,{layout:s,margin:i.margin}),E.createElement(fee,{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(sVe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(hee,zR({},a,{ref:n})))});function TG(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 CG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TG(Object(n),!0).forEach(function(r){dVe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dVe(t,e,n){return(e=fVe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fVe(t){var e=hVe(t,"string");return typeof e=="symbol"?e:e+""}function hVe(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 pVe=["item"],mVe=CG(CG({},mee),{},{layout:"centric",startAngle:0,endAngle:360}),gVe=E.forwardRef((t,e)=>{var n=ei(t,mVe);return E.createElement(uVe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:pVe,tooltipPayloadSearcher:mL,categoricalChartProps:n,ref:e})}),xVe=["axis"],bVe=E.forwardRef((t,e)=>E.createElement(pee,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:xVe,tooltipPayloadSearcher:mL,categoricalChartProps:t,ref:e}));const __=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function vVe(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 yVe({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=vVe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],b=g.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((m,v)=>m.date.localeCompare(v.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=E.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const v=new Date(m.completed_at||m.created_at),y=new Date(v);y.setDate(v.getDate()-v.getDay());const b=y.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,v)=>m.week.localeCompare(v.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,s,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(b=>{const x=(m.filament_used_grams||0)/y.length;g.set(b,(g.get(b)||0)+x)})}),Array.from(g.entries()).map(([m,v])=>({name:m,value:Math.round(v)})).sort((m,v)=>v.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let v=5;v>=0;v--){const y=new Date(g.getFullYear(),g.getMonth()-v,1),b=new Date(g.getFullYear(),g.getMonth()-v+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=y&&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"?s:a,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),h=i.reduce((g,m)=>g+(m.cost||0),0);return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),u.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>u.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))})]}),u.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),u.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(h/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),u.jsx(ZC,{width:"100%",height:250,children:u.jsxs(bVe,{data:c,children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),u.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),u.jsx(QJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):u.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(ZC,{width:160,height:160,children:u.jsxs(gVe,{children:[u.jsx(DJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>u.jsx(kb,{fill:__[m%__.length]},`cell-${m}`))}),u.jsx(mN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),u.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const v=o.reduce((b,x)=>b+x.value,0),y=v>0?(g.value/v*100).toFixed(0):0;return u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:__[m%__.length]}}),u.jsx("span",{className:"text-white truncate flex-1",children:g.name}),u.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):u.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[u.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),u.jsx(ZC,{width:"100%",height:200,children:u.jsxs(iVe,{data:l,children:[u.jsx(DR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),u.jsx(LR,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),u.jsx(IR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),u.jsx(mN,{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"]}),u.jsx(qY,{}),u.jsx(UJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function _Ve({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:d,transition:h,isDragging:g}=aK({id:t}),m={transform:xm.Transform.toString(d),transition:h,opacity:g?.5:1};return r?null:u.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:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.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:u.jsx(aP,{className:"w-4 h-4 text-bambu-gray"})}),u.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:a,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?u.jsx(Voe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):u.jsx(zoe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),u.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:u.jsx(rP,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),u.jsx("div",{className:"p-4",children:n})]})}function SVe({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const b={};return t.forEach(x=>{b[x.id]=x.defaultSize||4}),b},[i,s]=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()}}),[a,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&&s(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=UX(lS(Bw,{activationConstraint:{distance:8}}),lS(zw,{coordinateGetter:oK})),c=b=>{const{active:x,over:M}=b;M&&x.id!==M.id&&s(w=>{const A=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Vw(w.order,A,T)}})},d=b=>{s(x=>({...x,hidden:x.hidden.includes(b)?x.hidden.filter(M=>M!==b):[...x.hidden,b]}))},h=b=>{s(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()};s(b)},m=i.order.map(b=>t.find(x=>x.id===b)).filter(Boolean),v=m.filter(b=>!i.hidden.includes(b.id)),y=m.filter(b=>i.hidden.includes(b.id));return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>o(!a),children:[u.jsx(t0,{className:"w-4 h-4"}),y.length," Hidden"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:g,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset Layout"]})]}),a&&y.length>0&&u.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[u.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(b=>u.jsxs("button",{onClick:()=>d(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:[u.jsx(t0,{className:"w-3 h-3"}),b.title]},b.id))})]}),u.jsx(tK,{sensors:l,collisionDetection:HX,onDragEnd:c,children:u.jsx(iK,{items:v.map(b=>b.id),strategy:DD,children:u.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(b=>u.jsx(_Ve,{id:b.id,title:b.title,isHidden:i.hidden.includes(b.id),size:i.sizes[b.id]||2,onToggleVisibility:()=>d(b.id),onToggleSize:()=>h(b.id),children:b.component},b.id))})})}),v.length===0&&u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx("p",{children:"All widgets are hidden."}),u.jsx(Ue,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function wVe({stats:t,currency:e}){return u.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),u.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:u.jsx(Qr,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:u.jsx(n1,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:u.jsx(s0,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:u.jsx(XN,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),u.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function MVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),u.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:u.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ud,{className:"w-4 h-4 text-red-400"}),u.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),u.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function EVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return u.jsx("div",{className:"flex items-center justify-center h-full",children:u.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,a=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("div",{className:"relative w-28 h-28",children:[u.jsxs("svg",{className:"w-full h-full -rotate-90",children:[u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),u.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),u.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),u.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),u.jsxs("div",{className:"space-y-2 flex-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[u.jsx(E9,{className:"w-3 h-3"}),u.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&u.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>u.jsxs("div",{className:"flex items-center justify-between text-xs",children:[u.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),u.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 AVe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return u.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 u.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return u.jsxs("div",{children:[u.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[u.jsx("span",{className:"text-white",children:n}),u.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),u.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:u.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function TVe({printDates:t}){return u.jsx(h3e,{printDates:t,months:4})}function CVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):u.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>u.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:u.jsx(ko,{className:"w-4 h-4 text-bambu-green"})}),u.jsxs("div",{children:[u.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),u.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function NVe({archives:t,currency:e}){return!t||t.length===0?u.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):u.jsx(yVe,{archives:t,currency:e})}function kVe(){const{data:t,isLoading:e}=Mt({queryKey:["archiveStats"],queryFn:Le.getArchiveStats}),{data:n}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:r}=Mt({queryKey:["archives"],queryFn:()=>Le.getArchives(void 0,1e3,0)}),{data:i}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),s=i?.currency||"$",a=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return u.jsx("div",{className:"p-8",children:u.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:u.jsx(wVe,{stats:t,currency:s}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:u.jsx(MVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:u.jsx(EVe,{stats:t,printerMap:a}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:u.jsx(AVe,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:u.jsx(TVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:u.jsx(CVe,{stats:t,printerMap:a}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:u.jsx(NVe,{archives:r||[],currency:s}),defaultSize:4}];return u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-6",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),u.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),u.jsx(SVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function RVe({plug:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(!1),[c,d]=E.useState(!1),{data:h,isLoading:g,refetch:m}=Mt({queryKey:["smart-plug-status",t.id],queryFn:()=>Le.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),y=v?.find(R=>R.id===t.printer_id),b=At({mutationFn:R=>Le.controlSmartPlug(t.id,R),onSuccess:()=>{m()}}),x=At({mutationFn:R=>Le.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=At({mutationFn:()=>Le.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=h?.state==="ON",A=h?.reachable??!1,T=b.isPending;return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:u.jsx(Nx,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),u.jsx("div",{className:"flex items-center gap-2",children:g?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?u.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[u.jsx(T9,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:h?.state||"Unknown"})]}):u.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[u.jsx(fP,{className:"w-4 h-4"}),u.jsx("span",{children:"Offline"})]})})]}),y&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),u.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&u.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[u.jsx(ff,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&u.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[u.jsx(Wr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),u.jsxs("div",{className:"flex gap-2 mb-3",children:[u.jsxs(Ue,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4"}),"On"]}),u.jsxs(Ue,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4"}),"Off"]})]}),u.jsxs("button",{onClick:()=>d(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Automation Settings"]}),u.jsx("span",{children:c?"-":"+"})]}),c&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto On"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),u.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&&u.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),u.jsxs("div",{className:"flex gap-2",children:[u.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:[u.jsx(Qr,{className:"w-4 h-4"}),"Time"]}),u.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:[u.jsx(Ip,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),u.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"})]}):u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),u.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"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{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)}),s&&u.jsx(Zi,{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"),a(!1)},onCancel:()=>a(!1)}),o&&u.jsx(Zi,{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 PVe({plug:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[d,h]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[v,y]=E.useState(null),[b,x]=E.useState(null),[M,w]=E.useState(t?.power_alert_enabled||!1),[A,T]=E.useState(t?.power_alert_high?.toString()||""),[R,C]=E.useState(t?.power_alert_low?.toString()||""),[I,N]=E.useState(t?.schedule_enabled||!1),[D,z]=E.useState(t?.schedule_on_time||""),[j,W]=E.useState(t?.schedule_off_time||""),{data:P}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:$}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs});E.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const K=At({mutationFn:()=>Le.testSmartPlugConnection(a,l||null,d||null),onSuccess:q=>{y(q),x(null),!i&&q.device_name&&s(q.device_name)},onError:q=>{y(null),x(q.message)}}),G=At({mutationFn:q=>Le.createSmartPlug(q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Z=At({mutationFn:q=>Le.updateSmartPlug(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:q=>{x(q.message)}}),Q=P?.filter(q=>!$?.some(ae=>ae.printer_id===q.id&&ae.id!==t?.id)),ee=q=>{if(q.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!a.trim()){x("IP address is required");return}const te={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:M,power_alert_high:A?parseFloat(A):null,power_alert_low:R?parseFloat(R):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:j||null};r?Z.mutate(te):G.mutate(te)},H=G.isPending||Z.isPending;return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:q=>q.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ee,className:"p-6 space-y-4",children:[b&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:a,onChange:q=>{o(q.target.value),y(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"}),u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(T9,{className:"w-4 h-4"}),"Test"]})]})]}),v&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${v.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:v.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsxs("div",{children:[u.jsx("p",{className:"font-medium",children:"Connected!"}),u.jsxs("p",{className:"text-sm opacity-80",children:[v.device_name&&`Device: ${v.device_name} - `,"State: ",v.state]})]})]}):u.jsxs(u.Fragment,{children:[u.jsx(fP,{className:"w-5 h-5"}),u.jsx("span",{children:"Connection failed"})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:q=>s(q.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"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),u.jsx("input",{type:"text",value:l,onChange:q=>c(q.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:d,onChange:q=>h(q.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"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),u.jsxs("select",{value:g??"",onChange:q=>m(q.target.value?Number(q.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:[u.jsx("option",{value:"",children:"No printer (manual control only)"}),Q?.map(q=>u.jsx("option",{value:q.id,children:q.name},q.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ff,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:M,onChange:q=>w(q.target.checked),className:"sr-only peer"}),u.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"})]})]}),M&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),u.jsx("input",{type:"number",value:A,onChange:q=>T(q.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),u.jsx("input",{type:"number",value:R,onChange:q=>C(q.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-green"}),u.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:I,onChange:q=>N(q.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),u.jsx("input",{type:"time",value:D,onChange:q=>z(q.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),u.jsx("input",{type:"time",value:j,onChange:q=>W(q.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"})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:H,className:"flex-1",children:[H?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function er({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return u.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:u.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 DVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function OVe({provider:t,onEdit:e}){const n=Nn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),d=c?.find(y=>y.id===t.printer_id),h=At({mutationFn:y=>Le.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=At({mutationFn:()=>Le.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=At({mutationFn:()=>Le.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),v=y=>y||"";return u.jsxs(u.Fragment,{children:[u.jsx(Lt,{className:"relative",children:u.jsxs(Ft,{className:"p-4",children:[u.jsxs("div",{className:"flex items-start justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:u.jsx(ff,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),u.jsxs("div",{children:[u.jsx("h3",{className:"font-medium text-white",children:t.name}),u.jsx("p",{className:"text-sm text-bambu-gray",children:DVe[t.provider_type]||t.provider_type})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&u.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&u.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),d&&u.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),u.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&u.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:u.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),u.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&u.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&u.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&u.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&u.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&u.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&u.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&u.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&u.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&u.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[u.jsx(t1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&u.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),u.jsx("div",{className:"mb-3",children:u.jsxs(Ue,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&u.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?u.jsx(Ss,{className:"w-4 h-4"}):u.jsx(ud,{className:"w-4 h-4"}),u.jsx("span",{children:o.message})]}),u.jsxs("button",{onClick:()=>a(!s),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:[u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fw,{className:"w-4 h-4"}),"Event Settings"]}),s?u.jsx(cw,{className:"w-4 h-4"}):u.jsx(Qf,{className:"w-4 h-4"})]}),s&&u.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Enabled"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),u.jsx(er,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Started"}),u.jsx(er,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),u.jsx(er,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),u.jsx(er,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),u.jsx(er,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),u.jsx(er,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),u.jsx(er,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),u.jsx(er,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),u.jsx(er,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(t1,{className:"w-4 h-4 text-purple-400"}),u.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),u.jsx(er,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:[v(t.quiet_hours_start)||"22:00"," - ",v(t.quiet_hours_end)||"07:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Wr,{className:"w-4 h-4 text-emerald-400"}),u.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),u.jsx(er,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&u.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),u.jsxs("span",{className:"text-sm text-white",children:["Send at ",v(t.daily_digest_time)||"08:00"]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),u.jsxs("div",{className:"flex gap-2 pt-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[u.jsx(lP,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})]})}),r&&u.jsx(Zi,{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 NG=[{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"email",label:"Email",description:"SMTP email notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function LVe({provider:t,onClose:e}){const n=Nn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.provider_type||"discord"),[l,c]=E.useState(t?.printer_id||null),[d,h]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[v,y]=E.useState(t?.quiet_hours_end||"07:00"),[b,x]=E.useState(t?.daily_digest_enabled||!1),[M,w]=E.useState(t?.daily_digest_time||"08:00"),[A,T]=E.useState(t?.on_print_start??!1),[R,C]=E.useState(t?.on_print_complete??!0),[I,N]=E.useState(t?.on_print_failed??!0),[D,z]=E.useState(t?.on_print_stopped??!0),[j,W]=E.useState(t?.on_print_progress??!1),[P,$]=E.useState(t?.on_printer_offline??!1),[K,G]=E.useState(t?.on_printer_error??!1),[Z,Q]=E.useState(t?.on_filament_low??!1),[ee,H]=E.useState(t?.on_maintenance_due??!1),[q,te]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,J])=>[V,String(J)])):{}),[ae,xe]=E.useState(null),[re,pe]=E.useState(null),{data:Ce}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{const V=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const fe=At({mutationFn:()=>Le.testNotificationConfig({provider_type:a,config:q}),onSuccess:V=>{xe(V),pe(null)},onError:V=>{xe({success:!1,message:V.message})}}),Se=At({mutationFn:V=>Le.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),Re=At({mutationFn:V=>Le.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{pe(V.message)}}),ue=V=>{if(V.preventDefault(),pe(null),!i.trim()){pe("Name is required");return}const J=F(a);for(const Ae of J)if(!q[Ae.key]?.trim()){pe(`${Ae.label} is required`);return}const le={name:i.trim(),provider_type:a,config:q,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?v:null,daily_digest_enabled:b,daily_digest_time:b?M:null,on_print_start:A,on_print_complete:R,on_print_failed:I,on_print_stopped:D,on_print_progress:j,on_printer_offline:P,on_printer_error:K,on_filament_low:Z,on_maintenance_due:ee};r?Re.mutate(le):Se.mutate(le)},ct=Se.isPending||Re.isPending,B=V=>{switch(V){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},F=V=>B(V).filter(J=>J.required),ie=B(a);return u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:V=>V.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),u.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[re&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:re}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),u.jsx("input",{type:"text",value:i,onChange:V=>s(V.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),u.jsx("select",{value:a,onChange:V=>{o(V.target.value),te({}),xe(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:NG.map(V=>u.jsx("option",{value:V.value,children:V.label},V.value))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:NG.find(V=>V.value===a)?.description})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ie.map(V=>u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?u.jsx("select",{value:q[V.key]||V.options[0]?.value||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(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:V.options.map(J=>u.jsx("option",{value:J.value,children:J.label},J.value))}):u.jsx("input",{type:V.type,value:q[V.key]||"",onChange:J=>{te({...q,[V.key]:J.target.value}),xe(null)},placeholder:V.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"})]},V.key))]}),u.jsx("div",{className:"flex gap-2",children:u.jsxs(Ue,{type:"button",variant:"secondary",onClick:()=>{xe(null),fe.mutate()},disabled:fe.isPending||!q[F(a)[0]?.key],className:"flex-1",children:[fe.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&u.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.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:ae.success?u.jsxs(u.Fragment,{children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]}):u.jsxs(u.Fragment,{children:[u.jsx(ud,{className:"w-5 h-5"}),u.jsx("span",{children:ae.message})]})}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),u.jsxs("select",{value:l??"",onChange:V=>c(V.target.value?Number(V.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:[u.jsx("option",{value:"",children:"All printers"}),Ce?.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),u.jsx(er,{checked:d,onChange:h})]}),d&&u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),u.jsx("input",{type:"time",value:g,onChange:V=>m(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),u.jsx("input",{type:"time",value:v,onChange:V=>y(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),u.jsx(er,{checked:b,onChange:x})]}),b&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),u.jsx("input",{type:"time",value:M,onChange:V=>w(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Start"}),u.jsx(er,{checked:A,onChange:T})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Complete"}),u.jsx(er,{checked:R,onChange:C})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Failed"}),u.jsx(er,{checked:I,onChange:N})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Stopped"}),u.jsx(er,{checked:D,onChange:z})]}),u.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-sm text-white",children:"Progress"}),u.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),u.jsx(er,{checked:j,onChange:W})]})]})]}),u.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[u.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Offline"}),u.jsx(er,{checked:P,onChange:$})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Error"}),u.jsx(er,{checked:K,onChange:G})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),u.jsx(er,{checked:Z,onChange:Q})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),u.jsx(er,{checked:ee,onChange:H})]})]})]})]}),u.jsxs("div",{className:"flex gap-3 pt-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:ct,className:"flex-1",children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function jVe({template:t,onClose:e}){const n=Nn(),r=E.useRef(null),[i,s]=E.useState(t.title_template),[a,o]=E.useState(t.body_template),[l,c]=E.useState(null),[d,h]=E.useState(!0),{data:g}=Mt({queryKey:["template-variables"],queryFn:Le.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:v,isLoading:y}=Mt({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Le.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:d&&i.length>0&&a.length>0});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const b=At({mutationFn:T=>Le.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{c(T.message)}}),x=At({mutationFn:()=>Le.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{c(T.message)}}),M=T=>{if(T.preventDefault(),c(null),!i.trim()){c("Title is required");return}if(!a.trim()){c("Body is required");return}b.mutate({title_template:i,body_template:a})},w=T=>{const R=r.current;if(!R)return;const C=R.selectionStart,I=R.selectionEnd,N=a,D=N.substring(0,C),z=N.substring(I),j=D+`{${T}}`+z;o(j),setTimeout(()=>{R.focus();const W=C+T.length+2;R.setSelectionRange(W,W)},0)},A=i!==t.title_template||a!==t.body_template;return u.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),u.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:u.jsx(Qt,{className:"w-5 h-5 text-bambu-gray"})})]}),u.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&u.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),u.jsx("input",{type:"text",value:i,onChange:T=>s(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),u.jsx("textarea",{ref:r,value:a,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>u.jsxs("button",{type:"button",onClick:()=>w(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[u.jsx(li,{className:"w-3 h-3"}),T]},T))}),u.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(t0,{className:"w-4 h-4"}),"Live Preview"]}),u.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&u.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):v?u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),u.jsx("div",{className:"text-white font-medium",children:v.title})]}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),u.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:v.body})]})]}):u.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[u.jsxs(Ue,{type:"button",variant:"ghost",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-orange-400 hover:text-orange-300",children:[x.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(X0,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),u.jsxs(Ue,{onClick:M,disabled:b.isPending||!A,children:[b.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin mr-2"}):u.jsx(Qo,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const IVe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},UVe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function FVe({onClose:t}){const e=Nn(),{showToast:n}=Di(),[r,i]=E.useState(7),[s,a]=E.useState(null),[o,l]=E.useState(!1),{data:c,isLoading:d,refetch:h,isRefetching:g}=Mt({queryKey:["notification-logs",r,o],queryFn:()=>Le.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=Mt({queryKey:["notification-log-stats",r],queryFn:()=>Le.getNotificationLogStats(r)}),v=At({mutationFn:()=>Le.clearNotificationLogs(30),onSuccess:b=>{n(b.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:b=>{n(`Failed to clear logs: ${b.message}`,"error")}}),y=b=>{const x=new Date(b),w=new Date().getTime()-x.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:x.toLocaleDateString()+" "+x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[u.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(KN,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&u.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:u.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[u.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",u.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),u.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[u.jsxs("select",{value:r,onChange:b=>i(Number(b.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[u.jsx("option",{value:1,children:"Last 24 hours"}),u.jsx("option",{value:7,children:"Last 7 days"}),u.jsx("option",{value:30,children:"Last 30 days"}),u.jsx("option",{value:90,children:"Last 90 days"})]}),u.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:o,onChange:b=>l(b.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),u.jsx("div",{className:"flex-1"}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>h(),disabled:g,children:[g?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Refresh"]}),u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-red-400 hover:text-red-300",children:[v.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Clear Old"]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c&&c.length>0?u.jsx("div",{className:"space-y-2",children:c.map(b=>u.jsx(zVe,{log:b,isExpanded:s===b.id,onToggle:()=>a(s===b.id?null:b.id),formatDate:y},b.id))}):u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx(KN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function zVe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return u.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[u.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?u.jsx(Ss,{className:"w-4 h-4 text-bambu-green shrink-0"}):u.jsx(ud,{className:"w-4 h-4 text-red-400 shrink-0"}),u.jsx("span",{className:`text-xs font-medium ${UVe[t.event_type]||"text-bambu-gray"}`,children:IVe[t.event_type]||t.event_type}),u.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&u.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),u.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?u.jsx(cw,{className:"w-4 h-4 text-bambu-gray shrink-0"}):u.jsx(Qf,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&u.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),u.jsx("p",{className:"text-sm text-white",children:t.title})]}),u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),u.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),u.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),u.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[u.jsxs("span",{children:["Provider: ",t.provider_type]}),u.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const S_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:u.jsx(dP,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:u.jsx(ff,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:u.jsx(rc,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:u.jsx(Nx,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:u.jsx(ko,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:u.jsx(Zoe,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:u.jsx(Df,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:u.jsx(eP,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function BVe({onClose:t,onExport:e}){const{t:n}=sw(),[r,i]=E.useState(()=>{const v={};return S_.forEach(y=>{v[y.id]=y.default}),v}),[s,a]=E.useState(!1),[o,l]=E.useState(!1);E.useEffect(()=>{const v=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);const c=v=>{i(y=>({...y,[v]:!y[v]}))},d=()=>{const v={};S_.forEach(y=>{v[y.id]=!0}),i(v)},h=()=>{const v={};S_.forEach(y=>{v[y.id]=!1}),i(v)},g=Object.values(r).filter(Boolean).length,m=async()=>{l(!0);try{await e({...r,access_codes:s&&r.printers})}finally{l(!1)}};return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:u.jsx(Lt,{className:"w-full max-w-lg",onClick:v=>v.stopPropagation(),children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:u.jsx(va,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),u.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[u.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),u.jsx("span",{className:"text-bambu-gray",children:"|"}),u.jsx("button",{onClick:h,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),u.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:S_.map(v=>u.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[v.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[u.jsx("input",{type:"checkbox",checked:r[v.id],onChange:()=>c(v.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),u.jsx("div",{className:`${r[v.id]?"text-bambu-green":"text-bambu-gray"}`,children:v.icon}),u.jsxs("div",{className:"flex-1",children:[u.jsx("div",{className:"text-white text-sm font-medium",children:n(v.labelKey,{defaultValue:v.defaultLabel})}),u.jsx("div",{className:"text-xs text-bambu-gray",children:v.description})]})]},v.id))}),r.archives&&u.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(eP,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[u.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),u.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&u.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx(y9,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),u.jsx(er,{checked:s,onChange:a})]}),s&&u.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[u.jsx(ws,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),u.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),u.jsx(Ue,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?u.jsxs(u.Fragment,{children:[u.jsx(Ot,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(va,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const kG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives"};function HVe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=E.useState("options"),[s,a]=E.useState(!1),[o,l]=E.useState(null),[c,d]=E.useState(null),[h,g]=E.useState(new Set),m=E.useRef(null);E.useEffect(()=>{const w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const v=w=>{const A=w.target.files?.[0];A&&l(A)},y=async()=>{if(o){i("restoring");try{const w=await e(o,s);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},x=c?.restored?Object.values(c.restored).reduce((w,A)=>w+A,0)+(c.files_restored||0):0,M=c?.total_skipped||0;return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:u.jsx(Lt,{className:"w-full max-w-lg",children:u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-full ${r==="result"&&c?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!c?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&c?.success?u.jsx(Ss,{className:"w-5 h-5"}):r==="result"&&!c?.success?u.jsx(ws,{className:"w-5 h-5"}):u.jsx(Ka,{className:"w-5 h-5"})}),u.jsxs("div",{children:[u.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(c?.success?"Restore Complete":"Restore Failed")]}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&c?.message]})]})]}),r!=="restoring"&&u.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),r==="options"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:v}),u.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?u.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[u.jsx(Ss,{className:"w-5 h-5"}),u.jsx("span",{className:"font-medium",children:o.name})]}):u.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[u.jsx(Ka,{className:"w-8 h-8"}),u.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),u.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[u.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),u.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[u.jsxs("li",{children:[u.jsx("strong",{children:"Printers"})," - matched by serial number"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),u.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?u.jsx(qs,{className:"w-4 h-4 text-orange-400"}):u.jsx(i1,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),u.jsx(er,{checked:s,onChange:a})]})}),s&&u.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:u.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[u.jsx(ws,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),u.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[u.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),u.jsxs(Ue,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[u.jsx(Ka,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&u.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[u.jsx(Ot,{className:"w-12 h-12 text-bambu-green animate-spin"}),u.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&c&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[u.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:x}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),u.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[u.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:M}),u.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),c.restored&&Object.entries(c.restored).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(Ss,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),u.jsxs("div",{className:"space-y-1",children:[Object.entries(c.restored).filter(([,w])=>w>0).map(([w,A])=>u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:kG[w]||w}),u.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(c.files_restored||0)>0&&u.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[u.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),u.jsx("span",{className:"text-bambu-green font-medium",children:c.files_restored})]})]})]}),c.skipped&&Object.entries(c.skipped).some(([,w])=>w>0)&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[u.jsx(i1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),u.jsx("div",{className:"space-y-1",children:Object.entries(c.skipped).filter(([,w])=>w>0).map(([w,A])=>{const T=c.skipped_details?.[w]||[],R=h.has(w);return u.jsxs("div",{children:[u.jsxs("button",{onClick:()=>T.length>0&&b(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[u.jsxs("span",{className:"text-white flex items-center gap-2",children:[kG[w]||w,T.length>0&&(R?u.jsx(cw,{className:"w-3 h-3"}):u.jsx(Qf,{className:"w-3 h-3"}))]}),u.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),R&&T.length>0&&u.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((C,I)=>u.jsx("div",{children:C},I)),T.length>10&&u.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},w)})})]}),x===0&&M===0&&u.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),u.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:u.jsx(Ue,{onClick:t,children:"Close"})})]})]})})})}async function $Ve(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function VVe(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 GVe(){const t=Nn(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[s,a]=E.useState("auto"),[o,l]=E.useState(!1),[c,d]=E.useState("all"),[h,g]=E.useState(!1),{data:m,isLoading:v}=Mt({queryKey:["spoolman-settings"],queryFn:$Ve}),{data:y,isLoading:b,refetch:x}=Mt({queryKey:["spoolman-status"],queryFn:Le.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Mt({queryKey:["printers"],queryFn:Le.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"),g(!0))},[m]),E.useEffect(()=>{if(!h||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s){const W=setTimeout(()=>{w.mutate()},500);return()=>clearTimeout(W)}},[e,r,s,h]);const w=At({mutationFn:()=>VVe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!0),setTimeout(()=>l(!1),2e3)}}),A=At({mutationFn:Le.connectSpoolman,onSuccess:()=>{x()}}),T=At({mutationFn:Le.disconnectSpoolman,onSuccess:()=>{x()}}),R=At({mutationFn:Le.syncAllPrintersAms,onSuccess:j=>{j.success}}),C=At({mutationFn:j=>Le.syncPrinterAms(j),onSuccess:j=>{j.success}}),I=()=>{c==="all"?R.mutate():C.mutate(c)},N=R.isPending||C.isPending,D=c==="all"?R.data:C.data,z=c==="all"?R.isSuccess:C.isSuccess;return v?u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),u.jsx(Ft,{children:u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(dF,{className:"w-5 h-5 text-bambu-green"}),u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),w.isPending&&u.jsx(Ot,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&u.jsx(Qp,{className:"w-4 h-4 text-bambu-green"})]})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Enable Spoolman"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),u.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),u.jsxs("select",{value:s,onChange:j=>a(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[u.jsx("option",{value:"auto",children:"Automatic"}),u.jsx("option",{value:"manual",children:"Manual Only"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&u.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),b?u.jsx(Ot,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?u.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[u.jsx(Qp,{className:"w-4 h-4"}),"Connected"]}):u.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[u.jsx(Qt,{className:"w-4 h-4"}),"Disconnected"]})]}),u.jsx("div",{className:"flex gap-2",children:y?.connected?u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Noe,{className:"w-4 h-4"}),"Disconnect"]}):u.jsxs(Ue,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Roe,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&u.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}),y?.connected&&u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1",children:[u.jsxs("select",{value:c,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[u.jsx("option",{value:"all",children:"All Printers"}),M?.map(j=>u.jsx("option",{value:j.id,children:j.name},j.id))]}),u.jsx(Qf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:I,disabled:N,children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Sync"]})]})]}),z&&D&&u.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.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:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function WVe(){const t=Nn(),{t:e,i18n:n}=sw(),{showToast:r}=Di(),[i,s]=E.useState(null),[a,o]=E.useState(!1),[l,c]=E.useState(null),[d,h]=E.useState(!1),[g,m]=E.useState(null),[v,y]=E.useState(null),[b,x]=E.useState(!1),[M,w]=E.useState(k9()),[A,T]=E.useState("general"),[R,C]=E.useState(!1),[I,N]=E.useState(!1),[D,z]=E.useState(null),[j,W]=E.useState(!1),[P,$]=E.useState(!1),K=X=>{w(X),vce(X)},G=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Z,isLoading:Q}=Mt({queryKey:["settings"],queryFn:Le.getSettings}),{data:ee,isLoading:H}=Mt({queryKey:["smart-plugs"],queryFn:Le.getSmartPlugs}),{data:q,isLoading:te}=Mt({queryKey:["smart-plugs-energy",ee?.map(X=>X.id)],queryFn:async()=>{if(!ee||ee.length===0)return null;const X=await Promise.all(ee.filter(ze=>ze.enabled).map(async ze=>{try{const at=await Le.getSmartPlugStatus(ze.id);return{plug:ze,status:at}}catch{return{plug:ze,status:null}}}));let me=0,ve=0,ge=0,Ke=0,Ie=0;for(const{status:ze}of X)ze?.reachable&&ze.energy&&(Ie++,ze.energy.power!=null&&(me+=ze.energy.power),ze.energy.today!=null&&(ve+=ze.energy.today),ze.energy.yesterday!=null&&(ge+=ze.energy.yesterday),ze.energy.total!=null&&(Ke+=ze.energy.total));return{totalPower:me,totalToday:ve,totalYesterday:ge,totalLifetime:Ke,reachableCount:Ie,totalPlugs:ee.filter(ze=>ze.enabled).length}},enabled:A==="plugs"&&!!ee&&ee.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:ae,isLoading:xe}=Mt({queryKey:["notification-providers"],queryFn:Le.getNotificationProviders}),{data:re}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:pe,isLoading:Ce}=Mt({queryKey:["notification-templates"],queryFn:Le.getNotificationTemplates}),{data:fe}=Mt({queryKey:["ffmpeg-status"],queryFn:Le.checkFfmpeg}),{data:Se}=Mt({queryKey:["version"],queryFn:Le.getVersion}),{data:Re,refetch:ue,isRefetching:ct}=Mt({queryKey:["updateCheck"],queryFn:Le.checkForUpdates,staleTime:300*1e3}),{data:B,refetch:F}=Mt({queryKey:["updateStatus"],queryFn:Le.getUpdateStatus,refetchInterval:X=>{const me=X.state.data;return me?.status==="downloading"||me?.status==="installing"?1e3:!1}}),ie=At({mutationFn:Le.applyUpdate,onSuccess:()=>{F()}}),[V,J]=E.useState(null),le=At({mutationFn:Le.testAllNotificationProviders,onSuccess:X=>{J(X),t.invalidateQueries({queryKey:["notification-providers"]}),X.failed===0?r(`All ${X.tested} providers tested successfully!`,"success"):r(`${X.success}/${X.tested} providers succeeded`,X.failed>0?"error":"success")},onError:X=>{r(`Failed to test providers: ${X.message}`,"error")}}),Ae=At({mutationFn:async X=>{if(!ee)return{success:0,failed:0};const me=ee.filter(ge=>ge.enabled),ve=await Promise.all(me.map(async ge=>{try{return await Le.controlSmartPlug(ge.id,X),{success:!0}}catch{return{success:!1}}}));return{success:ve.filter(ge=>ge.success).length,failed:ve.filter(ge=>!ge.success).length}},onSuccess:(X,me)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),X.failed===0?r(`All ${X.success} plugs turned ${me}`,"success"):r(`${X.success} plugs turned ${me}, ${X.failed} failed`,"error")},onError:X=>{r(`Failed: ${X.message}`,"error")}}),Ee=E.useRef(null),se=E.useRef(!0);E.useEffect(()=>{Z&&!i&&(s(Z),setTimeout(()=>{se.current=!1},100))},[Z,i]);const U=At({mutationFn:Le.updateSettings,onSuccess:X=>{t.setQueryData(["settings"],X),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:X=>{r(`Failed to save: ${X.message}`,"error")}});E.useEffect(()=>{if(!(se.current||!i||!Z||!(Z.auto_archive!==i.auto_archive||Z.save_thumbnails!==i.save_thumbnails||Z.capture_finish_photo!==i.capture_finish_photo||Z.default_filament_cost!==i.default_filament_cost||Z.currency!==i.currency||Z.energy_cost_per_kwh!==i.energy_cost_per_kwh||Z.energy_tracking_mode!==i.energy_tracking_mode||Z.check_updates!==i.check_updates||Z.notification_language!==i.notification_language||Z.ams_humidity_good!==i.ams_humidity_good||Z.ams_humidity_fair!==i.ams_humidity_fair||Z.ams_temp_good!==i.ams_temp_good||Z.ams_temp_fair!==i.ams_temp_fair||Z.date_format!==i.date_format||Z.time_format!==i.time_format||Z.default_printer_id!==i.default_printer_id)))return Ee.current&&clearTimeout(Ee.current),Ee.current=setTimeout(()=>{U.mutate(i)},500),()=>{Ee.current&&clearTimeout(Ee.current)}},[i,Z,U]);const L=E.useCallback((X,me)=>{s(ve=>ve?{...ve,[X]:me}:null)},[]);return Q||!i?u.jsx("div",{className:"p-8 flex justify-center",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-8",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),u.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),u.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[u.jsx("button",{onClick:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),u.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(Nx,{className:"w-4 h-4"}),"Smart Plugs",ee&&ee.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ee.length})]}),u.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(ff,{className:"w-4 h-4"}),"Notifications",ae&&ae.length>0&&u.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ae.length})]})]}),A==="general"&&u.jsxs("div",{className:"flex gap-8",children:[u.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[u.jsx(e1,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),u.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:WU.map(X=>u.jsxs("option",{value:X.code,children:[X.nativeName," (",X.name,")"]},X.code))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),u.jsx("select",{value:M,onChange:X=>K(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:A_.map(X=>u.jsx("option",{value:X.to,children:e(X.labelKey)},X.id))}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),u.jsxs("select",{value:i.date_format||"system",onChange:X=>L("date_format",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:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),u.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),u.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),u.jsxs("select",{value:i.time_format||"system",onChange:X=>L("time_format",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:[u.jsx("option",{value:"system",children:"System Default"}),u.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),u.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),u.jsxs("select",{value:i.default_printer_id??"",onChange:X=>L("default_printer_id",X.target.value?Number(X.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"No default (ask each time)"}),re?.map(X=>u.jsx("option",{value:X.id,children:X.name},X.id))]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Sidebar order"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:G,children:[u.jsx(X0,{className:"w-4 h-4"}),"Reset"]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Auto-archive prints"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:X=>L("auto_archive",X.target.checked),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Save thumbnails"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:X=>L("save_thumbnails",X.target.checked),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Capture finish photo"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:X=>L("capture_finish_photo",X.target.checked),className:"sr-only peer"}),u.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&fe&&!fe.installed&&u.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[u.jsx(ws,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),u.jsxs("div",{className:"text-sm",children:[u.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),u.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",u.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:X=>L("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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),u.jsxs("select",{value:i.currency,onChange:X=>L("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:[u.jsx("option",{value:"USD",children:"USD ($)"}),u.jsx("option",{value:"EUR",children:"EUR (€)"}),u.jsx("option",{value:"GBP",children:"GBP (£)"}),u.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),u.jsx("option",{value:"JPY",children:"JPY (¥)"}),u.jsx("option",{value:"CNY",children:"CNY (¥)"}),u.jsx("option",{value:"CAD",children:"CAD ($)"}),u.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),u.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:X=>L("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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),u.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:X=>L("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:[u.jsx("option",{value:"print",children:"Prints Only"}),u.jsx("option",{value:"total",children:"Total Consumption"})]}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Bae,{className:"w-4 h-4 text-blue-400"}),u.jsx("span",{className:"font-medium",children:"Humidity"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:X=>L("ams_humidity_good",parseInt(X.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:X=>L("ams_humidity_fair",parseInt(X.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),u.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-2 text-white",children:[u.jsx(Ip,{className:"w-4 h-4 text-orange-400"}),u.jsx("span",{className:"font-medium",children:"Temperature"})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:X=>L("ams_temp_good",parseFloat(X.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:X=>L("ams_temp_fair",parseFloat(X.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),u.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]}),u.jsx(GVe,{})]}),u.jsxs("div",{className:"space-y-6 flex-1 max-w-sm",children:[u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Check for updates"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),u.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:X=>L("check_updates",X.target.checked),className:"sr-only peer"}),u.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"})]})]}),u.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Current version"}),u.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Se?.version||"..."]})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>ue(),disabled:ct,children:[ct?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(qs,{className:"w-4 h-4"}),"Check now"]})]}),Re?.update_available?u.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsxs("div",{children:[u.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Re.latest_version]}),Re.release_name&&Re.release_name!==Re.latest_version&&u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Re.release_name}),Re.release_notes&&u.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:Re.release_notes})]}),Re.release_url&&u.jsx("a",{href:Re.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:u.jsx(vc,{className:"w-4 h-4"})})]}),B?.status==="downloading"||B?.status==="installing"?u.jsxs("div",{className:"mt-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[u.jsx(Ot,{className:"w-4 h-4 animate-spin"}),u.jsx("span",{children:B.message})]}),u.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:u.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${B.progress}%`}})})]}):B?.status==="complete"?u.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:B.message}):B?.status==="error"?u.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:B.error||B.message}):u.jsxs(Ue,{className:"mt-3",onClick:()=>ie.mutate(),disabled:ie.isPending,children:[ie.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(va,{className:"w-4 h-4"}),"Install Update"]})]}):Re?.error?u.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: ",Re.error]}):Re&&!Re.update_available?u.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),u.jsxs(Lt,{children:[u.jsx(Yl,{children:u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),u.jsxs(Ft,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Backup Data"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>W(!0),children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Restore Backup"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[u.jsx(Ka,{className:"w-4 h-4"}),"Restore"]})]}),u.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Clear"]})]})}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>N(!0),children:[u.jsx(Qn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="plugs"&&u.jsxs("div",{className:"max-w-4xl",children:[u.jsxs("div",{className:"flex items-start justify-between mb-6",children:[u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Nx,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),u.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ee&&ee.filter(X=>X.enabled).length>1&&u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("on"),disabled:Ae.isPending,title:"Turn all plugs on",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(dd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),u.jsxs(Ue,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>z("off"),disabled:Ae.isPending,title:"Turn all plugs off",children:[Ae.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(cP,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),u.jsxs(Ue,{className:"whitespace-nowrap",onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ee&&ee.length>0&&u.jsxs(Lt,{className:"mb-6",children:[u.jsx(Yl,{children:u.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[u.jsx(s0,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",te&&u.jsx(Ot,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),u.jsx(Ft,{children:q?u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(s0,{className:"w-3 h-3"}),"Current Power"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalPower.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[q.reachableCount,"/",q.totalPlugs," plugs online"]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Wr,{className:"w-3 h-3"}),"Today"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalToday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(Xle,{className:"w-3 h-3"}),"Yesterday"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalYesterday.toFixed(2),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),u.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[u.jsx(XN,{className:"w-3 h-3"}),"Total"]}),u.jsxs("div",{className:"text-xl font-bold text-white",children:[q.totalLifetime.toFixed(1),u.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&u.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(q.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):te?null:u.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),H?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ee&&ee.length>0?u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(X=>u.jsx(RVe,{plug:X,onEdit:me=>{c(me),o(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-12",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(Nx,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),u.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),u.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),u.jsxs(Ue,{onClick:()=>{c(null),o(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="notifications"&&u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(ff,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>x(!0),children:[u.jsx(KN,{className:"w-4 h-4"}),"Log"]}),ae&&ae.length>0&&u.jsxs(Ue,{size:"sm",variant:"secondary",onClick:()=>{J(null),le.mutate()},disabled:le.isPending,children:[le.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(uP,{className:"w-4 h-4"}),"Test All"]}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add"]})]})]}),u.jsx(Lt,{className:"mb-4",children:u.jsx(Ft,{className:"py-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),u.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),u.jsx("select",{value:i.notification_language||"en",onChange:X=>L("notification_language",X.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:WU.map(X=>u.jsx("option",{value:X.code,children:X.nativeName},X.code))})]})})}),V&&u.jsx(Lt,{className:"mb-4",children:u.jsxs(Ft,{className:"py-3",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),u.jsx("button",{onClick:()=>J(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),u.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[u.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[u.jsx(Ss,{className:"w-4 h-4"}),V.success," passed"]}),V.failed>0&&u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(ud,{className:"w-4 h-4"}),V.failed," failed"]})]}),V.results.filter(X=>!X.success).length>0&&u.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:V.results.filter(X=>!X.success).map(X=>u.jsxs("div",{className:"text-xs text-red-400",children:[u.jsxs("span",{className:"font-medium",children:[X.provider_name,":"]})," ",X.message]},X.provider_id))})]})}),xe?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ae&&ae.length>0?u.jsx("div",{className:"space-y-3",children:ae.map(X=>u.jsx(OVe,{provider:X,onEdit:me=>{m(me),h(!0)}},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(ff,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),u.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),u.jsxs(Ue,{size:"sm",onClick:()=>{m(null),h(!0)},children:[u.jsx(li,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),u.jsxs("div",{children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[u.jsx(rc,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),u.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Ce?u.jsx("div",{className:"flex justify-center py-8",children:u.jsx(Ot,{className:"w-6 h-6 text-bambu-green animate-spin"})}):pe&&pe.length>0?u.jsx("div",{className:"space-y-2",children:pe.map(X=>u.jsx(Lt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(X),children:u.jsx(Ft,{className:"py-2.5 px-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"text-white font-medium text-sm truncate",children:X.name}),u.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:X.title_template})]}),u.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:me=>{me.stopPropagation(),y(X)},children:u.jsx(lP,{className:"w-4 h-4 text-bambu-gray"})})]})})},X.id))}):u.jsx(Lt,{children:u.jsx(Ft,{className:"py-8",children:u.jsxs("div",{className:"text-center text-bambu-gray",children:[u.jsx(rc,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),u.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),a&&u.jsx(PVe,{plug:l,onClose:()=>{o(!1),c(null)}}),d&&u.jsx(LVe,{provider:g,onClose:()=>{h(!1),m(null)}}),v&&u.jsx(jVe,{template:v,onClose:()=>y(null)}),b&&u.jsx(FVe,{onClose:()=>x(!1)}),R&&u.jsx(Zi,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{C(!1);try{const X=await Le.clearNotificationLogs(30);r(X.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>C(!1)}),I&&u.jsx(Zi,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{N(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>N(!1)}),D&&u.jsx(Zi,{title:`Turn All Plugs ${D==="on"?"On":"Off"}`,message:`This will turn ${D==="on"?"ON":"OFF"} all ${ee?.filter(X=>X.enabled).length||0} enabled smart plugs. ${D==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${D==="on"?"On":"Off"}`,variant:D==="off"?"danger":"warning",onConfirm:()=>{const X=D;z(null),Ae.mutate(X)},onCancel:()=>z(null)}),j&&u.jsx(BVe,{onClose:()=>W(!1),onExport:async X=>{W(!1);try{const{blob:me,filename:ve}=await Le.exportBackup(X),ge=URL.createObjectURL(me),Ke=document.createElement("a");Ke.href=ge,Ke.download=ve,Ke.click(),URL.revokeObjectURL(ge),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),P&&u.jsx(HVe,{onClose:()=>$(!1),onRestore:async(X,me)=>await Le.importBackup(X,me),onSuccess:()=>{t.invalidateQueries()}})]})}const gee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},qVe=t=>t.startsWith("HH")?"HF":"S",XVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},BR=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 RN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=qVe(t.nozzle_id),l=t.nozzle_diameter,c=()=>{r&&s?s():e()};return u.jsxs("div",{className:"flex items-center gap-2",children:[r&&u.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?u.jsx(Pf,{className:"w-4 h-4 text-bambu-green"}):u.jsx(em,{className:"w-4 h-4"})}),u.jsxs("button",{onClick:c,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:gee(t.k_value)}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&u.jsx("span",{title:"Has note",children:u.jsx(M9,{className:"w-3 h-3 text-yellow-500"})}),u.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&u.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:a,children:["Note: ",a.length>50?a.substring(0,50)+"...":a]})]}),!r&&n&&u.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function PN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:d}=Di(),[h,g]=E.useState(t?.name||""),[m,v]=E.useState(t?.k_value?gee(t.k_value):"0.020"),[y,b]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?XVe(t.nozzle_id):"HH00"),[w,A]=E.useState(t?.nozzle_diameter||n),[T,R]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,I]=E.useState(!1),[N,D]=E.useState({current:0,total:0}),[z,j]=E.useState(s),W=fr.useMemo(()=>{const ee=new Map;for(const H of r)if(H.filament_id&&!ee.has(H.filament_id)){const q=BR(H.name||"");ee.set(H.filament_id,{id:H.filament_id,name:q||H.filament_id})}return Array.from(ee.values()).sort((H,q)=>H.name.localeCompare(q.name))},[r]),P=At({mutationFn:ee=>(console.log("[KProfile] Calling API..."),Le.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),d("K-profile saved"),c&&z!==s){let H;z===""&&a?H=a:t&&t.slot_id>0?H=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:H=`name_${h}_${y}`,c(H,z)}I(!0),setTimeout(()=>{I(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),d(ee.message,"error"),I(!1)}}),$=At({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),Le.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),d(ee.message,"error"),I(!1)}}),[K,G]=E.useState(!1),Z=()=>{t&&$.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})},Q=async ee=>{if(ee.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const H=parseFloat(m).toFixed(6),q=`${x}-${w}`;if(t||T.length===1){const ae={name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),P.mutate(ae);return}I(!0),D({current:1,total:T.length});const te=T.map(ae=>({name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${te.length} profiles in batch:`,te);try{if(await Le.setKProfilesBatch(e,te),d(`K-profile saved to ${T.length} extruders`),c&&z){const ae=`name_${h}_${y}`;c(ae,z)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),l()},3e3)};return u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[u.jsxs(Lt,{className:"w-full max-w-md relative",children:[C&&u.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),u.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),u.jsxs(Ft,{className:"p-0",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),u.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("form",{onSubmit:Q,className:"p-4 space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),u.jsx("input",{type:"text",value:h,onChange:ee=>g(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),u.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:ee=>{const H=ee.target.value;(H===""||/^\d*\.?\d*$/.test(H))&&v(H)},onBlur:ee=>{const H=parseFloat(ee.target.value);isNaN(H)||v((Math.trunc(H*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}),u.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"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),u.jsxs("select",{value:y,onChange:ee=>{const H=ee.target.value;if(b(H),!t&&H&&!h){const q=W.find(te=>te.id===H);q&&g(`${x==="HH00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[u.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&u.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>u.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),u.jsxs("select",{value:x,onChange:ee=>{const H=ee.target.value;if(M(H),!t&&y&&!h){const q=W.find(te=>te.id===y);q&&g(`${H==="HS00"?"HF":"S"} ${q.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"HH00",children:"High Flow"}),u.jsx("option",{value:"HS00",children:"Standard"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),u.jsxs("select",{value:w,onChange:ee=>A(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?u.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"}):u.jsxs("div",{className:"flex gap-4",children:[u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:ee=>{ee.target.checked?R([...T,1]):R(T.filter(H=>H!==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"}),u.jsx("span",{className:"text-white",children:"Left"})]}),u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:ee=>{ee.target.checked?R([...T,0]):R(T.filter(H=>H!==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"}),u.jsx("span",{className:"text-white",children:"Right"})]})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),u.jsx("textarea",{value:z,onChange:ee=>j(ee.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),u.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:$.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"})}),u.jsx(Ue,{type:"button",variant:"secondary",onClick:o,disabled:C,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{type:"submit",disabled:P.isPending||C,className:"flex-1",children:[P.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(sP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:()=>{G(!1),Z()},disabled:$.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[$.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const w_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function KVe(){const{showToast:t}=Di(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(w_.NOZZLE_DIAMETER)||"0.4"),[s,a]=E.useState(null),[o,l]=E.useState(!1),[c,d]=E.useState(null),[h,g]=E.useState(""),[m,v]=E.useState("all"),[y,b]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(w_.SORT_OPTION)||"name"),[w,A]=E.useState(!1),[T,R]=E.useState(new Set),[C,I]=E.useState(!1),[N,D]=E.useState(!1),z=V=>`${V.slot_id}_${V.extruder_id}`;E.useEffect(()=>{localStorage.setItem(w_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(w_.SORT_OPTION,x)},[x]);const{data:j,isLoading:W}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:P,isLoading:$,isFetching:K,error:G,refetch:Z}=Mt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await Le.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",V?.profiles?.length||0,"profiles"),V},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Q}=Mt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Le.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:H}=Mt({queryKey:["kprofile-notes",e],queryFn:()=>Le.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),q=G?.message?.includes("not connected");E.useEffect(()=>{if(!e&&j&&j.length>0){const V=j.find(J=>J.is_active);V&&n(V.id)}},[e,j]),E.useEffect(()=>{if(e){const V=setTimeout(()=>{Z()},150);return()=>clearTimeout(V)}},[e,r]);const te=j?.filter(V=>V.is_active)||[],ae=fr.useMemo(()=>P?.profiles?P.profiles.filter(J=>{const le=h.toLowerCase(),Ae=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ee=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Ae&&Ee&&se}).sort((J,le)=>{switch(x){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return BR(J.name).localeCompare(BR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[P?.profiles,h,m,y,x]),xe=j?.find(V=>V.id===e),re=xe?.nozzle_count===2;E.useEffect(()=>{const V=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||c||(J.key==="r"||J.key==="R"?(J.preventDefault(),Z()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&w&&(J.preventDefault(),A(!1),R(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[s,o,c,w,Z]);const pe=E.useCallback(()=>{if(!P?.profiles||P.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:xe?.name||"Unknown",nozzle_diameter:r,profiles:P.profiles.map(Ee=>({name:Ee.name,k_value:Ee.k_value,filament_id:Ee.filament_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,extruder_id:Ee.extruder_id}))},J=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Ae=document.createElement("a");Ae.href=le,Ae.download=`kprofiles_${xe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(le),t(`Exported ${P.profiles.length} profiles`)},[P?.profiles,xe,r,t]),Ce=E.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const Ae=await le.text(),Ee=JSON.parse(Ae);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let se=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await Le.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${se} of ${Ee.profiles.length} profiles`),Z()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},V.click()},[e,r,t,Z]),fe=E.useCallback(V=>{R(J=>{const le=new Set(J);return le.has(V)?le.delete(V):le.add(V),le})},[]),Se=E.useCallback(()=>{R(new Set(ae.map(V=>z(V))))},[ae,z]),Re=E.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),ue=E.useCallback(async()=>{const V=ae.filter(le=>T.has(z(le)));D(!0);let J=0;for(const le of V)try{await Le.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",le.name,Ae)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),R(new Set),Z()},[e,T,ae,t,Z,z]),ct=E.useCallback(V=>{const J=[];return V.setting_id&&J.push(V.setting_id),J.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),J.push(`name_${V.name}_${V.filament_id}`),J},[]),B=E.useCallback(async(V,J)=>{if(e)try{await Le.setKProfileNote(e,V,J),H()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,H,t]),F=E.useCallback(V=>{if(!ee?.notes)return{note:"",key:null};const J=ct(V);for(const le of J)if(ee.notes[le])return{note:ee.notes[le],key:le};return{note:"",key:null}},[ee,ct]),ie=E.useCallback(V=>F(V).note,[F]);return W?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(No,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),u.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):te.length===0?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(ko,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),u.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):u.jsxs(u.Fragment,{children:[K&&!$&&u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[u.jsx(Ot,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),u.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[u.jsxs("div",{className:"flex-1 min-w-48",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),u.jsx("select",{value:e||"",onChange:V=>n(parseInt(V.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:te.map(V=>u.jsx("option",{value:V.id,children:V.name},V.id))})]}),u.jsxs("div",{className:"w-32",children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),u.jsxs("select",{value:r,onChange:V=>i(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"0.2",children:"0.2mm"}),u.jsx("option",{value:"0.4",children:"0.4mm"}),u.jsx("option",{value:"0.6",children:"0.6mm"}),u.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),disabled:K,children:[u.jsx(qs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Profile"]})]})]}),u.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[u.jsxs("div",{className:"flex-1 min-w-48 relative",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:h,onChange:V=>g(V.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"})]}),re&&u.jsx("div",{className:"w-36",children:u.jsxs("select",{value:m,onChange:V=>v(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Extruders"}),u.jsx("option",{value:"left",children:"Left Only"}),u.jsx("option",{value:"right",children:"Right Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:y,onChange:V=>b(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"all",children:"All Flow"}),u.jsx("option",{value:"hf",children:"HF Only"}),u.jsx("option",{value:"s",children:"S Only"})]})}),u.jsx("div",{className:"w-32",children:u.jsxs("select",{value:x,onChange:V=>M(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"name",children:"Sort: Name"}),u.jsx("option",{value:"k_value",children:"Sort: K-Value"}),u.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),u.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[u.jsxs(Ue,{variant:"secondary",onClick:pe,disabled:!P?.profiles?.length,title:"Export profiles to JSON",children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]}),u.jsxs(Ue,{variant:"secondary",onClick:Ce,title:"Import profiles from JSON",children:[u.jsx(Ka,{className:"w-4 h-4"}),"Import"]}),u.jsx("div",{className:"flex-1"}),w?u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",onClick:Se,title:"Select all visible profiles",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select All"]}),u.jsxs(Ue,{variant:"secondary",onClick:Re,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),u.jsxs(Ue,{variant:"secondary",onClick:()=>{A(!1),R(new Set)},children:[u.jsx(Qt,{className:"w-4 h-4"}),"Cancel"]})]}):u.jsxs(Ue,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[u.jsx(Pf,{className:"w-4 h-4"}),"Select"]})]}),$?u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(fP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),u.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),u.jsxs(Ue,{variant:"secondary",onClick:()=>Z(),children:[u.jsx(qs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?re?u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===1).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),u.jsx("div",{className:"space-y-1",children:ae.filter(V=>V.extruder_id===0).map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))})]})]}):u.jsx("div",{className:"space-y-1",children:ae.map(V=>u.jsx(RN,{profile:V,onEdit:()=>a(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(z(V)),onToggleSelect:()=>fe(z(V)),note:ie(V)},z(V)))}):h||m!=="all"||y!=="all"?u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(Zu,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),u.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-12 text-center",children:[u.jsx(sP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),u.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),u.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),u.jsxs(Ue,{onClick:()=>l(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:V,key:J}=F(s);return u.jsx(PN,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,initialNote:V,initialNoteKey:J,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),Z()},onSave:()=>{a(null),Z()}})})(),o&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,onClose:()=>{l(!1),Z()},onSave:()=>{l(!1),Z()}}),c&&e&&u.jsx(PN,{printerId:e,nozzleDiameter:r,existingProfiles:Q?.profiles||P?.profiles,isDualNozzle:re,onSaveNote:B,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-sm",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:u.jsx(Qn,{className:"w-5 h-5 text-red-500"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),u.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",u.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>I(!1),disabled:N,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:ue,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function OL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=c?c[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:d}}function V0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function YVe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a<7?`${a}d ago`:e.toLocaleDateString()}function ZVe({onSuccess:t}){const{showToast:e}=Di(),[n,r]=E.useState("email"),[i,s]=E.useState(""),[a,o]=E.useState(""),[l,c]=E.useState(""),[d,h]=E.useState(""),[g,m]=E.useState("global"),v=At({mutationFn:()=>Le.cloudLogin(i,a,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")}),y=At({mutationFn:()=>Le.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),b=At({mutationFn:()=>Le.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?v.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},M=v.isPending||y.isPending||b.isPending;return u.jsx(Lt,{className:"max-w-md mx-auto",children:u.jsxs(Ft,{children:[u.jsxs("div",{className:"text-center mb-6",children:[u.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:u.jsx(tP,{className:"w-6 h-6 text-bambu-green"})}),u.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),u.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),u.jsx("input",{type:"email",value:i,onChange:w=>s(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),u.jsx("input",{type:"password",value:a,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),u.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:[u.jsx("option",{value:"global",children:"Global"}),u.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),u.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),u.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),u.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),u.jsx("textarea",{value:d,onChange:w=>h(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),u.jsxs("div",{className:"flex gap-2",children:[n==="code"&&u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),u.jsxs(Ue,{type:"submit",disabled:M,className:"flex-1",children:[M?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(pF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(y9,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&u.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:u.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[u.jsx(pF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Sp({label:t,value:e,options:n,onChange:r}){const[i,s]=E.useState(!1),a=n.find(o=>o.value===e);return u.jsxs("div",{className:"relative",children:[u.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[u.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),u.jsx("span",{children:a?.label||"All"}),u.jsx(Qf,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),u.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>u.jsxs("button",{onClick:()=>{r(o.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[u.jsx("span",{children:o.label}),o.count!==void 0&&u.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function QVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?u.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:u.jsx(Yp,{className:"w-5 h-5"})}):null}function DN({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=OL(t.name),l=V0(t.setting_id);return u.jsxs("div",{className:"flex items-center gap-2 group",children:[u.jsx("button",{onClick:e,disabled:a,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":a?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!a?"cursor-pointer":""}`,children:u.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&u.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&l&&u.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),u.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),u.jsx("button",{onClick:c=>{c.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:u.jsx(Jp,{className:"w-4 h-4"})})]})}function HR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
  8227. `)){const i=t.replace(/\\n/g,`
  8228. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8229. `);if(i.length>1)return`"""
  8230. `+i.map(s=>n+" "+s).join(`
  8231. `)+`
  8232. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8233. `+t.map(i=>n+" "+HR(i,e+1)).join(`,
  8234. `)+`
  8235. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8236. `+r.map(([s,a])=>n+" "+JSON.stringify(s)+": "+HR(a,e+1)).join(`,
  8237. `)+`
  8238. `+n+"}"}return String(t)}function JVe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=Di(),a=Nn(),[o,l]=E.useState(!1),{data:c,isLoading:d}=Mt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Le.getCloudSettingDetail(t.setting_id)}),h=At({mutationFn:()=>Le.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:v=>s(v.message,"error")}),g=V0(t.setting_id),m=OL(t.name,c?.setting?.inherits);return u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:u.jsxs(Ft,{className:"p-0 flex flex-col min-h-0 flex-1",children:[u.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&u.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),u.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[u.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"•"}),u.jsx("span",{children:m.printer})]})]})]}),u.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?u.jsx("div",{className:"flex items-center justify-center py-16",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?u.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:HR(c)}):u.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?u.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[u.jsx(ws,{className:"w-5 h-5"}),u.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),u.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>l(!1),disabled:h.isPending,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{variant:"danger",onClick:()=>h.mutate(),disabled:h.isPending,className:"flex-1",children:[h.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]}):u.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),u.jsxs(Ue,{variant:"secondary",onClick:r,children:[u.jsx(Jp,{className:"w-4 h-4"}),"Duplicate"]}),g&&u.jsxs(u.Fragment,{children:[u.jsxs(Ue,{variant:"secondary",onClick:i,disabled:d||!c,children:[u.jsx(Rf,{className:"w-4 h-4"}),"Edit"]}),u.jsx(Ue,{variant:"danger",onClick:()=>l(!0),children:u.jsx(Qn,{className:"w-4 h-4"})})]})]})})]})})})}function xee(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function bee(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function eGe({onClose:t,onApply:e}){const{showToast:n}=Di(),[r,i]=E.useState(xee),[s,a]=E.useState("all"),[o,l]=E.useState(null),[c,d]=E.useState(""),[h,g]=E.useState(""),[m,v]=E.useState("{}"),[y,b]=E.useState(null),[x,M]=E.useState(null),w=s==="all"?r:r.filter(j=>j.type===s),A=j=>{i(j),bee(j)},T=j=>{const W=r.filter(P=>P.id!==j);A(W),M(null),n("Template deleted")},R=j=>{l(j.id),d(j.name),g(j.description),v(JSON.stringify(j.settings,null,2)),b(null)},C=()=>{if(!(!o||!c.trim()))try{const j=JSON.parse(m),W=r.map(P=>P.id===o?{...P,name:c.trim(),description:h.trim(),settings:j}:P);A(W),l(null),n("Template updated")}catch(j){b(j.message)}},I=()=>{l(null),d(""),g(""),v("{}"),b(null)},N=j=>{const W=r.map(P=>P.id===j?{...P,showInModal:!P.showInModal}:P);A(W)},D={filament:{label:"Filament",icon:nP,color:"text-amber-400"},print:{label:"Process",icon:fw,color:"text-blue-400"},printer:{label:"Printer",icon:ko,color:"text-purple-400"}},z=x?r.find(j=>j.id===x):null;return E.useEffect(()=>{const j=W=>{W.key==="Escape"&&(x?M(null):o?I():t())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[x,o,t]),u.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&u.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:u.jsx(Lt,{className:"w-full max-w-md",children:u.jsxs(Ft,{className:"p-6",children:[u.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:u.jsx(ws,{className:"w-6 h-6 text-red-400"})}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),u.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',u.jsx("span",{className:"font-medium",children:z.name}),'"?']}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:()=>T(x),className:"flex-1 bg-red-500 hover:bg-red-600",children:[u.jsx(Qn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),u.jsx(Lt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:u.jsxs(Ft,{className:"p-0 flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(n0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(j=>u.jsx("button",{onClick:()=>a(j),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===j?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:j==="all"?"All":D[j].label},j))]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx(n0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),u.jsx("p",{children:"No templates yet"}),u.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):u.jsx("div",{className:"space-y-2",children:w.map(j=>{const W=D[j.type],P=W.icon;return o===j.id?u.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[u.jsx("input",{type:"text",value:c,onChange:$=>d($.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),u.jsx("input",{type:"text",value:h,onChange:$=>g($.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"mb-3",children:[u.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),u.jsx("textarea",{value:m,onChange:$=>{v($.target.value),b(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&u.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs(Ue,{size:"sm",onClick:C,disabled:!c.trim(),children:[u.jsx(Qo,{className:"w-4 h-4"}),"Save"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},j.id):u.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[u.jsx(P,{className:`w-5 h-5 ${W.color} flex-shrink-0`}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-white",children:j.name}),u.jsx("p",{className:"text-xs text-bambu-gray truncate",children:j.description})]}),u.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(j.settings).length," fields"]}),u.jsx("button",{onClick:()=>N(j.id),className:`p-1 transition-colors ${j.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:j.showInModal?"Shown in modals":"Hidden in modals",children:j.showInModal?u.jsx(t0,{className:"w-4 h-4"}):u.jsx(rP,{className:"w-4 h-4"})}),u.jsx("button",{onClick:()=>e(j),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),u.jsx("button",{onClick:()=>R(j),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:u.jsx(Rf,{className:"w-4 h-4"})}),u.jsx("button",{onClick:()=>M(j.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:u.jsx(Qn,{className:"w-4 h-4"})})]},j.id)})})})]})})]})}function vee({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,a]=E.useState("changes"),[o,l]=E.useState(""),c=E.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const y of m){if(y==="inherits"||y==="version")continue;const b=e[y],x=n[y],M=y in e,w=y in n;let A;!M&&w?A="added":M&&!w?A="removed":JSON.stringify(b)!==JSON.stringify(x)?A="changed":A="same",v.push({key:y,left:b,right:x,status:A})}return v.sort((y,b)=>{const x={changed:0,added:1,removed:2,same:3};return x[y.status]!==x[b.status]?x[y.status]-x[b.status]:y.key.localeCompare(b.key)})},[e,n]),d=E.useMemo(()=>{let m=[...c];if(s==="changes"&&(m=m.filter(v=>v.status!=="same")),o){const v=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(v)||String(y.left).toLowerCase().includes(v)||String(y.right).toLowerCase().includes(v))}return m},[c,s,o]),h=E.useMemo(()=>({added:c.filter(m=>m.status==="added").length,removed:c.filter(m=>m.status==="removed").length,changed:c.filter(m=>m.status==="changed").length,same:c.filter(m=>m.status==="same").length}),[c]),g=m=>{if(m===void 0)return"—";if(m===null)return"null";if(Array.isArray(m))return m.length===0?"[]":m.length===1?String(m[0]):m.join(", ");if(typeof m=="object")return JSON.stringify(m);const v=String(m);if(v.includes("\\n")||v.length>100){const y=v.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return E.useEffect(()=>{const m=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),u.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:u.jsx(Lt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:u.jsxs(Ft,{className:"p-0 flex flex-col min-h-0 flex-1",children:[u.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[u.jsx(Cx,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),u.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:u.jsx(Qt,{className:"w-5 h-5"})})]}),u.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[u.jsxs("div",{className:"text-center",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),u.jsx("p",{className:"text-white font-medium truncate",children:r})]}),u.jsxs("div",{className:"text-center",children:[u.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),u.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),u.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[u.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[u.jsx(li,{className:"w-3.5 h-3.5"}),h.added," added"]}),u.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[u.jsx(mF,{className:"w-3.5 h-3.5"}),h.removed," removed"]}),u.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[u.jsx(qN,{className:"w-3.5 h-3.5"}),h.changed," changed"]}),u.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[u.jsx(Q2,{className:"w-3.5 h-3.5"}),h.same," same"]})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative",children:[u.jsx(Zu,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:o,onChange:m=>l(m.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),h.same>0&&u.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[u.jsx("button",{onClick:()=>a("changes"),className:`px-3 py-1.5 text-sm transition-colors ${s==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),u.jsx("button",{onClick:()=>a("all"),className:`px-3 py-1.5 text-sm transition-colors ${s==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),u.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?u.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[u.jsx(Q2,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),u.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):u.jsxs("table",{className:"w-full",children:[u.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:u.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[u.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),u.jsx("th",{className:"text-left p-3 w-1/3",children:r}),u.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),u.jsx("tbody",{children:d.map(m=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:u.jsx(li,{className:"w-3.5 h-3.5 text-green-400"}),removed:u.jsx(mF,{className:"w-3.5 h-3.5 text-red-400"}),changed:u.jsx(qN,{className:"w-3.5 h-3.5 text-amber-400"}),same:u.jsx(Q2,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return u.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[u.jsx("td",{className:"p-3",children:u.jsxs("div",{className:"flex items-center gap-2",children:[y,u.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),u.jsx("td",{className:"p-3",children:u.jsx("span",{className:`text-sm font-mono break-all ${m.status==="removed"?"text-red-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.left)})}),u.jsx("td",{className:"p-3",children:u.jsx("span",{className:`text-sm font-mono break-all ${m.status==="added"?"text-green-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.right)})})]},m.key)})})]})})]})})})}function tGe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Di(),i=Nn(),s=!!e?.setting_id,[a,o]=E.useState("common"),[l,c]=E.useState(e?.type||"filament"),[d,h]=E.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[g,m]=E.useState(e?.base_id||""),[v,y]=E.useState(""),[b,x]=E.useState(e?.setting||{inherits:""}),[M,w]=E.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=E.useState(null),[R,C]=E.useState(""),[I,N]=E.useState(!1),[D,z]=E.useState(""),[j,W]=E.useState(!1),[P,$]=E.useState(xee),[K,G]=E.useState(!1),[Z,Q]=E.useState(""),[ee,H]=E.useState(""),[q,te]=E.useState(!0),[ae,xe]=E.useState(null),[re,pe]=E.useState(!1),Ce=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),fe=E.useMemo(()=>Ce.filter(ce=>V0(ce.setting_id)),[Ce]),{data:Se}=Mt({queryKey:["cloudFields",l],queryFn:()=>Le.getCloudFields(l==="print"?"process":l),staleTime:1e3*60*60}),{data:Re}=Mt({queryKey:["allPresetDetails",l,fe.map(ce=>ce.setting_id).join(",")],queryFn:async()=>{const ce={};for(let He=0;He<fe.length;He+=5){const Ye=fe.slice(He,He+5);(await Promise.all(Ye.map(async de=>{try{const Je=await Le.getCloudSettingDetail(de.setting_id);return{id:de.setting_id,detail:Je}}catch{return null}}))).forEach(de=>{de&&(ce[de.id]=de.detail)})}return ce},enabled:fe.length>0,staleTime:1e3*60*10}),{data:ue,isLoading:ct}=Mt({queryKey:["cloudSettingDetail",g],queryFn:()=>Le.getCloudSettingDetail(g),enabled:!!g});E.useEffect(()=>{a!=="json"&&w(JSON.stringify(b,null,2))},[b,a]);const B=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(Qe=>!V0(Qe.setting_id)).sort((Qe,He)=>Qe.name.localeCompare(He.name)),[n,l]);E.useEffect(()=>{if(!g)return;const ce=B.find(Qe=>Qe.setting_id===g);ce&&(y(ce.name),s||(x({inherits:ce.name}),w(JSON.stringify({inherits:ce.name},null,2))))},[g,B,s]);const F=E.useMemo(()=>{const ce=Se?.fields||[],Qe=new Set(ce.map(de=>de.key)),He=new Set,Ye=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Re&&Object.values(Re).forEach(de=>{de?.setting&&Object.keys(de.setting).forEach(Je=>{!Qe.has(Je)&&!Ye.has(Je)&&He.add(Je)})}),Object.keys(b).forEach(de=>{!Qe.has(de)&&!Ye.has(de)&&He.add(de)});const ut=Array.from(He).sort().map(de=>({key:de,label:de.replace(/_/g," ").replace(/\b\w/g,Je=>Je.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ce,...ut]},[Se,Re,b]),ie=F.filter(ce=>ce.label.toLowerCase().includes(R.toLowerCase())||ce.key.toLowerCase().includes(R.toLowerCase())),V=()=>{if(D.trim()){const ce=D.trim().toLowerCase().replace(/\s+/g,"_");J(ce,""),z(""),W(!1),r(`Field "${ce}" added`)}},J=(ce,Qe)=>{x(He=>{const Ye={...He};return Qe===""||Qe===void 0?delete Ye[ce]:Ye[ce]=Qe,Ye})},le=ce=>{x(Qe=>({...Qe,...ce.settings})),xe(ce.name),r("Template applied")},Ae=()=>{if(!Z.trim())return;const ce={...b};if(delete ce.inherits,Object.keys(ce).length===0){r("No overrides to save","error");return}const Qe={id:Date.now().toString(),name:Z.trim(),description:ee.trim()||"Custom template",type:l,settings:ce,showInModal:q},He=[...P,Qe];$(He),bee(He),G(!1),Q(""),H(""),te(!0),r("Template saved")},Ee=E.useMemo(()=>P.filter(ce=>ce.type===l&&ce.showInModal),[l,P]),se=ce=>{w(ce);try{const Qe=JSON.parse(ce);x(Qe),T(null)}catch(Qe){T(Qe.message)}},U=ce=>{ce.preventDefault(),N(!1);const Qe=ce.dataTransfer.files[0];if(Qe&&Qe.name.endsWith(".json")){const He=new FileReader;He.onload=Ye=>{try{const ut=Ye.target?.result,de=JSON.parse(ut),Je=de.setting||de;x(be=>({...be,...Je})),w(JSON.stringify({...b,...Je},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},He.readAsText(Qe)}},L=At({mutationFn:()=>{const ce={...b},Qe=l==="filament"?"filament_settings_id":l==="print"?"print_settings_id":"printer_settings_id";ce[Qe]=`"${d}"`;const He={type:l,name:d,base_id:g,setting:ce};return Le.createCloudSetting(He)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),X=At({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Le.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),me=s?X:L,ve=ue?.setting?.inherits,ge=ve?B.find(ce=>ce.name===ve):void 0,{data:Ke}=Mt({queryKey:["cloudSettingDetail",ge?.setting_id],queryFn:()=>Le.getCloudSettingDetail(ge.setting_id),enabled:!!ge?.setting_id}),Ie=E.useMemo(()=>{const ce=Ke?.setting||{},Qe=ue?.setting||{},He=g&&Re?.[g]?.setting?Re[g].setting:{};return{...ce,...Qe,...He}},[g,ue,Ke,Re]),ze=ce=>{if(ce==null)return"";if(Array.isArray(ce)){const Qe=[...new Set(ce.map(He=>String(He)))];return Qe.length===1?Qe[0]:ce.join(", ")}return String(ce)},at=ce=>{const Qe=b[ce.key],He=Ie[ce.key],Ye=ze(He),ut=ct?"Loading...":Ye||"",de="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ce.type==="boolean"){const Je=Qe==="1"||Qe===void 0&&He==="1";return u.jsx("button",{type:"button",onClick:()=>J(ce.key,Qe==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Je?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:u.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Je?"translate-x-3.5":"translate-x-0.5"}`})})}return ce.type==="select"?u.jsxs("select",{value:Qe||"",onChange:Je=>J(ce.key,Je.target.value),className:de,children:[u.jsx("option",{value:"",children:ut}),ce.options?.map(Je=>u.jsx("option",{value:Je.value,children:Je.label},Je.value))]}):u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:ce.type==="number"?"number":"text",value:Qe!==void 0?String(Qe):"",onChange:Je=>J(ce.key,Je.target.value),step:ce.step,min:ce.min,max:ce.max,placeholder:ut,className:de}),ce.unit&&u.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ce.unit})]})},Fe=E.useMemo(()=>ue?.setting?ue.setting:{},[ue]);return u.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ce=>{ce.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:U,children:[re&&g&&u.jsx(vee,{onClose:()=>pe(!1),leftPreset:Fe,rightPreset:b,leftLabel:`Base: ${v||g}`,rightLabel:`Current: ${d||"New Preset"}`}),u.jsx(Lt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:u.jsxs(Ft,{className:"p-0 flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[g&&u.jsxs("button",{onClick:()=>pe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[u.jsx(Cx,{className:"w-4 h-4"}),"Compare"]}),u.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:u.jsx(Qt,{className:"w-5 h-5"})})]})]}),I&&u.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Ka,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),u.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),u.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[u.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),u.jsxs("select",{value:l,onChange:ce=>{c(ce.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"filament",children:"Filament"}),u.jsx("option",{value:"print",children:"Process"}),u.jsx("option",{value:"printer",children:"Printer"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),u.jsxs("select",{value:g,onChange:ce=>m(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"",children:"Select base preset..."}),B.map(ce=>u.jsx("option",{value:ce.setting_id,children:ce.name},ce.setting_id))]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),u.jsx("input",{type:"text",value:d,onChange:ce=>h(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),v&&u.jsx("div",{className:"text-xs text-bambu-gray",children:u.jsxs("p",{className:"flex items-center gap-1",children:[u.jsx(Qp,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",u.jsx("span",{className:"text-white",children:v}),ct&&u.jsx(Ot,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),u.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[u.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(gF,{className:"w-4 h-4"}),"Common"]}),u.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(oP,{className:"w-4 h-4"}),"All Fields"]}),u.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[u.jsx(Pae,{className:"w-4 h-4"}),"JSON",A&&u.jsx(No,{className:"w-3 h-3 text-red-400"})]}),u.jsx("div",{className:"flex-1"}),u.jsxs("button",{onClick:()=>{const ce={name:d,type:l,base_id:g,setting:b},Qe=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),He=URL.createObjectURL(Qe),Ye=document.createElement("a");Ye.href=He,Ye.download=`${d||"preset"}.json`,document.body.appendChild(Ye),Ye.click(),document.body.removeChild(Ye),URL.revokeObjectURL(He),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[u.jsx(va,{className:"w-4 h-4"}),"Export"]}),u.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[u.jsx(Ka,{className:"w-4 h-4"}),"Import"]}),u.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ce=>{const Qe=ce.target.files?.[0];if(Qe){const He=new FileReader;He.onload=Ye=>{try{const ut=JSON.parse(Ye.target?.result),de=ut.setting||ut;x(Je=>({...Je,...de})),r("File imported")}catch{r("Invalid JSON","error")}},He.readAsText(Qe)}}})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[a==="common"&&u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[u.jsx(n0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(ce=>ce!=="inherits").length>0&&u.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[u.jsx(Qo,{className:"w-3 h-3"}),"Save as template"]})]}),K&&u.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[u.jsx("input",{type:"text",value:Z,onChange:ce=>Q(ce.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),u.jsx("input",{type:"text",value:ee,onChange:ce=>H(ce.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsxs(Ue,{size:"sm",onClick:Ae,disabled:!Z.trim(),children:[u.jsx(Qo,{className:"w-3 h-3"}),"Save"]}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),u.jsxs("button",{onClick:()=>te(!q),className:`flex items-center gap-1.5 text-xs transition-colors ${q?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[q?u.jsx(t0,{className:"w-3.5 h-3.5"}):u.jsx(rP,{className:"w-3.5 h-3.5"}),q?"Show in modals":"Hidden in modals"]})]})]}),ae&&u.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[u.jsx(Qp,{className:"w-4 h-4 text-bambu-green"}),u.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",u.jsx("span",{className:"font-medium",children:ae})]}),u.jsx("button",{onClick:()=>xe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:u.jsx(Qt,{className:"w-4 h-4"})})]}),u.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ee.map(ce=>u.jsxs("button",{onClick:()=>le(ce),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[u.jsx("p",{className:"text-sm font-medium text-white",children:ce.name}),u.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ce.description})]},ce.id)),Ee.length===0&&u.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),u.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),u.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:F.slice(0,10).map(ce=>u.jsxs("div",{className:"flex items-center justify-between gap-4",children:[u.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ce.label}),u.jsx("div",{className:"w-48",children:at(ce)})]},ce.key))})]}),Object.keys(b).length>1&&u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([ce])=>ce!=="inherits").map(([ce,Qe])=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ce,": ",String(Qe).slice(0,20),u.jsx("button",{onClick:()=>J(ce,void 0),className:"hover:text-white",children:u.jsx(Qt,{className:"w-3 h-3"})})]},ce))})]})]}),a==="fields"&&u.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[u.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),u.jsx("span",{className:"text-xs text-bambu-gray",children:Re?`${F.length} fields`:"Loading..."})]}),u.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:R,onChange:ce=>C(ce.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ie.filter(ce=>!(ce.key in b)).map(ce=>{const Qe=Ie[ce.key],He=ze(Qe);return u.jsxs("div",{onClick:()=>{x(Ye=>({...Ye,[ce.key]:He||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"text-sm text-white truncate",children:ce.label}),u.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ce.key})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[He&&u.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:He,children:[He.slice(0,20),He.length>20?"...":""]}),u.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:u.jsx(li,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ce.key)}),ie.filter(ce=>!(ce.key in b)).length===0&&u.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:R?"No matching fields":"All fields added"})]}),u.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:j?u.jsxs("div",{className:"flex gap-2",children:[u.jsx("input",{type:"text",value:D,onChange:ce=>z(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&V(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),u.jsx(Ue,{size:"sm",onClick:V,disabled:!D.trim(),children:u.jsx(li,{className:"w-4 h-4"})}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>{W(!1),z("")},children:u.jsx(Qt,{className:"w-4 h-4"})})]}):u.jsxs("button",{onClick:()=>W(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[u.jsx(li,{className:"w-4 h-4"}),"Add custom field"]})})]}),u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[u.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),u.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(ce=>ce!=="inherits").length," fields"]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([ce])=>ce!=="inherits").map(([ce,Qe])=>{const He=F.find(Ye=>Ye.key===ce);return u.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-medium text-white",children:He?.label||ce}),u.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ce})]}),u.jsx("button",{onClick:()=>J(ce,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:u.jsx(Qt,{className:"w-4 h-4"})})]}),He?at(He):u.jsx("input",{type:"text",value:String(Qe),onChange:Ye=>J(ce,Ye.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ce)}),Object.keys(b).filter(ce=>ce!=="inherits").length===0&&u.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[u.jsx(gF,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),u.jsx("p",{className:"text-sm",children:"No overrides yet"}),u.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(ce=>ce!=="inherits").length>0&&u.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:u.jsxs("button",{onClick:()=>{G(!0),o("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[u.jsx(Qo,{className:"w-4 h-4"}),"Save as template"]})})]})]}),a==="json"&&u.jsxs("div",{className:"space-y-2",children:[A&&u.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[u.jsx(No,{className:"w-4 h-4"}),A]}),u.jsx("textarea",{value:M,onChange:ce=>se(ce.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),u.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),u.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[u.jsx(Ue,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),u.jsxs(Ue,{onClick:()=>me.mutate(),disabled:me.isPending||!d.trim()||!s&&!g||!!A,className:"flex-1",children:[me.isPending?u.jsx(Ot,{className:"w-4 h-4 animate-spin"}):s?u.jsx(Qo,{className:"w-4 h-4"}):u.jsx(li,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function nGe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,a]=E.useState(""),[o,l]=E.useState("all"),[c,d]=E.useState("all"),[h,g]=E.useState("all"),[m,v]=E.useState("all"),[y,b]=E.useState("all"),[x,M]=E.useState("all"),[w,A]=E.useState(null),[T,R]=E.useState(!1),[C,I]=E.useState(!1),[N,D]=E.useState(null),[z,j]=E.useState(null),[W,P]=E.useState(null),[$,K]=E.useState(!1),[G,Z]=E.useState([null,null]),[Q,ee]=E.useState(!1),[H,q]=E.useState(null),te=Nn(),ae=E.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:OL(ie.name)})),[t]),xe=E.useMemo(()=>{const F=new Set,ie=new Set,V=new Set;return ae.forEach(J=>{J.meta.nozzle&&F.add(J.meta.nozzle),J.meta.filamentType&&ie.add(J.meta.filamentType),J.meta.layerHeight&&V.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(F).sort((J,le)=>parseFloat(J)-parseFloat(le)),filaments:Array.from(ie).sort(),layerHeights:Array.from(V).sort((J,le)=>parseFloat(J)-parseFloat(le))}},[ae,i]),re=E.useMemo(()=>h==="all"?null:i.find(ie=>ie.id.toString()===h)?.model||null,[h,i]),pe=E.useMemo(()=>ae.filter(F=>o==="all"||F.type===o).filter(F=>{if(c==="all")return!0;const ie=V0(F.setting_id);return c==="custom"?ie:!ie}).filter(F=>{if(h==="all"||!re)return!0;const ie=F.meta.printer?.toLowerCase()||"",V=re.toLowerCase();return ie.includes(V)||V.includes(ie)}).filter(F=>m==="all"||F.meta.nozzle===m).filter(F=>y==="all"||F.meta.filamentType===y).filter(F=>x==="all"||F.meta.layerHeight===x).filter(F=>s===""||F.name.toLowerCase().includes(s.toLowerCase())).sort((F,ie)=>F.name.localeCompare(ie.name)),[ae,o,c,h,re,m,y,x,s]),Ce=F=>{if($){const ie=G[0]?.setting_id===F.setting_id,V=G[1]?.setting_id===F.setting_id;if(ie)Z([G[1],null]);else if(V)Z([G[0],null]);else if(!G[0])Z([F,null]);else if(G[1]){if(G[0].type!==F.type)return;Z([G[0],F])}else{if(G[0].type!==F.type)return;Z([G[0],F])}}else A(F)},fe=F=>{if(G[0]?.setting_id===F.setting_id)return 0;if(G[1]?.setting_id===F.setting_id)return 1},Se=async F=>{try{const ie=await Le.getCloudSettingDetail(F.setting_id),V=F.type==="process"?"print":F.type;D({type:V,name:F.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),A(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},Re=async F=>{try{te.removeQueries({queryKey:["cloudSettingDetail",F.setting_id]});const ie=await Le.getCloudSettingDetail(F.setting_id),V=F.type==="process"?"print":F.type;j({type:V,name:F.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:F.setting_id}),A(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},ue=()=>{l("all"),d("all"),g("all"),v("all"),b("all"),M("all"),a("")},ct=o!=="all"||c!=="all"||h!=="all"||m!=="all"||y!=="all"||x!=="all"||s!=="",B=t.filament.length+t.printer.length+t.process.length;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-4 mb-6",children:[u.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[u.jsxs("div",{className:"relative flex-1",children:[u.jsx(Zu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),u.jsx("input",{type:"text",value:s,onChange:F=>a(F.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs(Ue,{variant:$?"primary":"secondary",onClick:()=>{$?(K(!1),Z([null,null])):K(!0)},children:[u.jsx(Cx,{className:"w-4 h-4"}),$?"Cancel":"Compare"]}),u.jsxs(Ue,{variant:"secondary",onClick:()=>I(!0),children:[u.jsx(n0,{className:"w-4 h-4"}),"Templates"]}),u.jsxs(Ue,{variant:"secondary",onClick:n,disabled:r,children:[u.jsx(qs,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),u.jsxs(Ue,{onClick:()=>R(!0),children:[u.jsx(li,{className:"w-4 h-4"}),"New Preset"]})]})]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(iP,{className:"w-4 h-4 text-bambu-gray"}),u.jsx(Sp,{label:"Type",value:o,options:[{value:"all",label:"All",count:B},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:F=>l(F)}),u.jsx(Sp,{label:"Owner",value:c,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:F=>d(F)}),xe.printers.length>0&&u.jsx(Sp,{label:"Printer",value:h,options:[{value:"all",label:"All"},...xe.printers.map(F=>({value:F.id,label:F.name}))],onChange:g}),xe.nozzles.length>0&&u.jsx(Sp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...xe.nozzles.map(F=>({value:F,label:F}))],onChange:v}),xe.filaments.length>0&&(o==="all"||o==="filament")&&u.jsx(Sp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...xe.filaments.map(F=>({value:F,label:F}))],onChange:b}),xe.layerHeights.length>0&&(o==="all"||o==="process")&&u.jsx(Sp,{label:"Layer",value:x,options:[{value:"all",label:"All"},...xe.layerHeights.map(F=>({value:F,label:F}))],onChange:M}),ct&&u.jsx("button",{onClick:ue,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),$&&u.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx(Cx,{className:"w-5 h-5 text-blue-400"}),u.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),u.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),u.jsx(qN,{className:"w-4 h-4 text-bambu-gray"}),u.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&u.jsxs(Ue,{size:"sm",onClick:async()=>{try{const[F,ie]=await Promise.all([Le.getCloudSettingDetail(G[0].setting_id),Le.getCloudSettingDetail(G[1].setting_id)]);q([F.setting||{},ie.setting||{}]),ee(!0)}catch{}},children:[u.jsx(Cx,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),u.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qr,{className:"w-3 h-3"}),"Last synced: ",YVe(e.toISOString())]}),u.jsxs("span",{children:["Showing ",pe.length," of ",B," presets"]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),u.jsx("span",{children:"= My preset (editable)"})]})]}),pe.length===0?u.jsxs("div",{className:"text-center py-16",children:[u.jsx(kf,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),u.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ct&&u.jsx("button",{onClick:ue,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[u.jsx(nP,{className:"w-4 h-4 text-amber-400"}),u.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),u.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter(F=>F.type==="filament").length,")"]})]}),u.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter(F=>F.type==="filament").map(F=>u.jsx(DN,{setting:F,onClick:()=>Ce(F),onDuplicate:()=>Se(F),compareMode:$,isCompareSelected:fe(F)!==void 0,compareIndex:fe(F),compareDisabled:$&&!!G[0]&&G[0].type!==F.type},F.setting_id)),pe.filter(F=>F.type==="filament").length===0&&u.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[u.jsx(fw,{className:"w-4 h-4 text-blue-400"}),u.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),u.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter(F=>F.type==="process").length,")"]})]}),u.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter(F=>F.type==="process").map(F=>u.jsx(DN,{setting:F,onClick:()=>Ce(F),onDuplicate:()=>Se(F),compareMode:$,isCompareSelected:fe(F)!==void 0,compareIndex:fe(F),compareDisabled:$&&!!G[0]&&G[0].type!==F.type},F.setting_id)),pe.filter(F=>F.type==="process").length===0&&u.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[u.jsx(ko,{className:"w-4 h-4 text-purple-400"}),u.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),u.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter(F=>F.type==="printer").length,")"]})]}),u.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter(F=>F.type==="printer").map(F=>u.jsx(DN,{setting:F,onClick:()=>Ce(F),onDuplicate:()=>Se(F),compareMode:$,isCompareSelected:fe(F)!==void 0,compareIndex:fe(F),compareDisabled:$&&!!G[0]&&G[0].type!==F.type},F.setting_id)),pe.filter(F=>F.type==="printer").length===0&&u.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&u.jsx(JVe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>Se(w),onEdit:()=>Re(w)}),(T||N||z||W)&&u.jsx(tGe,{onClose:()=>{R(!1),D(null),j(null),P(null)},initialData:z||N||(W?{type:W.type,name:"",base_id:"",setting:W.setting}:void 0),allPresets:t}),C&&u.jsx(eGe,{onClose:()=>I(!1),onApply:F=>{P({type:F.type,setting:F.settings}),I(!1)}}),Q&&H&&G[0]&&G[1]&&u.jsx(vee,{onClose:()=>{ee(!1),q(null)},leftPreset:H[0],rightPreset:H[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function rGe(){const t=Nn(),{showToast:e}=Di(),[n,r]=E.useState("cloud"),[i,s]=E.useState(),{data:a,isLoading:o}=Mt({queryKey:["cloudStatus"],queryFn:Le.getCloudStatus}),{data:l=[]}=Mt({queryKey:["printers"],queryFn:Le.getPrinters}),{data:c,isLoading:d,refetch:h,dataUpdatedAt:g}=Mt({queryKey:["cloudSettings"],queryFn:()=>Le.getCloudSettings(),enabled:!!a?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{g&&s(new Date(g))},[g]);const m=At({mutationFn:Le.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),v=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?u.jsx("div",{className:"p-8 flex items-center justify-center min-h-[400px]",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u.jsxs("div",{className:"p-6 lg:p-8",children:[u.jsxs("div",{className:"mb-6",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),u.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),u.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[u.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:[u.jsx(tP,{className:"w-4 h-4"}),"Cloud Profiles"]}),u.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:[u.jsx(sP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&u.jsxs(u.Fragment,{children:[a?.is_authenticated&&u.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),u.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",u.jsx("span",{className:"text-white",children:a.email})]})]}),u.jsxs(Ue,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[u.jsx(Uoe,{className:"w-4 h-4"}),"Logout"]})]}),a?.is_authenticated?d?u.jsx("div",{className:"flex items-center justify-center py-16",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?u.jsx(nGe,{settings:c,lastSyncTime:i,onRefresh:()=>h(),isRefreshing:d,printers:l}):u.jsxs("div",{className:"text-center py-16",children:[u.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),u.jsx(Ue,{onClick:()=>h(),children:"Retry"})]}):u.jsx(ZVe,{onSuccess:v})]}),n==="kprofiles"&&u.jsx(KVe,{}),u.jsx(QVe,{})]})}const Ex={Droplet:nP,Flame:soe,Ruler:ple,Sparkles:n0,Square:em,Cable:oae,Wrench:Df,Calendar:Wr,Timer:Ou,Cog:Oae,Fan:Kae,Zap:s0,Wind:ace,Thermometer:Ip,Layers:kf,Box:Zp,Target:E9,RefreshCw:qs,Settings:dP,Filter:iP,CircleDot:wae};function Yx(t){return t&&Ex[t]||Df}function wp(t,e){return e==="days"?t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<30?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`:t<1?`${Math.round(t*60)}m`:t<10?`${t.toFixed(1)}h`:`${Math.round(t)}h`}function ON(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function iGe({item:t,onPerform:e,onToggle:n}){const r=Yx(t.maintenance_type_icon),i=t.interval_type||"hours",a=(()=>{if(i==="days"){const h=t.days_since_maintenance??0;return Math.max(0,Math.min(100,h/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",l=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",c=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const h=t.days_until_due??0;return t.is_due?`Overdue by ${wp(Math.abs(h),"days")}`:t.is_warning?`Due in ${wp(h,"days")}`:`${wp(h,"days")} left`}else return t.is_due?`Overdue by ${wp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${wp(t.hours_until_due,"hours")}`:`${wp(t.hours_until_due,"hours")} left`};return u.jsx("div",{className:`rounded-xl border p-4 transition-all ${c()}`,children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[u.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&u.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&u.jsx("span",{title:"Time-based interval",children:u.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),u.jsx("div",{className:"mt-2 mb-1.5",children:u.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:u.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l()}`,style:{width:`${a}%`}})})}),u.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&u.jsx(ws,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&u.jsx(Qr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&u.jsx(Qp,{className:"w-3 h-3"}),d()]})]}),u.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[u.jsx(er,{checked:t.enabled,onChange:h=>n(t.id,h)}),u.jsxs(Ue,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[u.jsx(X0,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function sGe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=E.useState(!0),[a,o]=E.useState(!1),[l,c]=E.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,v)=>m.is_due&&!v.is_due?-1:!m.is_due&&v.is_due?1:m.is_warning&&!v.is_warning?-1:!m.is_warning&&v.is_warning?1:m.maintenance_type_id-v.maintenance_type_id),h=d.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return u.jsxs(Lt,{className:"overflow-hidden",children:[u.jsxs("div",{className:"p-5",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-4",children:[u.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),u.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&u.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[u.jsx(ws,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&u.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[u.jsx(Qr,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&u.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[u.jsx(Qp,{className:"w-3 h-3"}),"All good"]})]})]}),u.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?u.jsx(cw,{className:"w-4 h-4"}):u.jsx(Qf,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),u.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:u.jsx(Ou,{className:"w-4 h-4 text-bambu-gray"})}),a?u.jsxs("div",{className:"flex items-center gap-2",children:[u.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-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),u.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),u.jsx(Ue,{size:"sm",onClick:g,children:"Save"}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):u.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[u.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.floor(t.total_print_hours)," hours",u.jsx(r1,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),u.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),u.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),h&&u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`p-2 rounded-lg ${h.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=Yx(h.maintenance_type_icon);return u.jsx(m,{className:`w-4 h-4 ${h.is_due?"text-red-400":"text-amber-400"}`})})()}),u.jsxs("div",{children:[u.jsx("div",{className:`text-sm font-medium ${h.is_due?"text-red-400":"text-amber-400"}`,children:h.maintenance_type_name}),u.jsx("div",{className:`text-xs ${h.is_due?"text-red-400/70":"text-amber-400/70"}`,children:h.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&u.jsx(Ft,{className:"pt-0 border-t border-bambu-dark-tertiary",children:u.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>u.jsx(iGe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function aGe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s}){const[a,o]=E.useState(null),[l,c]=E.useState(""),[d,h]=E.useState("hours"),[g,m]=E.useState(!1),[v,y]=E.useState(""),[b,x]=E.useState("100"),[M,w]=E.useState("hours"),[A,T]=E.useState("Wrench"),[R,C]=E.useState(null),[I,N]=E.useState(""),[D,z]=E.useState(""),[j,W]=E.useState("hours"),[P,$]=E.useState("Wrench"),K=te=>{C(te),N(te.name),z(te.default_interval_hours.toString()),W(te.interval_type||"hours"),$(te.icon||"Wrench")},G=()=>{R&&I.trim()&&parseFloat(D)>0&&(i(R.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:j,icon:P}),C(null))},Z=(te,ae,xe)=>{const re=parseFloat(l);if(!isNaN(re)&&re>0){const pe=Math.abs(re-ae)<.01?null:re;n(te,{custom_interval_hours:pe,custom_interval_type:d!==xe?d:null})}o(null)},Q=te=>{te.preventDefault(),v.trim()&&parseFloat(b)>0&&(r({name:v.trim(),default_interval_hours:parseFloat(b),interval_type:M,icon:A}),y(""),x("100"),w("hours"),m(!1))},ee=t?.map(te=>({printerId:te.printer_id,printerName:te.printer_name,items:te.maintenance_items.sort((ae,xe)=>ae.maintenance_type_id-xe.maintenance_type_id)})).sort((te,ae)=>te.printerName.localeCompare(ae.printerName))||[],H=e.filter(te=>te.is_system),q=e.filter(te=>!te.is_system);return u.jsxs("div",{className:"space-y-8",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),u.jsxs(Ue,{onClick:()=>m(!g),children:[u.jsx(li,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&u.jsx(Lt,{className:"mb-6",children:u.jsx(Ft,{className:"py-4",children:u.jsxs("form",{onSubmit:Q,children:[u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"lg:col-span-2",children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),u.jsx("input",{type:"text",value:v,onChange:te=>y(te.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),u.jsxs("select",{value:M,onChange:te=>{w(te.target.value),te.target.value==="days"?x("30"):x("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"hours",children:"Print Hours"}),u.jsx("option",{value:"days",children:"Calendar Days"})]})]}),u.jsxs("div",{children:[u.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",M==="days"?"days":"hours",")"]}),u.jsx("input",{type:"number",value:b,onChange:te=>x(te.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),u.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),u.jsx("div",{className:"flex gap-1",children:Object.keys(Ex).map(te=>{const ae=Ex[te];return u.jsx("button",{type:"button",onClick:()=>T(te),className:`p-2 rounded-lg transition-colors ${A===te?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:u.jsx(ae,{className:"w-4 h-4"})},te)})})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),u.jsx(Ue,{type:"submit",disabled:!v.trim(),children:"Add Type"})]})]})]})})}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[H.map(te=>{const ae=Yx(te.icon),xe=te.interval_type||"hours";return u.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:u.jsx(ae,{className:"w-5 h-5 text-bambu-gray"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"text-sm font-medium text-white truncate",children:te.name}),u.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[xe==="days"?u.jsx(Wr,{className:"w-3 h-3"}):u.jsx(Ou,{className:"w-3 h-3"}),ON(te.default_interval_hours,xe)]})]})]})},te.id)}),q.map(te=>{const ae=Yx(te.icon),xe=te.interval_type||"hours";return R?.id===te.id?u.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:u.jsxs("div",{className:"space-y-3",children:[u.jsx("input",{type:"text",value:I,onChange:pe=>N(pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("select",{value:j,onChange:pe=>W(pe.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[u.jsx("option",{value:"hours",children:"Print Hours"}),u.jsx("option",{value:"days",children:"Calendar Days"})]}),u.jsx("input",{type:"number",value:D,onChange:pe=>z(pe.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),u.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Ex).map(pe=>{const Ce=Ex[pe];return u.jsx("button",{type:"button",onClick:()=>$(pe),className:`p-1.5 rounded transition-colors ${P===pe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:u.jsx(Ce,{className:"w-3.5 h-3.5"})},pe)})}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ue,{size:"sm",onClick:G,disabled:!I.trim(),children:"Save"}),u.jsx(Ue,{size:"sm",variant:"secondary",onClick:()=>C(null),children:"Cancel"})]})]})},te.id):u.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:u.jsx(ae,{className:"w-5 h-5 text-bambu-green"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-sm font-medium text-white truncate",children:te.name}),u.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),u.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[xe==="days"?u.jsx(Wr,{className:"w-3 h-3"}):u.jsx(Ou,{className:"w-3 h-3"}),ON(te.default_interval_hours,xe)]})]}),u.jsx("button",{onClick:()=>K(te),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:u.jsx(r1,{className:"w-4 h-4"})}),u.jsx("button",{onClick:()=>{confirm(`Delete "${te.name}"?`)&&s(te.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:u.jsx(Qn,{className:"w-4 h-4"})})]})},te.id)})]})]}),ee.length>0&&u.jsxs("div",{children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),u.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),u.jsx("div",{className:"space-y-4",children:ee.map(te=>u.jsx(Lt,{children:u.jsxs(Ft,{className:"py-4",children:[u.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:te.printerName}),u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:te.items.map(ae=>{const xe=Yx(ae.maintenance_type_icon),re=e.find(Re=>Re.id===ae.maintenance_type_id),pe=re?.default_interval_hours||ae.interval_hours,Ce=re?.interval_type||"hours",fe=ae.interval_type||"hours",Se=a===ae.id;return u.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[u.jsx(xe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),u.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ae.maintenance_type_name}),Se?u.jsxs("div",{className:"flex items-center gap-1",children:[d==="days"?u.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):u.jsx(Ou,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),u.jsxs("select",{value:d,onChange:Re=>h(Re.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[u.jsx("option",{value:"hours",children:"Print Hours"}),u.jsx("option",{value:"days",children:"Calendar Days"})]}),u.jsx("input",{type:"number",value:l,onChange:Re=>c(Re.target.value),onKeyDown:Re=>{Re.key==="Enter"&&Z(ae.id,pe,Ce),Re.key==="Escape"&&o(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),u.jsx(Ue,{size:"sm",onClick:()=>Z(ae.id,pe,Ce),children:"OK"})]}):u.jsxs("button",{onClick:()=>{o(ae.id),c(ae.interval_hours.toString()),h(fe)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[fe==="days"?u.jsx(Wr,{className:"w-3 h-3"}):u.jsx(Ou,{className:"w-3 h-3"}),ON(ae.interval_hours,fe),u.jsx(r1,{className:"w-3 h-3 text-bambu-gray"})]})]},ae.id)})})]})},te.printerId))})]}),ee.length===0&&u.jsx(Lt,{children:u.jsxs(Ft,{className:"text-center py-12",children:[u.jsx(Qr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),u.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),u.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function oGe(){const t=Nn(),{showToast:e}=Di(),[n,r]=E.useState("status"),{data:i,isLoading:s}=Mt({queryKey:["maintenanceOverview"],queryFn:Le.getMaintenanceOverview}),{data:a}=Mt({queryKey:["maintenanceTypes"],queryFn:Le.getMaintenanceTypes}),o=At({mutationFn:({id:M,notes:w})=>Le.performMaintenance(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),l=At({mutationFn:({id:M,data:w})=>Le.updateMaintenanceItem(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),c=At({mutationFn:Le.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:M=>{e(M.message,"error")}}),d=At({mutationFn:({id:M,data:w})=>Le.updateMaintenanceType(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),h=At({mutationFn:Le.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),g=At({mutationFn:({printerId:M,hours:w})=>Le.setPrinterHours(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=M=>{o.mutate({id:M})},v=(M,w)=>{l.mutate({id:M,data:{enabled:w}})},y=(M,w)=>{g.mutate({printerId:M,hours:w})};if(s)return u.jsx("div",{className:"p-8 flex justify-center",children:u.jsx(Ot,{className:"w-8 h-8 text-bambu-green animate-spin"})});const b=i?.reduce((M,w)=>M+w.due_count,0)||0,x=i?.reduce((M,w)=>M+w.warning_count,0)||0;return u.jsxs("div",{className:"p-8",children:[u.jsxs("div",{className:"mb-6",children:[u.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),u.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?u.jsxs(u.Fragment,{children:[b>0&&u.jsxs("span",{className:"text-red-400",children:[b," task",b!==1?"s":""," overdue"]}),b>0&&x>0&&" · ",x>0&&u.jsxs("span",{className:"text-amber-400",children:[x," due soon"]}),b===0&&x===0&&u.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),u.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[u.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"}),u.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"?u.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((M,w)=>{const A=M.due_count*10+M.warning_count,T=w.due_count*10+w.warning_count;return A!==T?T-A:M.printer_name.localeCompare(w.printer_name)}).map(M=>u.jsx(sGe,{overview:M,onPerform:m,onToggle:v,onSetHours:y},M.printer_id)):u.jsx(Lt,{children:u.jsxs(Ft,{className:"text-center py-16",children:[u.jsx(Df,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),u.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),u.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):u.jsx(aGe,{overview:i,types:a||[],onUpdateInterval:(M,w)=>l.mutate({id:M,data:w}),onAddType:M=>c.mutate(M),onUpdateType:(M,w)=>d.mutate({id:M,data:w}),onDeleteType:M=>h.mutate(M)})]})}function lGe(){const{printerId:t}=mie(),e=parseInt(t||"0",10),[n,r]=E.useState("stream"),[i,s]=E.useState(!1),[a,o]=E.useState(!0),[l,c]=E.useState(Date.now()),[d,h]=E.useState(!1),[g,m]=E.useState(!1),v=E.useRef(null),y=E.useRef(null),{data:b}=Mt({queryKey:["printer",e],queryFn:()=>Le.getPrinter(e),enabled:e>0});E.useEffect(()=>(b&&(document.title=`${b.name} - Camera`),()=>{document.title="Bambuddy"}),[b]),E.useEffect(()=>()=>{v.current&&(v.current.src="")},[]),E.useEffect(()=>{if(a&&!d){const N=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(N)}},[n,a,l,d]),E.useEffect(()=>{const I=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",I),()=>document.removeEventListener("fullscreenchange",I)},[]);const x=()=>{s(!0),o(!1)},M=()=>{o(!1),s(!1)},w=I=>{n===I||d||(h(!0),o(!0),s(!1),v.current&&(v.current.src=""),setTimeout(()=>{r(I),c(Date.now()),h(!1)},100))},A=()=>{d||(h(!0),o(!0),s(!1),v.current&&(v.current.src=""),setTimeout(()=>{c(Date.now()),h(!1)},100))},T=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},R=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,C=a||d;return e?u.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[u.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[u.jsx(J_,{className:"w-4 h-4"}),b?.name||`Printer ${e}`]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[u.jsx("button",{onClick:()=>w("stream"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),u.jsx("button",{onClick:()=>w("snapshot"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),u.jsx("button",{onClick:A,disabled:C,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:u.jsx(qs,{className:`w-4 h-4 text-bambu-gray ${C?"animate-spin":""}`})}),u.jsx("button",{onClick:T,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?u.jsx(Woe,{className:"w-4 h-4 text-bambu-gray"}):u.jsx(Hoe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),u.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:u.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(a||d)&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:u.jsxs("div",{className:"text-center",children:[u.jsx(qs,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:u.jsxs("div",{className:"text-center p-4",children:[u.jsx(ws,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),u.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),u.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),u.jsx("button",{onClick:A,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),u.jsx("img",{ref:v,src:R,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:R?x:void 0,onLoad:R?M:void 0},l)]})})]}):u.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:u.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function cGe(){const t=E.useRef(null),e=E.useRef(null),n=Nn(),[r,i]=E.useState(!1),s=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,d=new WebSocket(c);let h=null;d.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),h=window.setInterval(()=>{d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"}))},3e4)},d.onmessage=g=>{try{const m=JSON.parse(g.data);a(m)}catch{}},d.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),h&&(clearInterval(h),h=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{s()},3e3)},d.onerror=g=>{console.error("[WebSocket] Error",g),d.close()},t.current=d},[]),a=E.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>{const d={...c,...l.data};return d.wifi_signal==null&&c?.wifi_signal!=null&&(d.wifi_signal=c.wifi_signal),d});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(()=>(s(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[s]);const o=E.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const uGe=new Pse({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function dGe({children:t}){return cGe(),u.jsx(u.Fragment,{children:t})}function fGe(){return u.jsx(pce,{children:u.jsx(wce,{children:u.jsx(Dse,{client:uGe,children:u.jsx(dGe,{children:u.jsx(ese,{children:u.jsxs(Rie,{children:[u.jsx(Vo,{path:"/camera/:printerId",element:u.jsx(lGe,{})}),u.jsxs(Vo,{path:"/",element:u.jsx(yce,{}),children:[u.jsx(Vo,{index:!0,element:u.jsx(tue,{})}),u.jsx(Vo,{path:"archives",element:u.jsx(TCe,{})}),u.jsx(Vo,{path:"queue",element:u.jsx(f3e,{})}),u.jsx(Vo,{path:"stats",element:u.jsx(kVe,{})}),u.jsx(Vo,{path:"profiles",element:u.jsx(rGe,{})}),u.jsx(Vo,{path:"maintenance",element:u.jsx(oGe,{})}),u.jsx(Vo,{path:"settings",element:u.jsx(WVe,{})})]})]})})})})})})}One.createRoot(document.getElementById("root")).render(u.jsx(E.StrictMode,{children:u.jsx(fGe,{})}));